Merge in 5.20
[civicrm-core.git] / CRM / Activity / Form / Task / AddToTag.php
index ef9e9f080a91ec41348c9b44b8ff5f28ede35851..0e603bd7042502b798a9b568b51f451905fa04e7 100644 (file)
@@ -1,34 +1,18 @@
 <?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       |
  +--------------------------------------------------------------------+
  */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
  */
 
 /**
@@ -71,7 +55,7 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task {
   }
 
   public function addRules() {
-    $this->addFormRule(array('CRM_Activity_Form_Task_AddToTag', 'formRule'));
+    $this->addFormRule(['CRM_Activity_Form_Task_AddToTag', 'formRule']);
   }
 
   /**
@@ -81,7 +65,7 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task {
    * @return array
    */
   public static function formRule($form, $rule) {
-    $errors = array();
+    $errors = [];
     if (empty($form['tag']) && empty($form['activity_taglist'])) {
       $errors['_qf_default'] = ts("Please select at least one tag.");
     }
@@ -94,7 +78,7 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task {
   public function postProcess() {
     // Get the submitted values in an array.
     $params = $this->controller->exportValues($this->_name);
-    $activityTags = $tagList = array();
+    $activityTags = $tagList = [];
 
     // check if contact tags exists
     if (!empty($params['tag'])) {
@@ -131,22 +115,22 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task {
     // merge activity and taglist tags
     $allTags = CRM_Utils_Array::crmArrayMerge($activityTags, $tagList);
 
-    $this->_name = array();
+    $this->_name = [];
     foreach ($allTags as $key => $dnc) {
       $this->_name[] = $this->_tags[$key];
 
       list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addEntitiesToTag($this->_activityHolderIds, $key,
         'civicrm_activity', FALSE);
 
-      $status = array(ts('Activity tagged', array('count' => $added, 'plural' => '%count activities tagged')));
+      $status = [ts('Activity tagged', ['count' => $added, 'plural' => '%count activities tagged'])];
       if ($notAdded) {
-        $status[] = ts('1 activity already had this tag', array(
+        $status[] = ts('1 activity already had this tag', [
           'count' => $notAdded,
           'plural' => '%count activities already had this tag',
-        ));
+        ]);
       }
       $status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
-      CRM_Core_Session::setStatus($status, ts("Added Tag <em>%1</em>", array(1 => $this->_tags[$key])), 'success', array('expires' => 0));
+      CRM_Core_Session::setStatus($status, ts("Added Tag <em>%1</em>", [1 => $this->_tags[$key]]), 'success', ['expires' => 0]);
     }
 
   }