Merge pull request #15322 from alifrumin/removePrintIcon
[civicrm-core.git] / CRM / Core / BAO / PreferencesDate.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2019
32 */
33 class CRM_Core_BAO_PreferencesDate extends CRM_Core_DAO_PreferencesDate {
34
35 /**
36 * Static holder for the default LT.
37 * @var string
38 */
39 public static $_defaultPreferencesDate = NULL;
40
41 /**
42 * Class constructor.
43 */
44 public function __construct() {
45 parent::__construct();
46 }
47
48 /**
49 * Fetch object based on array of properties.
50 *
51 * @param array $params
52 * (reference ) an assoc array of name/value pairs.
53 * @param array $defaults
54 * (reference ) an assoc array to hold the flattened values.
55 *
56 * @return CRM_Core_BAO_PreferencesDate|null
57 * object on success, null otherwise
58 */
59 public static function retrieve(&$params, &$defaults) {
60 $dao = new CRM_Core_DAO_PreferencesDate();
61 $dao->copyValues($params);
62 if ($dao->find(TRUE)) {
63 CRM_Core_DAO::storeValues($dao, $defaults);
64 return $dao;
65 }
66 return NULL;
67 }
68
69 /**
70 * Update the is_active flag in the db.
71 *
72 * @param int $id
73 * Id of the database record.
74 * @param bool $is_active
75 * Value we want to set the is_active field.
76 */
77 public static function setIsActive($id, $is_active) {
78 CRM_Core_Error::fatal();
79 }
80
81 /**
82 * Delete preference dates.
83 *
84 * @param int $id
85 */
86 public static function del($id) {
87 CRM_Core_Error::fatal();
88 }
89
90 /**
91 * (Setting Callback - On Change)
92 * Respond to changes in the "timeInputFormat" setting.
93 *
94 * @param array $oldValue
95 * List of component names.
96 * @param array $newValue
97 * List of component names.
98 * @param array $metadata
99 * Specification of the setting (per *.settings.php).
100 */
101 public static function onChangeSetting($oldValue, $newValue, $metadata) {
102 if ($oldValue == $newValue) {
103 return;
104 }
105
106 $query = "
107 UPDATE civicrm_preferences_date
108 SET time_format = %1
109 WHERE time_format IS NOT NULL
110 AND time_format <> ''
111 ";
112 $sqlParams = [1 => [$newValue, 'String']];
113 CRM_Core_DAO::executeQuery($query, $sqlParams);
114 }
115
116 }