X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContribute%2FForm%2FManagePremiums.php;h=61da18d8f4437fdfc0de4e9d5581ef8ff0ff1646;hb=d1d2bcec61c334aa62e388af0a8f1dc499c4fc3b;hp=1176098f2c54d95a0b6bc341d16fa5ab36858363;hpb=7481d51b832ba89932216bcc67bedbc17d7fc651;p=civicrm-core.git
diff --git a/CRM/Contribute/Form/ManagePremiums.php b/CRM/Contribute/Form/ManagePremiums.php
index 1176098f2c..61da18d8f4 100644
--- a/CRM/Contribute/Form/ManagePremiums.php
+++ b/CRM/Contribute/Form/ManagePremiums.php
@@ -1,34 +1,18 @@
_id) {
- $params = array('id' => $this->_id);
+ $params = ['id' => $this->_id];
CRM_Contribute_BAO_Product::retrieve($params, $tempDefaults);
if (isset($tempDefaults['image']) && isset($tempDefaults['thumbnail'])) {
$defaults['imageUrl'] = $tempDefaults['image'];
@@ -91,10 +75,10 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'name'), TRUE);
- $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', array(
- 'CRM_Contribute_DAO_Product',
- $this->_id,
- ));
+ $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', [
+ 'CRM_Contribute_DAO_Product',
+ $this->_id,
+ ]);
$this->add('text', 'sku', ts('SKU'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'sku'));
$this->add('textarea', 'description', ts('Description'), 'rows=3, cols=60');
@@ -123,25 +107,25 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
$this->add('textarea', 'options', ts('Options'), 'rows=3, cols=60');
- $this->add('select', 'period_type', ts('Period Type'), array(
- '' => '- select -',
- 'rolling' => 'Rolling',
- 'fixed' => 'Fixed',
- ));
+ $this->add('select', 'period_type', ts('Period Type'), [
+ '' => '- select -',
+ 'rolling' => 'Rolling',
+ 'fixed' => 'Fixed',
+ ]);
$this->add('text', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'fixed_period_start_day'));
- $this->add('Select', 'duration_unit', ts('Duration Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits());
+ $this->add('Select', 'duration_unit', ts('Duration Unit'), ['' => '- select period -'] + CRM_Core_SelectValues::getPremiumUnits());
$this->add('text', 'duration_interval', ts('Duration'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'duration_interval'));
- $this->add('Select', 'frequency_unit', ts('Frequency Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits());
+ $this->add('Select', 'frequency_unit', ts('Frequency Unit'), ['' => '- select period -'] + CRM_Core_SelectValues::getPremiumUnits());
$this->add('text', 'frequency_interval', ts('Frequency'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'frequency_interval'));
//Financial Type CRM-11106
$financialType = CRM_Contribute_PseudoConstant::financialType();
- $premiumFinancialType = array();
+ $premiumFinancialType = [];
CRM_Core_PseudoConstant::populate(
$premiumFinancialType,
'CRM_Financial_DAO_EntityFinancialAccount',
@@ -151,7 +135,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
'account_relationship = 8'
);
- $costFinancialType = array();
+ $costFinancialType = [];
CRM_Core_PseudoConstant::populate(
$costFinancialType,
'CRM_Financial_DAO_EntityFinancialAccount',
@@ -173,25 +157,24 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
'select',
'financial_type_id',
ts('Financial Type'),
- array('' => ts('- select -')) + $financialType
+ ['' => ts('- select -')] + $financialType
);
$this->add('checkbox', 'is_active', ts('Enabled?'));
- $this->addFormRule(array('CRM_Contribute_Form_ManagePremiums', 'formRule'));
-
- $this->addButtons(array(
- array(
- 'type' => 'upload',
- 'name' => ts('Save'),
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- )
- );
+ $this->addFormRule(['CRM_Contribute_Form_ManagePremiums', 'formRule']);
+
+ $this->addButtons([
+ [
+ 'type' => 'upload',
+ 'name' => ts('Save'),
+ 'isDefault' => TRUE,
+ ],
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ ],
+ ]);
$this->assign('productId', $this->_id);
}
@@ -275,7 +258,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
CRM_Contribute_BAO_Product::del($this->_id);
}
catch (CRM_Core_Exception $e) {
- $message = ts("This Premium is linked to an Online Contribution page. Please remove it before deleting this Premium.", array(1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')));
+ $message = ts("This Premium is linked to an Online Contribution page. Please remove it before deleting this Premium.", [1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')]);
CRM_Core_Session::setStatus($message, ts('Cannot delete Premium'), 'error');
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin/contribute/managePremiums', 'reset=1&action=browse'));
return;
@@ -289,7 +272,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
$params = $this->controller->exportValues($this->_name);
// Clean the the money fields
- $moneyFields = array('cost', 'price', 'min_contribution');
+ $moneyFields = ['cost', 'price', 'min_contribution'];
foreach ($moneyFields as $field) {
$params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
}
@@ -305,7 +288,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
$premium = CRM_Contribute_BAO_Product::create($params);
CRM_Core_Session::setStatus(
- ts("The Premium '%1' has been saved.", array(1 => $premium->name)),
+ ts("The Premium '%1' has been saved.", [1 => $premium->name]),
ts('Saved'), 'success');
}
@@ -316,14 +299,14 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
* @param array $params
*/
protected function _processImages(&$params) {
- $defaults = array(
+ $defaults = [
'imageOption' => 'noImage',
- 'uploadFile' => array('name' => ''),
+ 'uploadFile' => ['name' => ''],
'image' => '',
'thumbnail' => '',
'imageUrl' => '',
'thumbnailUrl' => '',
- );
+ ];
$params = array_merge($defaults, $params);
// User is uploading an image