Update copyright date for 2020
[civicrm-core.git] / CRM / Core / Form / Task / Batch.php
index 474dd6c83dbd9d23e57bbc60a26846a6a46f298d..b68131cd1827615bd009bb74bd73b5e778f416bb 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
+ | Copyright CiviCRM LLC (c) 2004-2020                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -27,7 +27,7 @@
 
 /**
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC (c) 2004-2020
  */
 
 /**
@@ -44,18 +44,27 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task {
 
   /**
    * Maximum profile fields that will be displayed.
+   * @var int
    */
   protected $_maxFields = 9;
 
   /**
-   * @var array Fields that belong to this UF Group
+   * Fields that belong to this UF Group.
+   *
+   * @var array
    */
   protected $_fields;
 
-  // Must be set to entity table name (eg. civicrm_participant) by child class
-  static $tableName = NULL;
-  // Must be set to entity shortname (eg. event)
-  static $entityShortname = NULL;
+  /**
+   * Must be set to entity table name (eg. civicrm_participant) by child class
+   * @var string
+   */
+  public static $tableName = NULL;
+  /**
+   * Must be set to entity shortname (eg. event)
+   * @var string
+   */
+  public static $entityShortname = NULL;
 
   /**
    * Build all the data structures needed to build the form.
@@ -67,7 +76,7 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task {
     parent::preProcess();
 
     // get the contact read only fields to display.
-    $readOnlyFields = array_merge(array('sort_name' => ts('Name')),
+    $readOnlyFields = array_merge(['sort_name' => ts('Name')],
       CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
         'contact_autocomplete_options',
         TRUE, NULL, FALSE, 'name', TRUE
@@ -95,7 +104,7 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task {
     if (!$ufGroupId) {
       throw new InvalidArgumentException('ufGroupId is missing');
     }
-    $this->_title = ts("Update multiple %1s", array(1 => $this::$entityShortname)) . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
+    $this->_title = ts("Update multiple %1s", [1 => $this::$entityShortname]) . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
     CRM_Utils_System::setTitle($this->_title);
 
     $this->addDefaultButtons(ts('Save'));
@@ -103,7 +112,7 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task {
 
     // remove file type field and then limit fields
     $suppressFields = FALSE;
-    $removeHtmlTypes = array('File');
+    $removeHtmlTypes = ['File'];
     foreach ($this->_fields as $name => $field) {
       if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) &&
         in_array($this->_fields[$name]['html_type'], $removeHtmlTypes)
@@ -121,17 +130,17 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task {
 
     $this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
 
-    $this->addButtons(array(
-      array(
+    $this->addButtons([
+      [
         'type' => 'submit',
-        'name' => ts('Update ' . ucfirst($this::$entityShortname) . 's)'),
+        'name' => ts('Update'),
         'isDefault' => TRUE,
-      ),
-      array(
+      ],
+      [
         'type' => 'cancel',
         'name' => ts('Cancel'),
-      ),
-    ));
+      ],
+    ]);
 
     $this->assign('profileTitle', $this->_title);
     $this->assign('componentIds', $this->_entityIds);
@@ -142,7 +151,7 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task {
       foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
           $customValue = CRM_Utils_Array::value($customFieldID, $customFields);
-          $entityColumnValue = array();
+          $entityColumnValue = [];
           if (!empty($customValue['extends_entity_column_value'])) {
             $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR,
               $customValue['extends_entity_column_value']
@@ -166,10 +175,10 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task {
     // don't set the status message when form is submitted.
     $buttonName = $this->controller->getButtonName('submit');
     if ($suppressFields && $buttonName != '_qf_Batch_next') {
-      CRM_Core_Session::setStatus(ts("File type field(s) in the selected profile are not supported for Update multiple %1s", array(1 => $this::$entityShortname)), ts('Unsupported Field Type'), 'error');
+      CRM_Core_Session::setStatus(ts("File type fields in the selected profile are not supported for Update multiple %1s", [1 => $this::$entityShortname]), ts('Unsupported Field Type'), 'error');
     }
 
-    $this->addDefaultButtons(ts('Update ' . ucfirst($this::$entityShortname) . 's'));
+    $this->addDefaultButtons(ts('Update'));
 
     $taskComponent['lc'] = $this::$entityShortname;
     $taskComponent['ucfirst'] = ucfirst($this::$entityShortname);
@@ -183,10 +192,10 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task {
    */
   public function setDefaultValues() {
     if (empty($this->_fields)) {
-      return array();
+      return [];
     }
 
-    $defaults = array();
+    $defaults = [];
     foreach ($this->_entityIds as $entityId) {
       CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $entityId, ucfirst($this::$entityShortname));
     }