Merge pull request #13241 from seamuslee001/561_schedule_reminders
[civicrm-core.git] / CRM / Core / BAO / PreferencesDate.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
6b83d5bd 6 | Copyright CiviCRM LLC (c) 2004-2019 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
6b83d5bd 31 * @copyright CiviCRM LLC (c) 2004-2019
6a488035
TO
32 */
33class CRM_Core_BAO_PreferencesDate extends CRM_Core_DAO_PreferencesDate {
34
35 /**
fe482240 36 * Static holder for the default LT.
6a488035
TO
37 */
38 static $_defaultPreferencesDate = NULL;
39
40 /**
fe482240 41 * Class constructor.
6a488035 42 */
00be9182 43 public function __construct() {
6a488035
TO
44 parent::__construct();
45 }
46
47 /**
fe482240 48 * Fetch object based on array of properties.
6a488035 49 *
6a0b768e
TO
50 * @param array $params
51 * (reference ) an assoc array of name/value pairs.
52 * @param array $defaults
53 * (reference ) an assoc array to hold the flattened values.
6a488035 54 *
16b10e64
CW
55 * @return CRM_Core_BAO_PreferencesDate|null
56 * object on success, null otherwise
6a488035 57 */
00be9182 58 public static function retrieve(&$params, &$defaults) {
6a488035
TO
59 $dao = new CRM_Core_DAO_PreferencesDate();
60 $dao->copyValues($params);
61 if ($dao->find(TRUE)) {
62 CRM_Core_DAO::storeValues($dao, $defaults);
63 return $dao;
64 }
65 return NULL;
66 }
67
68 /**
fe482240 69 * Update the is_active flag in the db.
6a488035 70 *
6a0b768e
TO
71 * @param int $id
72 * Id of the database record.
73 * @param bool $is_active
74 * Value we want to set the is_active field.
6a488035 75 */
00be9182 76 public static function setIsActive($id, $is_active) {
6a488035
TO
77 CRM_Core_Error::fatal();
78 }
79
80 /**
fe482240 81 * Delete preference dates.
6a488035 82 *
6a0b768e 83 * @param int $id
6a488035 84 */
00be9182 85 public static function del($id) {
6a488035
TO
86 CRM_Core_Error::fatal();
87 }
96025800 88
630d30ec
TO
89 /**
90 * (Setting Callback - On Change)
91 * Respond to changes in the "timeInputFormat" setting.
92 *
93 * @param array $oldValue
94 * List of component names.
95 * @param array $newValue
96 * List of component names.
97 * @param array $metadata
98 * Specification of the setting (per *.settings.php).
99 */
100 public static function onChangeSetting($oldValue, $newValue, $metadata) {
101 if ($oldValue == $newValue) {
102 return;
103 }
104
105 $query = "
106UPDATE civicrm_preferences_date
107SET time_format = %1
108WHERE time_format IS NOT NULL
109AND time_format <> ''
110";
111 $sqlParams = array(1 => array($newValue, 'String'));
112 CRM_Core_DAO::executeQuery($query, $sqlParams);
113 }
114
6a488035 115}