Commit 4be79955 authored by bgm's avatar bgm Committed by Aegir user

Update cividiscount to v3.5

parent fad0ab9c
......@@ -25,6 +25,8 @@
+--------------------------------------------------------------------+
*/
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* @package CiviDiscount
*/
......@@ -225,7 +227,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'code' => array(
'name' => 'code',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Code'),
'title' => E::ts('Code'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
......@@ -233,7 +235,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'description' => array(
'name' => 'description',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Description'),
'title' => E::ts('Description'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
......@@ -241,7 +243,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'filters' => array(
'name' => 'filters',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Discount Filters'),
'title' => E::ts('Discount Filters'),
'required' => FALSE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
......@@ -249,7 +251,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'amount' => array(
'name' => 'amount',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Amount'),
'title' => E::ts('Amount'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
......@@ -257,7 +259,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'amount_type' => array(
'name' => 'amount_type',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Amount Type'),
'title' => E::ts('Amount Type'),
'required' => TRUE,
'maxlength' => 4,
'size' => CRM_Utils_Type::FOUR,
......@@ -265,35 +267,35 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'count_max' => array(
'name' => 'count_max',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Count Max'),
'title' => E::ts('Count Max'),
'required' => TRUE,
),
'count_use' => array(
'name' => 'count_use',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Count Use'),
'title' => E::ts('Count Use'),
'required' => TRUE,
'default' => 0,
),
'events' => array(
'name' => 'events',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Events'),
'title' => E::ts('Events'),
),
'pricesets' => array(
'name' => 'pricesets',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Pricesets'),
'title' => E::ts('Pricesets'),
),
'memberships' => array(
'name' => 'memberships',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Memberships'),
'title' => E::ts('Memberships'),
),
'autodiscount' => array(
'name' => 'autodiscount',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Autodiscount'),
'title' => E::ts('Autodiscount'),
),
'organization_id' => array(
'name' => 'organization_id',
......@@ -303,12 +305,12 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'active_on' => array(
'name' => 'active_on',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'title' => ts('Activation Date'),
'title' => E::ts('Activation Date'),
),
'expire_on' => array(
'name' => 'expire_on',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'title' => ts('Expiration Date'),
'title' => E::ts('Expiration Date'),
),
'is_active' => array(
'name' => 'is_active',
......@@ -321,7 +323,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'discount_msg' => array(
'name' => 'discount_msg',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Discount Message'),
'title' => E::ts('Discount Message'),
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
),
......
......@@ -25,6 +25,8 @@
+--------------------------------------------------------------------+
*/
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* @package CiviDiscount
*/
......@@ -73,7 +75,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
);
$this->select2style = array(
'placeholder' => ts('- none -'),
'placeholder' => E::ts('- none -'),
'multiple' => TRUE,
'class' => 'crm-select2 huge',
);
......@@ -152,60 +154,60 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$this->applyFilter('__ALL__', 'trim');
$element = $this->add('text',
'code',
ts('Discount Code'),
E::ts('Discount Code'),
CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'code'),
TRUE
);
$this->addRule('code',
ts('Code already exists in Database.'),
E::ts('Code already exists in Database.'),
'objectExists',
array('CRM_CiviDiscount_DAO_Item', $this->_id, 'code'));
$this->addRule('code',
ts('Code can only consist of alpha-numeric characters'),
E::ts('Code can only consist of alpha-numeric characters'),
'variable');
if ($this->_action & CRM_Core_Action::UPDATE) {
$element->freeze();
}
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'description'));
$this->add('text', 'description', E::ts('Description'), CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'description'));
$this->addMoney('amount', ts('Discount Amount'), TRUE, CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'amount'), FALSE);
$this->addMoney('amount', E::ts('Discount Amount'), TRUE, CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'amount'), FALSE);
$this->add('select', 'amount_type', NULL,
array(
1 => ts('Percent'),
2 => ts('Fixed Amount')
1 => E::ts('Percent'),
2 => E::ts('Fixed Amount')
),
TRUE);
$this->add('text', 'count_max', ts('Usage Limit'), CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'count_max') + array('min' => 1));
$this->addRule('count_max', ts('Must be an integer'), 'integer');
$this->add('text', 'count_max', E::ts('Usage Limit'), CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'count_max') + array('min' => 1));
$this->addRule('count_max', E::ts('Must be an integer'), 'integer');
$this->addDate('active_on', ts('Activation Date'), FALSE);
$this->addDate('expire_on', ts('Expiration Date'), FALSE);
$this->addDate('active_on', E::ts('Activation Date'), FALSE);
$this->addDate('expire_on', E::ts('Expiration Date'), FALSE);
$this->addEntityRef('organization_id', ts('Organization'), array('api' => array('params' => array('contact_type' => 'Organization'))));
$this->addEntityRef('organization_id', E::ts('Organization'), array('api' => array('params' => array('contact_type' => 'Organization'))));
// is this discount active ?
$this->addElement('checkbox', 'is_active', ts('Is this discount active?'));
$this->addElement('checkbox', 'is_active', E::ts('Is this discount active?'));
$this->addElement('checkbox', 'discount_msg_enabled', ts('Display a message to users not eligible for this discount?'));
$this->add('textarea', 'discount_msg', ts('Message to non-eligible users'), array('class' => 'big'));
$this->addElement('checkbox', 'discount_msg_enabled', E::ts('Display a message to users not eligible for this discount?'));
$this->add('textarea', 'discount_msg', E::ts('Message to non-eligible users'), array('class' => 'big'));
// add memberships, events, pricesets
$membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
if (!empty($membershipTypes)) {
$this->add('select',
'memberships',
ts('Memberships'),
E::ts('Memberships'),
$membershipTypes,
FALSE,
$this->select2style
);
}
$this->assignAutoDiscountFields();
$this->addElement('text', 'advanced_autodiscount_filter_entity', ts('Specify entity for advanced autodiscount'));
$this->addElement('text', 'advanced_autodiscount_filter_string', ts('Specify api string for advanced filter'), array('class' => 'huge'));
$this->addElement('text', 'advanced_autodiscount_filter_entity', E::ts('Specify entity for advanced autodiscount'));
$this->addElement('text', 'advanced_autodiscount_filter_string', E::ts('Specify api string for advanced filter'), array('class' => 'huge'));
$events = CRM_CiviDiscount_Utils::getEvents();
if (!empty($events)) {
......@@ -213,7 +215,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$this->_multiValued['events'] = $events;
$this->add('select',
'events',
ts('Events'),
E::ts('Events'),
$events,
FALSE,
$this->select2style
......@@ -223,7 +225,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$this->_multiValued['eventtypes'] = $eventTypes;
$this->add('select',
'event_type_id',
ts('Event Types'),
E::ts('Event Types'),
$eventTypes,
FALSE,
$this->select2style
......@@ -235,10 +237,10 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$this->_multiValued['pricesets'] = $pricesets;
$this->add('select',
'pricesets',
ts('Price Field Options'),
E::ts('Price Field Options'),
$pricesets,
FALSE,
array('placeholder' => ts('- any -')) + $this->select2style
array('placeholder' => E::ts('- any -')) + $this->select2style
);
}
}
......@@ -263,7 +265,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
);
$assignedAutoFilters[] = $autoFilter['form_field_name'];
if (!empty($autoFilter['rule_data_type'])) {
$this->addRule($autoFilter['form_field_name'], 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 ' . $autoFilter['title'] . ' you need to enter an ' . $autoFilter['rule_data_type']), $autoFilter['rule_data_type']);
}
}
}
......@@ -279,7 +281,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_CiviDiscount_BAO_Item::del($this->_id);
CRM_Core_Session::setStatus(ts('Selected Discount has been deleted.'), ts('Deleted'), 'success');
CRM_Core_Session::setStatus(ts('Selected Discount has been deleted.'), E::ts('Deleted'), 'success');
return;
}
......@@ -287,7 +289,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$params = $this->exportValues();
$newCode = CRM_CiviDiscount_Utils::randomString('abcdefghjklmnpqrstwxyz23456789', 8);
CRM_CiviDiscount_BAO_Item::copy($this->_cloneID, $params, $newCode);
CRM_Core_Session::setStatus(ts('Selected Discount has been duplicated.'), ts('Copied'), 'success');
CRM_Core_Session::setStatus(ts('Selected Discount has been duplicated.'), E::ts('Copied'), 'success');
return;
}
......@@ -315,7 +317,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$item = CRM_CiviDiscount_BAO_Item::add($params);
CRM_Core_Session::setStatus(ts('The discount \'%1\' has been saved.',
array(1 => $item->description ? $item->description : $item->code)), ts('Saved'), 'success');
array(1 => $item->description ? $item->description : $item->code)), E::ts('Saved'), 'success');
}
/**
......@@ -617,31 +619,31 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
return array(
'membership' => array(
'membership_type_id' => array(
'title' => ts('Automatic discount for existing members of type'),
'title' => E::ts('Automatic discount for existing members of type'),
'form_field_name' => 'autodiscount_membership_type_id',
'operator' => 'IN',
'field_type' => 'select',
'options' => $this->getOptions('membership', 'membership_type_id'),
),
'status_id' => array(
'title' => ts('Automatic discount for Membership Statuses'),
'title' => E::ts('Automatic discount for Membership Statuses'),
'form_field_name' => 'autodiscount_membership_status_id',
'operator' => 'IN',
'field_type' => 'select',
'options' => array('' => ts('--any current status--')) + $this->getOptions('membership', 'status_id'),
'options' => array('' => E::ts('--any current status--')) + $this->getOptions('membership', 'status_id'),
'defaults_callback' => 'setMembershipStatusDefaults',
),
),
'contact' => array(
'contact_type' => array(
'title' => ts('Contact Type'),
'title' => E::ts('Contact Type'),
'form_field_name' => 'autodiscount_contact_type',
'operator' => 'IN',
'options' => $this->getOptions('contact', 'contact_type'),
'field_type' => 'select',
),
'age_low' => array(
'title' => ts('Minimum Age'),
'title' => E::ts('Minimum Age'),
'field_type' => 'Text',
'form_field_name' => 'autodiscount_age_low',
'rule_data_type' => 'integer',
......@@ -649,7 +651,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
'defaults_callback' => 'setAgeDefaults',
),
'age_high' => array(
'title' => ts('Maximum Age'),
'title' => E::ts('Maximum Age'),
'field_type' => 'Text',
'operator' => '=',// we could make this the adjustment fn name?
'form_field_name' => 'autodiscount_age_high',
......@@ -659,7 +661,7 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
),
'address' => array(
'country_id' => array(
'title' => ts('Country'),
'title' => E::ts('Country'),
'form_field_name' => 'autodiscount_country_id',
'operator' => 'IN',
'field_type' => 'select',
......
......@@ -30,6 +30,7 @@
*/
require_once 'CRM/CiviDiscount/DAO/Item.php';
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* Page for displaying list of discount codes
......@@ -63,38 +64,38 @@ class CRM_CiviDiscount_Page_List extends CRM_Core_Page_Basic {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::VIEW => array(
'name' => ts('View'),
'name' => E::ts('View'),
'url' => 'civicrm/cividiscount/discount/view',
'qs' => 'id=%%id%%&reset=1',
'title' => ts('View Discount Code')
'title' => E::ts('View Discount Code')
),
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'name' => E::ts('Edit'),
'url' => 'civicrm/cividiscount/discount/edit',
'qs' => '&id=%%id%%&reset=1',
'title' => ts('Edit Discount Code')
'title' => E::ts('Edit Discount Code')
),
CRM_Core_Action::COPY => array(
'name' => ts('Copy'),
'name' => E::ts('Copy'),
'url' => 'civicrm/cividiscount/discount/copy',
'qs' => '&cloneID=%%id%%&reset=1',
'title' => ts('Clone Discount Code')
'title' => E::ts('Clone Discount Code')
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'name' => E::ts('Disable'),
'class' => 'crm-enable-disable',
'title' => ts('Disable Discount Code')
'title' => E::ts('Disable Discount Code')
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'name' => E::ts('Enable'),
'class' => 'crm-enable-disable',
'title' => ts('Enable Discount Code')
'title' => E::ts('Enable Discount Code')
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'name' => E::ts('Delete'),
'url' => 'civicrm/cividiscount/discount/delete',
'qs' => '&id=%%id%%',
'title' => ts('Delete Discount Code')
'title' => E::ts('Delete Discount Code')
)
);
}
......@@ -116,7 +117,7 @@ class CRM_CiviDiscount_Page_List extends CRM_Core_Page_Basic {
* @return string name of this page.
*/
function editName() {
return ts('Discount Code');
return E::ts('Discount Code');
}
/**
......
......@@ -30,6 +30,7 @@
*/
require_once 'CRM/CiviDiscount/DAO/Item.php';
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* Page for displaying discount code details
......@@ -70,26 +71,26 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'name' => E::ts('Edit'),
'url' => 'civicrm/cividiscount/discount/edit',
'qs' => '&id=%%id%%&reset=1',
'title' => ts('Edit Discount')
'title' => E::ts('Edit Discount')
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'name' => E::ts('Disable'),
'class' => 'crm-enable-disable',
'title' => ts('Disable Discount')
'title' => E::ts('Disable Discount')
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'name' => E::ts('Enable'),
'class' => 'crm-enable-disable',
'title' => ts('Enable Discount')
'title' => E::ts('Enable Discount')
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'name' => E::ts('Delete'),
'url' => 'civicrm/cividiscount/discount/delete',
'qs' => '&id=%%id%%&reset=1',
'title' => ts('Delete Discount')
'title' => E::ts('Delete Discount')
)
);
}
......
......@@ -56,7 +56,11 @@ function civicrm_api3_discount_code_create($params) {
*/
function _civicrm_api3_discount_code_create_spec(&$params) {
$params['is_active']['api.default'] = 1;
$params['multi_valued']['api.default'] = array();
$params['multi_valued']['api.default'] = array(
'events' => NULL,
'memberships' => NULL,
'pricesets' => NULL,
);
$params['multi_valued']['title'] = 'List of discount types being passed in';
}
......
......@@ -3,32 +3,116 @@
// AUTO-GENERATED FILE -- Civix may overwrite any changes made to this file
/**
* (Delegated) Implementation of hook_civicrm_config
* The ExtensionUtil class provides small stubs for accessing resources of this
* extension.
*/
class CRM_CiviDiscount_ExtensionUtil {
const SHORT_NAME = "cividiscount";
const LONG_NAME = "org.civicrm.module.cividiscount";
const CLASS_PREFIX = "CRM_CiviDiscount";
/**
* Translate a string using the extension's domain.
*
* If the extension doesn't have a specific translation
* for the string, fallback to the default translations.
*
* @param string $text
* Canonical message text (generally en_US).
* @param array $params
* @return string
* Translated text.
* @see ts
*/
public static function ts($text, $params = array()) {
if (!array_key_exists('domain', $params)) {
$params['domain'] = array(self::LONG_NAME, NULL);
}
return ts($text, $params);
}
/**
* Get the URL of a resource file (in this extension).
*
* @param string|NULL $file
* Ex: NULL.
* Ex: 'css/foo.css'.
* @return string
* Ex: 'http://example.org/sites/default/ext/org.example.foo'.
* Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'.
*/
public static function url($file = NULL) {
if ($file === NULL) {
return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/');
}
return CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME, $file);
}
/**
* Get the path of a resource file (in this extension).
*
* @param string|NULL $file
* Ex: NULL.
* Ex: 'css/foo.css'.
* @return string
* Ex: '/var/www/example.org/sites/default/ext/org.example.foo'.
* Ex: '/var/www/example.org/sites/default/ext/org.example.foo/css/foo.css'.
*/
public static function path($file = NULL) {
// return CRM_Core_Resources::singleton()->getPath(self::LONG_NAME, $file);
return __DIR__ . ($file === NULL ? '' : (DIRECTORY_SEPARATOR . $file));
}
/**
* Get the name of a class within this extension.
*
* @param string $suffix
* Ex: 'Page_HelloWorld' or 'Page\\HelloWorld'.
* @return string
* Ex: 'CRM_Foo_Page_HelloWorld'.
*/
public static function findClass($suffix) {
return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix);
}
}
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* (Delegated) Implements hook_civicrm_config().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
*/
function _cividiscount_civix_civicrm_config(&$config = NULL) {
static $configured = FALSE;
if ($configured) return;
if ($configured) {
return;
}
$configured = TRUE;
$template =& CRM_Core_Smarty::singleton();
$extRoot = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
$extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$extDir = $extRoot . 'templates';
if ( is_array( $template->template_dir ) ) {
array_unshift( $template->template_dir, $extDir );
} else {
$template->template_dir = array( $extDir, $template->template_dir );
if (is_array($template->template_dir)) {
array_unshift($template->template_dir, $extDir);
}
else {
$template->template_dir = array($extDir, $template->template_dir);
}
$include_path = $extRoot . PATH_SEPARATOR . get_include_path( );
set_include_path( $include_path );
$include_path = $extRoot . PATH_SEPARATOR . get_include_path();
set_include_path($include_path);
}
/**
* (Delegated) Implementation of hook_civicrm_xmlMenu
* (Delegated) Implements hook_civicrm_xmlMenu().
*
* @param $files array(string)
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
*/
function _cividiscount_civix_civicrm_xmlMenu(&$files) {
foreach (_cividiscount_civix_glob(__DIR__ . '/xml/Menu/*.xml') as $file) {
......@@ -37,57 +121,82 @@ function _cividiscount_civix_civicrm_xmlMenu(&$files) {
}
/**
* Implementation of hook_civicrm_install
* Implements hook_civicrm_install().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
*/
function _cividiscount_civix_civicrm_install() {
_cividiscount_civix_civicrm_config();
if ($upgrader = _cividiscount_civix_upgrader()) {
return $upgrader->onInstall();
$upgrader->onInstall();
}
}
/**
* Implements hook_civicrm_postInstall().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_postInstall
*/
function _cividiscount_civix_civicrm_postInstall() {
_cividiscount_civix_civicrm_config();
if ($upgrader = _cividiscount_civix_upgrader()) {
if (is_callable(array($upgrader, 'onPostInstall'))) {
$upgrader->onPostInstall();
}
}
}
/**
* Implementation of hook_civicrm_uninstall
* Implements hook_civicrm_uninstall().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
*/
function _cividiscount_civix_civicrm_uninstall() {
_cividiscount_civix_civicrm_config();
if ($upgrader = _cividiscount_civix_upgrader()) {
return $upgrader->onUninstall();
$upgrader->onUninstall();
}
}
/**
* (Delegated) Implementation of hook_civicrm_enable
* (Delegated) Implements hook_civicrm_enable().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
*/
function _cividiscount_civix_civicrm_enable() {
_cividiscount_civix_civicrm_config();
if ($upgrader = _cividiscount_civix_upgrader()) {
if (is_callable(array($upgrader, 'onEnable'))) {
return $upgrader->onEnable();
$upgrader->onEnable();
}
}
}
/**
* (Delegated) Implementation of hook_civicrm_disable
* (Delegated) Implements hook_civicrm_disable().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
* @return mixed
*/
function _cividiscount_civix_civicrm_disable() {
_cividiscount_civix_civicrm_config();
if ($upgrader = _cividiscount_civix_upgrader()) {
if (is_callable(array($upgrader, 'onDisable'))) {
return $upgrader->onDisable();
$upgrader->onDisable();
}
}
}
/**
* (Delegated) Implementation of hook_civicrm_upgrade
* (Delegated) Implements hook_civicrm_upgrade().
*
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
*
* @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
* for 'enqueue', returns void
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
*/
function _cividiscount_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
if ($upgrader = _cividiscount_civix_upgrader()) {
......@@ -95,10 +204,14 @@ function _cividiscount_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL)
}
}
/**
* @return CRM_CiviDiscount_Upgrader
*/
function _cividiscount_civix_upgrader() {
if (!file_exists(__DIR__.'/CRM/CiviDiscount/Upgrader.php')) {
if (!file_exists(__DIR__ . '/CRM/CiviDiscount/Upgrader.php')) {
return NULL;
} else {
}
else {
return CRM_CiviDiscount_Upgrader_Base::instance();