Merge pull request #15821 from seamuslee001/dev_core_183_custom_group
[civicrm-core.git] / CRM / Contribute / Form / ContributionView.php
index aee9f0ec37e929eaa2ffc674c1f02fff424137bd..154896968f0a473cf8cf186243c41ec3a542b91b 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
  */
 
 /**
@@ -41,7 +25,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
    */
   public function preProcess() {
     $id = $this->get('id');
-    $params = array('id' => $id);
+    $params = ['id' => $id];
     $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
     $this->assign('context', $context);
 
@@ -57,7 +41,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
         $this->assign('canDelete', TRUE);
       }
       if (!CRM_Core_Permission::check('view contributions of type ' . $financialTypeID)) {
-        CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
+        CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
       }
     }
     elseif ($this->_action & CRM_Core_Action::VIEW) {
@@ -94,7 +78,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
 
     if (!empty($values['contribution_recur_id'])) {
       $sql = "SELECT  installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
-      $params = array(1 => array($values['contribution_recur_id'], 'Integer'));
+      $params = [1 => [$values['contribution_recur_id'], 'Integer']];
       $dao = CRM_Core_DAO::executeQuery($sql, $params);
       if ($dao->fetch()) {
         $values['recur_installments'] = $dao->installments;
@@ -132,7 +116,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
 
     // show billing address location details, if exists
     if (!empty($values['address_id'])) {
-      $addressParams = array('id' => CRM_Utils_Array::value('address_id', $values));
+      $addressParams = ['id' => CRM_Utils_Array::value('address_id', $values)];
       $addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
       $addressDetails = array_values($addressDetails);
       $values['billing_address'] = $addressDetails[0]['display'];
@@ -150,10 +134,10 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
       $this->assign($name, $value);
     }
 
-    $lineItems = array();
+    $lineItems = [];
     $displayLineItems = FALSE;
     if ($id) {
-      $lineItems = array(CRM_Price_BAO_LineItem::getLineItemsByContributionID(($id)));
+      $lineItems = [CRM_Price_BAO_LineItem::getLineItemsByContributionID(($id))];
       $firstLineItem = reset($lineItems[0]);
       if (empty($firstLineItem['price_set_id'])) {
         // CRM-20297 All we care is that it's not QuickConfig, so no price set
@@ -162,10 +146,10 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
       }
       else {
         try {
-          $priceSet = civicrm_api3('PriceSet', 'getsingle', array(
+          $priceSet = civicrm_api3('PriceSet', 'getsingle', [
             'id' => $firstLineItem['price_set_id'],
             'return' => 'is_quick_config, id',
-          ));
+          ]);
           $displayLineItems = !$priceSet['is_quick_config'];
         }
         catch (CiviCRM_API3_Exception $e) {
@@ -215,7 +199,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
 
     $title = $displayName . ' - (' . CRM_Utils_Money::format($values['total_amount'], $values['currency']) . ' ' . ' - ' . $values['financial_type'] . ')';
 
-    $recentOther = array();
+    $recentOther = [];
     if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::UPDATE)) {
       $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution',
         "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
@@ -235,7 +219,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
       $recentOther
     );
     $contributionStatus = $status[$values['contribution_status_id']];
-    if (in_array($contributionStatus, array('Partially paid', 'Pending refund'))
+    if (in_array($contributionStatus, ['Partially paid', 'Pending refund'])
         || ($contributionStatus == 'Pending' && $values['is_pay_later'])
         ) {
       if ($contributionStatus == 'Pending refund') {
@@ -256,14 +240,14 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
    * Build the form object.
    */
   public function buildQuickForm() {
-    $this->addButtons(array(
-      array(
+    $this->addButtons([
+      [
         'type' => 'cancel',
         'name' => ts('Done'),
         'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
         'isDefault' => TRUE,
-      ),
-    ));
+      ],
+    ]);
   }
 
   /**
@@ -275,7 +259,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
    *
    * @param int $id
    *
-   * @return string $title
+   * @return string
    *   Block title.
    */
   protected function assignPaymentInfoBlock($id) {