Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | class CRM_Core_BAO_PreferencesDate extends CRM_Core_DAO_PreferencesDate { | |
18 | ||
19 | /** | |
fe482240 | 20 | * Static holder for the default LT. |
518fa0ee | 21 | * @var string |
6a488035 | 22 | */ |
518fa0ee | 23 | public static $_defaultPreferencesDate = NULL; |
6a488035 TO |
24 | |
25 | /** | |
fe482240 | 26 | * Class constructor. |
6a488035 | 27 | */ |
00be9182 | 28 | public function __construct() { |
6a488035 TO |
29 | parent::__construct(); |
30 | } | |
31 | ||
32 | /** | |
fe482240 | 33 | * Fetch object based on array of properties. |
6a488035 | 34 | * |
6a0b768e TO |
35 | * @param array $params |
36 | * (reference ) an assoc array of name/value pairs. | |
37 | * @param array $defaults | |
38 | * (reference ) an assoc array to hold the flattened values. | |
6a488035 | 39 | * |
16b10e64 CW |
40 | * @return CRM_Core_BAO_PreferencesDate|null |
41 | * object on success, null otherwise | |
6a488035 | 42 | */ |
00be9182 | 43 | public static function retrieve(&$params, &$defaults) { |
6a488035 TO |
44 | $dao = new CRM_Core_DAO_PreferencesDate(); |
45 | $dao->copyValues($params); | |
46 | if ($dao->find(TRUE)) { | |
47 | CRM_Core_DAO::storeValues($dao, $defaults); | |
48 | return $dao; | |
49 | } | |
50 | return NULL; | |
51 | } | |
52 | ||
53 | /** | |
fe482240 | 54 | * Update the is_active flag in the db. |
6a488035 | 55 | * |
6a0b768e TO |
56 | * @param int $id |
57 | * Id of the database record. | |
58 | * @param bool $is_active | |
59 | * Value we want to set the is_active field. | |
6a488035 | 60 | */ |
00be9182 | 61 | public static function setIsActive($id, $is_active) { |
6a488035 TO |
62 | CRM_Core_Error::fatal(); |
63 | } | |
64 | ||
65 | /** | |
fe482240 | 66 | * Delete preference dates. |
6a488035 | 67 | * |
6a0b768e | 68 | * @param int $id |
6a488035 | 69 | */ |
00be9182 | 70 | public static function del($id) { |
6a488035 TO |
71 | CRM_Core_Error::fatal(); |
72 | } | |
96025800 | 73 | |
630d30ec TO |
74 | /** |
75 | * (Setting Callback - On Change) | |
76 | * Respond to changes in the "timeInputFormat" setting. | |
77 | * | |
78 | * @param array $oldValue | |
79 | * List of component names. | |
80 | * @param array $newValue | |
81 | * List of component names. | |
82 | * @param array $metadata | |
83 | * Specification of the setting (per *.settings.php). | |
84 | */ | |
85 | public static function onChangeSetting($oldValue, $newValue, $metadata) { | |
86 | if ($oldValue == $newValue) { | |
87 | return; | |
88 | } | |
89 | ||
90 | $query = " | |
91 | UPDATE civicrm_preferences_date | |
92 | SET time_format = %1 | |
93 | WHERE time_format IS NOT NULL | |
94 | AND time_format <> '' | |
95 | "; | |
be2fb01f | 96 | $sqlParams = [1 => [$newValue, 'String']]; |
630d30ec TO |
97 | CRM_Core_DAO::executeQuery($query, $sqlParams); |
98 | } | |
99 | ||
6a488035 | 100 | } |