Merge pull request #1 from civicrm/master
[civicrm-core.git] / CRM / Grant / BAO / Grant.php
index d736ca39471bdcce5e5ff78c281fef2cb6ac42d2..4db6f2a3c23f32ab93817435271401db23557082 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  * $Id$
  *
  */
@@ -57,23 +57,23 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
 
     $dao = CRM_Core_DAO::executeQuery($query);
 
-    $status = array();
-    $summary = array();
+    $status = [];
+    $summary = [];
     $summary['total_grants'] = NULL;
     $status = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
 
     foreach ($status as $id => $name) {
-      $stats[$id] = array(
+      $stats[$id] = [
         'label' => $name,
         'total' => 0,
-      );
+      ];
     }
 
     while ($dao->fetch()) {
-      $stats[$dao->status_id] = array(
+      $stats[$dao->status_id] = [
         'label' => $status[$dao->status_id],
         'total' => $dao->status_total,
-      );
+      ];
       $summary['total_grants'] += $dao->status_total;
     }
 
@@ -90,10 +90,10 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
    */
   public static function getGrantStatusOptGroup() {
 
-    $params = array();
+    $params = [];
     $params['name'] = CRM_Grant_BAO_Grant::$statusGroupName;
 
-    $defaults = array();
+    $defaults = [];
 
     $og = CRM_Core_BAO_OptionGroup::retrieve($params, $defaults);
     if (!$og) {
@@ -144,23 +144,23 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
     }
 
     // first clean up all the money fields
-    $moneyFields = array(
+    $moneyFields = [
       'amount_total',
       'amount_granted',
       'amount_requested',
-    );
+    ];
     foreach ($moneyFields as $field) {
       if (isset($params[$field])) {
         $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
       }
     }
     // convert dates to mysql format
-    $dates = array(
+    $dates = [
       'application_received_date',
       'decision_date',
       'money_transfer_date',
       'grant_due_date',
-    );
+    ];
 
     foreach ($dates as $d) {
       if (isset($params[$d])) {
@@ -191,7 +191,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
       }
       $title = CRM_Contact_BAO_Contact::displayName($grant->contact_id) . ' - ' . ts('Grant') . ': ' . $grantTypes[$grant->grant_type_id];
 
-      $recentOther = array();
+      $recentOther = [];
       if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant',
           "action=update&reset=1&id={$grant->id}&cid={$grant->contact_id}&context=home"
@@ -250,23 +250,23 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
       $id = CRM_Utils_Array::value('contact_id', $params);
     }
     if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note', $ids))) {
-      $noteParams = array(
+      $noteParams = [
         'entity_table' => 'civicrm_grant',
         'note' => $params['note'] = $params['note'] ? $params['note'] : "null",
         'entity_id' => $grant->id,
         'contact_id' => $id,
         'modified_date' => date('Ymd'),
-      );
+      ];
 
       CRM_Core_BAO_Note::add($noteParams, (array) CRM_Utils_Array::value('note', $ids));
     }
     // Log the information on successful add/edit of Grant
-    $logParams = array(
+    $logParams = [
       'entity_table' => 'civicrm_grant',
       'entity_id' => $grant->id,
       'modified_id' => $id,
       'modified_date' => date('Ymd'),
-    );
+    ];
 
     CRM_Core_BAO_Log::add($logParams);
 
@@ -319,10 +319,10 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
     $grant->find();
 
     // delete the recently created Grant
-    $grantRecent = array(
+    $grantRecent = [
       'id' => $id,
       'type' => 'Grant',
-    );
+    ];
     CRM_Utils_Recent::del($grantRecent);
 
     if ($grant->fetch()) {
@@ -341,13 +341,13 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
    */
   public static function &exportableFields() {
     $fields = CRM_Grant_DAO_Grant::export();
-    $grantNote = array(
-      'grant_note' => array(
+    $grantNote = [
+      'grant_note' => [
         'title' => ts('Grant Note'),
         'name' => 'grant_note',
         'data_type' => CRM_Utils_Type::T_TEXT,
-      ),
-    );
+      ],
+    ];
     $fields = array_merge($fields, $grantNote,
       CRM_Core_BAO_CustomField::getFieldsForImport('Grant')
     );