Merge pull request #15921 from civicrm/5.20
[civicrm-core.git] / api / v3 / MailingContact.php
index c001039b1a51ccb1ab59e4c3d7b1f15208069073..b3f2d8bb2608234716260d5a95d40f343820564c 100644 (file)
@@ -1,27 +1,11 @@
 <?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.   |
+ | Copyright CiviCRM LLC. All rights reserved.                        |
  |                                                                    |
- | 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.        |
- |                                                                    |
- | 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       |
  +--------------------------------------------------------------------+
  */
 
@@ -75,21 +59,22 @@ function _civicrm_api3_mailing_contact_getresults($params, $count) {
  *   Array of parameters determined by getfields.
  */
 function _civicrm_api3_mailing_contact_get_spec(&$params) {
-  $params['contact_id'] = array(
+  $params['contact_id'] = [
     'api.required' => 1,
     'title' => 'Contact ID',
     'type' => CRM_Utils_Type::T_INT,
-  );
+  ];
 
-  $params['type'] = array(
+  $params['type'] = [
     'api.default' => 'Delivered',
-    'title' => 'Type', // doesn't really explain the field - but not sure I understand it to explain it better
+    // doesn't really explain the field - but not sure I understand it to explain it better
+    'title' => 'Type',
     'type' => CRM_Utils_Type::T_STRING,
-    'options' => array(
+    'options' => [
       'Delivered' => 'Delivered',
       'Bounced' => 'Bounced',
-    ),
-  );
+    ],
+  ];
 }
 
 /**
@@ -131,20 +116,20 @@ AND        meq.contact_id = %1
 GROUP BY   m.id
 ";
 
-    $qParams = array(
-      1 => array($contactID, 'Integer'),
-    );
+    $qParams = [
+      1 => [$contactID, 'Integer'],
+    ];
     $dao = CRM_Core_DAO::executeQuery($sql, $qParams);
 
     $results = $dao->N;
   }
   else {
-    $defaultFields = array(
+    $defaultFields = [
       'm.id'       => 'mailing_id',
       'm.subject'  => 'subject',
       'c.id' => 'creator_id',
       'c.sort_name' => 'creator_name',
-    );
+    ];
 
     if ($selectFields) {
       $fields = array_merge($selectFields, $defaultFields);
@@ -153,7 +138,7 @@ GROUP BY   m.id
       $fields = $defaultFields;
     }
 
-    $select = array();
+    $select = [];
     foreach ($fields as $n => $l) {
       $select[] = "$n as $l";
     }
@@ -186,14 +171,14 @@ LIMIT %2, %3
 ";
     }
 
-    $qParams = array(
-      1 => array($contactID, 'Integer'),
-      2 => array($offset, 'Integer'),
-      3 => array($limit, 'Integer'),
-    );
+    $qParams = [
+      1 => [$contactID, 'Integer'],
+      2 => [$offset, 'Integer'],
+      3 => [$limit, 'Integer'],
+    ];
     $dao = CRM_Core_DAO::executeQuery($sql, $qParams);
 
-    $results = array();
+    $results = [];
     while ($dao->fetch()) {
       foreach ($fields as $n => $l) {
         $results[$dao->mailing_id][$l] = $dao->$l;
@@ -222,7 +207,7 @@ function _civicrm_api3_mailing_contact_get_delivered(
   $sort,
   $getCount
 ) {
-  $selectFields = array('med.time_stamp' => 'start_date');
+  $selectFields = ['med.time_stamp' => 'start_date'];
 
   $fromClause = "
 INNER JOIN civicrm_mailing_event_delivered med ON med.event_queue_id = meq.id