forked from opendream/hotri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsQuery.php
129 lines (119 loc) · 5.26 KB
/
SettingsQuery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/* This file is part of a copyrighted work; it is distributed with NO WARRANTY.
* See the file COPYRIGHT.html for more details.
*/
require_once("../shared/global_constants.php");
require_once("../classes/Query.php");
/******************************************************************************
* SettingsQuery data access component for settings table
*
* @author David Stevens <[email protected]>;
* @version 1.0
* @access public
******************************************************************************
*/
class SettingsQuery extends Query {
/****************************************************************************
* Executes a query
* @return boolean returns false, if error occurs
* @access public
****************************************************************************
*/
function execSelect() {
$sql = "select * from settings";
return $this->_query($sql, "Error accessing library settings information.");
}
/****************************************************************************
* Fetches a row from the query result and populates the Settings object.
* @return Settings returns settings object or false if no more rows to fetch
* @access public
****************************************************************************
*/
function fetchRow() {
$array = $this->_conn->fetchRow();
if ($array == false) {
return false;
}
$set = new Settings();
$set->setLibraryName($array["library_name"]);
$set->setLibraryImageUrl($array["library_image_url"]);
if ($array["use_image_flg"] == 'Y') {
$set->setUseImageFlg(true);
} else {
$set->setUseImageFlg(false);
}
$set->setLibraryHours($array["library_hours"]);
$set->setLibraryPhone($array["library_phone"]);
$set->setLibraryUrl($array["library_url"]);
$set->setOpacUrl($array["opac_url"]);
$set->setSessionTimeout($array["session_timeout"]);
$set->setItemsPerPage($array["items_per_page"]);
$set->setVersion($array["version"]);
$set->setThemeid($array["themeid"]);
$set->setPurgeHistoryAfterMonths($array["purge_history_after_months"]);
if ($array["block_checkouts_when_fines_due"] == 'Y') {
$set->setBlockCheckoutsWhenFinesDue(true);
} else {
$set->setBlockCheckoutsWhenFinesDue(false);
}
$set->setHoldMaxDays($array["hold_max_days"]);
$set->setLocale($array["locale"]);
$set->setCharset($array["charset"]);
$set->setHtmlLangAttr($array["html_lang_attr"]);
$set->setInactiveMemberAfterDays($array["inactive_member_after_days"]);
$set->setFontNormal($array["font_normal"]);
$set->setFontSize($array["font_size"]);
return $set;
}
/****************************************************************************
* Update a the row in the settings table.
* @param Settings $set settings object to update
* @return boolean returns false, if error occurs
* @access public
****************************************************************************
*/
function update($set) {
$sql = $this->mkSQL("update settings set "
. "library_name=%Q, library_image_url=%Q, "
. "use_image_flg=%Q, library_hours=%Q, "
. "library_phone=%Q, library_url=%Q, "
. "opac_url=%Q, session_timeout=%N, "
. "items_per_page=%N, purge_history_after_months=%N, "
. "block_checkouts_when_fines_due=%Q, "
. "hold_max_days=%N, "
. "locale=%Q, charset=%Q, html_lang_attr=%Q, "
. "font_normal=%Q, font_size=%Q, inactive_member_after_days=%Q",
$set->getLibraryName(), $set->getLibraryImageUrl(),
$set->isUseImageSet() ? "Y" : "N",
$set->getLibraryHours(), $set->getLibraryPhone(),
$set->getLibraryUrl(), $set->getOpacUrl(),
$set->getSessionTimeout(), $set->getItemsPerPage(),
$set->getPurgeHistoryAfterMonths(),
$set->isBlockCheckoutsWhenFinesDue() ? "Y" : "N",
$set->getHoldMaxDays(),
$set->getLocale(), $set->getCharset(),
$set->getHtmlLangAttr(),
$set->getFontNormal(), $set->getFontSize(), $set->getInactiveMemberAfterDays());
return $this->_query($sql, "Error updating library settings information");
}
/****************************************************************************
* Update a the row in the settings table.
* @param Settings $set settings object to update
* @return boolean returns false, if error occurs
* @access public
****************************************************************************
*/
function updateTheme($themeId) {
$sql = $this->mkSQL("update settings set themeid=%N", $themeId);
return $this->_query($sql, "Error updating library theme in use");
}
function getPurgeHistoryAfterMonths($query) {
$sql = "select purge_history_after_months from settings";
$rows = $query->exec($sql);
if (count($rows) != 1) {
Fatal::internalError("Wrong number of settings rows");
}
return $rows[0]["purge_history_after_months"];
}
}
?>