);
}
- // 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'],
public $_settings = array(
'weekBegins' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
+ 'dateInputFormat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
+ 'timeInputFormat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
);
/**
$this->addElement('text', 'dateformatPartial', ts('Month and Year'));
$this->addElement('text', 'dateformatYear', ts('Year Only'));
$this->addElement('text', 'dateformatTime', ts('Time Only'));
- $this->add('select', 'dateInputFormat', ts('Complete Date'),
- CRM_Core_SelectValues::getDatePluginInputFormats()
- );
- $this->add('select', 'timeInputFormat', ts('Time'),
- CRM_Core_SelectValues::getTimeFormats()
- );
$this->add('date', 'fiscalYearStart', ts('Fiscal Year Start'),
CRM_Core_SelectValues::date(NULL, 'M d')
CRM_Core_Error::fatal();
}
+ /**
+ * (Setting Callback - On Change)
+ * Respond to changes in the "timeInputFormat" setting.
+ *
+ * @param array $oldValue
+ * List of component names.
+ * @param array $newValue
+ * List of component names.
+ * @param array $metadata
+ * Specification of the setting (per *.settings.php).
+ */
+ public static function onChangeSetting($oldValue, $newValue, $metadata) {
+ if ($oldValue == $newValue) {
+ return;
+ }
+
+ $query = "
+UPDATE civicrm_preferences_date
+SET time_format = %1
+WHERE time_format IS NOT NULL
+AND time_format <> ''
+";
+ $sqlParams = array(1 => array($newValue, 'String'));
+ CRM_Core_DAO::executeQuery($query, $sqlParams);
+ }
+
}
'title' => 'Date Format: Year Only',
'description' => '',
),
+ 'dateInputFormat' => array(
+ 'add' => '4.7',
+ 'prefetch' => 1,
+ 'help_text' => NULL,
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'group_name' => 'Localization Preferences',
+ 'group' => 'localization',
+ 'name' => 'dateInputFormat',
+ 'type' => 'String',
+ 'quick_form_type' => 'Select',
+ 'html_type' => 'Select',
+ 'pseudoconstant' => array(
+ 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
+ ),
+ 'default' => 'mm/dd/yy',
+ 'title' => 'Date Input Format',
+ 'description' => '',
+ ),
'fieldSeparator' => array(
'add' => '4.7',
'prefetch' => 1,
'title' => 'Legacy Encoding',
'description' => 'If import files are NOT encoded as UTF-8, specify an alternate character encoding for these files. The default of Windows-1252 will work for Excel-created .CSV files on many computers.',
),
+ 'timeInputFormat' => array(
+ 'add' => '4.7',
+ 'prefetch' => 1,
+ 'help_text' => NULL,
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'group_name' => 'Localization Preferences',
+ 'group' => 'localization',
+ 'name' => 'timeInputFormat',
+ 'type' => 'String',
+ 'quick_form_type' => 'Select',
+ 'html_type' => 'Select',
+ 'pseudoconstant' => array(
+ 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
+ ),
+ 'default' => '1',
+ 'title' => 'Time Input Format',
+ 'description' => '',
+ 'on_change' => array(
+ 'CRM_Core_BAO_PreferencesDate::onChangeSetting',
+ ),
+ ),
'weekBegins' => array(
'group_name' => 'Localization Preferences',
'group' => 'localization',