(NFC) Apply upcoming civicrm/coder policies (batch 2)
[civicrm-core.git] / CRM / Campaign / Page / AJAX.php
index ccb04eeed6cdc7ec6ac43bdc97c51e279c0118fc..ecec01993619f5a8578543f4945c00d71b55140b 100644 (file)
@@ -38,7 +38,7 @@
 class CRM_Campaign_Page_AJAX {
 
   public static function registerInterview() {
-    $fields = array(
+    $fields = [
       'result',
       'voter_id',
       'survey_id',
@@ -46,9 +46,9 @@ class CRM_Campaign_Page_AJAX {
       'surveyTitle',
       'interviewer_id',
       'activity_type_id',
-    );
+    ];
 
-    $params = array();
+    $params = [];
     foreach ($fields as $fld) {
       $params[$fld] = CRM_Utils_Array::value($fld, $_POST);
     }
@@ -82,11 +82,11 @@ class CRM_Campaign_Page_AJAX {
       }
     }
 
-    $result = array(
+    $result = [
       'status' => 'fail',
       'voter_id' => $voterId,
       'activity_id' => $params['interviewer_id'],
-    );
+    ];
 
     //time to validate custom data.
     $errors = CRM_Core_BAO_CustomField::validateCustomData($params);
@@ -108,7 +108,7 @@ class CRM_Campaign_Page_AJAX {
 
     $id = CRM_Utils_Request::retrieve('option_group_id', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
     $status = 'fail';
-    $opValues = array();
+    $opValues = [];
 
     if ($id) {
       $groupParams['id'] = $id;
@@ -136,10 +136,10 @@ class CRM_Campaign_Page_AJAX {
       $status = 'success';
     }
 
-    $result = array(
+    $result = [
       'status' => $status,
       'result' => $opValues,
-    );
+    ];
 
     CRM_Utils_JSON::output($result);
   }
@@ -149,7 +149,7 @@ class CRM_Campaign_Page_AJAX {
     $searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
     $searchParams = explode(',', $searchCriteria);
 
-    $params = $searchRows = array();
+    $params = $searchRows = [];
     foreach ($searchParams as $param) {
       if (!empty($_POST[$param])) {
         $params[$param] = $_POST[$param];
@@ -157,10 +157,10 @@ class CRM_Campaign_Page_AJAX {
     }
 
     //format multi-select group and contact types.
-    foreach (array(
-               'group',
-               'contact_type',
-             ) as $param) {
+    foreach ([
+      'group',
+      'contact_type',
+    ] as $param) {
       $paramValue = CRM_Utils_Array::value($param, $params);
       if ($paramValue) {
         unset($params[$param]);
@@ -171,12 +171,12 @@ class CRM_Campaign_Page_AJAX {
       }
     }
 
-    $voterClauseParams = array();
-    foreach (array(
-               'campaign_survey_id',
-               'survey_interviewer_id',
-               'campaign_search_voter_for',
-             ) as $fld) {
+    $voterClauseParams = [];
+    foreach ([
+      'campaign_survey_id',
+      'survey_interviewer_id',
+      'campaign_search_voter_for',
+    ] as $fld) {
       $voterClauseParams[$fld] = CRM_Utils_Array::value($fld, $params);
     }
 
@@ -224,42 +224,42 @@ class CRM_Campaign_Page_AJAX {
       }
     }
 
-    $selectorCols = array(
+    $selectorCols = [
       'sort_name',
       'street_address',
       'street_name',
       'street_number',
       'street_unit',
-    );
+    ];
 
     // get the data table params.
-    $dataTableParams = array(
-      'sEcho' => array(
+    $dataTableParams = [
+      'sEcho' => [
         'name' => 'sEcho',
         'type' => 'Integer',
         'default' => 0,
-      ),
-      'offset' => array(
+      ],
+      'offset' => [
         'name' => 'iDisplayStart',
         'type' => 'Integer',
         'default' => 0,
-      ),
-      'rowCount' => array(
+      ],
+      'rowCount' => [
         'name' => 'iDisplayLength',
         'type' => 'Integer',
         'default' => 25,
-      ),
-      'sort' => array(
+      ],
+      'sort' => [
         'name' => 'iSortCol_0',
         'type' => 'Integer',
         'default' => 'sort_name',
-      ),
-      'sortOrder' => array(
+      ],
+      'sortOrder' => [
         'name' => 'sSortDir_0',
         'type' => 'String',
         'default' => 'asc',
-      ),
-    );
+      ],
+    ];
     foreach ($dataTableParams as $pName => $pValues) {
       $$pName = $pValues['default'];
       if (!empty($_POST[$pValues['name']])) {
@@ -291,14 +291,14 @@ class CRM_Campaign_Page_AJAX {
 
     $iTotal = $searchCount;
 
-    $selectorCols = array(
+    $selectorCols = [
       'contact_type',
       'sort_name',
       'street_address',
       'street_name',
       'street_number',
       'street_unit',
-    );
+    ];
 
     $extraVoterColName = 'is_interview_conducted';
     if ($params['campaign_search_voter_for'] == 'reserve') {
@@ -328,7 +328,7 @@ class CRM_Campaign_Page_AJAX {
           $result->contact_id
         );
 
-        $searchRows[$contactID] = array('id' => $contactID);
+        $searchRows[$contactID] = ['id' => $contactID];
         foreach ($selectorCols as $col) {
           $val = $result->$col;
           if ($col == 'contact_type') {
@@ -357,7 +357,7 @@ class CRM_Campaign_Page_AJAX {
       }
     }
 
-    $selectorElements = array_merge($selectorCols, array($extraVoterColName));
+    $selectorElements = array_merge($selectorCols, [$extraVoterColName]);
 
     $iFilteredTotal = $iTotal;
 
@@ -400,13 +400,13 @@ class CRM_Campaign_Page_AJAX {
         }
       }
       if ($createActivity) {
-        $ids = array(
+        $ids = [
           'source_record_id',
           'source_contact_id',
           'target_contact_id',
           'assignee_contact_id',
-        );
-        $activityParams = array();
+        ];
+        $activityParams = [];
         foreach ($ids as $id) {
           $val = CRM_Utils_Array::value($id, $_POST);
           if (!$val) {
@@ -421,12 +421,12 @@ class CRM_Campaign_Page_AJAX {
         $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
         $scheduledStatusId = array_search('Scheduled', $activityStatus);
         if ($isReserved) {
-          $surveyValues = array();
-          $surveyParams = array('id' => $activityParams['source_record_id']);
+          $surveyValues = [];
+          $surveyParams = ['id' => $activityParams['source_record_id']];
           CRM_Core_DAO::commonRetrieve('CRM_Campaign_DAO_Survey',
             $surveyParams,
             $surveyValues,
-            array('title', 'activity_type_id', 'campaign_id')
+            ['title', 'activity_type_id', 'campaign_id']
           );
 
           $activityTypeId = $surveyValues['activity_type_id'];
@@ -451,11 +451,11 @@ class CRM_Campaign_Page_AJAX {
         }
         else {
           //delete reserved activity for given voter.
-          $voterIds = array($activityParams['target_contact_id']);
+          $voterIds = [$activityParams['target_contact_id']];
           $activities = CRM_Campaign_BAO_Survey::voterActivityDetails($activityParams['source_record_id'],
             $voterIds,
             $activityParams['source_contact_id'],
-            array($scheduledStatusId)
+            [$scheduledStatusId]
           );
           foreach ($activities as $voterId => $values) {
             $activityId = CRM_Utils_Array::value('activity_id', $values);
@@ -491,14 +491,14 @@ class CRM_Campaign_Page_AJAX {
       }
     }
 
-    CRM_Utils_JSON::output(array('status' => $status));
+    CRM_Utils_JSON::output(['status' => $status]);
   }
 
   public function campaignGroups() {
     $surveyId = CRM_Utils_Request::retrieve('survey_id', 'Positive',
       CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST'
     );
-    $campGroups = array();
+    $campGroups = [];
     if ($surveyId) {
       $campaignId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'campaign_id');
       if ($campaignId) {
@@ -511,22 +511,22 @@ class CRM_Campaign_Page_AJAX {
     if (empty($campGroups)) {
       $campGroups = CRM_Core_PseudoConstant::group();
     }
-    $groups = array(
-      array(
+    $groups = [
+      [
         'value' => '',
         'title' => ts('- select -'),
-      ),
-    );
+      ],
+    ];
     foreach ($campGroups as $grpId => $title) {
-      $groups[] = array(
+      $groups[] = [
         'value' => $grpId,
         'title' => $title,
-      );
+      ];
     }
-    $results = array(
+    $results = [
       'status' => 'success',
       'groups' => $groups,
-    );
+    ];
 
     CRM_Utils_JSON::output($results);
   }
@@ -540,7 +540,7 @@ class CRM_Campaign_Page_AJAX {
     $searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
     $searchParams = explode(',', $searchCriteria);
 
-    $params = $searchRows = array();
+    $params = $searchRows = [];
     foreach ($searchParams as $param) {
       if (isset($_POST[$param])) {
         $params[$param] = $_POST[$param];
@@ -548,7 +548,7 @@ class CRM_Campaign_Page_AJAX {
     }
 
     //this is sequence columns on datatable.
-    $selectorCols = array(
+    $selectorCols = [
       'id',
       'name',
       'title',
@@ -562,36 +562,36 @@ class CRM_Campaign_Page_AJAX {
       'is_active',
       'isActive',
       'action',
-    );
+    ];
 
     // get the data table params.
-    $dataTableParams = array(
-      'sEcho' => array(
+    $dataTableParams = [
+      'sEcho' => [
         'name' => 'sEcho',
         'type' => 'Integer',
         'default' => 0,
-      ),
-      'offset' => array(
+      ],
+      'offset' => [
         'name' => 'iDisplayStart',
         'type' => 'Integer',
         'default' => 0,
-      ),
-      'rowCount' => array(
+      ],
+      'rowCount' => [
         'name' => 'iDisplayLength',
         'type' => 'Integer',
         'default' => 25,
-      ),
-      'sort' => array(
+      ],
+      'sort' => [
         'name' => 'iSortCol_0',
         'type' => 'Integer',
         'default' => 'start_date',
-      ),
-      'sortOrder' => array(
+      ],
+      'sortOrder' => [
         'name' => 'sSortDir_0',
         'type' => 'String',
         'default' => 'desc',
-      ),
-    );
+      ],
+    ];
     foreach ($dataTableParams as $pName => $pValues) {
       $$pName = $pValues['default'];
       if (!empty($_POST[$pValues['name']])) {
@@ -601,12 +601,12 @@ class CRM_Campaign_Page_AJAX {
         }
       }
     }
-    foreach (array(
-               'sort',
-               'offset',
-               'rowCount',
-               'sortOrder',
-             ) as $sortParam) {
+    foreach ([
+      'sort',
+      'offset',
+      'rowCount',
+      'sortOrder',
+    ] as $sortParam) {
       $params[$sortParam] = $$sortParam;
     }
 
@@ -643,7 +643,7 @@ class CRM_Campaign_Page_AJAX {
     $searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
     $searchParams = explode(',', $searchCriteria);
 
-    $params = $searchRows = array();
+    $params = $searchRows = [];
     foreach ($searchParams as $param) {
       if (!empty($_POST[$param])) {
         $params[$param] = $_POST[$param];
@@ -651,7 +651,7 @@ class CRM_Campaign_Page_AJAX {
     }
 
     //this is sequence columns on datatable.
-    $selectorCols = array(
+    $selectorCols = [
       'id',
       'title',
       'campaign_id',
@@ -667,36 +667,36 @@ class CRM_Campaign_Page_AJAX {
       'result_id',
       'action',
       'voterLinks',
-    );
+    ];
 
     // get the data table params.
-    $dataTableParams = array(
-      'sEcho' => array(
+    $dataTableParams = [
+      'sEcho' => [
         'name' => 'sEcho',
         'type' => 'Integer',
         'default' => 0,
-      ),
-      'offset' => array(
+      ],
+      'offset' => [
         'name' => 'iDisplayStart',
         'type' => 'Integer',
         'default' => 0,
-      ),
-      'rowCount' => array(
+      ],
+      'rowCount' => [
         'name' => 'iDisplayLength',
         'type' => 'Integer',
         'default' => 25,
-      ),
-      'sort' => array(
+      ],
+      'sort' => [
         'name' => 'iSortCol_0',
         'type' => 'Integer',
         'default' => 'created_date',
-      ),
-      'sortOrder' => array(
+      ],
+      'sortOrder' => [
         'name' => 'sSortDir_0',
         'type' => 'String',
         'default' => 'desc',
-      ),
-    );
+      ],
+    ];
     foreach ($dataTableParams as $pName => $pValues) {
       $$pName = $pValues['default'];
       if (!empty($_POST[$pValues['name']])) {
@@ -706,12 +706,12 @@ class CRM_Campaign_Page_AJAX {
         }
       }
     }
-    foreach (array(
-               'sort',
-               'offset',
-               'rowCount',
-               'sortOrder',
-             ) as $sortParam) {
+    foreach ([
+      'sort',
+      'offset',
+      'rowCount',
+      'sortOrder',
+    ] as $sortParam) {
       $params[$sortParam] = $$sortParam;
     }
 
@@ -748,7 +748,7 @@ class CRM_Campaign_Page_AJAX {
     $searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
     $searchParams = explode(',', $searchCriteria);
 
-    $params = $searchRows = array();
+    $params = $searchRows = [];
     foreach ($searchParams as $param) {
       if (!empty($_POST[$param])) {
         $params[$param] = $_POST[$param];
@@ -756,7 +756,7 @@ class CRM_Campaign_Page_AJAX {
     }
 
     //this is sequence columns on datatable.
-    $selectorCols = array(
+    $selectorCols = [
       'id',
       'title',
       'campaign_id',
@@ -767,36 +767,36 @@ class CRM_Campaign_Page_AJAX {
       'is_active',
       'isActive',
       'action',
-    );
+    ];
 
     // get the data table params.
-    $dataTableParams = array(
-      'sEcho' => array(
+    $dataTableParams = [
+      'sEcho' => [
         'name' => 'sEcho',
         'type' => 'Integer',
         'default' => 0,
-      ),
-      'offset' => array(
+      ],
+      'offset' => [
         'name' => 'iDisplayStart',
         'type' => 'Integer',
         'default' => 0,
-      ),
-      'rowCount' => array(
+      ],
+      'rowCount' => [
         'name' => 'iDisplayLength',
         'type' => 'Integer',
         'default' => 25,
-      ),
-      'sort' => array(
+      ],
+      'sort' => [
         'name' => 'iSortCol_0',
         'type' => 'Integer',
         'default' => 'created_date',
-      ),
-      'sortOrder' => array(
+      ],
+      'sortOrder' => [
         'name' => 'sSortDir_0',
         'type' => 'String',
         'default' => 'desc',
-      ),
-    );
+      ],
+    ];
     foreach ($dataTableParams as $pName => $pValues) {
       $$pName = $pValues['default'];
       if (!empty($_POST[$pValues['name']])) {
@@ -806,12 +806,12 @@ class CRM_Campaign_Page_AJAX {
         }
       }
     }
-    foreach (array(
-               'sort',
-               'offset',
-               'rowCount',
-               'sortOrder',
-             ) as $sortParam) {
+    foreach ([
+      'sort',
+      'offset',
+      'rowCount',
+      'sortOrder',
+    ] as $sortParam) {
       $params[$sortParam] = $$sortParam;
     }