Merge pull request #15983 from eileenmcnaughton/search_nfc
[civicrm-core.git] / CRM / Contact / ActionMapping.php
index 4dee05a6ed910acb6c7c494fac012dbe55ffcb5e..f4aee154e83038bff31a4bd9381728d63b45bdf3 100644 (file)
@@ -1,31 +1,14 @@
 <?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       |
  +--------------------------------------------------------------------+
  */
 
-use Civi\ActionSchedule\RecipientBuilder;
 
 /**
  * Class CRM_Contact_ActionMapping
@@ -51,7 +34,7 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping {
    * @param \Civi\ActionSchedule\Event\MappingRegisterEvent $registrations
    */
   public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\MappingRegisterEvent $registrations) {
-    $registrations->register(CRM_Contact_ActionMapping::create(array(
+    $registrations->register(CRM_Contact_ActionMapping::create([
       'id' => CRM_Contact_ActionMapping::CONTACT_MAPPING_ID,
       'entity' => 'civicrm_contact',
       'entity_label' => ts('Contact'),
@@ -60,14 +43,14 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping {
       'entity_status' => 'contact_date_reminder_options',
       'entity_status_label' => ts('Annual Options'),
       'entity_date_start' => 'date_field',
-    )));
+    ]));
   }
 
-  private $contactDateFields = array(
+  private $contactDateFields = [
     'birth_date',
     'created_date',
     'modified_date',
-  );
+  ];
 
   /**
    * Determine whether a schedule based on this mapping is sufficiently
@@ -79,7 +62,7 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping {
    *   List of error messages.
    */
   public function validateSchedule($schedule) {
-    $errors = array();
+    $errors = [];
     if (CRM_Utils_System::isNull($schedule->entity_value) || $schedule->entity_value === '0') {
       $errors['entity'] = ts('Please select a specific date field.');
     }
@@ -119,30 +102,31 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping {
     elseif (in_array($selectedValues[0], $this->contactDateFields)) {
       $dateDBField = $selectedValues[0];
       $query = \CRM_Utils_SQL_Select::from("{$this->entity} e")->param($defaultParams);
-      $query->param(array(
+      $query->param([
         'casAddlCheckFrom' => 'civicrm_contact e',
         'casContactIdField' => 'e.id',
         'casEntityIdField' => 'e.id',
         'casContactTableAlias' => 'e',
-      ));
+      ]);
       $query->where('e.is_deleted = 0 AND e.is_deceased = 0');
     }
     else {
       //custom field
-      $customFieldParams = array('id' => substr($selectedValues[0], 7));
-      $customGroup = $customField = array();
+      $customFieldParams = ['id' => substr($selectedValues[0], 7)];
+      $customGroup = $customField = [];
       \CRM_Core_BAO_CustomField::retrieve($customFieldParams, $customField);
       $dateDBField = $customField['column_name'];
-      $customGroupParams = array('id' => $customField['custom_group_id'], $customGroup);
+      $customGroupParams = ['id' => $customField['custom_group_id'], $customGroup];
       \CRM_Core_BAO_CustomGroup::retrieve($customGroupParams, $customGroup);
       $query = \CRM_Utils_SQL_Select::from("{$customGroup['table_name']} e")->param($defaultParams);
-      $query->param(array(
+      $query->param([
         'casAddlCheckFrom' => "{$customGroup['table_name']} e",
         'casContactIdField' => 'e.entity_id',
         'casEntityIdField' => 'e.id',
         'casContactTableAlias' => NULL,
-      ));
-      $query->where('1'); // possible to have no "where" in this case
+      ]);
+      // possible to have no "where" in this case
+      $query->where('1');
     }
 
     $query['casDateField'] = 'e.' . $dateDBField;