CRM_Core_BAO_Setting::getItem() - Fix calls which use deprecated parameters
[civicrm-core.git] / CRM / Admin / Form / Setting.php
index 910e5f90d35ef8df960762b633f88b06399f60ab..3b62810ad409e46cb948335e34e7525c02ec2a0c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
  */
 
 /**
- * This class generates form components generic to CiviCRM settings
+ * This class generates form components generic to CiviCRM settings.
  */
 class CRM_Admin_Form_Setting extends CRM_Core_Form {
 
-  protected $_defaults;
   protected $_settings = array();
 
   /**
@@ -103,8 +101,8 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
         );
       }
 
-      $this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL', NULL, 0);
-      $this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL', NULL, 1);
+      $this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL');
+      $this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
     }
 
     return $this->_defaults;
@@ -145,6 +143,12 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
             $props['html_type'] == 'select' ? CRM_Utils_Array::value('html_attributes', $props) : NULL
           );
         }
+        elseif ($add == 'addSelect') {
+          $options = civicrm_api3('Setting', 'getoptions', array(
+            'field' => $setting,
+          ));
+          $this->addElement('select', $setting, ts($props['title']), $options['values'], CRM_Utils_Array::value('html_attributes', $props));
+        }
         else {
           $this->$add($setting, ts($props['title']));
         }
@@ -162,6 +166,15 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
     }
   }
 
+  /**
+   * Get default entity.
+   *
+   * @return string
+   */
+  public function getDefaultEntity() {
+    return 'Setting';
+  }
+
   /**
    * Process the form submission.
    */
@@ -225,18 +238,6 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
       );
     }
 
-    // update time for date formats when global time is changed
-    if (!empty($params['timeInputFormat'])) {
-      $query = "
-UPDATE civicrm_preferences_date
-SET    time_format = %1
-WHERE  time_format IS NOT NULL
-AND    time_format <> ''
-";
-      $sqlParams = array(1 => array($params['timeInputFormat'], 'String'));
-      CRM_Core_DAO::executeQuery($query, $sqlParams);
-    }
-
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
       CRM_Core_BAO_Setting::setItem($params['verifySSL'],
@@ -260,6 +261,10 @@ AND    time_format <> ''
       //@todo array_diff this
       unset($params[$setting]);
     }
+    if (!empty($result['error_message'])) {
+      CRM_Core_Session::setStatus($result['error_message'], ts('Save Failed'), 'error');
+    }
+
     CRM_Core_BAO_ConfigSetting::create($params);
 
     CRM_Core_Config::clearDBCache();