Merge pull request #23210 from eileenmcnaughton/cancel
[civicrm-core.git] / CRM / Core / BAO / PreferencesDate.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17 class CRM_Core_BAO_PreferencesDate extends CRM_Core_DAO_PreferencesDate {
18
19 /**
20 * Retrieve DB object and copy to defaults array.
21 *
22 * @param array $params
23 * Array of criteria values.
24 * @param array $defaults
25 * Array to be populated with found values.
26 *
27 * @return self|null
28 * The DAO object, if found.
29 *
30 * @deprecated
31 */
32 public static function retrieve($params, &$defaults) {
33 return self::commonRetrieve(self::class, $params, $defaults);
34 }
35
36 /**
37 * Update the is_active flag in the db.
38 *
39 * @param int $id
40 * Id of the database record.
41 * @param bool $is_active
42 * Value we want to set the is_active field.
43 * @throws CRM_Core_Exception
44 */
45 public static function setIsActive($id, $is_active) {
46 throw new CRM_Core_Exception('Cannot call setIsActive function');
47 }
48
49 /**
50 * Delete preference dates.
51 *
52 * @param int $id
53 * @throws CRM_Core_Exception
54 */
55 public static function del($id) {
56 throw new CRM_Core_Exception('Cannot call del function');
57 }
58
59 /**
60 * (Setting Callback - On Change)
61 * Respond to changes in the "timeInputFormat" setting.
62 *
63 * @param array $oldValue
64 * List of component names.
65 * @param array $newValue
66 * List of component names.
67 * @param array $metadata
68 * Specification of the setting (per *.settings.php).
69 */
70 public static function onChangeSetting($oldValue, $newValue, $metadata) {
71 if ($oldValue == $newValue) {
72 return;
73 }
74
75 $query = "
76 UPDATE civicrm_preferences_date
77 SET time_format = %1
78 WHERE time_format IS NOT NULL
79 AND time_format <> ''
80 ";
81 $sqlParams = [1 => [$newValue, 'String']];
82 CRM_Core_DAO::executeQuery($query, $sqlParams);
83 }
84
85 }