Merge pull request #14118 from eileenmcnaughton/no_fin_item
[civicrm-core.git] / CRM / Contact / Form / Task / SaveSearch.php
index 39642e6fd6796a922bd4ad438ec349cb9142146e..1b888a6b53f8586f133473b5c7a866f9c3c044e9 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
  */
 
 /**
@@ -67,7 +67,7 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
     }
 
     // Get Task name
-    $modeValue = CRM_Contact_Form_Search::getModeValue($values['component_mode']);
+    $modeValue = CRM_Contact_Form_Search::getModeValue(CRM_Utils_Array::value('component_mode', $values, CRM_Contact_BAO_Query::MODE_CONTACTS));
     $className = $modeValue['taskClassName'];
     $taskList = $className::taskTitles();
     $this->_task = CRM_Utils_Array::value('task', $values);
@@ -138,7 +138,7 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
       $this->assign('partiallySelected', $formValues['radio_ts'] != 'ts_all');
     }
     $this->addRule('title', ts('Name already exists in Database.'),
-      'objectExists', array('CRM_Contact_DAO_Group', $groupID, 'title')
+      'objectExists', ['CRM_Contact_DAO_Group', $groupID, 'title']
     );
   }
 
@@ -160,9 +160,9 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
 
       if (!$this->_id) {
         //save record in mapping table
-        $mappingParams = array(
+        $mappingParams = [
           'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'),
-        );
+        ];
         $mapping = CRM_Core_BAO_Mapping::add($mappingParams);
         $mappingId = $mapping->id;
       }
@@ -205,10 +205,10 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
     $savedSearch->search_custom_id = $this->get('customSearchID');
     $savedSearch->save();
     $this->set('ssID', $savedSearch->id);
-    CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Group Saved'), 'success');
+    CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", [1 => $formValues['title']]), ts('Group Saved'), 'success');
 
     // also create a group that is associated with this saved search only if new saved search
-    $params = array();
+    $params = [];
     $params['title'] = $formValues['title'];
     $params['description'] = $formValues['description'];
     if (isset($formValues['group_type']) && is_array($formValues['group_type']) && count($formValues['group_type'])) {
@@ -233,12 +233,12 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
 
     // Update mapping with the name and description of the group.
     if ($mappingId && $group) {
-      $mappingParams = array(
+      $mappingParams = [
         'id' => $mappingId,
         'name' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $group->id, 'name', 'id'),
         'description' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $group->id, 'description', 'id'),
         'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'),
-      );
+      ];
       CRM_Core_BAO_Mapping::add($mappingParams);
     }
 
@@ -257,7 +257,7 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
    * return array
    */
   public function setDefaultValues() {
-    $defaults = array();
+    $defaults = [];
     if (empty($defaults['parents'])) {
       $defaults['parents'] = CRM_Core_BAO_Domain::getGroupId();
     }