Merge pull request #15815 from artfulrobot/issue-1108-fix-unsubscribe
[civicrm-core.git] / CRM / Admin / Form / Preferences.php
index ad9053ccba636f4161fdf6e9eede0c7f374450ee..f0dc5c9a364f5dd932ab8a072dbd0b36fdec4f39 100644 (file)
@@ -1,34 +1,18 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
- +--------------------------------------------------------------------+
- | 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       |
  +--------------------------------------------------------------------+
  */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
  */
 
 /**
@@ -104,7 +88,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
    * @return array
    */
   public function setDefaultValues() {
-    $this->_defaults = array();
+    $this->_defaults = [];
 
     $this->setDefaultsForMetadataDefinedFields();
     foreach ($this->_varNames as $groupName => $settings) {
@@ -135,7 +119,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
               substr($this->_config->$settingName, 1, -1)
             );
             if (!empty($value)) {
-              $defaults[$settingName] = array();
+              $defaults[$settingName] = [];
               foreach ($value as $n => $v) {
                 $defaults[$settingName][$v] = 1;
               }
@@ -157,7 +141,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
       foreach ($this->_varNames as $groupName => $groupValues) {
         $formName = CRM_Utils_String::titleToVar($groupName);
         $this->assign('formName', $formName);
-        $fields = array();
+        $fields = [];
         foreach ($groupValues as $fieldName => $fieldValue) {
           $fields[$fieldName] = $fieldValue;
 
@@ -166,10 +150,10 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
               $this->addElement('text',
                 $fieldName,
                 $fieldValue['title'],
-                array(
+                [
                   'maxlength' => 64,
                   'size' => 32,
-                )
+                ]
               );
               break;
 
@@ -187,12 +171,12 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
               break;
 
             case 'YesNo':
-              $this->addRadio($fieldName, $fieldValue['title'], array(0 => 'No', 1 => 'Yes'), NULL, '&nbsp;&nbsp;');
+              $this->addRadio($fieldName, $fieldValue['title'], [0 => 'No', 1 => 'Yes'], NULL, '&nbsp;&nbsp;');
               break;
 
             case 'checkboxes':
               $options = array_flip(CRM_Core_OptionGroup::values($fieldName, FALSE, FALSE, TRUE));
-              $newOptions = array();
+              $newOptions = [];
               foreach ($options as $key => $val) {
                 $newOptions[$key] = $val;
               }
@@ -200,7 +184,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
                 $fieldValue['title'],
                 $newOptions,
                 NULL, NULL, NULL, NULL,
-                array('&nbsp;&nbsp;', '&nbsp;&nbsp;', '<br/>')
+                ['&nbsp;&nbsp;', '&nbsp;&nbsp;', '<br/>']
               );
               break;
 
@@ -218,7 +202,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
               break;
 
             case 'entity_reference':
-              $this->addEntityRef($fieldName, $fieldValue['title'], CRM_Utils_Array::value('options', $fieldValue, array()));
+              $this->addEntityRef($fieldName, $fieldValue['title'], CRM_Utils_Array::value('options', $fieldValue, []));
           }
         }
 
@@ -227,18 +211,17 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
       }
     }
 
-    $this->addButtons(array(
-        array(
-          'type' => 'next',
-          'name' => ts('Save'),
-          'isDefault' => TRUE,
-        ),
-        array(
-          'type' => 'cancel',
-          'name' => ts('Cancel'),
-        ),
-      )
-    );
+    $this->addButtons([
+      [
+        'type' => 'next',
+        'name' => ts('Save'),
+        'isDefault' => TRUE,
+      ],
+      [
+        'type' => 'cancel',
+        'name' => ts('Cancel'),
+      ],
+    ]);
 
     if ($this->_action == CRM_Core_Action::VIEW) {
       $this->freeze();
@@ -303,7 +286,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
             $value = CRM_Utils_Array::value($settingName, $this->_params);
             if ($value) {
               $value = trim($value);
-              $value = str_replace(array("\r\n", "\r"), "\n", $value);
+              $value = str_replace(["\r\n", "\r"], "\n", $value);
             }
             $this->_config->$settingName = $value;
             break;