Commit e468c7a2 authored by bgm's avatar bgm Committed by Aegir user

Update org.civicrm.module.cividiscount to 3.6

parent a7d9003d
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
* @package CiviDiscount * @package CiviDiscount
*/ */
require_once 'CRM/CiviDiscount/DAO/Item.php';
class CRM_CiviDiscount_BAO_Item extends CRM_CiviDiscount_DAO_Item { class CRM_CiviDiscount_BAO_Item extends CRM_CiviDiscount_DAO_Item {
/** /**
......
...@@ -98,12 +98,6 @@ class CRM_CiviDiscount_BAO_Track extends CRM_CiviDiscount_DAO_Track { ...@@ -98,12 +98,6 @@ class CRM_CiviDiscount_BAO_Track extends CRM_CiviDiscount_DAO_Track {
} }
static function getUsage($id = NULL, $cid = NULL, $orgid = NULL) { static function getUsage($id = NULL, $cid = NULL, $orgid = NULL) {
require_once 'CRM/CiviDiscount/Utils.php';
require_once 'CRM/Member/BAO/Membership.php';
require_once 'CRM/Contact/BAO/Contact.php';
$where = '';
$sql = " $sql = "
SELECT t.item_id as item_id, SELECT t.item_id as item_id,
t.contact_id as contact_id, t.contact_id as contact_id,
......
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
/** /**
* @package CiviDiscount * @package CiviDiscount
*/ */
require_once 'CRM/Core/DAO.php'; use CRM_CiviDiscount_ExtensionUtil as E;
require_once 'CRM/Utils/Type.php';
class CRM_CiviDiscount_DAO_Track extends CRM_Core_DAO { class CRM_CiviDiscount_DAO_Track extends CRM_Core_DAO {
/** /**
...@@ -179,7 +178,7 @@ class CRM_CiviDiscount_DAO_Track extends CRM_Core_DAO { ...@@ -179,7 +178,7 @@ class CRM_CiviDiscount_DAO_Track extends CRM_Core_DAO {
'used_date' => array( 'used_date' => array(
'name' => 'used_date', 'name' => 'used_date',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'title' => ts('Used Date'), 'title' => E::ts('Used Date'),
), ),
'contribution_id' => array( 'contribution_id' => array(
'name' => 'contribution_id', 'name' => 'contribution_id',
...@@ -189,7 +188,7 @@ class CRM_CiviDiscount_DAO_Track extends CRM_Core_DAO { ...@@ -189,7 +188,7 @@ class CRM_CiviDiscount_DAO_Track extends CRM_Core_DAO {
'entity_table' => array( 'entity_table' => array(
'name' => 'entity_table', 'name' => 'entity_table',
'type' => CRM_Utils_Type::T_STRING, 'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Entity Table'), 'title' => E::ts('Entity Table'),
'required' => TRUE, 'required' => TRUE,
'maxlength' => 64, 'maxlength' => 64,
'size' => CRM_Utils_Type::BIG, 'size' => CRM_Utils_Type::BIG,
...@@ -202,7 +201,7 @@ class CRM_CiviDiscount_DAO_Track extends CRM_Core_DAO { ...@@ -202,7 +201,7 @@ class CRM_CiviDiscount_DAO_Track extends CRM_Core_DAO {
'description' => array( 'description' => array(
'name' => 'description', 'name' => 'description',
'type' => CRM_Utils_Type::T_TEXT, 'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Description'), 'title' => E::ts('Description'),
), ),
); );
} }
......
...@@ -56,17 +56,17 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -56,17 +56,17 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
// check and ensure that update / delete have a valid id // check and ensure that update / delete have a valid id
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) { if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
if (!CRM_Utils_Rule::positiveInteger($this->_id)) { if (!CRM_Utils_Rule::positiveInteger($this->_id)) {
CRM_Core_Error::fatal(ts('We need a valid discount ID for update and/or delete')); CRM_Core_Error::fatal('We need a valid discount ID for update and/or delete');
} }
} }
if ($this->_action & CRM_Core_Action::COPY) { if ($this->_action & CRM_Core_Action::COPY) {
if (!CRM_Utils_Rule::positiveInteger($this->_cloneID)) { if (!CRM_Utils_Rule::positiveInteger($this->_cloneID)) {
CRM_Core_Error::fatal(ts('We need a valid discount ID for update and/or delete')); CRM_Core_Error::fatal('We need a valid discount ID for update and/or delete');
} }
} }
CRM_Utils_System::setTitle(ts('Discounts')); CRM_Utils_System::setTitle(E::ts('Discounts'));
$this->_multiValued = array( $this->_multiValued = array(
'memberships' => NULL, 'memberships' => NULL,
...@@ -211,7 +211,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -211,7 +211,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$events = CRM_CiviDiscount_Utils::getEvents(); $events = CRM_CiviDiscount_Utils::getEvents();
if (!empty($events)) { if (!empty($events)) {
$events = array(ts('--any event--')) + $events; $events = array(E::ts('--any event--')) + $events;
$this->_multiValued['events'] = $events; $this->_multiValued['events'] = $events;
$this->add('select', $this->add('select',
'events', 'events',
...@@ -265,7 +265,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -265,7 +265,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
); );
$assignedAutoFilters[] = $autoFilter['form_field_name']; $assignedAutoFilters[] = $autoFilter['form_field_name'];
if (!empty($autoFilter['rule_data_type'])) { if (!empty($autoFilter['rule_data_type'])) {
$this->addRule($autoFilter['form_field_name'], E::ts('Please re-enter ' . $autoFilter['title'] . ' you need to enter an ' . $autoFilter['rule_data_type']), $autoFilter['rule_data_type']); $this->addRule($autoFilter['form_field_name'], E::ts('Please re-enter %1, a %2 is required.', [1 => $autoFilter['title'], 2 => $autoFilter['rule_data_type']]), $autoFilter['rule_data_type']);
} }
} }
} }
...@@ -281,7 +281,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -281,7 +281,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
public function postProcess() { public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) { if ($this->_action & CRM_Core_Action::DELETE) {
CRM_CiviDiscount_BAO_Item::del($this->_id); CRM_CiviDiscount_BAO_Item::del($this->_id);
CRM_Core_Session::setStatus(ts('Selected Discount has been deleted.'), E::ts('Deleted'), 'success'); CRM_Core_Session::setStatus(E::ts('Selected Discount has been deleted.'), E::ts('Deleted'), 'success');
return; return;
} }
...@@ -289,7 +289,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -289,7 +289,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$params = $this->exportValues(); $params = $this->exportValues();
$newCode = CRM_CiviDiscount_Utils::randomString('abcdefghjklmnpqrstwxyz23456789', 8); $newCode = CRM_CiviDiscount_Utils::randomString('abcdefghjklmnpqrstwxyz23456789', 8);
CRM_CiviDiscount_BAO_Item::copy($this->_cloneID, $params, $newCode); CRM_CiviDiscount_BAO_Item::copy($this->_cloneID, $params, $newCode);
CRM_Core_Session::setStatus(ts('Selected Discount has been duplicated.'), E::ts('Copied'), 'success'); CRM_Core_Session::setStatus(E::ts('Selected Discount has been duplicated.'), E::ts('Saved'), 'success');
return; return;
} }
...@@ -303,7 +303,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -303,7 +303,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$params['multi_valued'] = $this->_multiValued; $params['multi_valued'] = $this->_multiValued;
if (isset($params['events']) && in_array(0, $params['events']) && count($params['events']) > 1) { if (isset($params['events']) && in_array(0, $params['events']) && count($params['events']) > 1) {
CRM_Core_Session::setStatus(ts('You selected `any event` and specific events, specific events have been unset')); CRM_Core_Session::setStatus(E::ts('The events you selected will be ignored because you also chose "any event."'));
$params['events'] = array(0); $params['events'] = array(0);
} }
if (!empty($params['autodiscount_membership_type_id']) && count($params['autodiscount_membership_status_id']) == 0) { if (!empty($params['autodiscount_membership_type_id']) && count($params['autodiscount_membership_status_id']) == 0) {
...@@ -316,8 +316,8 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -316,8 +316,8 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
} }
$item = CRM_CiviDiscount_BAO_Item::add($params); $item = CRM_CiviDiscount_BAO_Item::add($params);
CRM_Core_Session::setStatus(ts('The discount \'%1\' has been saved.', CRM_Core_Session::setStatus(E::ts('The discount "%1" has been saved.',
array(1 => $item->description ? $item->description : $item->code)), E::ts('Saved'), 'success'); [1 => $item->description ?: $item->code]), E::ts('Saved'), 'success');
} }
/** /**
...@@ -330,9 +330,10 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -330,9 +330,10 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
* @throws \CRM_Core_Exception * @throws \CRM_Core_Exception
*/ */
private function addAdvancedFilterToAutodiscount(&$params, $discountEntity, $discountString) { private function addAdvancedFilterToAutodiscount(&$params, $discountEntity, $discountString) {
$discounts = [];
if ($discountString) { if ($discountString) {
if (stristr($discountString, 'api.') || stristr($discountString, 'api_')) { if (stristr($discountString, 'api.') || stristr($discountString, 'api_')) {
throw new CRM_Core_Exception(ts('You cannot nest apis in the advanced filter')); throw new CRM_Core_Exception(E::ts('You cannot nest apis in the advanced filter'));
} }
if (stristr($discountString, '{')) { if (stristr($discountString, '{')) {
$discounts = json_decode($discountString, TRUE); $discounts = json_decode($discountString, TRUE);
...@@ -341,7 +342,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -341,7 +342,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$discounts = explode(',', $discountString); $discounts = explode(',', $discountString);
foreach ($discounts as $id => $discount) { foreach ($discounts as $id => $discount) {
if (!stristr($discount, '=')) { if (!stristr($discount, '=')) {
throw new CRM_Core_Exception(ts('You have a criteria without an = sign')); throw new CRM_Core_Exception(E::ts('You have a criteria without an = sign'));
} }
$parts = explode('=', $discount); $parts = explode('=', $discount);
$discounts[$parts[0]] = $parts[1]; $discounts[$parts[0]] = $parts[1];
...@@ -405,7 +406,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -405,7 +406,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
/** /**
* Convert handling of age fields to api-acceptable 'birth_date_high' & birth_date_low * Convert handling of age fields to api-acceptable 'birth_date_high' & birth_date_low
* @param unknown $fields * @param array $fields
*/ */
function adjustAgeFields(&$fields) { function adjustAgeFields(&$fields) {
if (!empty($fields['contact'])) { if (!empty($fields['contact'])) {
...@@ -436,7 +437,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -436,7 +437,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
if (empty($status)) { if (empty($status)) {
$fields['membership']['active_only'] = 1; $fields['membership']['active_only'] = 1;
if (count($fields['membership']['status_id']['IN']) > 1) { if (count($fields['membership']['status_id']['IN']) > 1) {
CRM_Core_Session::setStatus(ts('You set "any current status" and specific statuses, specific statuses have been discarded')); CRM_Core_Session::setStatus(E::ts('The statuses you selected will be ignored because you also chose "any current status."'));
} }
unset($fields['membership']['status_id']); unset($fields['membership']['status_id']);
continue; continue;
...@@ -565,6 +566,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form { ...@@ -565,6 +566,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
* @param string $fieldName * @param string $fieldName
* @param array $values * @param array $values
* @param null $spec * @param null $spec
* @return string
*/ */
function setMembershipStatusDefaults(&$defaults, $fieldName, $values, $spec) { function setMembershipStatusDefaults(&$defaults, $fieldName, $values, $spec) {
if (!empty($values['membership']['active_only'])) { if (!empty($values['membership']['active_only'])) {
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
* @package CiviDiscount * @package CiviDiscount
*/ */
require_once 'CRM/CiviDiscount/DAO/Item.php';
use CRM_CiviDiscount_ExtensionUtil as E; use CRM_CiviDiscount_ExtensionUtil as E;
/** /**
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* @package CiviDiscount * @package CiviDiscount
*/ */
require_once 'CRM/CiviDiscount/DAO/Item.php'; use CRM_CiviDiscount_ExtensionUtil as E;
/** /**
* Page for displaying discount code details * Page for displaying discount code details
...@@ -70,26 +70,26 @@ class CRM_CiviDiscount_Page_Report extends CRM_Core_Page { ...@@ -70,26 +70,26 @@ class CRM_CiviDiscount_Page_Report extends CRM_Core_Page {
if (!(self::$_links)) { if (!(self::$_links)) {
self::$_links = array( self::$_links = array(
CRM_Core_Action::UPDATE => array( CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'), 'name' => E::ts('Edit'),
'url' => 'civicrm/cividiscount/discount/edit', 'url' => 'civicrm/cividiscount/discount/edit',
'qs' => '&id=%%id%%&reset=1', 'qs' => '&id=%%id%%&reset=1',
'title' => ts('Edit Discount') 'title' => E::ts('Edit Discount')
), ),
CRM_Core_Action::DISABLE => array( CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'), 'name' => E::ts('Disable'),
'class' => 'crm-enable-disable', 'class' => 'crm-enable-disable',
'title' => ts('Disable Discount') 'title' => E::ts('Disable Discount')
), ),
CRM_Core_Action::ENABLE => array( CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'), 'name' => E::ts('Enable'),
'class' => 'crm-enable-disable', 'class' => 'crm-enable-disable',
'title' => ts('Enable Discount') 'title' => E::ts('Enable Discount')
), ),
CRM_Core_Action::DELETE => array( CRM_Core_Action::DELETE => array(
'name' => ts('Delete'), 'name' => E::ts('Delete'),
'url' => 'civicrm/cividiscount/discount/delete', 'url' => 'civicrm/cividiscount/discount/delete',
'qs' => '&id=%%id%%', 'qs' => '&id=%%id%%',
'title' => ts('Delete Discount') 'title' => E::ts('Delete Discount')
) )
); );
} }
...@@ -126,19 +126,16 @@ class CRM_CiviDiscount_Page_Report extends CRM_Core_Page { ...@@ -126,19 +126,16 @@ class CRM_CiviDiscount_Page_Report extends CRM_Core_Page {
function preProcess() { function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
require_once 'CRM/Utils/Rule.php';
if (!CRM_Utils_Rule::positiveInteger($this->_id)) { if (!CRM_Utils_Rule::positiveInteger($this->_id)) {
CRM_Core_Error::fatal(ts('We need a valid discount ID for view')); CRM_Core_Error::fatal('We need a valid discount ID for view');
} }
$this->assign('id', $this->_id); $this->assign('id', $this->_id);
$defaults = array(); $defaults = array();
$params = array('id' => $this->_id); $params = array('id' => $this->_id);
require_once 'CRM/CiviDiscount/BAO/Item.php';
CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults); CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults);
require_once 'CRM/CiviDiscount/BAO/Track.php';
$rows = CRM_CiviDiscount_BAO_Track::getUsageByCode($this->_id); $rows = CRM_CiviDiscount_BAO_Track::getUsageByCode($this->_id);
$this->assign('rows', $rows); $this->assign('rows', $rows);
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
* @package CiviDiscount * @package CiviDiscount
*/ */
require_once 'CRM/CiviDiscount/DAO/Item.php';
/** /**
* Page for displaying discount code details * Page for displaying discount code details
...@@ -63,10 +62,8 @@ class CRM_CiviDiscount_Page_Usage extends CRM_Core_Page { ...@@ -63,10 +62,8 @@ class CRM_CiviDiscount_Page_Usage extends CRM_Core_Page {
$defaults = array(); $defaults = array();
$params = array('id' => $this->_id); $params = array('id' => $this->_id);
require_once 'CRM/CiviDiscount/BAO/Item.php';
CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults); CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults);
require_once 'CRM/CiviDiscount/BAO/Track.php';
if ($cid) { if ($cid) {
$rows = CRM_CiviDiscount_BAO_Track::getUsageByContact($this->_id); $rows = CRM_CiviDiscount_BAO_Track::getUsageByContact($this->_id);
} }
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
* @package CiviDiscount * @package CiviDiscount
*/ */
require_once 'CRM/CiviDiscount/DAO/Item.php';
use CRM_CiviDiscount_ExtensionUtil as E; use CRM_CiviDiscount_ExtensionUtil as E;
/** /**
...@@ -127,7 +126,6 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page { ...@@ -127,7 +126,6 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page {
function preProcess() { function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
require_once 'CRM/Utils/Rule.php';
if (!CRM_Utils_Rule::positiveInteger($this->_id)) { if (!CRM_Utils_Rule::positiveInteger($this->_id)) {
CRM_Core_Error::fatal(ts('We need a valid discount ID for view')); CRM_Core_Error::fatal(ts('We need a valid discount ID for view'));
} }
...@@ -136,7 +134,6 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page { ...@@ -136,7 +134,6 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page {
$defaults = array(); $defaults = array();
$params = array('id' => $this->_id); $params = array('id' => $this->_id);
require_once 'CRM/CiviDiscount/BAO/Item.php';
CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults); CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults);
$this->assign('code_id', $defaults['id']); $this->assign('code_id', $defaults['id']);
...@@ -158,7 +155,6 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page { ...@@ -158,7 +155,6 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page {
if (array_key_exists('organization_id', $defaults)) { if (array_key_exists('organization_id', $defaults)) {
$this->assign('organization_id', $defaults['organization_id']); $this->assign('organization_id', $defaults['organization_id']);
require_once 'CRM/Contact/BAO/Contact.php';
$orgname = CRM_Contact_BAO_Contact::displayName($defaults['organization_id']); $orgname = CRM_Contact_BAO_Contact::displayName($defaults['organization_id']);
$this->assign('organization', $orgname); $this->assign('organization', $orgname);
} }
...@@ -184,9 +180,6 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page { ...@@ -184,9 +180,6 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page {
} }
} }
require_once 'CRM/CiviDiscount/Utils.php';
require_once 'CRM/Member/BAO/MembershipType.php';
if (array_key_exists('events', $defaults)) { if (array_key_exists('events', $defaults)) {
$events = CRM_CiviDiscount_Utils::getEvents(); $events = CRM_CiviDiscount_Utils::getEvents();
$defaults['events'] = CRM_CiviDiscount_Utils::getIdsTitles($defaults['events'], $events); $defaults['events'] = CRM_CiviDiscount_Utils::getIdsTitles($defaults['events'], $events);
......
...@@ -12,15 +12,31 @@ class CRM_CiviDiscount_Upgrader extends CRM_CiviDiscount_Upgrader_Base { ...@@ -12,15 +12,31 @@ class CRM_CiviDiscount_Upgrader extends CRM_CiviDiscount_Upgrader_Base {
* *
*/ */
public function upgrade_2201() { public function upgrade_2201() {
$this->ctx->log->info('Applying update 2201'); if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists('cividiscount_item', 'discount_msg_enabled')) {
CRM_Core_DAO::executeQuery('ALTER TABLE cividiscount_item ADD COLUMN discount_msg_enabled TINYINT(1) DEFAULT 0 AFTER is_active'); $this->ctx->log->info('Skipped cividiscount update 2201. Column discount_msg_enabled already present on cividiscount_item table.');
CRM_Core_DAO::executeQuery('ALTER TABLE cividiscount_item ADD COLUMN discount_msg VARCHAR(255) AFTER discount_msg_enabled'); }
else {
$this->ctx->log->info('Applying cividiscount update 2201. Adding discount_msg_enabled to the cividiscount_item table.');
CRM_Core_DAO::executeQuery('ALTER TABLE cividiscount_item ADD COLUMN discount_msg_enabled TINYINT(1) DEFAULT 0 AFTER is_active');
}
if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists('cividiscount_item', 'discount_msg')) {
$this->ctx->log->info('Skipped cividiscount update 2201. Column discount_msg already present on cividiscount_item table.');
}
else {
$this->ctx->log->info('Applying cividiscount update 2201. Adding discount_msg to the cividiscount_item table.');
CRM_Core_DAO::executeQuery('ALTER TABLE cividiscount_item ADD COLUMN discount_msg VARCHAR(255) AFTER discount_msg_enabled');
}
return TRUE; return TRUE;
} }
public function upgrade_2202() { public function upgrade_2202() {
$this->ctx->log->info('Applying update 2202'); if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists('cividiscount_item', 'filters')) {
CRM_Core_DAO::executeQuery('ALTER TABLE cividiscount_item ADD COLUMN filters VARCHAR(255)'); $this->ctx->log->info('Skipped cividiscount update 2202. Column filters already present on cividiscount_item table.');
}
else {
$this->ctx->log->info('Applying cividiscount update 2202. Adding filters to the cividiscount_item table.');
CRM_Core_DAO::executeQuery('ALTER TABLE cividiscount_item ADD COLUMN filters VARCHAR(255)');
}
return TRUE; return TRUE;
} }
...@@ -36,4 +52,4 @@ class CRM_CiviDiscount_Upgrader extends CRM_CiviDiscount_Upgrader_Base { ...@@ -36,4 +52,4 @@ class CRM_CiviDiscount_Upgrader extends CRM_CiviDiscount_Upgrader_Base {
} }
return TRUE; return TRUE;
} }
} }
\ No newline at end of file
...@@ -88,7 +88,6 @@ class CRM_CiviDiscount_Upgrader_Base { ...@@ -88,7 +88,6 @@ class CRM_CiviDiscount_Upgrader_Base {
* @return bool * @return bool
*/ */
protected static function executeCustomDataFileByAbsPath($xml_file) { protected static function executeCustomDataFileByAbsPath($xml_file) {
require_once 'CRM/Utils/Migrate/Import.php';
$import = new CRM_Utils_Migrate_Import(); $import = new CRM_Utils_Migrate_Import();
$import->run($xml_file); $import->run($xml_file);
return TRUE; return TRUE;
......
...@@ -16,6 +16,11 @@ will get an automatic discount if they meet other criteria above - ie a minimum ...@@ -16,6 +16,11 @@ will get an automatic discount if they meet other criteria above - ie a minimum
<img src='https://github.com/dlobo/org.civicrm.module.cividiscount/blob/master/docs/images/advancedFilters.jpg'> <img src='https://github.com/dlobo/org.civicrm.module.cividiscount/blob/master/docs/images/advancedFilters.jpg'>
DOCUMENTATION
--
View the [CiviDiscount documentation](https://docs.civicrm.org/discount/en/latest/) on https://docs.civicrm.org.
NEEDED NEEDED
-- --
......
...@@ -71,30 +71,31 @@ function cividiscount_civicrm_managed(&$entities) { ...@@ -71,30 +71,31 @@ function cividiscount_civicrm_managed(&$entities) {
} }
/** /**
* Implementation of hook_civicrm_tabs() * Implementation of hook_civicrm_tabset()
* *
* Display a discounts tab listing discount code usage for that contact. * Display a discounts tab listing discount code usage for that contact.
*/ */
function cividiscount_civicrm_tabs(&$tabs, $cid) { function cividiscount_civicrm_tabset($path, &$tabs, $context) {
if (_cividiscount_is_org($cid)) { if ($path === 'civicrm/contact/view') {
$count = _cividiscount_get_tracking_count_by_org($cid); $cid = $context['contact_id'];
if (_cividiscount_is_org($cid)) {
$tabs[] = array(
'id' => 'discounts_assigned',
'count' => _cividiscount_get_tracking_count_by_org($cid),
'title' => E::ts('Codes Assigned'),
'weight' => 115,
'url' => CRM_Utils_System::url('civicrm/cividiscount/usage', "reset=1&oid={$cid}", FALSE, NULL, FALSE),
);
}
$tabs[] = array( $tabs[] = array(
'id' => 'discounts', 'id' => 'discounts',
'count' => $count, 'count' => _cividiscount_get_tracking_count($cid),
'title' => E::ts('Codes Assigned'), 'title' => E::ts('Codes Redeemed'),
'weight' => '98', 'weight' => 116,
'url' => CRM_Utils_System::url('civicrm/cividiscount/usage', "reset=1&oid={$cid}", false, null, false), 'url' => CRM_Utils_System::url('civicrm/cividiscount/usage', "reset=1&cid={$cid}", FALSE, NULL, FALSE),
); );
} }
$count = _cividiscount_get_tracking_count($cid);
$tabs[] = array(
'id' => 'discounts',
'count' => $count,
'title' => E::ts('Codes Redeemed'),
'weight' => '99',
'url' => CRM_Utils_System::url('civicrm/cividiscount/usage', "reset=1&cid={$cid}", false, null, false),
);
} }
/** /**
...@@ -1156,7 +1157,7 @@ function cividiscount_civicrm_navigationMenu( &$params ) { ...@@ -1156,7 +1157,7 @@ function cividiscount_civicrm_navigationMenu( &$params ) {
} }
foreach (array('Events', 'Contributions') as $header) { foreach (array('Events', 'Contributions') as $header) {
_cividiscount_civix_insert_navigation_menu($params, $header, array( _cividiscount_civix_insert_navigation_menu($params, $header, array(
'label' => ts('CiviDiscount', array('domain' => 'org.civicrm.module.cividiscount')), 'label' => E::ts('CiviDiscount'),
'name' => 'CiviDiscount', 'name' => 'CiviDiscount',
'url' => 'civicrm/cividiscount', 'url' => 'civicrm/cividiscount',
'permission' => 'administer CiviCRM,administer CiviDiscount', 'permission' => 'administer CiviCRM,administer CiviDiscount',
...@@ -1185,6 +1186,6 @@ function cividiscount_civicrm_entityTypes(&$entityTypes) { ...@@ -1185,6 +1186,6 @@ function cividiscount_civicrm_entityTypes(&$entityTypes) {
function cividiscount_civicrm_permission(&$permissions) { function cividiscount_civicrm_permission(&$permissions) {
$permissions += array( $permissions += array(
'administer CiviDiscount' => ts('administer CiviDiscount', array('domain' => 'org.civicrm.module.cividiscount')), 'administer CiviDiscount' => E::ts('administer CiviDiscount'),
); );
} }
# Installation # Installation and Configuration
## Installation
Use the following steps to install CiviDiscount. Use the following steps to install CiviDiscount.
* **Administer > System Settings > Extensions** * **Administer** > **System Settings** > **Extensions**
* **Add New** * **Add New**
* Find, download, and install CiviDiscount * Find, download, and install CiviDiscount
To access the CiviDiscount dashboard to setup and manage codes go to **Administer > CiviDiscount**. You can view this extension in the [Extension Directory](https://civicrm.org/extensions/cividiscount).
\ No newline at end of file
## Configuration
To access the CiviDiscount dashboard to set up and manage codes go to **Administer** > **CiviDiscount**.
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
<author>CiviCRM LLC</author> <author>CiviCRM LLC</author>
<email>info@civicrm.org</email> <email>info@civicrm.org</email>
</maintainer> </maintainer>
<releaseDate>2018-07-30</releaseDate> <releaseDate>2018-10-21</releaseDate>
<version>3.5</version> <version>3.6</version>
<compatibility> <compatibility>
<ver>5.3</ver> <ver>5.3</ver>
</compatibility> </compatibility>
......
Markdown is supported
0% or