Merge pull request #17008 from ivan-compucorp/CPS-70-fix-radio-value
[civicrm-core.git] / CRM / Core / BAO / PreferencesDate.php
CommitLineData
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 */
17class 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.
ac15829d 60 * @throws CRM_Core_Exception
6a488035 61 */
00be9182 62 public static function setIsActive($id, $is_active) {
ac15829d 63 throw new CRM_Core_Exception('Cannot call setIsActive function');
6a488035
TO
64 }
65
66 /**
fe482240 67 * Delete preference dates.
6a488035 68 *
6a0b768e 69 * @param int $id
ac15829d 70 * @throws CRM_Core_Exception
6a488035 71 */
00be9182 72 public static function del($id) {
ac15829d 73 throw new CRM_Core_Exception('Cannot call del function');
6a488035 74 }
96025800 75
630d30ec
TO
76 /**
77 * (Setting Callback - On Change)
78 * Respond to changes in the "timeInputFormat" setting.
79 *
80 * @param array $oldValue
81 * List of component names.
82 * @param array $newValue
83 * List of component names.
84 * @param array $metadata
85 * Specification of the setting (per *.settings.php).
86 */
87 public static function onChangeSetting($oldValue, $newValue, $metadata) {
88 if ($oldValue == $newValue) {
89 return;
90 }
91
92 $query = "
93UPDATE civicrm_preferences_date
94SET time_format = %1
95WHERE time_format IS NOT NULL
96AND time_format <> ''
97";
be2fb01f 98 $sqlParams = [1 => [$newValue, 'String']];
630d30ec
TO
99 CRM_Core_DAO::executeQuery($query, $sqlParams);
100 }
101
6a488035 102}