Merge pull request #16591 from ixiam/dev/core#1575
[civicrm-core.git] / CRM / Price / Page / Option.php
index 44acb2bcd54a807c722778279bef0731c3bb3276..df3b6a3fc99afe59657c9f21b416fe8be6dbabfd 100644 (file)
@@ -1,34 +1,18 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
+ | Copyright CiviCRM LLC. All rights reserved.                        |
  |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
  */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
  * $Id$
  *
  */
@@ -62,7 +46,7 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
   /**
    * The price set is reserved or not.
    *
-   * @var boolean
+   * @var bool
    */
   protected $_isSetReserved = FALSE;
 
@@ -81,36 +65,36 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
    */
   public static function &actionLinks() {
     if (!isset(self::$_actionLinks)) {
-      self::$_actionLinks = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_actionLinks = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit Option'),
           'url' => 'civicrm/admin/price/field/option',
           'qs' => 'reset=1&action=update&oid=%%oid%%&fid=%%fid%%&sid=%%sid%%',
           'title' => ts('Edit Price Option'),
-        ),
-        CRM_Core_Action::VIEW => array(
+        ],
+        CRM_Core_Action::VIEW => [
           'name' => ts('View'),
           'url' => 'civicrm/admin/price/field/option',
           'qs' => 'action=view&oid=%%oid%%',
           'title' => ts('View Price Option'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable Price Option'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable Price Option'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/price/field/option',
           'qs' => 'action=delete&oid=%%oid%%',
           'title' => ts('Disable Price Option'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_actionLinks;
   }
@@ -121,16 +105,16 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
    * @return void
    */
   public function browse() {
-    $priceOptions = civicrm_api3('PriceFieldValue', 'get', array(
-        'price_field_id' => $this->_fid,
+    $priceOptions = civicrm_api3('PriceFieldValue', 'get', [
+      'price_field_id' => $this->_fid,
          // Explicitly do not check permissions so we are not
          // restricted by financial type, so we can change them.
-        'check_permissions' => FALSE,
-        'options' => array(
-          'limit' => 0,
-          'sort' => array('weight', 'label'),
-        ),
-    ));
+      'check_permissions' => FALSE,
+      'options' => [
+        'limit' => 0,
+        'sort' => ['weight', 'label'],
+      ],
+    ]);
     $customOption = $priceOptions['values'];
 
     // CRM-15378 - check if these price options are in an Event price set
@@ -146,8 +130,8 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
     $taxRate = CRM_Core_PseudoConstant::getTaxRates();
     // display taxTerm for priceFields
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
-    $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
-    $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
+    $taxTerm = $invoiceSettings['tax_term'] ?? NULL;
+    $invoicing = $invoiceSettings['invoicing'] ?? NULL;
     $getTaxDetails = FALSE;
     foreach ($customOption as $id => $values) {
       $action = array_sum(array_keys(self::actionLinks()));
@@ -184,11 +168,11 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
       }
       $customOption[$id]['order'] = $customOption[$id]['weight'];
       $customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action,
-        array(
+        [
           'oid' => $id,
           'fid' => $this->_fid,
           'sid' => $this->_sid,
-        ),
+        ],
         ts('more'),
         FALSE,
         'priceFieldValue.row.actions',
@@ -224,7 +208,7 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
     $oid = CRM_Utils_Request::retrieve('oid', 'Positive',
       $this, FALSE, 0
     );
-    $params = array();
+    $params = [];
     if ($oid) {
       $params['oid'] = $oid;
       $sid = CRM_Price_BAO_PriceSet::getSetId($params);
@@ -251,11 +235,11 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
       );
       $this->assign('usedPriceSetTitle', CRM_Price_BAO_PriceFieldValue::getOptionLabel($oid));
       $this->assign('usedBy', $usedBy);
-      $comps = array(
+      $comps = [
         "Event" => "civicrm_event",
         "Contribution" => "civicrm_contribution_page",
-      );
-      $priceSetContexts = array();
+      ];
+      $priceSetContexts = [];
       foreach ($comps as $name => $table) {
         if (array_key_exists($table, $usedBy)) {
           $priceSetContexts[] = $name;
@@ -289,19 +273,19 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
       $this->assign('isReserved', $this->_isSetReserved);
     }
     //as url contain $sid so append breadcrumb dynamically.
-    $breadcrumb = array(
-      array(
+    $breadcrumb = [
+      [
         'title' => ts('Price Fields'),
         'url' => CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&sid=' . $this->_sid),
-      ),
-    );
+      ],
+    ];
     CRM_Utils_System::appendBreadCrumb($breadcrumb);
 
     if ($this->_fid) {
       $fieldTitle = CRM_Price_BAO_PriceField::getTitle($this->_fid);
       $this->assign('fid', $this->_fid);
       $this->assign('fieldTitle', $fieldTitle);
-      CRM_Utils_System::setTitle(ts('%1 - Price Options', array(1 => $fieldTitle)));
+      CRM_Utils_System::setTitle(ts('%1 - Price Options', [1 => $fieldTitle]));
 
       $htmlType = CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceField', $this->_fid, 'html_type');
       $this->assign('addMoreFields', TRUE);