Merge lp:~dangarner/xibo/server-160rc2 into lp:xibo/1.6
- server-160rc2
- Merge into ponswinnecke
Proposed by
Dan Garner
Status: | Merged |
---|---|
Approved by: | Dan Garner |
Approved revision: | 346 |
Merged at revision: | 317 |
Proposed branch: | lp:~dangarner/xibo/server-160rc2 |
Merge into: | lp:xibo/1.6 |
Diff against target: |
7269 lines (+2762/-2878) 59 files modified
server/3rdparty/simplepie/library/SimplePie/File.php (+9/-0) server/install.php (+0/-748) server/install/database/46.php (+3/-3) server/install/database/66.sql (+2/-2) server/install/database/67.sql (+30/-0) server/install/master/data.sql (+9/-4) server/install/master/structure.sql (+14/-1) server/lib/app/kit.class.php (+69/-64) server/lib/app/modulemanager.class.php (+80/-80) server/lib/app/pagemanager.class.php (+9/-7) server/lib/app/thememanager.class.php (+5/-2) server/lib/data/display.data.class.php (+64/-12) server/lib/data/displaygroup.data.class.php (+303/-202) server/lib/data/layout.data.class.php (+51/-0) server/lib/data/lkmediadisplaygroup.data.class.php (+113/-0) server/lib/data/media.data.class.php (+31/-2) server/lib/data/schedule.data.class.php (+2/-2) server/lib/include.php (+1/-1) server/lib/modules/module.class.php (+9/-5) server/lib/pages/content.class.php (+11/-2) server/lib/pages/display.class.php (+16/-2) server/lib/pages/displaygroup.class.php (+599/-328) server/lib/pages/layout.class.php (+2/-2) server/lib/pages/module.class.php (+5/-2) server/lib/pages/schedule.class.php (+3/-3) server/lib/pages/stats.class.php (+3/-3) server/lib/pages/statusdashboard.class.php (+1/-1) server/lib/service/xmdssoap.class.php (+113/-63) server/locale/dbtranslate.php (+4/-0) server/manual/content/admin/fileassociations.php (+33/-0) server/manual/content/content/content_genericfile.php (+25/-0) server/manual/content/routes.php (+2/-0) server/manual/content/toc_library.php (+1/-0) server/manual/content/toc_user_and_display.php (+1/-0) server/modules/datasetview.module.php (+16/-7) server/modules/genericfile.module.php (+128/-0) server/modules/module_user_general.php (+615/-582) server/modules/preview/HtmlTemplateForGetResource.html (+3/-1) server/modules/preview/html-preview.js (+3/-3) server/modules/preview/xibo-text-render.js (+49/-17) server/modules/text.module.php (+3/-1) server/modules/ticker.module.php (+3/-1) server/theme/default/css/xibo.css (+46/-27) server/theme/default/html/display_form_version_instructions.php (+56/-0) server/theme/default/html/displaygroup_fileassociations_form_assign.php (+58/-0) server/theme/default/html/displaygroup_fileassociations_form_assign_list.php (+39/-0) server/theme/default/html/footer.php (+2/-1) server/theme/default/html/library_form_media_add.php (+6/-6) server/theme/default/html/library_form_media_edit.php (+2/-1) server/theme/default/html/media_form_ticker_add.php (+2/-2) server/theme/default/html/media_form_ticker_edit.php (+1/-1) server/theme/default/html/media_form_webpage_add.php (+1/-1) server/theme/default/html/media_form_webpage_edit.php (+1/-1) server/theme/default/html/module_page_grid.php (+2/-0) server/theme/default/js/xibo-forms.js (+68/-0) server/theme/default/js/xibo-layout-designer.js (+18/-0) server/theme/default/libraries/bootstrap/js/bootstrap-ckeditor-fix.js (+15/-0) server/theme/default/libraries/ckeditor/config.js (+2/-2) server/upgrade.php (+0/-683) |
To merge this branch: | bzr merge lp:~dangarner/xibo/server-160rc2 |
Related bugs: |
|
Related blueprints: |
Add Clock Media Type
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Xibo Maintainters | Pending | ||
Review via email: mp+213360@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'server/3rdparty/simplepie/library/SimplePie/File.php' | |||
2 | --- server/3rdparty/simplepie/library/SimplePie/File.php 2013-05-11 15:26:38 +0000 | |||
3 | +++ server/3rdparty/simplepie/library/SimplePie/File.php 2014-03-29 13:09:24 +0000 | |||
4 | @@ -113,6 +113,15 @@ | |||
5 | 113 | curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); | 113 | curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); |
6 | 114 | } | 114 | } |
7 | 115 | 115 | ||
8 | 116 | // Dan Garner PATCH | ||
9 | 117 | if (Config::GetSetting('PROXY_HOST') != '') { | ||
10 | 118 | curl_setopt($fp, CURLOPT_PROXY, Config::GetSetting('PROXY_HOST')); | ||
11 | 119 | curl_setopt($fp, CURLOPT_PROXYPORT, Config::GetSetting('PROXY_PORT')); | ||
12 | 120 | |||
13 | 121 | if (Config::GetSetting('PROXY_AUTH') != '') | ||
14 | 122 | curl_setopt($fp, CURLOPT_PROXYUSERPWD, Config::GetSetting('PROXY_AUTH')); | ||
15 | 123 | } | ||
16 | 124 | |||
17 | 116 | $this->headers = curl_exec($fp); | 125 | $this->headers = curl_exec($fp); |
18 | 117 | if (curl_errno($fp) === 23 || curl_errno($fp) === 61) | 126 | if (curl_errno($fp) === 23 || curl_errno($fp) === 61) |
19 | 118 | { | 127 | { |
20 | 119 | 128 | ||
21 | === removed file 'server/install.php' | |||
22 | --- server/install.php 2013-08-21 22:27:13 +0000 | |||
23 | +++ server/install.php 1970-01-01 00:00:00 +0000 | |||
24 | @@ -1,748 +0,0 @@ | |||
25 | 1 | <?php | ||
26 | 2 | /* | ||
27 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | ||
28 | 4 | * Copyright (C) 2009-2013 Alex Harrington | ||
29 | 5 | * | ||
30 | 6 | * This file is part of Xibo. | ||
31 | 7 | * | ||
32 | 8 | * Xibo is free software: you can redistribute it and/or modify | ||
33 | 9 | * it under the terms of the GNU Affero General Public License as published by | ||
34 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
35 | 11 | * any later version. | ||
36 | 12 | * | ||
37 | 13 | * Xibo is distributed in the hope that it will be useful, | ||
38 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
39 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
40 | 16 | * GNU Affero General Public License for more details. | ||
41 | 17 | * | ||
42 | 18 | * You should have received a copy of the GNU Affero General Public License | ||
43 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | ||
44 | 20 | */ | ||
45 | 21 | DEFINE('XIBO', true); | ||
46 | 22 | |||
47 | 23 | if (! checkPHP()) | ||
48 | 24 | { | ||
49 | 25 | die('Xibo requires PHP 5.2.4 or later'); | ||
50 | 26 | } | ||
51 | 27 | |||
52 | 28 | error_reporting(0); | ||
53 | 29 | ini_set('display_errors', 0); | ||
54 | 30 | |||
55 | 31 | include('lib/app/kit.class.php'); | ||
56 | 32 | include('install/header.inc'); | ||
57 | 33 | include('config/config.class.php'); | ||
58 | 34 | include('config/db_config.php'); | ||
59 | 35 | |||
60 | 36 | // Setup for the Translations using Gettext. | ||
61 | 37 | // There is normally a class that will do this for us - but it requires a DB object (which we do not have at install time) | ||
62 | 38 | // Would be nice to include a method on the TranslationEngine that did this for us - but without the debugging | ||
63 | 39 | // The actual translation function __() is included later in this file. | ||
64 | 40 | $langs = Kit::GetParam('HTTP_ACCEPT_LANGUAGE', $_SERVER, _STRING); | ||
65 | 41 | $lang = 'en-gb'; // Default language | ||
66 | 42 | $encoding = ''; // We do not seem to need an encoding, but I read somewhere that we might - left as a reminder of this. | ||
67 | 43 | |||
68 | 44 | if ($langs != '') | ||
69 | 45 | { | ||
70 | 46 | $langs = explode(',', $langs); | ||
71 | 47 | $lang = $langs[0]; | ||
72 | 48 | } | ||
73 | 49 | |||
74 | 50 | // For windows | ||
75 | 51 | putenv('LANG='.$lang.'.'.$encoding); | ||
76 | 52 | putenv('LANGUAGE='.$lang.'.'.$encoding); | ||
77 | 53 | putenv('LC_ALL='.$lang.'.'.$encoding); | ||
78 | 54 | |||
79 | 55 | // Set local | ||
80 | 56 | setlocale(LC_ALL, $lang.'.'.$encoding); | ||
81 | 57 | |||
82 | 58 | // Translations have been setup. | ||
83 | 59 | |||
84 | 60 | $fault = false; | ||
85 | 61 | |||
86 | 62 | $xibo_step = Kit::GetParam('xibo_step',_POST,_INT,'0'); | ||
87 | 63 | |||
88 | 64 | if (!isset($xibo_step) || $xibo_step == 0) { | ||
89 | 65 | # First step of the process. | ||
90 | 66 | # Show a welcome screen and next button | ||
91 | 67 | ?> | ||
92 | 68 | <?php echo __("Welcome to the Xibo Installer!"); ?><br /><br /> | ||
93 | 69 | <?php echo __("The installer will take you through setting up Xibo one step at a time."); ?><br /><br /> | ||
94 | 70 | <?php echo __("Lets get started!"); ?><br /><br /> | ||
95 | 71 | <form action="install.php" method="POST"> | ||
96 | 72 | <input type="hidden" name="xibo_step" value="1" /> | ||
97 | 73 | <div class="loginbutton"><button type="submit"><?php echo __("Next"); ?> ></button></div> | ||
98 | 74 | </form> | ||
99 | 75 | <?php | ||
100 | 76 | } | ||
101 | 77 | elseif ($xibo_step == 1) { | ||
102 | 78 | # Check environment | ||
103 | 79 | $db = new Database(); | ||
104 | 80 | $cObj = new Config(); | ||
105 | 81 | ?> | ||
106 | 82 | <p><?php echo __("First we need to check if your server meets Xibo's requirements."); ?></p> | ||
107 | 83 | <div class="checks"> | ||
108 | 84 | <?php | ||
109 | 85 | echo $cObj->CheckEnvironment(); | ||
110 | 86 | if ($cObj->EnvironmentFault()) { | ||
111 | 87 | ?> | ||
112 | 88 | <form action="install.php" method="POST"> | ||
113 | 89 | <input type="hidden" name="xibo_step" value="1" /> | ||
114 | 90 | <div class="loginbutton"><button type="submit"><?php echo __("Retest"); ?></button></div> | ||
115 | 91 | </form> | ||
116 | 92 | <?php | ||
117 | 93 | } | ||
118 | 94 | else if ($cObj->EnvironmentWarning()) { | ||
119 | 95 | ?> | ||
120 | 96 | <form action="install.php" method="POST"> | ||
121 | 97 | <input type="hidden" name="xibo_step" value="1" /> | ||
122 | 98 | <div class="loginbutton"><button type="submit"><?php echo __("Retest"); ?></button></div> | ||
123 | 99 | </form> | ||
124 | 100 | <form action="install.php" method="POST"> | ||
125 | 101 | <input type="hidden" name="xibo_step" value="2" /> | ||
126 | 102 | <div class="loginbutton"><button type="submit"><?php echo __("Next"); ?> ></button></div> | ||
127 | 103 | </form> | ||
128 | 104 | <?php | ||
129 | 105 | } | ||
130 | 106 | else { | ||
131 | 107 | ?> | ||
132 | 108 | <form action="install.php" method="POST"> | ||
133 | 109 | <input type="hidden" name="xibo_step" value="2" /> | ||
134 | 110 | <div class="loginbutton"><button type="submit"><?php echo __("Next"); ?> ></button></div> | ||
135 | 111 | </form> | ||
136 | 112 | <?php | ||
137 | 113 | } | ||
138 | 114 | } | ||
139 | 115 | elseif ($xibo_step == 2) { | ||
140 | 116 | # Create database | ||
141 | 117 | ## Does database exist already? | ||
142 | 118 | |||
143 | 119 | ?> | ||
144 | 120 | <div class="info"> | ||
145 | 121 | <p><?php echo __("Xibo needs to setup a new database."); ?></p> | ||
146 | 122 | <p><?php echo __("If you have not yet created an empty database and database user for Xibo to use, and know the username/password of a MySQL administrator, click the \"Create New\" button, otherwise click \"Use Existing\"."); ?></p> | ||
147 | 123 | <p><i><?php echo __("Note that any existing database must be empty"); ?></i></p> | ||
148 | 124 | </div> | ||
149 | 125 | <form action="install.php" method="POST"> | ||
150 | 126 | <input type="hidden" name="xibo_step" value="3" /> | ||
151 | 127 | <button type="submit"><?php echo __("Create New"); ?></button> | ||
152 | 128 | </form> | ||
153 | 129 | <form action="install.php" method="POST"> | ||
154 | 130 | <input type="hidden" name="xibo_step" value="4" /> | ||
155 | 131 | <button type="submit"><?php echo __("Use Existing"); ?></button> | ||
156 | 132 | </form> | ||
157 | 133 | <?php | ||
158 | 134 | } | ||
159 | 135 | elseif ($xibo_step == 3) { | ||
160 | 136 | ## If not, gather admin password and use to create empty db and new user. | ||
161 | 137 | ?> | ||
162 | 138 | <div class="info"> | ||
163 | 139 | <p><?php echo __("Since no empty database has been created for Xibo to use, we need the username and password of a MySQL administrator to create a new database, and database user for Xibo."); ?></p> | ||
164 | 140 | <p><?php echo __("Additionally, please give us a new username and password to create in MySQL for Xibo to use. Xibo will create this automatically for you."); ?></p> | ||
165 | 141 | <form action="install.php" method="POST"> | ||
166 | 142 | <input type="hidden" name="xibo_step" value="5" /> | ||
167 | 143 | <input type="hidden" name="db_create" value="On" /> | ||
168 | 144 | <div class="install_table"> | ||
169 | 145 | <p><label for="host"><?php echo __("Host:"); ?> </label><input class="username" type="text" id="host" name="host" size="12" value="localhost" /></p> | ||
170 | 146 | <p><label for="admin_username"><?php echo __("Admin Username:"); ?> </label><input class="username" type="text" id="admin_username" name="admin_username" size="12" /></p> | ||
171 | 147 | <p><label for="admin_password"><?php echo __("Admin Password:"); ?> </label><input class="username" type="password" id="admin_password" name="admin_password" size="12" /></p> | ||
172 | 148 | <p><label for="db_name"><?php echo __("Xibo Database Name:"); ?> </label><input class="username" type="text" id="db_name" name="db_name" size="12" value="xibo" /></p> | ||
173 | 149 | <p><label for="db_username"><?php echo __("Xibo Database Username:"); ?> </label><input class="username" type="text" id="db_username" name="db_username" size="12" value="xibo" /></p> | ||
174 | 150 | <p><label for="db_password"><?php echo __("Xibo Database Password:"); ?> </label><input class="username" type="password" id="db_password" name="db_password" size="12" /></p> | ||
175 | 151 | </div> | ||
176 | 152 | </div> | ||
177 | 153 | <button type="submit"><?php echo __("Create"); ?></button> | ||
178 | 154 | </form> | ||
179 | 155 | <?php | ||
180 | 156 | } | ||
181 | 157 | elseif ($xibo_step == 4) { | ||
182 | 158 | ## Get details of db that's been created already for us | ||
183 | 159 | ?> | ||
184 | 160 | <div class="info"> | ||
185 | 161 | <p><?php echo __("Please enter the details of the database and user you have created for Xibo."); ?></p> | ||
186 | 162 | <form action="install.php" method="POST"> | ||
187 | 163 | <input type="hidden" name="xibo_step" value="5" /> | ||
188 | 164 | <input type="hidden" name="db_create" value="Off" /> | ||
189 | 165 | <div class="install_table"> | ||
190 | 166 | <p><label for="host"><?php echo __("Host:"); ?> </label><input class="username" type="text" id="host" name="host" size="12" value="localhost" /></p> | ||
191 | 167 | <p><label for="db_name"><?php echo __("Xibo Database Name:"); ?> </label><input class="username" type="text" id="db_name" name="db_name" size="12" value="xibo" /></p> | ||
192 | 168 | <p><label for="db_username"><?php echo __("Xibo Database Username:"); ?> </label><input class="username" type="text" id="db_username" name="db_username" size="12" value="xibo" /></p> | ||
193 | 169 | <p><label for="db_password"><?php echo __("Xibo Database Password:"); ?> </label><input class="username" type="password" id="db_password" name="db_password" size="12" /></p> | ||
194 | 170 | </div> | ||
195 | 171 | </div> | ||
196 | 172 | <button type="submit"><?php echo __("Create"); ?></button> | ||
197 | 173 | </form> | ||
198 | 174 | <?php | ||
199 | 175 | } | ||
200 | 176 | elseif ($xibo_step == 5) { | ||
201 | 177 | |||
202 | 178 | $db_create = Kit::GetParam('db_create',_POST,_STRING); | ||
203 | 179 | |||
204 | 180 | if (!isset($db_create)) { | ||
205 | 181 | reportError("2",__("Something went wrong")); | ||
206 | 182 | } | ||
207 | 183 | else { | ||
208 | 184 | $db_host = Kit::GetParam('host',_POST,_STRING,'localhost'); | ||
209 | 185 | $db_user = Kit::GetParam('db_username',_POST,_PASSWORD); | ||
210 | 186 | $db_pass = Kit::GetParam('db_password',_POST,_PASSWORD); | ||
211 | 187 | $db_name = Kit::GetParam('db_name',_POST,_PASSWORD); | ||
212 | 188 | ?> | ||
213 | 189 | <div class="info"> | ||
214 | 190 | <?php | ||
215 | 191 | if ($db_create == 'On') { | ||
216 | 192 | $db_admin_user = Kit::GetParam('admin_username',_POST,_PASSWORD); | ||
217 | 193 | $db_admin_pass = Kit::GetParam('admin_password',_POST,_PASSWORD); | ||
218 | 194 | |||
219 | 195 | if (! ($db_host && $db_name && $db_user && $db_admin_user)) { | ||
220 | 196 | # Something was blank. | ||
221 | 197 | # Throw an error. | ||
222 | 198 | reportError("3", __("A field was blank. Please fill in all fields.")); | ||
223 | 199 | } | ||
224 | 200 | |||
225 | 201 | $db = @mysql_connect($db_host,$db_admin_user,$db_admin_pass); | ||
226 | 202 | |||
227 | 203 | if (! $db) { | ||
228 | 204 | reportError("3", __("Could not connect to MySQL with the administrator details. Please check and try again.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
229 | 205 | } | ||
230 | 206 | |||
231 | 207 | ?> | ||
232 | 208 | <p><?php echo __("Creating new database."); ?></p> | ||
233 | 209 | <?php | ||
234 | 210 | flush(); | ||
235 | 211 | |||
236 | 212 | $SQL = sprintf("CREATE DATABASE `%s`", | ||
237 | 213 | mysql_real_escape_string($db_name)); | ||
238 | 214 | if (! @mysql_query($SQL, $db)) { | ||
239 | 215 | # Create database and user | ||
240 | 216 | reportError("3", __("Could not create a new database with the administrator details. Please check and try again.") . "<br /><br />" . "MySQL Error:" . "<br />" . mysql_error()); | ||
241 | 217 | } | ||
242 | 218 | |||
243 | 219 | # Choose the MySQL DB to create a user | ||
244 | 220 | @mysql_select_db("mysql", $db); | ||
245 | 221 | |||
246 | 222 | # Make $db_host lowercase so it matches "localhost" if required. | ||
247 | 223 | $db_host = strtolower($db_host); | ||
248 | 224 | |||
249 | 225 | ?> | ||
250 | 226 | <p><?php echo __("Creating new user"); ?></p> | ||
251 | 227 | <?php | ||
252 | 228 | flush(); | ||
253 | 229 | |||
254 | 230 | if ($db_host == 'localhost') { | ||
255 | 231 | $SQL = sprintf("GRANT ALL PRIVILEGES ON `%s`.* to '%s'@'%s' IDENTIFIED BY '%s'", | ||
256 | 232 | mysql_real_escape_string($db_name), | ||
257 | 233 | mysql_real_escape_string($db_user), | ||
258 | 234 | mysql_real_escape_string($db_host), | ||
259 | 235 | mysql_real_escape_string($db_pass)); | ||
260 | 236 | } | ||
261 | 237 | else { | ||
262 | 238 | $SQL = sprintf("GRANT ALL PRIVILEGES ON `%s`.* to '%s'@'%%' IDENTIFIED BY '%s'", | ||
263 | 239 | mysql_real_escape_string($db_name), | ||
264 | 240 | mysql_real_escape_string($db_user), | ||
265 | 241 | mysql_real_escape_string($db_pass)); | ||
266 | 242 | } | ||
267 | 243 | if (! @mysql_query($SQL, $db)) { | ||
268 | 244 | reportError("3", __("Could not create a new user with the administrator details. Please check and try again.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
269 | 245 | } | ||
270 | 246 | |||
271 | 247 | |||
272 | 248 | @mysql_query("FLUSH PRIVILEGES", $db); | ||
273 | 249 | @mysql_close($db); | ||
274 | 250 | |||
275 | 251 | } | ||
276 | 252 | else { | ||
277 | 253 | if (! ($db_host && $db_name && $db_user && $db_pass)) { | ||
278 | 254 | # Something was blank | ||
279 | 255 | # Throw an error. | ||
280 | 256 | reportError("4", __("A field was blank. Please fill in all fields.") . " " . $db_host . " " . $db_name . " " . $db_user . " " . $db_pass); | ||
281 | 257 | } | ||
282 | 258 | } | ||
283 | 259 | ## Populate database | ||
284 | 260 | |||
285 | 261 | $db = @mysql_connect($db_host,$db_user,$db_pass); | ||
286 | 262 | |||
287 | 263 | if (! $db) { | ||
288 | 264 | reportError("4", __("Could not connect to MySQL with the Xibo User account details. Please check and try again.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
289 | 265 | } | ||
290 | 266 | |||
291 | 267 | @mysql_select_db($db_name,$db); | ||
292 | 268 | |||
293 | 269 | ?> | ||
294 | 270 | <p>Populating the database</p> | ||
295 | 271 | <?php | ||
296 | 272 | flush(); | ||
297 | 273 | |||
298 | 274 | # Load from sql files to db - HOW? | ||
299 | 275 | $sql_files = array('structure.sql', 'data.sql'); | ||
300 | 276 | |||
301 | 277 | $sqlStatementCount = 0; | ||
302 | 278 | |||
303 | 279 | foreach ($sql_files as $filename) { | ||
304 | 280 | ?> | ||
305 | 281 | <p>Loading from <?php print $filename; ?> | ||
306 | 282 | <?php | ||
307 | 283 | flush(); | ||
308 | 284 | |||
309 | 285 | $delimiter = ';'; | ||
310 | 286 | $sql_file = @file_get_contents('install/master/' . $filename); | ||
311 | 287 | $sql_file = remove_remarks($sql_file); | ||
312 | 288 | $sql_file = split_sql_file($sql_file, $delimiter); | ||
313 | 289 | |||
314 | 290 | foreach ($sql_file as $sql) { | ||
315 | 291 | print "."; | ||
316 | 292 | $sqlStatementCount++; | ||
317 | 293 | flush(); | ||
318 | 294 | if (! @mysql_query($sql,$db)) { | ||
319 | 295 | reportError("4", __("An error occured populating the database.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error() . "<br /><br />SQL executed:<br />" . $sql . "<br /><br />Statement number: " . $sqlStatementCount); | ||
320 | 296 | } | ||
321 | 297 | } | ||
322 | 298 | print "</p>"; | ||
323 | 299 | } | ||
324 | 300 | @mysql_close($db); | ||
325 | 301 | } | ||
326 | 302 | # Write out a new settings.php | ||
327 | 303 | $fh = fopen("settings.php", 'wt'); | ||
328 | 304 | |||
329 | 305 | if (! $fh) { | ||
330 | 306 | reportError("0", __("Unable to write to settings.php. We already checked this was possible earlier, so something changed.")); | ||
331 | 307 | } | ||
332 | 308 | |||
333 | 309 | settings_strings(); | ||
334 | 310 | |||
335 | 311 | $settings_content = '$dbhost = \'' . $db_host . '\';' . "\n"; | ||
336 | 312 | $settings_content .= '$dbuser = \'' . $db_user . '\';' . "\n"; | ||
337 | 313 | $settings_content .= '$dbpass = \'' . $db_pass . '\';' . "\n"; | ||
338 | 314 | $settings_content .= '$dbname = \'' . $db_name . '\';' . "\n\n"; | ||
339 | 315 | $settings_content .= 'define(\'SECRET_KEY\',\'' . gen_secret() . '\');' . "\n"; | ||
340 | 316 | |||
341 | 317 | if (! fwrite($fh, $settings_header . $settings_content . $settings_footer)) { | ||
342 | 318 | reportError("0", __("Unable to write to settings.php. We already checked this was possible earlier, so something changed.")); | ||
343 | 319 | } | ||
344 | 320 | |||
345 | 321 | fclose($fh); | ||
346 | 322 | |||
347 | 323 | ?> | ||
348 | 324 | </div> | ||
349 | 325 | <div class="install_table"> | ||
350 | 326 | <form action="install.php" method="POST"> | ||
351 | 327 | <input type="hidden" name="xibo_step" value="6" /> | ||
352 | 328 | </div> | ||
353 | 329 | <button type="submit"><?php echo __("Next"); ?> ></button> | ||
354 | 330 | </form> | ||
355 | 331 | <?php | ||
356 | 332 | } | ||
357 | 333 | elseif ($xibo_step == 6) { | ||
358 | 334 | # Form to get new admin password | ||
359 | 335 | ?> | ||
360 | 336 | <div class="info"> | ||
361 | 337 | <p><?php echo __("Xibo needs to set the \"xibo_admin\" user password. Please enter a password for this account below."); ?></p> | ||
362 | 338 | </div> | ||
363 | 339 | <div class="install_table"> | ||
364 | 340 | <form action="install.php" method="POST"> | ||
365 | 341 | <input type="hidden" name="xibo_step" value="7" /> | ||
366 | 342 | <p><label for="password1"><?php echo __("Password:"); ?> </label><input type="password" name="password1" size="12" /></p> | ||
367 | 343 | <p><label for="password2"><?php echo __("Retype Password:"); ?> </label><input type="password" name="password2" size="12" /></p> | ||
368 | 344 | </div> | ||
369 | 345 | <button type="submit"><?php echo __("Next"); ?> ></button> | ||
370 | 346 | </form> | ||
371 | 347 | <?php | ||
372 | 348 | } | ||
373 | 349 | elseif ($xibo_step == 7) { | ||
374 | 350 | # Setup xibo_admin password | ||
375 | 351 | $password1 = Kit::GetParam('password1',_POST,_PASSWORD); | ||
376 | 352 | $password2 = Kit::GetParam('password2',_POST,_PASSWORD); | ||
377 | 353 | |||
378 | 354 | if (!(($password1 && $password2) && ($password1 == $password2))) { | ||
379 | 355 | reportError("6", __("Please input a new password. Ensure both password fields are identical.")); | ||
380 | 356 | } | ||
381 | 357 | |||
382 | 358 | include('settings.php'); | ||
383 | 359 | |||
384 | 360 | $password_hash = md5($password1); | ||
385 | 361 | |||
386 | 362 | $db = @mysql_connect($dbhost,$dbuser,$dbpass); | ||
387 | 363 | |||
388 | 364 | if (! $db) { | ||
389 | 365 | reportError("6", __("Could not connect to MySQL with the Xibo User account details saved in settings.php. Please check and try again.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
390 | 366 | } | ||
391 | 367 | |||
392 | 368 | @mysql_select_db($dbname,$db); | ||
393 | 369 | |||
394 | 370 | $SQL = sprintf("UPDATE `user` SET UserPassword = '%s' WHERE UserID = 1 LIMIT 1", | ||
395 | 371 | mysql_real_escape_string($password_hash)); | ||
396 | 372 | if (! @mysql_query($SQL, $db)) { | ||
397 | 373 | reportError("6", __("An error occured changing the xibo_admin password.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
398 | 374 | } | ||
399 | 375 | |||
400 | 376 | @mysql_close($db); | ||
401 | 377 | |||
402 | 378 | ?> | ||
403 | 379 | <div class="info"> | ||
404 | 380 | <?php echo __("Successfully changed the xibo_admin password. We're nearly there now. Just a couple more steps!"); ?> | ||
405 | 381 | </div> | ||
406 | 382 | <form action="install.php" method="POST"> | ||
407 | 383 | <input type="hidden" name="xibo_step" value="8" /> | ||
408 | 384 | <button type="submit"><?php echo __("Next"); ?> ></button> | ||
409 | 385 | </form> | ||
410 | 386 | <?php | ||
411 | 387 | } | ||
412 | 388 | elseif ($xibo_step == 8) { | ||
413 | 389 | # Configure paths and keys | ||
414 | 390 | ## nuSoap | ||
415 | 391 | ## libraries | ||
416 | 392 | ## server_key | ||
417 | 393 | ?> | ||
418 | 394 | <div class="info"> | ||
419 | 395 | <p><b><?php echo __("Library Location"); ?></b></p> | ||
420 | 396 | <p><?php echo __("Xibo needs somewhere to store the things you upload to be shown. Ideally, this should be somewhere outside the root of your webserver - that is such that is not accessible by a web browser. Please input the full path to this folder. If the folder does not already exist, Xibo will attempt to create it for you."); ?></p> | ||
421 | 397 | <form action="install.php" method="POST"> | ||
422 | 398 | <div class="install_table"> | ||
423 | 399 | <p><label for="library_location"><?php echo __("Library Location:"); ?> </label><input type="text" name="library_location" value="" /></p> | ||
424 | 400 | </div> | ||
425 | 401 | <p><b><?php echo __("Server Key"); ?></b></p> | ||
426 | 402 | <p><?php echo __("Xibo needs you to choose a \"key\". This will be required each time you setup a new client. It should be complicated, and hard to remember. It is visible in the admin interface, so it need not be written down separately."); ?></p> | ||
427 | 403 | <div class="install_table"> | ||
428 | 404 | <p><label for="server_key"><?php echo __("Server Key:"); ?> </label><input type="text" name="server_key" value="" /></p> | ||
429 | 405 | </div> | ||
430 | 406 | <p><b><?php echo __("Statistics"); ?></b></p> | ||
431 | 407 | <p><?php echo __("We'd love to know you're running Xibo. If you're happy for us to collect anonymous statistics (version number, number of displays) then please leave the box ticked. Please untick the box if your server does not have direct access to the internet."); ?></p> | ||
432 | 408 | <div class="install_table"> | ||
433 | 409 | <p><label for="stats"><?php echo __("Anonymous Statistics:"); ?> </label><input type="checkbox" name="stats" value="true" checked /></p> | ||
434 | 410 | </div> | ||
435 | 411 | <input type="hidden" name="xibo_step" value="9" /> | ||
436 | 412 | </div> | ||
437 | 413 | <button type="submit"><?php echo __("Next"); ?> ></button> | ||
438 | 414 | </form> | ||
439 | 415 | <?php | ||
440 | 416 | } | ||
441 | 417 | elseif ($xibo_step == 9) { | ||
442 | 418 | |||
443 | 419 | $server_key = Kit::GetParam('server_key',_POST,_STRING); | ||
444 | 420 | $library_location = Kit::GetParam('library_location',_POST,_STRING); | ||
445 | 421 | $stats = Kit::GetParam('stats',_POST,_BOOL); | ||
446 | 422 | |||
447 | 423 | // Remove trailing whitespace from the path given. | ||
448 | 424 | $library_location = trim($library_location); | ||
449 | 425 | |||
450 | 426 | // Check both fields were completed | ||
451 | 427 | if (! ($server_key && $library_location)) { | ||
452 | 428 | reportError("8", __("A field was blank. Please make sure you complete all fields")); | ||
453 | 429 | } | ||
454 | 430 | |||
455 | 431 | if ($stats) { | ||
456 | 432 | $stats="On"; // Fixme: translate ? | ||
457 | 433 | } | ||
458 | 434 | else { | ||
459 | 435 | $stats="Off"; //Fixme : translate ? | ||
460 | 436 | } | ||
461 | 437 | |||
462 | 438 | // Does library_location exist already? | ||
463 | 439 | if (! is_dir($library_location)) { | ||
464 | 440 | if (is_file($library_location)) { | ||
465 | 441 | reportError("8", __("A file exists with the name you gave for the Library Location. Please choose another location")); | ||
466 | 442 | } | ||
467 | 443 | |||
468 | 444 | // Directory does not exist. Attempt to make it | ||
469 | 445 | // Using mkdir recursively, so it will attempt to make any | ||
470 | 446 | // intermediate folders required. | ||
471 | 447 | if (! mkdir($library_location,0755,true)) { | ||
472 | 448 | reportError("8", __("Could not create the Library Location directory for you. Please ensure the webserver has permission to create a folder in this location, or create the folder manually and grant permission for the webserver to write to the folder.")); | ||
473 | 449 | } | ||
474 | 450 | |||
475 | 451 | } | ||
476 | 452 | |||
477 | 453 | // Is library_location writable? | ||
478 | 454 | if (! is_writable($library_location)) { | ||
479 | 455 | // Directory is not writable. | ||
480 | 456 | reportError("8", __("The Library Location you gave is not writable by the webserver. Please fix the permissions and try again.")); | ||
481 | 457 | } | ||
482 | 458 | |||
483 | 459 | // Is library_location empty? | ||
484 | 460 | if (count(ls("*",$library_location,true)) > 0) { | ||
485 | 461 | reportError("8", __("The Library Location you gave is not empty. Please give the location of an empty folder")); | ||
486 | 462 | } | ||
487 | 463 | |||
488 | 464 | // Check if the user has added a trailing slash. | ||
489 | 465 | // If not, add one. | ||
490 | 466 | if (!((substr($library_location, -1) == '/') || (substr($library_location, -1) == '\\'))) { | ||
491 | 467 | $library_location = $library_location . '/'; | ||
492 | 468 | } | ||
493 | 469 | |||
494 | 470 | include('settings.php'); | ||
495 | 471 | |||
496 | 472 | $db = @mysql_connect($dbhost,$dbuser,$dbpass); | ||
497 | 473 | |||
498 | 474 | if (! $db) { | ||
499 | 475 | reportError("8", __("Could not connect to MySQL with the Xibo User account details saved in settings.php. Please check and try again.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
500 | 476 | } | ||
501 | 477 | |||
502 | 478 | @mysql_select_db($dbname,$db); | ||
503 | 479 | |||
504 | 480 | $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'LIBRARY_LOCATION' LIMIT 1", | ||
505 | 481 | mysql_real_escape_string($library_location)); | ||
506 | 482 | if (! @mysql_query($SQL, $db)) { | ||
507 | 483 | reportError("8", __("An error occured changing the library location.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
508 | 484 | } | ||
509 | 485 | |||
510 | 486 | $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'SERVER_KEY' LIMIT 1", | ||
511 | 487 | mysql_real_escape_string($server_key)); | ||
512 | 488 | if (! @mysql_query($SQL, $db)) { | ||
513 | 489 | reportError("8", __("An error occured changing the server key.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
514 | 490 | } | ||
515 | 491 | |||
516 | 492 | $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'defaultTimezone' LIMIT 1", | ||
517 | 493 | mysql_real_escape_string(date_default_timezone_get())); | ||
518 | 494 | if (! @mysql_query($SQL, $db)) { | ||
519 | 495 | reportError("8", __("An error occured setting the default timezone.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
520 | 496 | } | ||
521 | 497 | |||
522 | 498 | $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'PHONE_HOME' LIMIT 1", | ||
523 | 499 | mysql_real_escape_string($stats)); | ||
524 | 500 | if (! @mysql_query($SQL, $db)) { | ||
525 | 501 | reportError("8", __("An error occured setting anonymous statistics.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
526 | 502 | } | ||
527 | 503 | $SQL = "UPDATE `setting` SET `value` = '" . md5(uniqid(rand(), true)) . "' WHERE `setting`.`setting` = 'PHONE_HOME_KEY' LIMIT 1"; | ||
528 | 504 | if (! @mysql_query($SQL, $db)) { | ||
529 | 505 | reportError("8", __("An error occured setting anonymous statistics.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error()); | ||
530 | 506 | } | ||
531 | 507 | |||
532 | 508 | @mysql_close($db); | ||
533 | 509 | |||
534 | 510 | ?> | ||
535 | 511 | <div class="info"> | ||
536 | 512 | <p><?php echo __("Successfully set library location and server key."); ?></p> | ||
537 | 513 | </div> | ||
538 | 514 | <form action="install.php" method="POST"> | ||
539 | 515 | <input type="hidden" name="xibo_step" value="10" /> | ||
540 | 516 | <button type="submit"><?php echo __("Next"); ?> ></button> | ||
541 | 517 | </form> | ||
542 | 518 | <?php | ||
543 | 519 | } | ||
544 | 520 | elseif ($xibo_step == 10) { | ||
545 | 521 | # Delete install.php | ||
546 | 522 | # Redirect to login page. | ||
547 | 523 | if (! unlink('install.php')) { | ||
548 | 524 | reportError("10", __("Unable to delete install.php. Please ensure the webserver has permission to unlink this file and retry"), __("Retry")); // Fixme : translate "Retry" ? | ||
549 | 525 | } | ||
550 | 526 | if (! unlink('upgrade.php')) { | ||
551 | 527 | reportError("10", __("Unable to delete upgrade.php. Please ensure the webserver has permission to unlink this file and retry"), __("Retry")); // Fixme : translate "Retry" ? | ||
552 | 528 | } | ||
553 | 529 | ?> | ||
554 | 530 | <div class="info"> | ||
555 | 531 | <p><b><?php echo __("Xibo was successfully installed."); ?></b></p> | ||
556 | 532 | <p><?php echo __("Please click"); ?> <a href="index.php"><?php echo __("here"); ?></a> <?php echo __("to logon to Xibo as \"xibo_admin\" with the password you chose earlier."); ?></p> | ||
557 | 533 | </div> | ||
558 | 534 | <?php | ||
559 | 535 | } | ||
560 | 536 | else { | ||
561 | 537 | reportError("0", __("A required parameter was missing. Please go through the installer sequentially!"), __("Start Again")); // Fixme : translate "Start Again" ? | ||
562 | 538 | } | ||
563 | 539 | |||
564 | 540 | include('install/footer.inc'); | ||
565 | 541 | |||
566 | 542 | # Functions | ||
567 | 543 | function checkFsPermissions() { | ||
568 | 544 | # Check for appropriate filesystem permissions | ||
569 | 545 | return ((is_writable("install.php") && (is_writable("settings.php")) && (is_writable("upgrade.php")) || is_writable("."))); | ||
570 | 546 | } | ||
571 | 547 | |||
572 | 548 | function checkMySQL() { | ||
573 | 549 | # Check PHP has MySQL module installed | ||
574 | 550 | return extension_loaded("mysql"); | ||
575 | 551 | } | ||
576 | 552 | |||
577 | 553 | function checkJson() { | ||
578 | 554 | # Check PHP has JSON module installed | ||
579 | 555 | return extension_loaded("json"); | ||
580 | 556 | } | ||
581 | 557 | |||
582 | 558 | function checkGd() { | ||
583 | 559 | # Check PHP has JSON module installed | ||
584 | 560 | return extension_loaded("gd"); | ||
585 | 561 | } | ||
586 | 562 | |||
587 | 563 | function checkCal() { | ||
588 | 564 | # Check PHP has JSON module installed | ||
589 | 565 | return extension_loaded("calendar"); | ||
590 | 566 | } | ||
591 | 567 | |||
592 | 568 | function reportError($step, $message, $button_text="< Back") { // fixme : translate ? | ||
593 | 569 | ?> | ||
594 | 570 | <div class="info"> | ||
595 | 571 | <?php print $message; ?> | ||
596 | 572 | </div> | ||
597 | 573 | <form action="install.php" method="POST"> | ||
598 | 574 | <input type="hidden" name="xibo_step" value="<?php print $step; ?>"/> | ||
599 | 575 | <button type="submit"><?php print $button_text; ?></button> | ||
600 | 576 | </form> | ||
601 | 577 | <?php | ||
602 | 578 | include('install/footer.inc'); | ||
603 | 579 | die(); | ||
604 | 580 | } | ||
605 | 581 | |||
606 | 582 | // Taken from http://forums.devshed.com/php-development-5/php-wont-load-sql-from-file-515902.html | ||
607 | 583 | // By Crackster | ||
608 | 584 | /** | ||
609 | 585 | * remove_remarks will strip the sql comment lines out of an uploaded sql file | ||
610 | 586 | */ | ||
611 | 587 | function remove_remarks($sql){ | ||
612 | 588 | $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^[-].*$/m', "\n", $sql)); | ||
613 | 589 | $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql)); | ||
614 | 590 | return $sql; | ||
615 | 591 | } | ||
616 | 592 | |||
617 | 593 | // Taken from http://forums.devshed.com/php-development-5/php-wont-load-sql-from-file-515902.html | ||
618 | 594 | // By Crackster | ||
619 | 595 | /** | ||
620 | 596 | * split_sql_file will split an uploaded sql file into single sql statements. | ||
621 | 597 | * Note: expects trim() to have already been run on $sql. | ||
622 | 598 | */ | ||
623 | 599 | function split_sql_file($sql, $delimiter){ | ||
624 | 600 | $sql = str_replace("\r" , '', $sql); | ||
625 | 601 | $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql); | ||
626 | 602 | $data = array_map('trim', $data); | ||
627 | 603 | // The empty case | ||
628 | 604 | $end_data = end($data); | ||
629 | 605 | if (empty($end_data)) | ||
630 | 606 | { | ||
631 | 607 | unset($data[key($data)]); | ||
632 | 608 | } | ||
633 | 609 | return $data; | ||
634 | 610 | } | ||
635 | 611 | |||
636 | 612 | /** | ||
637 | 613 | * This funtion will take a pattern and a folder as the argument and go thru it(recursivly if needed)and return the list of | ||
638 | 614 | * all files in that folder. | ||
639 | 615 | * Link : http://www.bin-co.com/php/scripts/filesystem/ls/ | ||
640 | 616 | * License : BSD | ||
641 | 617 | * Arguments : $pattern - The pattern to look out for [OPTIONAL] | ||
642 | 618 | * $folder - The path of the directory of which's directory list you want [OPTIONAL] | ||
643 | 619 | * $recursivly - The funtion will traverse the folder tree recursivly if this is true. Defaults to false. [OPTIONAL] | ||
644 | 620 | * $options - An array of values 'return_files' or 'return_folders' or both | ||
645 | 621 | * Returns : A flat list with the path of all the files(no folders) that matches the condition given. | ||
646 | 622 | */ | ||
647 | 623 | function ls($pattern="*", $folder="", $recursivly=false, $options=array('return_files','return_folders')) { | ||
648 | 624 | if($folder) { | ||
649 | 625 | $current_folder = realpath('.'); | ||
650 | 626 | if(in_array('quiet', $options)) { // If quiet is on, we will suppress the 'no such folder' error | ||
651 | 627 | if(!file_exists($folder)) return array(); | ||
652 | 628 | } | ||
653 | 629 | |||
654 | 630 | if(!chdir($folder)) return array(); | ||
655 | 631 | } | ||
656 | 632 | |||
657 | 633 | |||
658 | 634 | $get_files = in_array('return_files', $options); | ||
659 | 635 | $get_folders= in_array('return_folders', $options); | ||
660 | 636 | $both = array(); | ||
661 | 637 | $folders = array(); | ||
662 | 638 | |||
663 | 639 | // Get the all files and folders in the given directory. | ||
664 | 640 | if($get_files) $both = glob($pattern, GLOB_BRACE + GLOB_MARK); | ||
665 | 641 | if($recursivly or $get_folders) $folders = glob("*", GLOB_ONLYDIR + GLOB_MARK); | ||
666 | 642 | |||
667 | 643 | //If a pattern is specified, make sure even the folders match that pattern. | ||
668 | 644 | $matching_folders = array(); | ||
669 | 645 | if($pattern !== '*') $matching_folders = glob($pattern, GLOB_ONLYDIR + GLOB_MARK); | ||
670 | 646 | |||
671 | 647 | //Get just the files by removing the folders from the list of all files. | ||
672 | 648 | $all = array_values(array_diff($both,$folders)); | ||
673 | 649 | |||
674 | 650 | if($recursivly or $get_folders) { | ||
675 | 651 | foreach ($folders as $this_folder) { | ||
676 | 652 | if($get_folders) { | ||
677 | 653 | //If a pattern is specified, make sure even the folders match that pattern. | ||
678 | 654 | if($pattern !== '*') { | ||
679 | 655 | if(in_array($this_folder, $matching_folders)) array_push($all, $this_folder); | ||
680 | 656 | } | ||
681 | 657 | else array_push($all, $this_folder); | ||
682 | 658 | } | ||
683 | 659 | |||
684 | 660 | if($recursivly) { | ||
685 | 661 | // Continue calling this function for all the folders | ||
686 | 662 | $deep_items = ls($pattern, $this_folder, $recursivly, $options); # :RECURSION: | ||
687 | 663 | foreach ($deep_items as $item) { | ||
688 | 664 | array_push($all, $this_folder . $item); | ||
689 | 665 | } | ||
690 | 666 | } | ||
691 | 667 | } | ||
692 | 668 | } | ||
693 | 669 | |||
694 | 670 | if($folder) chdir($current_folder); | ||
695 | 671 | return $all; | ||
696 | 672 | } | ||
697 | 673 | |||
698 | 674 | function gen_secret() { | ||
699 | 675 | # Generates a random 12 character alphanumeric string to use as a salt | ||
700 | 676 | mt_srand((double)microtime()*1000000); | ||
701 | 677 | $key = ""; | ||
702 | 678 | for ($i=0; $i < 12; $i++) { | ||
703 | 679 | $c = mt_rand(0,2); | ||
704 | 680 | if ($c == 0) { | ||
705 | 681 | $key .= chr(mt_rand(65,90)); | ||
706 | 682 | } | ||
707 | 683 | elseif ($c == 1) { | ||
708 | 684 | $key .= chr(mt_rand(97,122)); | ||
709 | 685 | } | ||
710 | 686 | else { | ||
711 | 687 | $key .= chr(mt_rand(48,57)); | ||
712 | 688 | } | ||
713 | 689 | } | ||
714 | 690 | |||
715 | 691 | return $key; | ||
716 | 692 | } | ||
717 | 693 | |||
718 | 694 | function checkPHP() | ||
719 | 695 | { | ||
720 | 696 | return (version_compare("5.2.4",phpversion(), "<=")); | ||
721 | 697 | } | ||
722 | 698 | |||
723 | 699 | function CheckGettext() | ||
724 | 700 | { | ||
725 | 701 | return extension_loaded("gettext"); | ||
726 | 702 | } | ||
727 | 703 | |||
728 | 704 | // Setup the translations for gettext | ||
729 | 705 | function __($string) | ||
730 | 706 | { | ||
731 | 707 | if (CheckGettext()) | ||
732 | 708 | { | ||
733 | 709 | return _($string); | ||
734 | 710 | } | ||
735 | 711 | else | ||
736 | 712 | { | ||
737 | 713 | return $string; | ||
738 | 714 | } | ||
739 | 715 | } | ||
740 | 716 | |||
741 | 717 | function settings_strings() { | ||
742 | 718 | global $settings_header; | ||
743 | 719 | global $settings_footer; | ||
744 | 720 | |||
745 | 721 | $settings_header = <<<END | ||
746 | 722 | <?php | ||
747 | 723 | |||
748 | 724 | /* | ||
749 | 725 | * Xibo - Digital Signage - http://www.xibo.org.uk | ||
750 | 726 | * | ||
751 | 727 | * This file is part of Xibo - and is automatically generated by the installer | ||
752 | 728 | * | ||
753 | 729 | * You should not need to edit this file, unless your SQL connection details have changed. | ||
754 | 730 | */ | ||
755 | 731 | |||
756 | 732 | defined('XIBO') or die(__("Sorry, you are not allowed to directly access this page.") . "<br />" . __("Please press the back button in your browser.")); | ||
757 | 733 | |||
758 | 734 | global \$dbhost; | ||
759 | 735 | global \$dbuser; | ||
760 | 736 | global \$dbpass; | ||
761 | 737 | global \$dbname; | ||
762 | 738 | |||
763 | 739 | |||
764 | 740 | END; | ||
765 | 741 | |||
766 | 742 | $settings_footer = <<<END | ||
767 | 743 | ?> | ||
768 | 744 | END; | ||
769 | 745 | |||
770 | 746 | return; | ||
771 | 747 | } | ||
772 | 748 | ?> | ||
773 | 749 | 0 | ||
774 | === modified file 'server/install/database/46.php' | |||
775 | --- server/install/database/46.php 2013-08-21 09:07:09 +0000 | |||
776 | +++ server/install/database/46.php 2014-03-29 13:09:24 +0000 | |||
777 | @@ -1,7 +1,7 @@ | |||
778 | 1 | <?php | 1 | <?php |
782 | 2 | include('lib/data/data.class.php'); | 2 | include_once('lib/data/data.class.php'); |
783 | 3 | include('lib/data/campaign.data.class.php'); | 3 | include_once('lib/data/campaign.data.class.php'); |
784 | 4 | include('lib/data/campaignsecurity.data.class.php'); | 4 | include_once('lib/data/campaignsecurity.data.class.php'); |
785 | 5 | 5 | ||
786 | 6 | class Step46 extends UpgradeStep | 6 | class Step46 extends UpgradeStep |
787 | 7 | { | 7 | { |
788 | 8 | 8 | ||
789 | === modified file 'server/install/database/66.sql' | |||
790 | --- server/install/database/66.sql 2014-02-16 13:43:52 +0000 | |||
791 | +++ server/install/database/66.sql 2014-03-29 13:09:24 +0000 | |||
792 | @@ -90,9 +90,9 @@ | |||
793 | 90 | `userChange` | 90 | `userChange` |
794 | 91 | ) | 91 | ) |
795 | 92 | VALUES ( | 92 | VALUES ( |
797 | 93 | NULL , 'SETTING_IMPORT_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0' | 93 | NULL , 'SETTING_IMPORT_ENABLED', 'On', 'dropdown', NULL , 'On|Off', 'general', '1' |
798 | 94 | ), ( | 94 | ), ( |
800 | 95 | NULL , 'SETTING_LIBRARY_TIDY_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0' | 95 | NULL , 'SETTING_LIBRARY_TIDY_ENABLED', 'On', 'dropdown', NULL , 'On|Off', 'general', '1' |
801 | 96 | ), ( | 96 | ), ( |
802 | 97 | NULL, 'SENDFILE_MODE', 'Off', 'dropdown', 'When a user downloads a file from the library or previews a layout, should we attempt to use Apache X-Sendfile, Nginx X-Accel, or PHP (Off) to return the file from the library?', 'Off|Apache|Nginx', 'general', '1'); | 97 | NULL, 'SENDFILE_MODE', 'Off', 'dropdown', 'When a user downloads a file from the library or previews a layout, should we attempt to use Apache X-Sendfile, Nginx X-Accel, or PHP (Off) to return the file from the library?', 'Off|Apache|Nginx', 'general', '1'); |
803 | 98 | 98 | ||
804 | 99 | 99 | ||
805 | === added file 'server/install/database/67.sql' | |||
806 | --- server/install/database/67.sql 1970-01-01 00:00:00 +0000 | |||
807 | +++ server/install/database/67.sql 2014-03-29 13:09:24 +0000 | |||
808 | @@ -0,0 +1,30 @@ | |||
809 | 1 | ALTER TABLE `module` ADD `assignable` TINYINT NOT NULL DEFAULT '1'; | ||
810 | 2 | |||
811 | 3 | INSERT INTO `module` (`ModuleID`, `Module`, `Name`, `Enabled`, `RegionSpecific`, `Description`, `ImageUri`, `SchemaVersion`, `ValidExtensions`, `PreviewEnabled`, `assignable`) VALUES (NULL, 'genericfile', 'Generic File', '1', '0', 'A generic file to be stored in the library', 'forms/library.gif', '1', 'apk,js,html,htm', '0', '0'); | ||
812 | 4 | |||
813 | 5 | ALTER TABLE `media` CHANGE `type` `type` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; | ||
814 | 6 | |||
815 | 7 | CREATE TABLE IF NOT EXISTS `lkmediadisplaygroup` ( | ||
816 | 8 | `id` int(11) NOT NULL AUTO_INCREMENT, | ||
817 | 9 | `mediaid` int(11) NOT NULL, | ||
818 | 10 | `displaygroupid` int(11) NOT NULL, | ||
819 | 11 | PRIMARY KEY (`id`) | ||
820 | 12 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='File associations directly to Display Groups' AUTO_INCREMENT=1 ; | ||
821 | 13 | |||
822 | 14 | ALTER TABLE `display` ADD `version_instructions` VARCHAR( 255 ) NULL, | ||
823 | 15 | ADD `client_type` VARCHAR( 20 ) NULL , | ||
824 | 16 | ADD `client_version` VARCHAR( 5 ) NULL , | ||
825 | 17 | ADD `client_code` SMALLINT NULL; | ||
826 | 18 | |||
827 | 19 | INSERT INTO `help` (`HelpID`, `Topic`, `Category`, `Link`) VALUES | ||
828 | 20 | (1, 'DisplayGroup', 'FileAssociations', 'manual/single.php?p=admin/fileassociations'); | ||
829 | 21 | |||
830 | 22 | INSERT INTO `setting` (`settingid`, `setting`, `value`, `type`, `helptext`, `options`, `cat`, `userChange`) | ||
831 | 23 | VALUES | ||
832 | 24 | (NULL, 'PROXY_HOST', '', 'text', 'The Proxy URL', NULL, 'general', '1'), | ||
833 | 25 | (NULL, 'PROXY_PORT', '', 'text', 'The Proxy Port', NULL, 'general', '1'), | ||
834 | 26 | (NULL, 'PROXY_AUTH', '', 'text', 'The Authentication information for this proxy. username:password', NULL, 'general', '1'); | ||
835 | 27 | |||
836 | 28 | UPDATE `version` SET `app_ver` = '1.6.0', `XmdsVersion` = 3; | ||
837 | 29 | UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE'; | ||
838 | 30 | UPDATE `version` SET `DBVersion` = '67'; | ||
839 | 0 | 31 | ||
840 | === modified file 'server/install/master/data.sql' | |||
841 | --- server/install/master/data.sql 2014-02-16 13:43:52 +0000 | |||
842 | +++ server/install/master/data.sql 2014-03-29 13:09:24 +0000 | |||
843 | @@ -1,5 +1,5 @@ | |||
844 | 1 | INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES | 1 | INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES |
846 | 2 | ('1.6.0-rc1', 3, 1, 66); | 2 | ('1.6.0', 3, 1, 67); |
847 | 3 | 3 | ||
848 | 4 | INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`) VALUES | 4 | INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`) VALUES |
849 | 5 | (1, 'Users', 0, 0), | 5 | (1, 'Users', 0, 0), |
850 | @@ -83,7 +83,8 @@ | |||
851 | 83 | (77, 'Transition', 'Edit', 'manual/single.php?p=layout/transitions'), | 83 | (77, 'Transition', 'Edit', 'manual/single.php?p=layout/transitions'), |
852 | 84 | (78, 'User', 'SetPassword', 'manual/single.php?p=users/users#Set_Password'), | 84 | (78, 'User', 'SetPassword', 'manual/single.php?p=users/users#Set_Password'), |
853 | 85 | (79, 'DataSet', 'ImportCSV', 'manual/single.php?p=content/content_dataset#Import_CSV'), | 85 | (79, 'DataSet', 'ImportCSV', 'manual/single.php?p=content/content_dataset#Import_CSV'), |
855 | 86 | (80, 'Statusdashboard', 'General', 'manual/single.php?p=coreconcepts/dashboard#Status_Dashboard'); | 86 | (80, 'DisplayGroup', 'FileAssociations', 'manual/single.php?p=admin/fileassociations'), |
856 | 87 | (81, 'Statusdashboard', 'General', 'manual/single.php?p=coreconcepts/dashboard#Status_Dashboard'); | ||
857 | 87 | 88 | ||
858 | 88 | INSERT INTO `menu` (`MenuID`, `Menu`) VALUES | 89 | INSERT INTO `menu` (`MenuID`, `Menu`) VALUES |
859 | 89 | (8, 'Administration Menu'), | 90 | (8, 'Administration Menu'), |
860 | @@ -107,7 +108,8 @@ | |||
861 | 107 | (10, 'Counter', 'Counter', 0, 1, 'Customer Counter connected to a Remote Control', 'forms/counter.gif', 1, NULL, 1), | 108 | (10, 'Counter', 'Counter', 0, 1, 'Customer Counter connected to a Remote Control', 'forms/counter.gif', 1, NULL, 1), |
862 | 108 | (11, 'datasetview', 'Data Set', 1, 1, 'A view on a DataSet', 'forms/datasetview.gif', 1, NULL, 1), | 109 | (11, 'datasetview', 'Data Set', 1, 1, 'A view on a DataSet', 'forms/datasetview.gif', 1, NULL, 1), |
863 | 109 | (12, 'shellcommand', 'Shell Command', 1, 1, 'Execute a shell command on the client', 'forms/shellcommand.gif', 1, NULL, 1), | 110 | (12, 'shellcommand', 'Shell Command', 1, 1, 'Execute a shell command on the client', 'forms/shellcommand.gif', 1, NULL, 1), |
865 | 110 | (13, 'localvideo', 'Local Video', 0, 1, 'Play a video locally stored on the client', 'forms/video.gif', 1, NULL, 1); | 111 | (13, 'localvideo', 'Local Video', 0, 1, 'Play a video locally stored on the client', 'forms/video.gif', 1, NULL, 1), |
866 | 112 | (14, 'genericfile', 'Generic File', 1, 0, 'A generic file to be stored in the library', 'forms/library.gif', 1, 'apk,js,html,htm', 0, 0); | ||
867 | 111 | 113 | ||
868 | 112 | INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES | 114 | INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES |
869 | 113 | (1, 'Schedule'), | 115 | (1, 'Schedule'), |
870 | @@ -258,7 +260,10 @@ | |||
871 | 258 | (67, 'SETTING_IMPORT_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0'), | 260 | (67, 'SETTING_IMPORT_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0'), |
872 | 259 | (68, 'SETTING_LIBRARY_TIDY_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0'), | 261 | (68, 'SETTING_LIBRARY_TIDY_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0'), |
873 | 260 | (69, 'SENDFILE_MODE', 'Off', 'dropdown', 'When a user downloads a file from the library or previews a layout, should we attempt to use Apache X-Sendfile, Nginx X-Accel, or PHP (Off) to return the file from the library?', 'Off|Apache|Nginx', 'general', '1'), | 262 | (69, 'SENDFILE_MODE', 'Off', 'dropdown', 'When a user downloads a file from the library or previews a layout, should we attempt to use Apache X-Sendfile, Nginx X-Accel, or PHP (Off) to return the file from the library?', 'Off|Apache|Nginx', 'general', '1'), |
875 | 261 | (70, 'EMBEDDED_STATUS_WIDGET', '', 'text', 'HTML to embed in an iframe on the Status Dashboard' , NULL, 'general', '0'); | 263 | (70, 'EMBEDDED_STATUS_WIDGET', '', 'text', 'HTML to embed in an iframe on the Status Dashboard' , NULL, 'general', '0'), |
876 | 264 | (71, 'PROXY_HOST', '', 'text', 'The Proxy URL' , NULL, 'general', '1'), | ||
877 | 265 | (72, 'PROXY_PORT', '', 'text', 'The Proxy Port' , NULL, 'general', '1'), | ||
878 | 266 | (73, 'PROXY_AUTH', '', 'text', 'The Authentication information for this proxy. username:password' , NULL, 'general', '1'); | ||
879 | 262 | 267 | ||
880 | 263 | INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES | 268 | INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES |
881 | 264 | (1, 'Super Admin'), | 269 | (1, 'Super Admin'), |
882 | 265 | 270 | ||
883 | === modified file 'server/install/master/structure.sql' | |||
884 | --- server/install/master/structure.sql 2014-02-12 18:11:45 +0000 | |||
885 | +++ server/install/master/structure.sql 2014-03-29 13:09:24 +0000 | |||
886 | @@ -85,6 +85,10 @@ | |||
887 | 85 | `SecureOn` varchar(17) DEFAULT NULL, | 85 | `SecureOn` varchar(17) DEFAULT NULL, |
888 | 86 | `Cidr` smallint(6) DEFAULT NULL, | 86 | `Cidr` smallint(6) DEFAULT NULL, |
889 | 87 | `GeoLocation` POINT NULL, | 87 | `GeoLocation` POINT NULL, |
890 | 88 | `version_instructions` varchar(255) NULL, | ||
891 | 89 | `client_type` VARCHAR( 20 ) NULL , | ||
892 | 90 | `client_version` VARCHAR( 5 ) NULL , | ||
893 | 91 | `client_code` SMALLINT NULL, | ||
894 | 88 | PRIMARY KEY (`displayid`), | 92 | PRIMARY KEY (`displayid`), |
895 | 89 | KEY `defaultplaylistid` (`defaultlayoutid`) | 93 | KEY `defaultplaylistid` (`defaultlayoutid`) |
896 | 90 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; | 94 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; |
897 | @@ -303,7 +307,7 @@ | |||
898 | 303 | CREATE TABLE IF NOT EXISTS `media` ( | 307 | CREATE TABLE IF NOT EXISTS `media` ( |
899 | 304 | `mediaID` int(11) NOT NULL AUTO_INCREMENT, | 308 | `mediaID` int(11) NOT NULL AUTO_INCREMENT, |
900 | 305 | `name` varchar(100) NOT NULL, | 309 | `name` varchar(100) NOT NULL, |
902 | 306 | `type` varchar(10) NOT NULL, | 310 | `type` varchar(15) NOT NULL, |
903 | 307 | `duration` int(11) NOT NULL, | 311 | `duration` int(11) NOT NULL, |
904 | 308 | `originalFilename` varchar(254) DEFAULT NULL, | 312 | `originalFilename` varchar(254) DEFAULT NULL, |
905 | 309 | `storedAs` varchar(254) DEFAULT NULL COMMENT 'What has this media been stored as', | 313 | `storedAs` varchar(254) DEFAULT NULL COMMENT 'What has this media been stored as', |
906 | @@ -349,6 +353,7 @@ | |||
907 | 349 | `SchemaVersion` int(11) NOT NULL DEFAULT '1', | 353 | `SchemaVersion` int(11) NOT NULL DEFAULT '1', |
908 | 350 | `ValidExtensions` varchar(254) DEFAULT NULL, | 354 | `ValidExtensions` varchar(254) DEFAULT NULL, |
909 | 351 | `PreviewEnabled` tinyint(4) NOT NULL DEFAULT '1', | 355 | `PreviewEnabled` tinyint(4) NOT NULL DEFAULT '1', |
910 | 356 | `assignable` tinyint(4) NOT NULL DEFAULT '1', | ||
911 | 352 | PRIMARY KEY (`ModuleID`) | 357 | PRIMARY KEY (`ModuleID`) |
912 | 353 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Functional Modules' AUTO_INCREMENT=14 ; | 358 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Functional Modules' AUTO_INCREMENT=14 ; |
913 | 354 | 359 | ||
914 | @@ -589,6 +594,14 @@ | |||
915 | 589 | `DataSetColumnType` varchar(100) NOT NULL | 594 | `DataSetColumnType` varchar(100) NOT NULL |
916 | 590 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | 595 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
917 | 591 | 596 | ||
918 | 597 | |||
919 | 598 | CREATE TABLE IF NOT EXISTS `lkmediadisplaygroup` ( | ||
920 | 599 | `id` int(11) NOT NULL AUTO_INCREMENT, | ||
921 | 600 | `mediaid` int(11) NOT NULL, | ||
922 | 601 | `displaygroupid` int(11) NOT NULL, | ||
923 | 602 | PRIMARY KEY (`id`) | ||
924 | 603 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='File associations directly to Display Groups' AUTO_INCREMENT=1 ; | ||
925 | 604 | |||
926 | 592 | -- | 605 | -- |
927 | 593 | -- Constraints for dumped tables | 606 | -- Constraints for dumped tables |
928 | 594 | -- | 607 | -- |
929 | 595 | 608 | ||
930 | === modified file 'server/lib/app/kit.class.php' | |||
931 | --- server/lib/app/kit.class.php 2014-02-15 11:25:09 +0000 | |||
932 | +++ server/lib/app/kit.class.php 2014-03-29 13:09:24 +0000 | |||
933 | @@ -34,6 +34,7 @@ | |||
934 | 34 | define('_BOOLEAN', "bool"); | 34 | define('_BOOLEAN', "bool"); |
935 | 35 | define('_WORD', "word"); | 35 | define('_WORD', "word"); |
936 | 36 | define('_ARRAY', "array"); | 36 | define('_ARRAY', "array"); |
937 | 37 | define('_ARRAY_INT', "array_int"); | ||
938 | 37 | define('_USERNAME', "username"); | 38 | define('_USERNAME', "username"); |
939 | 38 | define('_CHECKBOX', "checkbox"); | 39 | define('_CHECKBOX', "checkbox"); |
940 | 39 | define('_FILENAME', "filename"); | 40 | define('_FILENAME', "filename"); |
941 | @@ -77,7 +78,7 @@ | |||
942 | 77 | * @param $type Object[optional] | 78 | * @param $type Object[optional] |
943 | 78 | * @param $default Object[optional] | 79 | * @param $default Object[optional] |
944 | 79 | */ | 80 | */ |
946 | 80 | static public function GetParam($param, $source = _POST, $type = _STRING, $default = '') | 81 | static public function GetParam($param, $source = _POST, $type = _STRING, $default = '', $sanitize = true) |
947 | 81 | { | 82 | { |
948 | 82 | // lower case param (we dont care) | 83 | // lower case param (we dont care) |
949 | 83 | $param = strtolower($param); | 84 | $param = strtolower($param); |
950 | @@ -204,7 +205,7 @@ | |||
951 | 204 | } | 205 | } |
952 | 205 | 206 | ||
953 | 206 | // Validate this param | 207 | // Validate this param |
955 | 207 | return Kit::ValidateParam($return, $type); | 208 | return Kit::ValidateParam($return, $type, $sanitize); |
956 | 208 | } | 209 | } |
957 | 209 | 210 | ||
958 | 210 | /** | 211 | /** |
959 | @@ -214,9 +215,13 @@ | |||
960 | 214 | * @param $param Object | 215 | * @param $param Object |
961 | 215 | * @param $type Object | 216 | * @param $type Object |
962 | 216 | */ | 217 | */ |
964 | 217 | static function ValidateParam($param, $type) | 218 | static function ValidateParam($param, $type, $sanitize = true) |
965 | 218 | { | 219 | { |
967 | 219 | // If we are a NULL always return a null | 220 | // If we are a NULL always return a null?? |
968 | 221 | //if ($param == NULL || $param == '') | ||
969 | 222 | // return NULL; | ||
970 | 223 | |||
971 | 224 | // Store in return var | ||
972 | 220 | $return = $param; | 225 | $return = $param; |
973 | 221 | 226 | ||
974 | 222 | // Validate | 227 | // Validate |
975 | @@ -224,30 +229,35 @@ | |||
976 | 224 | switch ($type) | 229 | switch ($type) |
977 | 225 | { | 230 | { |
978 | 226 | case _INT : | 231 | case _INT : |
987 | 227 | // Only use the first integer value | 232 | |
988 | 228 | if ($return == '') | 233 | if ($sanitize) { |
989 | 229 | return 0; | 234 | // Only use the first integer value |
990 | 230 | 235 | if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_INT)) | |
991 | 231 | if (preg_match('/-?[0-9]+/', $return, $matches) == 0) | 236 | $return = 0; |
992 | 232 | trigger_error(sprintf(__('No integer match found for %s, and return value is not an int'), $param), E_USER_ERROR); | 237 | } |
993 | 233 | 238 | else { | |
994 | 234 | $return = @ (int) $matches[0]; | 239 | if (!$return = filter_var($return, FILTER_VALIDATE_INT)) |
995 | 240 | trigger_error(sprintf(__('No integer match found for [%s] and return value is not an integer'), $param), E_USER_ERROR); | ||
996 | 241 | } | ||
997 | 242 | |||
998 | 235 | break; | 243 | break; |
999 | 236 | 244 | ||
1000 | 237 | case _DOUBLE : | 245 | case _DOUBLE : |
1001 | 238 | if ($return == '') | ||
1002 | 239 | { | ||
1003 | 240 | $return = 0; | ||
1004 | 241 | break; | ||
1005 | 242 | } | ||
1006 | 243 | 246 | ||
1010 | 244 | // Only use the first floating point value | 247 | if ($sanitize) { |
1011 | 245 | @ preg_match('/-?[0-9]+(\.[0-9]+)?/', $return, $matches); | 248 | // Only use the first integer value |
1012 | 246 | $return = @ (float) $matches[0]; | 249 | if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)) |
1013 | 250 | $return = 0; | ||
1014 | 251 | } | ||
1015 | 252 | else { | ||
1016 | 253 | if (!$return = filter_var($return, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_FRACTION)) | ||
1017 | 254 | trigger_error(sprintf(__('No integer match found for %s, and return value is not an integer'), $param), E_USER_ERROR); | ||
1018 | 255 | } | ||
1019 | 256 | |||
1020 | 247 | break; | 257 | break; |
1021 | 248 | 258 | ||
1022 | 249 | case _BOOL : | 259 | case _BOOL : |
1024 | 250 | $return = (bool) $return; | 260 | $return = filter_var($return, FILTER_VALIDATE_BOOLEAN); |
1025 | 251 | break; | 261 | break; |
1026 | 252 | 262 | ||
1027 | 253 | case _ARRAY : | 263 | case _ARRAY : |
1028 | @@ -259,67 +269,55 @@ | |||
1029 | 259 | 269 | ||
1030 | 260 | if (!is_array($return)) | 270 | if (!is_array($return)) |
1031 | 261 | { | 271 | { |
1033 | 262 | $return = array ($return); | 272 | $return = array($return); |
1034 | 273 | } | ||
1035 | 274 | break; | ||
1036 | 275 | |||
1037 | 276 | case _ARRAY_INT: | ||
1038 | 277 | |||
1039 | 278 | if ($return == '') { | ||
1040 | 279 | $return = array(); | ||
1041 | 280 | } | ||
1042 | 281 | else { | ||
1043 | 282 | if ($sanitize) { | ||
1044 | 283 | // Only use the first integer value | ||
1045 | 284 | if (!$return = filter_var_array($return, FILTER_SANITIZE_NUMBER_INT)) | ||
1046 | 285 | $return = array(); | ||
1047 | 286 | } | ||
1048 | 287 | else { | ||
1049 | 288 | if (!$return = filter_var_array($return, FILTER_VALIDATE_INT)) | ||
1050 | 289 | trigger_error(sprintf(__('No integer found for %s, and return value is not an integer'), $param), E_USER_ERROR); | ||
1051 | 290 | } | ||
1052 | 263 | } | 291 | } |
1053 | 264 | break; | 292 | break; |
1054 | 265 | 293 | ||
1055 | 266 | case _STRING : | 294 | case _STRING : |
1056 | 267 | if ($return == '') | ||
1057 | 268 | { | ||
1058 | 269 | $return = ''; | ||
1059 | 270 | break; | ||
1060 | 271 | } | ||
1061 | 272 | |||
1062 | 273 | $return = preg_replace('/&#(\d+);/me', "chr(\\1)", $return); // decimal notation | ||
1063 | 274 | // convert hex | ||
1064 | 275 | $return = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $return); // hex notation | ||
1065 | 276 | $return = htmlspecialchars($return); | ||
1066 | 277 | $return = (string) $return; | ||
1067 | 278 | break; | ||
1068 | 279 | |||
1069 | 280 | case _PASSWORD : | 295 | case _PASSWORD : |
1080 | 281 | if ($return == '') | 296 | $return = filter_var($return, FILTER_SANITIZE_STRING); |
1071 | 282 | { | ||
1072 | 283 | $return = ''; | ||
1073 | 284 | break; | ||
1074 | 285 | } | ||
1075 | 286 | |||
1076 | 287 | $return = preg_replace('/&#(\d+);/me', "chr(\\1)", $return); // decimal notation | ||
1077 | 288 | // convert hex | ||
1078 | 289 | $return = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $return); // hex notation | ||
1079 | 290 | $return = (string) $return; | ||
1081 | 291 | break; | 297 | break; |
1082 | 292 | 298 | ||
1083 | 293 | case _HTMLSTRING : | 299 | case _HTMLSTRING : |
1084 | 294 | if ($return == '') | ||
1085 | 295 | { | ||
1086 | 296 | $return = ''; | ||
1087 | 297 | break; | ||
1088 | 298 | } | ||
1089 | 299 | 300 | ||
1091 | 300 | $return = preg_replace('/&#(\d+);/me', "chr(\\1)", $return); // decimal notation | 301 | // decimal notation |
1092 | 302 | $return = preg_replace_callback('/&#(\d+);/m', function($m){ | ||
1093 | 303 | return chr($m[1]); | ||
1094 | 304 | }, $return); | ||
1095 | 305 | |||
1096 | 301 | // convert hex | 306 | // convert hex |
1098 | 302 | $return = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $return); // hex notation | 307 | $return = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){ |
1099 | 308 | return chr("0x".$m[1]); | ||
1100 | 309 | }, $return); | ||
1101 | 310 | |||
1102 | 303 | $return = (string) $return; | 311 | $return = (string) $return; |
1103 | 304 | break; | 312 | break; |
1104 | 305 | 313 | ||
1105 | 306 | case _WORD : | 314 | case _WORD : |
1112 | 307 | if ($return == '') | 315 | $return = filter_var($return, FILTER_SANITIZE_STRING); |
1107 | 308 | { | ||
1108 | 309 | $return = ''; | ||
1109 | 310 | break; | ||
1110 | 311 | } | ||
1111 | 312 | |||
1113 | 313 | $return = (string) preg_replace( '/[^A-Z_\-]/i', '', $return ); | 316 | $return = (string) preg_replace( '/[^A-Z_\-]/i', '', $return ); |
1114 | 314 | break; | 317 | break; |
1115 | 315 | 318 | ||
1116 | 316 | case _USERNAME : | 319 | case _USERNAME : |
1123 | 317 | if ($return == '') | 320 | $return = filter_var($return, FILTER_SANITIZE_STRING); |
1118 | 318 | { | ||
1119 | 319 | $return = ''; | ||
1120 | 320 | break; | ||
1121 | 321 | } | ||
1122 | 322 | |||
1124 | 323 | $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return ); | 321 | $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return ); |
1125 | 324 | $return = strtolower($return); | 322 | $return = strtolower($return); |
1126 | 325 | break; | 323 | break; |
1127 | @@ -353,6 +351,9 @@ | |||
1128 | 353 | 351 | ||
1129 | 354 | default : | 352 | default : |
1130 | 355 | // No casting necessary | 353 | // No casting necessary |
1131 | 354 | if (!$sanitize) | ||
1132 | 355 | trigger_error(sprintf(__('Unknown Type %s'), $type), E_USER_ERROR); | ||
1133 | 356 | |||
1134 | 356 | break; | 357 | break; |
1135 | 357 | } | 358 | } |
1136 | 358 | 359 | ||
1137 | @@ -629,5 +630,9 @@ | |||
1138 | 629 | 630 | ||
1139 | 630 | return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; | 631 | return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; |
1140 | 631 | } | 632 | } |
1141 | 633 | |||
1142 | 634 | public static function uniqueId() { | ||
1143 | 635 | return uniqid(rand()); | ||
1144 | 636 | } | ||
1145 | 632 | } | 637 | } |
1146 | 633 | ?> | 638 | ?> |
1147 | 634 | 639 | ||
1148 | === modified file 'server/lib/app/modulemanager.class.php' | |||
1149 | --- server/lib/app/modulemanager.class.php 2014-01-18 09:47:41 +0000 | |||
1150 | +++ server/lib/app/modulemanager.class.php 2014-03-29 13:09:24 +0000 | |||
1151 | @@ -1,7 +1,7 @@ | |||
1152 | 1 | <?php | 1 | <?php |
1153 | 2 | /* | 2 | /* |
1154 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk |
1156 | 4 | * Copyright (C) 2006-2012 Daniel Garner | 4 | * Copyright (C) 2006-2014 Daniel Garner |
1157 | 5 | * | 5 | * |
1158 | 6 | * This file is part of Xibo. | 6 | * This file is part of Xibo. |
1159 | 7 | * | 7 | * |
1160 | @@ -22,84 +22,84 @@ | |||
1161 | 22 | 22 | ||
1162 | 23 | class ModuleManager | 23 | class ModuleManager |
1163 | 24 | { | 24 | { |
1243 | 25 | private $db; | 25 | private $db; |
1244 | 26 | private $user; | 26 | private $user; |
1245 | 27 | 27 | ||
1246 | 28 | public $message; | 28 | public $message; |
1247 | 29 | 29 | ||
1248 | 30 | private $theMenu; | 30 | private $theMenu; |
1249 | 31 | private $current; | 31 | private $current; |
1250 | 32 | private $numberItems; | 32 | private $numberItems; |
1251 | 33 | 33 | ||
1252 | 34 | /** | 34 | /** |
1253 | 35 | * Constructs the Module Manager. | 35 | * Constructs the Module Manager. |
1254 | 36 | * @return | 36 | * @return |
1255 | 37 | * @param $db Object | 37 | * @param $db Object |
1256 | 38 | * @param $user Object | 38 | * @param $user Object |
1257 | 39 | */ | 39 | */ |
1258 | 40 | public function __construct(database $db, User $user, $regionSpecific = -1, $module = '') | 40 | public function __construct(database $db, User $user, $regionSpecific = -1, $module = '', $assignable = 1) |
1259 | 41 | { | 41 | { |
1260 | 42 | $this->db =& $db; | 42 | $this->db =& $db; |
1261 | 43 | $this->user =& $user; | 43 | $this->user =& $user; |
1262 | 44 | 44 | ||
1263 | 45 | if (!$this->theMenu = $user->ModuleAuth($regionSpecific, $module)) | 45 | if (!$this->theMenu = $user->ModuleAuth($regionSpecific, $module, $assignable)) |
1264 | 46 | { | 46 | { |
1265 | 47 | $this->message = 'No enabled modules.'; | 47 | $this->message = 'No enabled modules.'; |
1266 | 48 | return false; | 48 | return false; |
1267 | 49 | } | 49 | } |
1268 | 50 | 50 | ||
1269 | 51 | // Set some information about this menu | 51 | // Set some information about this menu |
1270 | 52 | $this->current = 0; | 52 | $this->current = 0; |
1271 | 53 | $this->numberItems = count($this->theMenu); | 53 | $this->numberItems = count($this->theMenu); |
1272 | 54 | 54 | ||
1273 | 55 | // We dont want to do 0 items | 55 | // We dont want to do 0 items |
1274 | 56 | if ($this->numberItems == 0) $this->numberItems = -1; | 56 | if ($this->numberItems == 0) $this->numberItems = -1; |
1275 | 57 | 57 | ||
1276 | 58 | $this->message = $this->numberItems . ' modules loaded'; | 58 | $this->message = $this->numberItems . ' modules loaded'; |
1277 | 59 | 59 | ||
1278 | 60 | return true; | 60 | return true; |
1279 | 61 | } | 61 | } |
1280 | 62 | 62 | ||
1281 | 63 | /** | 63 | /** |
1282 | 64 | * Returns the internal message | 64 | * Returns the internal message |
1283 | 65 | * @return | 65 | * @return |
1284 | 66 | */ | 66 | */ |
1285 | 67 | public function GetMessage() | 67 | public function GetMessage() |
1286 | 68 | { | 68 | { |
1287 | 69 | return $this->message; | 69 | return $this->message; |
1288 | 70 | } | 70 | } |
1289 | 71 | 71 | ||
1290 | 72 | /** | 72 | /** |
1291 | 73 | * Gets the next menu item in the queue | 73 | * Gets the next menu item in the queue |
1292 | 74 | * @return | 74 | * @return |
1293 | 75 | */ | 75 | */ |
1294 | 76 | public function GetNextModule() | 76 | public function GetNextModule() |
1295 | 77 | { | 77 | { |
1296 | 78 | if (!$item = $this->GetModule($this->current)) | 78 | if (!$item = $this->GetModule($this->current)) |
1297 | 79 | { | 79 | { |
1298 | 80 | $message = 'No more modules.'; | 80 | $message = 'No more modules.'; |
1299 | 81 | return false; | 81 | return false; |
1300 | 82 | } | 82 | } |
1301 | 83 | 83 | ||
1302 | 84 | $this->current++; | 84 | $this->current++; |
1303 | 85 | 85 | ||
1304 | 86 | return $item; | 86 | return $item; |
1305 | 87 | } | 87 | } |
1306 | 88 | 88 | ||
1307 | 89 | /** | 89 | /** |
1308 | 90 | * Gets the menu item at position i | 90 | * Gets the menu item at position i |
1309 | 91 | * @return | 91 | * @return |
1310 | 92 | * @param $i Object | 92 | * @param $i Object |
1311 | 93 | */ | 93 | */ |
1312 | 94 | public function GetModule($i) | 94 | public function GetModule($i) |
1313 | 95 | { | 95 | { |
1314 | 96 | if ($i >= $this->numberItems) | 96 | if ($i >= $this->numberItems) |
1315 | 97 | { | 97 | { |
1316 | 98 | $this->message = 'There are only ' . $this->numberItems . ' modules.'; | 98 | $this->message = 'There are only ' . $this->numberItems . ' modules.'; |
1317 | 99 | return false; | 99 | return false; |
1318 | 100 | } | 100 | } |
1319 | 101 | 101 | ||
1320 | 102 | return $this->theMenu[$i]; | 102 | return $this->theMenu[$i]; |
1321 | 103 | } | 103 | } |
1322 | 104 | } | 104 | } |
1323 | 105 | ?> | 105 | ?> |
1324 | 106 | 106 | ||
1325 | === modified file 'server/lib/app/pagemanager.class.php' | |||
1326 | --- server/lib/app/pagemanager.class.php 2014-01-18 09:47:41 +0000 | |||
1327 | +++ server/lib/app/pagemanager.class.php 2014-03-29 13:09:24 +0000 | |||
1328 | @@ -1,7 +1,7 @@ | |||
1329 | 1 | <?php | 1 | <?php |
1330 | 2 | /* | 2 | /* |
1331 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk |
1333 | 4 | * Copyright (C) 2006-2013 Daniel Garner | 4 | * Copyright (C) 2006-2014 Daniel Garner |
1334 | 5 | * | 5 | * |
1335 | 6 | * This file is part of Xibo. | 6 | * This file is part of Xibo. |
1336 | 7 | * | 7 | * |
1337 | @@ -52,7 +52,7 @@ | |||
1338 | 52 | $this->q = Kit::GetParam('q', _REQUEST, _WORD); | 52 | $this->q = Kit::GetParam('q', _REQUEST, _WORD); |
1339 | 53 | $this->userid = $this->user->userid; | 53 | $this->userid = $this->user->userid; |
1340 | 54 | 54 | ||
1342 | 55 | // Default not authourised | 55 | // Default not authorised |
1343 | 56 | $this->authed = false; | 56 | $this->authed = false; |
1344 | 57 | 57 | ||
1345 | 58 | // Create a theme | 58 | // Create a theme |
1346 | @@ -94,11 +94,13 @@ | |||
1347 | 94 | $user =& $this->user; | 94 | $user =& $this->user; |
1348 | 95 | 95 | ||
1349 | 96 | if (!$this->authed) | 96 | if (!$this->authed) |
1355 | 97 | { | 97 | throw new Exception(__('You do not have permission to access this page.')); |
1356 | 98 | // Output some message to say that we are not authed | 98 | |
1357 | 99 | trigger_error(__('You do not have permission to access this page.'), E_USER_ERROR); | 99 | // Check the requested pages exits before trying to load it |
1358 | 100 | exit; | 100 | // this check should be redundant, because the page should have been validated against the pages in the DB first. |
1359 | 101 | } | 101 | // do it just in case... |
1360 | 102 | if (!file_exists($this->path)) | ||
1361 | 103 | throw new Exception(__('The requested page does not exist')); | ||
1362 | 102 | 104 | ||
1363 | 103 | // Load the file in question | 105 | // Load the file in question |
1364 | 104 | if (!class_exists($this->page)) | 106 | if (!class_exists($this->page)) |
1365 | 105 | 107 | ||
1366 | === modified file 'server/lib/app/thememanager.class.php' | |||
1367 | --- server/lib/app/thememanager.class.php 2014-01-18 09:47:41 +0000 | |||
1368 | +++ server/lib/app/thememanager.class.php 2014-03-29 13:09:24 +0000 | |||
1369 | @@ -173,15 +173,18 @@ | |||
1370 | 173 | $return = null; | 173 | $return = null; |
1371 | 174 | else | 174 | else |
1372 | 175 | $return = $theme->vars[$key]; | 175 | $return = $theme->vars[$key]; |
1374 | 176 | 176 | ||
1375 | 177 | if ($key == 'form_meta') { | 177 | if ($key == 'form_meta') { |
1376 | 178 | // Append a token to the end | 178 | // Append a token to the end |
1377 | 179 | $return = $return . Kit::Token(); | 179 | $return = $return . Kit::Token(); |
1378 | 180 | } | 180 | } |
1379 | 181 | |||
1380 | 182 | return $return; | 181 | return $return; |
1381 | 183 | } | 182 | } |
1382 | 184 | 183 | ||
1383 | 184 | public static function Prepare($string) { | ||
1384 | 185 | return htmlspecialchars($string); | ||
1385 | 186 | } | ||
1386 | 187 | |||
1387 | 185 | public static function SetPagename($pageName) { | 188 | public static function SetPagename($pageName) { |
1388 | 186 | Theme::GetInstance()->pageName = $pageName; | 189 | Theme::GetInstance()->pageName = $pageName; |
1389 | 187 | } | 190 | } |
1390 | 188 | 191 | ||
1391 | === modified file 'server/lib/data/display.data.class.php' | |||
1392 | --- server/lib/data/display.data.class.php 2014-01-18 09:47:41 +0000 | |||
1393 | +++ server/lib/data/display.data.class.php 2014-03-29 13:09:24 +0000 | |||
1394 | @@ -321,12 +321,17 @@ | |||
1395 | 321 | } | 321 | } |
1396 | 322 | 322 | ||
1397 | 323 | /** | 323 | /** |
1404 | 324 | * Sets the information required on the display to indicate | 324 | * Sets the information required on the display to indicate that it is still logged in |
1405 | 325 | * that it is still logged in | 325 | * @param string $license The display licence key |
1406 | 326 | * @return | 326 | * @param string $clientAddress The client IP address |
1407 | 327 | * @param $license Object | 327 | * @param integer $mediaInventoryComplete The Media Inventory Status |
1408 | 328 | */ | 328 | * @param string $mediaInventoryXml The Media Inventory XML |
1409 | 329 | public function Touch($license, $clientAddress = '', $mediaInventoryComplete = 0, $mediaInventoryXml = '', $macAddress = '') | 329 | * @param string $macAddress The Client Mac Address |
1410 | 330 | * @param string $clientType The Client Type | ||
1411 | 331 | * @param string $clientVersion The Client Version | ||
1412 | 332 | * @param integer $clientCode The Client Version Code | ||
1413 | 333 | */ | ||
1414 | 334 | public function Touch($license, $clientAddress = '', $mediaInventoryComplete = 0, $mediaInventoryXml = '', $macAddress = '', $clientType = '', $clientVersion = '', $clientCode = 0) | ||
1415 | 330 | { | 335 | { |
1416 | 331 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Touch'); | 336 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Touch'); |
1417 | 332 | 337 | ||
1418 | @@ -359,6 +364,22 @@ | |||
1419 | 359 | $params['mediainventoryxml'] = $mediaInventoryXml; | 364 | $params['mediainventoryxml'] = $mediaInventoryXml; |
1420 | 360 | } | 365 | } |
1421 | 361 | 366 | ||
1422 | 367 | // Client information if present | ||
1423 | 368 | if ($clientType != '') { | ||
1424 | 369 | $SQL .= " , client_type = :client_type "; | ||
1425 | 370 | $params['client_type'] = $clientType; | ||
1426 | 371 | } | ||
1427 | 372 | |||
1428 | 373 | if ($clientVersion != '') { | ||
1429 | 374 | $SQL .= " , client_version = :client_version "; | ||
1430 | 375 | $params['client_version'] = $clientVersion; | ||
1431 | 376 | } | ||
1432 | 377 | |||
1433 | 378 | if ($clientCode != '') { | ||
1434 | 379 | $SQL .= " , client_code = :client_code "; | ||
1435 | 380 | $params['client_code'] = $clientCode; | ||
1436 | 381 | } | ||
1437 | 382 | |||
1438 | 362 | // Mac address storage | 383 | // Mac address storage |
1439 | 363 | if ($macAddress != '') | 384 | if ($macAddress != '') |
1440 | 364 | { | 385 | { |
1441 | @@ -402,7 +423,7 @@ | |||
1442 | 402 | * Flags a display as being incomplete | 423 | * Flags a display as being incomplete |
1443 | 403 | * @param <type> $displayId | 424 | * @param <type> $displayId |
1444 | 404 | */ | 425 | */ |
1446 | 405 | private function FlagIncomplete($displayId) | 426 | public function FlagIncomplete($displayId) |
1447 | 406 | { | 427 | { |
1448 | 407 | Debug::LogEntry('audit', sprintf('Flag DisplayID %d incomplete.', $displayId), 'display', 'NotifyDisplays'); | 428 | Debug::LogEntry('audit', sprintf('Flag DisplayID %d incomplete.', $displayId), 'display', 'NotifyDisplays'); |
1449 | 408 | 429 | ||
1450 | @@ -508,6 +529,37 @@ | |||
1451 | 508 | } | 529 | } |
1452 | 509 | } | 530 | } |
1453 | 510 | 531 | ||
1454 | 532 | public function SetVersionInstructions($displayId, $mediaId, $storedAs) { | ||
1455 | 533 | Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); | ||
1456 | 534 | |||
1457 | 535 | try { | ||
1458 | 536 | $dbh = PDOConnect::init(); | ||
1459 | 537 | |||
1460 | 538 | // Set the instructions | ||
1461 | 539 | $version_instructions = array(); | ||
1462 | 540 | $version_instructions['id'] = $mediaId; | ||
1463 | 541 | $version_instructions['file'] = $storedAs; | ||
1464 | 542 | |||
1465 | 543 | $sth = $dbh->prepare('UPDATE `display` SET version_instructions = :version_instructions WHERE displayid = :displayid'); | ||
1466 | 544 | $sth->execute(array( | ||
1467 | 545 | 'displayid' => $displayId, | ||
1468 | 546 | 'version_instructions' => json_encode($version_instructions) | ||
1469 | 547 | )); | ||
1470 | 548 | |||
1471 | 549 | return true; | ||
1472 | 550 | } | ||
1473 | 551 | catch (Exception $e) { | ||
1474 | 552 | |||
1475 | 553 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
1476 | 554 | |||
1477 | 555 | if (!$this->IsError()) | ||
1478 | 556 | $this->SetError(1, __('Unknown Error')); | ||
1479 | 557 | |||
1480 | 558 | return false; | ||
1481 | 559 | } | ||
1482 | 560 | |||
1483 | 561 | } | ||
1484 | 562 | |||
1485 | 511 | /** | 563 | /** |
1486 | 512 | * Wake this display using a WOL command | 564 | * Wake this display using a WOL command |
1487 | 513 | * @param <int> $displayId | 565 | * @param <int> $displayId |
1488 | @@ -560,11 +612,11 @@ | |||
1489 | 560 | /** | 612 | /** |
1490 | 561 | * Wake On Lan Script | 613 | * Wake On Lan Script |
1491 | 562 | * // Version: 2 | 614 | * // Version: 2 |
1497 | 563 | // Author of this application: | 615 | * // Author of this application: |
1498 | 564 | // DS508_customer (http://www.synology.com/enu/forum/memberlist.php?mode=viewprofile&u=12636) | 616 | * // DS508_customer (http://www.synology.com/enu/forum/memberlist.php?mode=viewprofile&u=12636) |
1499 | 565 | // Please inform the author of any suggestions on (the functionality, graphical design, ... of) this application. | 617 | * // Please inform the author of any suggestions on (the functionality, graphical design, ... of) this application. |
1500 | 566 | // More info: http://wolviaphp.sourceforge.net | 618 | * // More info: http://wolviaphp.sourceforge.net |
1501 | 567 | // License: GPLv2.0 | 619 | * // License: GPLv2.0 |
1502 | 568 | * | 620 | * |
1503 | 569 | * Modified for use with the Xibo project by Dan Garner. | 621 | * Modified for use with the Xibo project by Dan Garner. |
1504 | 570 | */ | 622 | */ |
1505 | 571 | 623 | ||
1506 | === modified file 'server/lib/data/displaygroup.data.class.php' | |||
1507 | --- server/lib/data/displaygroup.data.class.php 2014-01-18 09:47:41 +0000 | |||
1508 | +++ server/lib/data/displaygroup.data.class.php 2014-03-29 13:09:24 +0000 | |||
1509 | @@ -1,7 +1,7 @@ | |||
1510 | 1 | <?php | 1 | <?php |
1511 | 2 | /* | 2 | /* |
1512 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk |
1514 | 4 | * Copyright (C) 2009-13 Daniel Garner | 4 | * Copyright (C) 2009-14 Daniel Garner |
1515 | 5 | * | 5 | * |
1516 | 6 | * This file is part of Xibo. | 6 | * This file is part of Xibo. |
1517 | 7 | * | 7 | * |
1518 | @@ -22,36 +22,36 @@ | |||
1519 | 22 | 22 | ||
1520 | 23 | class DisplayGroup extends Data | 23 | class DisplayGroup extends Data |
1521 | 24 | { | 24 | { |
1540 | 25 | public function __construct(database $db) | 25 | public function __construct(database $db) |
1541 | 26 | { | 26 | { |
1542 | 27 | include_once('lib/data/schedule.data.class.php'); | 27 | include_once('lib/data/schedule.data.class.php'); |
1543 | 28 | include_once('lib/data/displaygroupsecurity.data.class.php'); | 28 | include_once('lib/data/displaygroupsecurity.data.class.php'); |
1544 | 29 | 29 | ||
1545 | 30 | parent::__construct($db); | 30 | parent::__construct($db); |
1546 | 31 | } | 31 | } |
1547 | 32 | 32 | ||
1548 | 33 | /** | 33 | /** |
1549 | 34 | * Adds a Display Group to Xibo | 34 | * Adds a Display Group to Xibo |
1550 | 35 | * @return | 35 | * @return |
1551 | 36 | * @param $displayGroup string | 36 | * @param $displayGroup string |
1552 | 37 | * @param $isDisplaySpecific int | 37 | * @param $isDisplaySpecific int |
1553 | 38 | * @param $description string[optional] | 38 | * @param $description string[optional] |
1554 | 39 | */ | 39 | */ |
1555 | 40 | public function Add($displayGroup, $isDisplaySpecific, $description = '') | 40 | public function Add($displayGroup, $isDisplaySpecific, $description = '') |
1556 | 41 | { | 41 | { |
1557 | 42 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Add'); | 42 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Add'); |
1558 | 43 | 43 | ||
1560 | 44 | try { | 44 | try { |
1561 | 45 | $dbh = PDOConnect::init(); | 45 | $dbh = PDOConnect::init(); |
1562 | 46 | 46 | ||
1569 | 47 | // Validation | 47 | // Validation |
1570 | 48 | if ($displayGroup == '') | 48 | if ($displayGroup == '') |
1571 | 49 | $this->ThrowError(__('Please enter a display group name')); | 49 | $this->ThrowError(__('Please enter a display group name')); |
1572 | 50 | 50 | ||
1573 | 51 | if (strlen($description) > 254) | 51 | if (strlen($description) > 254) |
1574 | 52 | $this->ThrowError(__("Description can not be longer than 254 characters")); | 52 | $this->ThrowError(__("Description can not be longer than 254 characters")); |
1575 | 53 | 53 | ||
1577 | 54 | $sth = $dbh->prepare('SELECT DisplayGroup FROM displaygroup WHERE DisplayGroup = :displaygroup AND IsDisplaySpecific = 0'); | 54 | $sth = $dbh->prepare('SELECT DisplayGroup FROM displaygroup WHERE DisplayGroup = :displaygroup AND IsDisplaySpecific = 0'); |
1578 | 55 | $sth->execute(array( | 55 | $sth->execute(array( |
1579 | 56 | 'displaygroup' => $displayGroup | 56 | 'displaygroup' => $displayGroup |
1580 | 57 | )); | 57 | )); |
1581 | @@ -59,10 +59,10 @@ | |||
1582 | 59 | if ($row = $sth->fetch()) | 59 | if ($row = $sth->fetch()) |
1583 | 60 | $this->ThrowError(25004, sprintf(__('You already own a display group called "%s". Please choose another name.'), $displayGroup)); | 60 | $this->ThrowError(25004, sprintf(__('You already own a display group called "%s". Please choose another name.'), $displayGroup)); |
1584 | 61 | 61 | ||
1589 | 62 | // End Validation | 62 | // End Validation |
1590 | 63 | 63 | ||
1591 | 64 | // Insert the display group | 64 | // Insert the display group |
1592 | 65 | $sth = $dbh->prepare('INSERT INTO displaygroup (DisplayGroup, IsDisplaySpecific, Description) VALUES (:displaygroup, :isdisplayspecific, :description)'); | 65 | $sth = $dbh->prepare('INSERT INTO displaygroup (DisplayGroup, IsDisplaySpecific, Description) VALUES (:displaygroup, :isdisplayspecific, :description)'); |
1593 | 66 | $sth->execute(array( | 66 | $sth->execute(array( |
1594 | 67 | 'displaygroup' => $displayGroup, | 67 | 'displaygroup' => $displayGroup, |
1595 | 68 | 'isdisplayspecific' => $isDisplaySpecific, | 68 | 'isdisplayspecific' => $isDisplaySpecific, |
1596 | @@ -70,11 +70,11 @@ | |||
1597 | 70 | )); | 70 | )); |
1598 | 71 | 71 | ||
1599 | 72 | $displayGroupID = $dbh->lastInsertId(); | 72 | $displayGroupID = $dbh->lastInsertId(); |
1602 | 73 | 73 | ||
1603 | 74 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Add'); | 74 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Add'); |
1604 | 75 | 75 | ||
1607 | 76 | return $displayGroupID; | 76 | return $displayGroupID; |
1608 | 77 | } | 77 | } |
1609 | 78 | catch (Exception $e) { | 78 | catch (Exception $e) { |
1610 | 79 | 79 | ||
1611 | 80 | Debug::LogEntry('error', $e->getMessage()); | 80 | Debug::LogEntry('error', $e->getMessage()); |
1612 | @@ -84,33 +84,33 @@ | |||
1613 | 84 | 84 | ||
1614 | 85 | return false; | 85 | return false; |
1615 | 86 | } | 86 | } |
1628 | 87 | } | 87 | } |
1629 | 88 | 88 | ||
1630 | 89 | /** | 89 | /** |
1631 | 90 | * Edits an existing Xibo Display Group | 90 | * Edits an existing Xibo Display Group |
1632 | 91 | * @return | 91 | * @return |
1633 | 92 | * @param $displayGroupID Object | 92 | * @param $displayGroupID Object |
1634 | 93 | * @param $displayGroup Object | 93 | * @param $displayGroup Object |
1635 | 94 | * @param $description Object | 94 | * @param $description Object |
1636 | 95 | */ | 95 | */ |
1637 | 96 | public function Edit($displayGroupID, $displayGroup, $description) | 96 | public function Edit($displayGroupID, $displayGroup, $description) |
1638 | 97 | { | 97 | { |
1639 | 98 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Edit'); | 98 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Edit'); |
1640 | 99 | 99 | ||
1642 | 100 | try { | 100 | try { |
1643 | 101 | $dbh = PDOConnect::init(); | 101 | $dbh = PDOConnect::init(); |
1644 | 102 | 102 | ||
1654 | 103 | // Validation | 103 | // Validation |
1655 | 104 | if ($displayGroupID == 0) | 104 | if ($displayGroupID == 0) |
1656 | 105 | $this->ThrowError(__('No Display Group Selected')); | 105 | $this->ThrowError(__('No Display Group Selected')); |
1657 | 106 | 106 | ||
1658 | 107 | if ($displayGroup == '') | 107 | if ($displayGroup == '') |
1659 | 108 | $this->ThrowError(__('Please enter a display group name')); | 108 | $this->ThrowError(__('Please enter a display group name')); |
1660 | 109 | 109 | ||
1661 | 110 | if (strlen($description) > 254) | 110 | if (strlen($description) > 254) |
1662 | 111 | $this->ThrowError(__("Description can not be longer than 254 characters")); | 111 | $this->ThrowError(__("Description can not be longer than 254 characters")); |
1663 | 112 | 112 | ||
1665 | 113 | $sth = $dbh->prepare('SELECT DisplayGroup FROM displaygroup WHERE DisplayGroup = :displaygroup AND IsDisplaySpecific = 0 AND DisplayGroupID <> :displaygroupid'); | 113 | $sth = $dbh->prepare('SELECT DisplayGroup FROM displaygroup WHERE DisplayGroup = :displaygroup AND IsDisplaySpecific = 0 AND DisplayGroupID <> :displaygroupid'); |
1666 | 114 | $sth->execute(array( | 114 | $sth->execute(array( |
1667 | 115 | 'displaygroup' => $displayGroup, | 115 | 'displaygroup' => $displayGroup, |
1668 | 116 | 'displaygroupid' => $displayGroupID | 116 | 'displaygroupid' => $displayGroupID |
1669 | @@ -118,21 +118,21 @@ | |||
1670 | 118 | 118 | ||
1671 | 119 | if ($row = $sth->fetch()) | 119 | if ($row = $sth->fetch()) |
1672 | 120 | $this->ThrowError(25004, sprintf(__('You already own a display group called "%s". Please choose another name.'), $displayGroup)); | 120 | $this->ThrowError(25004, sprintf(__('You already own a display group called "%s". Please choose another name.'), $displayGroup)); |
1678 | 121 | 121 | ||
1679 | 122 | // End Validation | 122 | // End Validation |
1680 | 123 | 123 | ||
1681 | 124 | // Update the DisplayGroup | 124 | // Update the DisplayGroup |
1682 | 125 | $sth = $dbh->prepare('UPDATE displaygroup SET DisplayGroup = :displaygroup, Description = :description WHERE DisplayGroupID = :displaygroupid'); | 125 | $sth = $dbh->prepare('UPDATE displaygroup SET DisplayGroup = :displaygroup, Description = :description WHERE DisplayGroupID = :displaygroupid'); |
1683 | 126 | $sth->execute(array( | 126 | $sth->execute(array( |
1684 | 127 | 'displaygroup' => $displayGroup, | 127 | 'displaygroup' => $displayGroup, |
1685 | 128 | 'description' => $description, | 128 | 'description' => $description, |
1686 | 129 | 'displaygroupid' => $displayGroupID | 129 | 'displaygroupid' => $displayGroupID |
1687 | 130 | )); | 130 | )); |
1693 | 131 | 131 | ||
1694 | 132 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Edit'); | 132 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Edit'); |
1695 | 133 | 133 | ||
1696 | 134 | return true; | 134 | return true; |
1697 | 135 | } | 135 | } |
1698 | 136 | catch (Exception $e) { | 136 | catch (Exception $e) { |
1699 | 137 | 137 | ||
1700 | 138 | Debug::LogEntry('error', $e->getMessage()); | 138 | Debug::LogEntry('error', $e->getMessage()); |
1701 | @@ -142,36 +142,36 @@ | |||
1702 | 142 | 142 | ||
1703 | 143 | return false; | 143 | return false; |
1704 | 144 | } | 144 | } |
1715 | 145 | } | 145 | } |
1716 | 146 | 146 | ||
1717 | 147 | /** | 147 | /** |
1718 | 148 | * Deletes an Xibo Display Group | 148 | * Deletes an Xibo Display Group |
1719 | 149 | * @return | 149 | * @return |
1720 | 150 | * @param $displayGroupID Object | 150 | * @param $displayGroupID Object |
1721 | 151 | */ | 151 | */ |
1722 | 152 | public function Delete($displayGroupID) | 152 | public function Delete($displayGroupID) |
1723 | 153 | { | 153 | { |
1724 | 154 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Delete'); | 154 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Delete'); |
1725 | 155 | 155 | ||
1726 | 156 | try { | 156 | try { |
1727 | 157 | $dbh = PDOConnect::init(); | 157 | $dbh = PDOConnect::init(); |
1728 | 158 | 158 | ||
1729 | 159 | // Tidy up the schedule detail records. | 159 | // Tidy up the schedule detail records. |
1730 | 160 | $schedule = new Schedule($this->db); | 160 | $schedule = new Schedule($this->db); |
1732 | 161 | 161 | ||
1733 | 162 | if (!$schedule->DeleteScheduleForDisplayGroup($displayGroupID)) | 162 | if (!$schedule->DeleteScheduleForDisplayGroup($displayGroupID)) |
1734 | 163 | throw new Exception('Unable to DeleteScheduleForDisplayGroup'); | 163 | throw new Exception('Unable to DeleteScheduleForDisplayGroup'); |
1735 | 164 | 164 | ||
1736 | 165 | // Delete the Display Group | 165 | // Delete the Display Group |
1738 | 166 | $sth = $dbh->prepare('DELETE FROM displaygroup WHERE DisplayGroupID = :displaygroupid'); | 166 | $sth = $dbh->prepare('DELETE FROM displaygroup WHERE DisplayGroupID = :displaygroupid'); |
1739 | 167 | $sth->execute(array( | 167 | $sth->execute(array( |
1740 | 168 | 'displaygroupid' => $displayGroupID | 168 | 'displaygroupid' => $displayGroupID |
1741 | 169 | )); | 169 | )); |
1742 | 170 | 170 | ||
1747 | 171 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Delete'); | 171 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Delete'); |
1748 | 172 | 172 | ||
1749 | 173 | return true; | 173 | return true; |
1750 | 174 | } | 174 | } |
1751 | 175 | catch (Exception $e) { | 175 | catch (Exception $e) { |
1752 | 176 | 176 | ||
1753 | 177 | Debug::LogEntry('error', $e->getMessage()); | 177 | Debug::LogEntry('error', $e->getMessage()); |
1754 | @@ -181,47 +181,54 @@ | |||
1755 | 181 | 181 | ||
1756 | 182 | return false; | 182 | return false; |
1757 | 183 | } | 183 | } |
1768 | 184 | } | 184 | } |
1769 | 185 | 185 | ||
1770 | 186 | /** | 186 | /** |
1771 | 187 | * Deletes all Display Group records associated with a display. | 187 | * Deletes all Display Group records associated with a display. |
1772 | 188 | * @return | 188 | * @return |
1773 | 189 | * @param $displayID Object | 189 | * @param $displayID Object |
1774 | 190 | */ | 190 | */ |
1775 | 191 | public function DeleteDisplay($displayID) | 191 | public function DeleteDisplay($displayID) |
1776 | 192 | { | 192 | { |
1777 | 193 | try { | 193 | Kit::ClassLoader('lkmediadisplaygroup'); |
1778 | 194 | |||
1779 | 195 | try { | ||
1780 | 194 | $dbh = PDOConnect::init(); | 196 | $dbh = PDOConnect::init(); |
1790 | 195 | 197 | ||
1791 | 196 | // Get the DisplaySpecific Group for this Display | 198 | // Get the DisplaySpecific Group for this Display |
1792 | 197 | $SQL = ""; | 199 | $SQL = ""; |
1793 | 198 | $SQL .= "SELECT displaygroup.DisplayGroupID "; | 200 | $SQL .= "SELECT displaygroup.DisplayGroupID "; |
1794 | 199 | $SQL .= "FROM displaygroup "; | 201 | $SQL .= "FROM displaygroup "; |
1795 | 200 | $SQL .= " INNER JOIN lkdisplaydg "; | 202 | $SQL .= " INNER JOIN lkdisplaydg "; |
1796 | 201 | $SQL .= " ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID "; | 203 | $SQL .= " ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID "; |
1797 | 202 | $SQL .= "WHERE displaygroup.IsDisplaySpecific = 1 "; | 204 | $SQL .= "WHERE displaygroup.IsDisplaySpecific = 1 "; |
1798 | 203 | $SQL .= " AND lkdisplaydg.DisplayID = :displayid"; | 205 | $SQL .= " AND lkdisplaydg.DisplayID = :displayid"; |
1799 | 204 | 206 | ||
1801 | 205 | $sth = $dbh->prepare($SQL); | 207 | $sth = $dbh->prepare($SQL); |
1802 | 206 | $sth->execute(array( | 208 | $sth->execute(array( |
1803 | 207 | 'displayid' => $displayID | 209 | 'displayid' => $displayID |
1804 | 208 | )); | 210 | )); |
1805 | 209 | 211 | ||
1806 | 210 | if (!$row = $sth->fetch()) | 212 | if (!$row = $sth->fetch()) |
1807 | 211 | $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display')); | 213 | $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display')); |
1813 | 212 | 214 | ||
1814 | 213 | // Get the Display Group ID | 215 | // Get the Display Group ID |
1815 | 214 | $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT); | 216 | $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT); |
1816 | 215 | 217 | ||
1817 | 216 | // If there is no region specific display record... what do we do? | 218 | // If there is no region specific display record... what do we do? |
1818 | 217 | if ($displayGroupID == 0) | 219 | if ($displayGroupID == 0) |
1821 | 218 | $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display')); | 220 | $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display')); |
1822 | 219 | 221 | ||
1823 | 220 | // Delete the Schedule for this Display Group | 222 | // Delete the Schedule for this Display Group |
1824 | 221 | $scheduleObject = new Schedule($this->db); | 223 | $scheduleObject = new Schedule($this->db); |
1825 | 222 | 224 | ||
1826 | 223 | if (!$scheduleObject->DeleteScheduleForDisplayGroup($displayGroupID)) | 225 | if (!$scheduleObject->DeleteScheduleForDisplayGroup($displayGroupID)) |
1828 | 224 | $this->ThrowError(25006, __('Unable to delete Schedule records for this DisplayGroup.')); | 226 | $this->ThrowError(25006, __('Unable to delete Schedule records for this DisplayGroup.')); |
1829 | 227 | |||
1830 | 228 | // Drop all current assignments | ||
1831 | 229 | $link = new LkMediaDisplayGroup($this->db); | ||
1832 | 230 | if (!$link->UnlinkAllFromDisplayGroup($displayGroupId)) | ||
1833 | 231 | $this->ThrowError(__('Unable to drop file assignments during display delete.')); | ||
1834 | 225 | 232 | ||
1835 | 226 | // Unlink all Display Groups from this Display | 233 | // Unlink all Display Groups from this Display |
1836 | 227 | $sth = $dbh->prepare('DELETE FROM lkdisplaydg WHERE DisplayID = :displayid'); | 234 | $sth = $dbh->prepare('DELETE FROM lkdisplaydg WHERE DisplayID = :displayid'); |
1837 | @@ -240,8 +247,8 @@ | |||
1838 | 240 | // An error will already be set - so just drop out | 247 | // An error will already be set - so just drop out |
1839 | 241 | throw new Exception('Unable to delete'); | 248 | throw new Exception('Unable to delete'); |
1840 | 242 | 249 | ||
1843 | 243 | return true; | 250 | return true; |
1844 | 244 | } | 251 | } |
1845 | 245 | catch (Exception $e) { | 252 | catch (Exception $e) { |
1846 | 246 | 253 | ||
1847 | 247 | Debug::LogEntry('error', $e->getMessage()); | 254 | Debug::LogEntry('error', $e->getMessage()); |
1848 | @@ -251,48 +258,48 @@ | |||
1849 | 251 | 258 | ||
1850 | 252 | return false; | 259 | return false; |
1851 | 253 | } | 260 | } |
1865 | 254 | } | 261 | } |
1866 | 255 | 262 | ||
1867 | 256 | /** | 263 | /** |
1868 | 257 | * Links a Display to a Display Group | 264 | * Links a Display to a Display Group |
1869 | 258 | * @return | 265 | * @return |
1870 | 259 | * @param $displayGroupID Object | 266 | * @param $displayGroupID Object |
1871 | 260 | * @param $displayID Object | 267 | * @param $displayID Object |
1872 | 261 | */ | 268 | */ |
1873 | 262 | public function Link($displayGroupID, $displayID) | 269 | public function Link($displayGroupID, $displayID) |
1874 | 263 | { | 270 | { |
1875 | 264 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Link'); | 271 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Link'); |
1876 | 265 | 272 | ||
1877 | 266 | try { | 273 | try { |
1878 | 267 | $dbh = PDOConnect::init(); | 274 | $dbh = PDOConnect::init(); |
1881 | 268 | 275 | ||
1882 | 269 | $sth = $dbh->prepare('INSERT INTO lkdisplaydg (DisplayGroupID, DisplayID) VALUES (:displaygroupid, :displayid)'); | 276 | $sth = $dbh->prepare('INSERT INTO lkdisplaydg (DisplayGroupID, DisplayID) VALUES (:displaygroupid, :displayid)'); |
1883 | 270 | $sth->execute(array( | 277 | $sth->execute(array( |
1884 | 271 | 'displaygroupid' => $displayGroupID, | 278 | 'displaygroupid' => $displayGroupID, |
1885 | 272 | 'displayid' => $displayID | 279 | 'displayid' => $displayID |
1886 | 273 | )); | 280 | )); |
1887 | 274 | 281 | ||
1892 | 275 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Link'); | 282 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Link'); |
1893 | 276 | 283 | ||
1894 | 277 | return true; | 284 | return true; |
1895 | 278 | } | 285 | } |
1896 | 279 | catch (Exception $e) { | 286 | catch (Exception $e) { |
1897 | 280 | Debug::LogEntry('error', $e->getMessage()); | 287 | Debug::LogEntry('error', $e->getMessage()); |
1898 | 281 | return $this->SetError(25005, __('Could not Link Display Group to Display')); | 288 | return $this->SetError(25005, __('Could not Link Display Group to Display')); |
1899 | 282 | } | 289 | } |
1913 | 283 | } | 290 | } |
1914 | 284 | 291 | ||
1915 | 285 | /** | 292 | /** |
1916 | 286 | * Unlinks a Display from a Display Group | 293 | * Unlinks a Display from a Display Group |
1917 | 287 | * @return | 294 | * @return |
1918 | 288 | * @param $displayGroupID Object | 295 | * @param $displayGroupID Object |
1919 | 289 | * @param $displayID Object | 296 | * @param $displayID Object |
1920 | 290 | */ | 297 | */ |
1921 | 291 | public function Unlink($displayGroupID, $displayID) | 298 | public function Unlink($displayGroupID, $displayID) |
1922 | 292 | { | 299 | { |
1923 | 293 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Unlink'); | 300 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Unlink'); |
1924 | 294 | 301 | ||
1925 | 295 | try { | 302 | try { |
1926 | 296 | $dbh = PDOConnect::init(); | 303 | $dbh = PDOConnect::init(); |
1927 | 297 | 304 | ||
1928 | 298 | $sth = $dbh->prepare('DELETE FROM lkdisplaydg WHERE DisplayGroupID = :displaygroupid AND DisplayID = :displayid'); | 305 | $sth = $dbh->prepare('DELETE FROM lkdisplaydg WHERE DisplayGroupID = :displaygroupid AND DisplayID = :displayid'); |
1929 | @@ -301,75 +308,75 @@ | |||
1930 | 301 | 'displayid' => $displayID | 308 | 'displayid' => $displayID |
1931 | 302 | )); | 309 | )); |
1932 | 303 | 310 | ||
1937 | 304 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Unlink'); | 311 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Unlink'); |
1938 | 305 | 312 | ||
1939 | 306 | return true; | 313 | return true; |
1940 | 307 | } | 314 | } |
1941 | 308 | catch (Exception $e) { | 315 | catch (Exception $e) { |
1942 | 309 | Debug::LogEntry('error', $e->getMessage()); | 316 | Debug::LogEntry('error', $e->getMessage()); |
1943 | 310 | return $this->SetError(25007, __('Could not Unlink Display Group from Display')); | 317 | return $this->SetError(25007, __('Could not Unlink Display Group from Display')); |
1944 | 311 | } | 318 | } |
1958 | 312 | } | 319 | } |
1959 | 313 | 320 | ||
1960 | 314 | /** | 321 | /** |
1961 | 315 | * Edits the Display Group associated with a Display | 322 | * Edits the Display Group associated with a Display |
1962 | 316 | * @return | 323 | * @return |
1963 | 317 | * @param $displayID Object | 324 | * @param $displayID Object |
1964 | 318 | * @param $display Object | 325 | * @param $display Object |
1965 | 319 | */ | 326 | */ |
1966 | 320 | public function EditDisplayGroup($displayID, $display) | 327 | public function EditDisplayGroup($displayID, $display) |
1967 | 321 | { | 328 | { |
1968 | 322 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'EditDisplayGroup'); | 329 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'EditDisplayGroup'); |
1969 | 323 | 330 | ||
1970 | 324 | try { | 331 | try { |
1971 | 325 | $dbh = PDOConnect::init(); | 332 | $dbh = PDOConnect::init(); |
1972 | 326 | 333 | ||
1983 | 327 | // Get the DisplayGroupID for this DisplayID | 334 | // Get the DisplayGroupID for this DisplayID |
1984 | 328 | $SQL = ""; | 335 | $SQL = ""; |
1985 | 329 | $SQL .= "SELECT displaygroup.DisplayGroupID "; | 336 | $SQL .= "SELECT displaygroup.DisplayGroupID "; |
1986 | 330 | $SQL .= "FROM displaygroup "; | 337 | $SQL .= "FROM displaygroup "; |
1987 | 331 | $SQL .= " INNER JOIN lkdisplaydg "; | 338 | $SQL .= " INNER JOIN lkdisplaydg "; |
1988 | 332 | $SQL .= " ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID "; | 339 | $SQL .= " ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID "; |
1989 | 333 | $SQL .= "WHERE displaygroup.IsDisplaySpecific = 1 "; | 340 | $SQL .= "WHERE displaygroup.IsDisplaySpecific = 1 "; |
1990 | 334 | $SQL .= " AND lkdisplaydg.DisplayID = :displayid"; | 341 | $SQL .= " AND lkdisplaydg.DisplayID = :displayid"; |
1991 | 335 | 342 | ||
1992 | 336 | $sth = $dbh->prepare($SQL); | 343 | $sth = $dbh->prepare($SQL); |
1993 | 337 | $sth->execute(array( | 344 | $sth->execute(array( |
1994 | 338 | 'displayid' => $displayID | 345 | 'displayid' => $displayID |
1995 | 339 | )); | 346 | )); |
1996 | 340 | 347 | ||
1997 | 341 | if (!$row = $sth->fetch()) | 348 | if (!$row = $sth->fetch()) |
1998 | 342 | $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display')); | 349 | $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display')); |
2004 | 343 | 350 | ||
2005 | 344 | // Get the Display Group ID | 351 | // Get the Display Group ID |
2006 | 345 | $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT); | 352 | $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT); |
2007 | 346 | 353 | ||
2008 | 347 | // If there is no region specific display record... what do we do? | 354 | // If there is no region specific display record... what do we do? |
2009 | 348 | if ($displayGroupID == 0) { | 355 | if ($displayGroupID == 0) { |
2025 | 349 | // We should always have 1 display specific DisplayGroup for a display. | 356 | // We should always have 1 display specific DisplayGroup for a display. |
2026 | 350 | // Do we a) Error here and give up? | 357 | // Do we a) Error here and give up? |
2027 | 351 | // b) Create one and link it up? | 358 | // b) Create one and link it up? |
2028 | 352 | // $this->SetError(25006, __('Unable to get the DisplayGroup for this Display')); | 359 | // $this->SetError(25006, __('Unable to get the DisplayGroup for this Display')); |
2029 | 353 | 360 | ||
2030 | 354 | if (!$displayGroupID = $this->Add($display, 1)) | 361 | if (!$displayGroupID = $this->Add($display, 1)) |
2031 | 355 | $this->ThrowError(25001, __('Could not add a display group for the new display.')); | 362 | $this->ThrowError(25001, __('Could not add a display group for the new display.')); |
2032 | 356 | 363 | ||
2033 | 357 | // Link the Two together | 364 | // Link the Two together |
2034 | 358 | if (!$this->Link($displayGroupID, $displayID)) | 365 | if (!$this->Link($displayGroupID, $displayID)) |
2035 | 359 | $this->ThrowError(25001, __('Could not link the new display with its group.')); | 366 | $this->ThrowError(25001, __('Could not link the new display with its group.')); |
2036 | 360 | } | 367 | } |
2037 | 361 | 368 | ||
2038 | 362 | // Update the Display group name | 369 | // Update the Display group name |
2039 | 363 | $sth = $dbh->prepare('UPDATE displaygroup SET DisplayGroup = :displaygroup WHERE DisplayGroupID = :displaygroupid'); | 370 | $sth = $dbh->prepare('UPDATE displaygroup SET DisplayGroup = :displaygroup WHERE DisplayGroupID = :displaygroupid'); |
2040 | 364 | $sth->execute(array( | 371 | $sth->execute(array( |
2041 | 365 | 'displaygroupid' => $displayGroupID, | 372 | 'displaygroupid' => $displayGroupID, |
2042 | 366 | 'displaygroup' => $display | 373 | 'displaygroup' => $display |
2043 | 367 | )); | 374 | )); |
2049 | 368 | 375 | ||
2050 | 369 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'EditDisplayGroup'); | 376 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'EditDisplayGroup'); |
2051 | 370 | 377 | ||
2052 | 371 | return true; | 378 | return true; |
2053 | 372 | } | 379 | } |
2054 | 373 | catch (Exception $e) { | 380 | catch (Exception $e) { |
2055 | 374 | 381 | ||
2056 | 375 | Debug::LogEntry('error', $e->getMessage()); | 382 | Debug::LogEntry('error', $e->getMessage()); |
2057 | @@ -379,8 +386,8 @@ | |||
2058 | 379 | 386 | ||
2059 | 380 | return false; | 387 | return false; |
2060 | 381 | } | 388 | } |
2063 | 382 | } | 389 | } |
2064 | 383 | 390 | ||
2065 | 384 | /** | 391 | /** |
2066 | 385 | * DEPRICATED: Removed in 1.2.0. Sets the Default Layout on display linked groups | 392 | * DEPRICATED: Removed in 1.2.0. Sets the Default Layout on display linked groups |
2067 | 386 | * @return | 393 | * @return |
2068 | @@ -389,10 +396,104 @@ | |||
2069 | 389 | */ | 396 | */ |
2070 | 390 | public function SetDefaultLayout($displayID, $layoutID) | 397 | public function SetDefaultLayout($displayID, $layoutID) |
2071 | 391 | { | 398 | { |
2072 | 392 | $db =& $this->db; | ||
2073 | 393 | |||
2074 | 394 | Debug::LogEntry('audit', 'Depricated method called.', 'DisplayGroup', 'SetDefaultLayout'); | 399 | Debug::LogEntry('audit', 'Depricated method called.', 'DisplayGroup', 'SetDefaultLayout'); |
2075 | 395 | return true; | 400 | return true; |
2076 | 396 | } | 401 | } |
2077 | 402 | |||
2078 | 403 | /** | ||
2079 | 404 | * Associate the list of provided media with this display group | ||
2080 | 405 | * @param user $user The logged in user | ||
2081 | 406 | * @param int $displayGroupId The Display Group to Assign to | ||
2082 | 407 | * @param array $mediaList The Media to Assign | ||
2083 | 408 | */ | ||
2084 | 409 | public function AssociateFiles($user, $displayGroupId, $mediaList) { | ||
2085 | 410 | Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); | ||
2086 | 411 | |||
2087 | 412 | Kit::ClassLoader('lkmediadisplaygroup'); | ||
2088 | 413 | $link = new LkMediaDisplayGroup($this->db); | ||
2089 | 414 | |||
2090 | 415 | try { | ||
2091 | 416 | $dbh = PDOConnect::init(); | ||
2092 | 417 | |||
2093 | 418 | // Check that some media assignments have been made | ||
2094 | 419 | if (count($mediaList) == 0) | ||
2095 | 420 | $this->ThrowError(25006, __('No media to assign')); | ||
2096 | 421 | |||
2097 | 422 | // Drop all current assignments | ||
2098 | 423 | if (!$link->UnlinkAllFromDisplayGroup($displayGroupId)) | ||
2099 | 424 | $this->ThrowError(__('Unable to make this assignment during preparation.')); | ||
2100 | 425 | |||
2101 | 426 | // Loop through all the media | ||
2102 | 427 | foreach ($mediaList as $mediaId) | ||
2103 | 428 | { | ||
2104 | 429 | $mediaId = Kit::ValidateParam($mediaId, _INT); | ||
2105 | 430 | |||
2106 | 431 | // Check we have permissions to use this media (we will use this to copy the media later) | ||
2107 | 432 | $mediaAuth = $user->MediaAuth($mediaId, true); | ||
2108 | 433 | |||
2109 | 434 | if (!$mediaAuth->view) | ||
2110 | 435 | $this->ThrowError(__('You have selected media that you no longer have permission to use. Please reload the form.')); | ||
2111 | 436 | |||
2112 | 437 | // Create the link | ||
2113 | 438 | if (!$link->Link($displayGroupId, $mediaId)) | ||
2114 | 439 | $this->ThrowError(__('Unable to make this assignment')); | ||
2115 | 440 | } | ||
2116 | 441 | |||
2117 | 442 | // Flag this display group as incomplete | ||
2118 | 443 | $this->FlagIncomplete($displayGroupId); | ||
2119 | 444 | |||
2120 | 445 | return true; | ||
2121 | 446 | } | ||
2122 | 447 | catch (Exception $e) { | ||
2123 | 448 | |||
2124 | 449 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
2125 | 450 | |||
2126 | 451 | if (!$this->IsError()) | ||
2127 | 452 | $this->SetError(1, __('Unknown Error')); | ||
2128 | 453 | |||
2129 | 454 | return false; | ||
2130 | 455 | } | ||
2131 | 456 | } | ||
2132 | 457 | |||
2133 | 458 | /** | ||
2134 | 459 | * Flag this display group as incomplete. Also flags all child displays. | ||
2135 | 460 | * @param int $displayGroupId The Display Group ID | ||
2136 | 461 | */ | ||
2137 | 462 | public function FlagIncomplete($displayGroupId) { | ||
2138 | 463 | Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); | ||
2139 | 464 | |||
2140 | 465 | Kit::ClassLoader('display'); | ||
2141 | 466 | $display = new Display($this->db); | ||
2142 | 467 | |||
2143 | 468 | try { | ||
2144 | 469 | $dbh = PDOConnect::init(); | ||
2145 | 470 | |||
2146 | 471 | // Which displays does a change to this layout effect? | ||
2147 | 472 | $sth = $dbh->prepare(' | ||
2148 | 473 | SELECT DISTINCT display.DisplayID | ||
2149 | 474 | FROM lkdisplaydg | ||
2150 | 475 | INNER JOIN display | ||
2151 | 476 | ON lkdisplaydg.DisplayID = display.displayID | ||
2152 | 477 | WHERE lkdisplaydg.displaygroupid = :displaygroupid | ||
2153 | 478 | '); | ||
2154 | 479 | |||
2155 | 480 | $sth->execute(array('displaygroupid' => $displayGroupId)); | ||
2156 | 481 | |||
2157 | 482 | while ($id = $sth->fetchColumn()) { | ||
2158 | 483 | $display->FlagIncomplete($id); | ||
2159 | 484 | } | ||
2160 | 485 | |||
2161 | 486 | return true; | ||
2162 | 487 | } | ||
2163 | 488 | catch (Exception $e) { | ||
2164 | 489 | |||
2165 | 490 | Debug::LogEntry('error', $e->getMessage()); | ||
2166 | 491 | |||
2167 | 492 | if (!$this->IsError()) | ||
2168 | 493 | $this->SetError(1, __('Unknown Error')); | ||
2169 | 494 | |||
2170 | 495 | return false; | ||
2171 | 496 | } | ||
2172 | 497 | } | ||
2173 | 397 | } | 498 | } |
2174 | 398 | ?> | 499 | ?> |
2175 | 399 | \ No newline at end of file | 500 | \ No newline at end of file |
2176 | 400 | 501 | ||
2177 | === modified file 'server/lib/data/layout.data.class.php' | |||
2178 | --- server/lib/data/layout.data.class.php 2014-01-18 09:47:41 +0000 | |||
2179 | +++ server/lib/data/layout.data.class.php 2014-03-29 13:09:24 +0000 | |||
2180 | @@ -1028,5 +1028,56 @@ | |||
2181 | 1028 | return false; | 1028 | return false; |
2182 | 1029 | } | 1029 | } |
2183 | 1030 | } | 1030 | } |
2184 | 1031 | |||
2185 | 1032 | /** | ||
2186 | 1033 | * Returns an array containing all the layouts particulars | ||
2187 | 1034 | * @param int $layoutId The layout ID | ||
2188 | 1035 | */ | ||
2189 | 1036 | public function LayoutInformation($layoutId) { | ||
2190 | 1037 | Debug::LogEntry('audit', '[IN]', 'layout', 'LayoutInformation'); | ||
2191 | 1038 | |||
2192 | 1039 | // The array to ultimately return | ||
2193 | 1040 | $info = array(); | ||
2194 | 1041 | $info['regions'] = array(); | ||
2195 | 1042 | |||
2196 | 1043 | // Use the Region class to help | ||
2197 | 1044 | Kit::ClassLoader('region'); | ||
2198 | 1045 | |||
2199 | 1046 | // Dummy User Object | ||
2200 | 1047 | $user = new User($this->db); | ||
2201 | 1048 | $user->userid = 0; | ||
2202 | 1049 | $user->usertypeid = 1; | ||
2203 | 1050 | |||
2204 | 1051 | // Take the layout, loop through its regions, check them and call LayoutInformation on all media in them. | ||
2205 | 1052 | $info['regions'] = $this->GetRegionList($layoutId); | ||
2206 | 1053 | |||
2207 | 1054 | if (count($info['regions']) <= 0) | ||
2208 | 1055 | return $info; | ||
2209 | 1056 | |||
2210 | 1057 | // Loop through each and build an array | ||
2211 | 1058 | foreach ($info['regions'] as &$region) { | ||
2212 | 1059 | |||
2213 | 1060 | $region['media'] = array(); | ||
2214 | 1061 | |||
2215 | 1062 | Debug::LogEntry('audit', 'Assessing Region: ' . $region['regionid'], 'layout', 'LayoutInformation'); | ||
2216 | 1063 | |||
2217 | 1064 | // Create a layout object | ||
2218 | 1065 | $regionObject = new Region($this->db); | ||
2219 | 1066 | $mediaNodes = $regionObject->GetMediaNodeList($layoutId, $region['regionid']); | ||
2220 | 1067 | |||
2221 | 1068 | foreach($mediaNodes as $mediaNode) { | ||
2222 | 1069 | // Put this node vertically in the region timeline | ||
2223 | 1070 | $region['media'][] = array( | ||
2224 | 1071 | 'mediaid' => $mediaNode->getAttribute('id'), | ||
2225 | 1072 | 'lkid' => $mediaNode->getAttribute('lkid'), | ||
2226 | 1073 | 'mediatype' => $mediaNode->getAttribute('type') | ||
2227 | 1074 | ); | ||
2228 | 1075 | } | ||
2229 | 1076 | |||
2230 | 1077 | Debug::LogEntry('audit', 'Finished with Region', 'layout', 'LayoutInformation'); | ||
2231 | 1078 | } | ||
2232 | 1079 | |||
2233 | 1080 | return $info; | ||
2234 | 1081 | } | ||
2235 | 1031 | } | 1082 | } |
2236 | 1032 | ?> | 1083 | ?> |
2237 | 1033 | 1084 | ||
2238 | === added file 'server/lib/data/lkmediadisplaygroup.data.class.php' | |||
2239 | --- server/lib/data/lkmediadisplaygroup.data.class.php 1970-01-01 00:00:00 +0000 | |||
2240 | +++ server/lib/data/lkmediadisplaygroup.data.class.php 2014-03-29 13:09:24 +0000 | |||
2241 | @@ -0,0 +1,113 @@ | |||
2242 | 1 | <?php | ||
2243 | 2 | /* | ||
2244 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | ||
2245 | 4 | * Copyright (C) 2006-2013 Daniel Garner | ||
2246 | 5 | * | ||
2247 | 6 | * This file is part of Xibo. | ||
2248 | 7 | * | ||
2249 | 8 | * Xibo is free software: you can redistribute it and/or modify | ||
2250 | 9 | * it under the terms of the GNU Affero General Public License as published by | ||
2251 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
2252 | 11 | * any later version. | ||
2253 | 12 | * | ||
2254 | 13 | * Xibo is distributed in the hope that it will be useful, | ||
2255 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2256 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2257 | 16 | * GNU Affero General Public License for more details. | ||
2258 | 17 | * | ||
2259 | 18 | * You should have received a copy of the GNU Affero General Public License | ||
2260 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | ||
2261 | 20 | */ | ||
2262 | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | ||
2263 | 22 | |||
2264 | 23 | class LkMediaDisplayGroup extends Data { | ||
2265 | 24 | |||
2266 | 25 | /** | ||
2267 | 26 | * Link display group and media item | ||
2268 | 27 | * @param int $displaygroupid The Display Group ID | ||
2269 | 28 | * @param int $mediaid The Media ID | ||
2270 | 29 | */ | ||
2271 | 30 | public function Link($displaygroupid, $mediaid) { | ||
2272 | 31 | Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); | ||
2273 | 32 | |||
2274 | 33 | try { | ||
2275 | 34 | $dbh = PDOConnect::init(); | ||
2276 | 35 | |||
2277 | 36 | $displaygroupid = Kit::ValidateParam($displaygroupid, _INT, false); | ||
2278 | 37 | $mediaid = Kit::ValidateParam($mediaid, _INT, false); | ||
2279 | 38 | |||
2280 | 39 | $sth = $dbh->prepare('INSERT INTO `lkmediadisplaygroup` (mediaid, displaygroupid) VALUES (:mediaid, :displaygroupid)'); | ||
2281 | 40 | $sth->execute(array( | ||
2282 | 41 | 'mediaid' => $mediaid, | ||
2283 | 42 | 'displaygroupid' => $displaygroupid | ||
2284 | 43 | )); | ||
2285 | 44 | |||
2286 | 45 | return true; | ||
2287 | 46 | } | ||
2288 | 47 | catch (Exception $e) { | ||
2289 | 48 | |||
2290 | 49 | Debug::LogEntry('error', $e->getMessage()); | ||
2291 | 50 | |||
2292 | 51 | if (!$this->IsError()) | ||
2293 | 52 | $this->SetError(1, __('Unknown Error')); | ||
2294 | 53 | |||
2295 | 54 | return false; | ||
2296 | 55 | } | ||
2297 | 56 | } | ||
2298 | 57 | |||
2299 | 58 | /** | ||
2300 | 59 | * Unlink all media from the provided display group | ||
2301 | 60 | * @param int $displaygroupid The display group to unlink from | ||
2302 | 61 | */ | ||
2303 | 62 | public function UnlinkAllFromDisplayGroup($displaygroupid) { | ||
2304 | 63 | Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); | ||
2305 | 64 | |||
2306 | 65 | try { | ||
2307 | 66 | $dbh = PDOConnect::init(); | ||
2308 | 67 | |||
2309 | 68 | $displaygroupid = Kit::ValidateParam($displaygroupid, _INT, false); | ||
2310 | 69 | |||
2311 | 70 | $sth = $dbh->prepare('DELETE FROM `lkmediadisplaygroup` WHERE displaygroupid = :displaygroupid'); | ||
2312 | 71 | $sth->execute(array('displaygroupid' => $displaygroupid)); | ||
2313 | 72 | |||
2314 | 73 | return true; | ||
2315 | 74 | } | ||
2316 | 75 | catch (Exception $e) { | ||
2317 | 76 | |||
2318 | 77 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
2319 | 78 | |||
2320 | 79 | if (!$this->IsError()) | ||
2321 | 80 | $this->SetError(1, __('Unknown Error')); | ||
2322 | 81 | |||
2323 | 82 | return false; | ||
2324 | 83 | } | ||
2325 | 84 | } | ||
2326 | 85 | |||
2327 | 86 | /** | ||
2328 | 87 | * Unlink all media from the provided media item | ||
2329 | 88 | * @param int $mediaid The media item to unlink from | ||
2330 | 89 | */ | ||
2331 | 90 | public function UnlinkAllFromMedia($mediaid) { | ||
2332 | 91 | Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); | ||
2333 | 92 | |||
2334 | 93 | try { | ||
2335 | 94 | $dbh = PDOConnect::init(); | ||
2336 | 95 | |||
2337 | 96 | $mediaid = Kit::ValidateParam($mediaid, _INT, false); | ||
2338 | 97 | |||
2339 | 98 | $sth = $dbh->prepare('DELETE FROM `lkmediadisplaygroup` WHERE mediaid = :mediaid'); | ||
2340 | 99 | $sth->execute(array('mediaid' => $mediaid)); | ||
2341 | 100 | |||
2342 | 101 | return true; | ||
2343 | 102 | } | ||
2344 | 103 | catch (Exception $e) { | ||
2345 | 104 | |||
2346 | 105 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
2347 | 106 | |||
2348 | 107 | if (!$this->IsError()) | ||
2349 | 108 | $this->SetError(1, __('Unknown Error')); | ||
2350 | 109 | |||
2351 | 110 | return false; | ||
2352 | 111 | } | ||
2353 | 112 | } | ||
2354 | 113 | } | ||
2355 | 0 | 114 | ||
2356 | === modified file 'server/lib/data/media.data.class.php' | |||
2357 | --- server/lib/data/media.data.class.php 2014-01-18 09:47:41 +0000 | |||
2358 | +++ server/lib/data/media.data.class.php 2014-03-29 13:09:24 +0000 | |||
2359 | @@ -77,7 +77,7 @@ | |||
2360 | 77 | $this->ThrowError(10, __('The name cannot be longer than 100 characters')); | 77 | $this->ThrowError(10, __('The name cannot be longer than 100 characters')); |
2361 | 78 | 78 | ||
2362 | 79 | // Test the duration (except for video and localvideo which can have a 0) | 79 | // Test the duration (except for video and localvideo which can have a 0) |
2364 | 80 | if ($duration == 0 && $type != 'video' && $type != 'localvideo') | 80 | if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile') |
2365 | 81 | $this->ThrowError(11, __('You must enter a duration.')); | 81 | $this->ThrowError(11, __('You must enter a duration.')); |
2366 | 82 | 82 | ||
2367 | 83 | // Check the naming of this item to ensure it doesnt conflict | 83 | // Check the naming of this item to ensure it doesnt conflict |
2368 | @@ -186,7 +186,7 @@ | |||
2369 | 186 | if (strlen($name) > 100) | 186 | if (strlen($name) > 100) |
2370 | 187 | $this->ThrowError(10, __('The name cannot be longer than 100 characters')); | 187 | $this->ThrowError(10, __('The name cannot be longer than 100 characters')); |
2371 | 188 | 188 | ||
2373 | 189 | if ($duration == 0 && $type != 'video' && $type != 'localvideo') | 189 | if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile') |
2374 | 190 | $this->ThrowError(11, __('You must enter a duration.')); | 190 | $this->ThrowError(11, __('You must enter a duration.')); |
2375 | 191 | 191 | ||
2376 | 192 | // Any media (not this one) already has this name? | 192 | // Any media (not this one) already has this name? |
2377 | @@ -322,6 +322,8 @@ | |||
2378 | 322 | public function Delete($mediaId) | 322 | public function Delete($mediaId) |
2379 | 323 | { | 323 | { |
2380 | 324 | Debug::LogEntry('audit', 'IN', 'Media', 'Delete'); | 324 | Debug::LogEntry('audit', 'IN', 'Media', 'Delete'); |
2381 | 325 | |||
2382 | 326 | Kit::ClassLoader('lkmediadisplaygroup'); | ||
2383 | 325 | 327 | ||
2384 | 326 | try { | 328 | try { |
2385 | 327 | $dbh = PDOConnect::init(); | 329 | $dbh = PDOConnect::init(); |
2386 | @@ -353,6 +355,11 @@ | |||
2387 | 353 | 355 | ||
2388 | 354 | if (!$security->UnlinkAll($mediaId)) | 356 | if (!$security->UnlinkAll($mediaId)) |
2389 | 355 | throw new Exception("Error Processing Request", 1); | 357 | throw new Exception("Error Processing Request", 1); |
2390 | 358 | |||
2391 | 359 | // Delete any assignments | ||
2392 | 360 | $link = new LkMediaDisplayGroup($this->db); | ||
2393 | 361 | if (!$link->UnlinkAllFromDisplayGroup($mediaId)) | ||
2394 | 362 | $this->ThrowError(__('Unable to drop file assignments during display delete.')); | ||
2395 | 356 | 363 | ||
2396 | 357 | // Delete the media | 364 | // Delete the media |
2397 | 358 | $sth = $dbh->prepare('DELETE FROM media WHERE MediaID = :mediaid'); | 365 | $sth = $dbh->prepare('DELETE FROM media WHERE MediaID = :mediaid'); |
2398 | @@ -393,6 +400,28 @@ | |||
2399 | 393 | } | 400 | } |
2400 | 394 | } | 401 | } |
2401 | 395 | 402 | ||
2402 | 403 | public function GetStoredAs($mediaId) { | ||
2403 | 404 | Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); | ||
2404 | 405 | |||
2405 | 406 | try { | ||
2406 | 407 | $dbh = PDOConnect::init(); | ||
2407 | 408 | |||
2408 | 409 | $sth = $dbh->prepare('SELECT storedas FROM `media` WHERE mediaid = :id'); | ||
2409 | 410 | $sth->execute(array('id' => $mediaId)); | ||
2410 | 411 | |||
2411 | 412 | return $sth->fetchColumn(); | ||
2412 | 413 | } | ||
2413 | 414 | catch (Exception $e) { | ||
2414 | 415 | |||
2415 | 416 | Debug::LogEntry('error', $e->getMessage()); | ||
2416 | 417 | |||
2417 | 418 | if (!$this->IsError()) | ||
2418 | 419 | $this->SetError(1, __('Unknown Error')); | ||
2419 | 420 | |||
2420 | 421 | return false; | ||
2421 | 422 | } | ||
2422 | 423 | } | ||
2423 | 424 | |||
2424 | 396 | public function DeleteMediaFile($fileName) | 425 | public function DeleteMediaFile($fileName) |
2425 | 397 | { | 426 | { |
2426 | 398 | Debug::LogEntry('audit', 'IN', 'Media', 'DeleteMediaFile'); | 427 | Debug::LogEntry('audit', 'IN', 'Media', 'DeleteMediaFile'); |
2427 | 399 | 428 | ||
2428 | === modified file 'server/lib/data/schedule.data.class.php' | |||
2429 | --- server/lib/data/schedule.data.class.php 2014-01-19 14:06:56 +0000 | |||
2430 | +++ server/lib/data/schedule.data.class.php 2014-03-29 13:09:24 +0000 | |||
2431 | @@ -131,8 +131,8 @@ | |||
2432 | 131 | break; | 131 | break; |
2433 | 132 | 132 | ||
2434 | 133 | case 'Week': | 133 | case 'Week': |
2437 | 134 | $t_start_temp = $t_start_temp + (60 * 60 * 24 * 7 * $recDetail); | 134 | $t_start_temp = mktime(date("H", $t_start_temp), date("i", $t_start_temp), date("s", $t_start_temp) ,date("m", $t_start_temp) ,date("d", $t_start_temp) + ($recDetail * 7), date("Y", $t_start_temp)); |
2438 | 135 | $t_end_temp = $t_end_temp + (60 * 60 * 24 * 7 * $recDetail); | 135 | $t_end_temp = mktime(date("H", $t_end_temp), date("i", $t_end_temp), date("s", $t_end_temp) ,date("m", $t_end_temp) ,date("d", $t_end_temp) + ($recDetail * 7), date("Y", $t_end_temp)); |
2439 | 136 | break; | 136 | break; |
2440 | 137 | 137 | ||
2441 | 138 | case 'Month': | 138 | case 'Month': |
2442 | 139 | 139 | ||
2443 | === modified file 'server/lib/include.php' | |||
2444 | --- server/lib/include.php 2014-01-18 09:47:41 +0000 | |||
2445 | +++ server/lib/include.php 2014-03-29 13:09:24 +0000 | |||
2446 | @@ -20,7 +20,7 @@ | |||
2447 | 20 | */ | 20 | */ |
2448 | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); |
2449 | 22 | 22 | ||
2451 | 23 | define('WEBSITE_VERSION', 66); | 23 | define('WEBSITE_VERSION', 67); |
2452 | 24 | 24 | ||
2453 | 25 | // No errors reported until we read the settings from the DB | 25 | // No errors reported until we read the settings from the DB |
2454 | 26 | error_reporting(0); | 26 | error_reporting(0); |
2455 | 27 | 27 | ||
2456 | === modified file 'server/lib/modules/module.class.php' | |||
2457 | --- server/lib/modules/module.class.php 2014-02-15 11:25:09 +0000 | |||
2458 | +++ server/lib/modules/module.class.php 2014-03-29 13:09:24 +0000 | |||
2459 | @@ -96,6 +96,7 @@ | |||
2460 | 96 | $this->existingMedia = false; | 96 | $this->existingMedia = false; |
2461 | 97 | $this->assignedMedia = false; | 97 | $this->assignedMedia = false; |
2462 | 98 | $this->deleteFromRegion = false; | 98 | $this->deleteFromRegion = false; |
2463 | 99 | $this->assignable = true; | ||
2464 | 99 | $this->duration = ''; | 100 | $this->duration = ''; |
2465 | 100 | 101 | ||
2466 | 101 | // Members used by forms (routed through the CMS) | 102 | // Members used by forms (routed through the CMS) |
2467 | @@ -142,6 +143,7 @@ | |||
2468 | 142 | $this->validExtensions = explode(',', $this->validExtensionsText); | 143 | $this->validExtensions = explode(',', $this->validExtensionsText); |
2469 | 143 | $this->validExtensionsText = str_replace(',', ', ', $this->validExtensionsText); | 144 | $this->validExtensionsText = str_replace(',', ', ', $this->validExtensionsText); |
2470 | 144 | $this->previewEnabled = Kit::ValidateParam($row['PreviewEnabled'], _INT); | 145 | $this->previewEnabled = Kit::ValidateParam($row['PreviewEnabled'], _INT); |
2471 | 146 | $this->assignable = Kit::ValidateParam($row['assignable'], _INT); | ||
2472 | 145 | 147 | ||
2473 | 146 | return true; | 148 | return true; |
2474 | 147 | } | 149 | } |
2475 | @@ -806,12 +808,12 @@ | |||
2476 | 806 | 808 | ||
2477 | 807 | $session->setSecurityToken($securityToken); | 809 | $session->setSecurityToken($securityToken); |
2478 | 808 | 810 | ||
2482 | 809 | //Get the default value for the shared list | 811 | // Set some defaults based on the type of media we are |
2483 | 810 | $default = Config::GetSetting('defaultMedia'); | 812 | // TODO: this should be passed in |
2481 | 811 | |||
2484 | 812 | switch ($this->type) { | 813 | switch ($this->type) { |
2485 | 813 | case 'video': | 814 | case 'video': |
2486 | 814 | case 'localvideo': | 815 | case 'localvideo': |
2487 | 816 | case 'genericfile': | ||
2488 | 815 | $defaultDuration = 0; | 817 | $defaultDuration = 0; |
2489 | 816 | break; | 818 | break; |
2490 | 817 | 819 | ||
2491 | @@ -860,7 +862,7 @@ | |||
2492 | 860 | // Setup the theme | 862 | // Setup the theme |
2493 | 861 | Theme::Set('form_upload_id', 'fileupload'); | 863 | Theme::Set('form_upload_id', 'fileupload'); |
2494 | 862 | Theme::Set('form_action', 'index.php?p=content&q=JqueryFileUpload&type=' . $this->type); | 864 | Theme::Set('form_action', 'index.php?p=content&q=JqueryFileUpload&type=' . $this->type); |
2496 | 863 | Theme::Set('form_meta', '<input type="hidden" name="type" value="' . $this->type . '"><input type="hidden" name="layoutid" value="' . $layoutid . '"><input type="hidden" name="regionid" value="' . $regionid . '">'); | 865 | Theme::Set('form_meta', '<input type="hidden" id="PHPSESSID" value="' . $sessionId . '" /><input type="hidden" id="SecurityToken" value="' . $securityToken . '" /><input type="hidden" name="type" value="' . $this->type . '"><input type="hidden" name="layoutid" value="' . $layoutid . '"><input type="hidden" name="regionid" value="' . $regionid . '">'); |
2497 | 864 | Theme::Set('form_valid_ext', '/(\.|\/)' . implode('|', $this->validExtensions) . '$/i'); | 866 | Theme::Set('form_valid_ext', '/(\.|\/)' . implode('|', $this->validExtensions) . '$/i'); |
2498 | 865 | Theme::Set('form_max_size', Kit::ReturnBytes($this->maxFileSize)); | 867 | Theme::Set('form_max_size', Kit::ReturnBytes($this->maxFileSize)); |
2499 | 866 | Theme::Set('valid_extensions', 'This form accepts: ' . $this->validExtensionsText . ' files up to a maximum size of ' . $this->maxFileSize); | 868 | Theme::Set('valid_extensions', 'This form accepts: ' . $this->validExtensionsText . ' files up to a maximum size of ' . $this->maxFileSize); |
2500 | @@ -976,6 +978,7 @@ | |||
2501 | 976 | Theme::Set('is_duration_field_enabled', $durationFieldEnabled); | 978 | Theme::Set('is_duration_field_enabled', $durationFieldEnabled); |
2502 | 977 | Theme::Set('valid_extensions', 'This form accepts: ' . $this->validExtensionsText . ' files up to a maximum size of ' . $this->maxFileSize); | 979 | Theme::Set('valid_extensions', 'This form accepts: ' . $this->validExtensionsText . ' files up to a maximum size of ' . $this->maxFileSize); |
2503 | 978 | Theme::Set('is_replace_field_checked', ((Config::GetSetting('LIBRARY_MEDIA_UPDATEINALL_CHECKB') == 'Checked') ? 'checked' : '')); | 980 | Theme::Set('is_replace_field_checked', ((Config::GetSetting('LIBRARY_MEDIA_UPDATEINALL_CHECKB') == 'Checked') ? 'checked' : '')); |
2504 | 981 | Theme::Set('is_assignable', $this->assignable); | ||
2505 | 979 | 982 | ||
2506 | 980 | $form = Theme::RenderReturn('library_form_media_edit'); | 983 | $form = Theme::RenderReturn('library_form_media_edit'); |
2507 | 981 | 984 | ||
2508 | @@ -1617,7 +1620,7 @@ | |||
2509 | 1617 | // Some messages for the form | 1620 | // Some messages for the form |
2510 | 1618 | $msgTransition = __('What transition should be applied to this media item?'); | 1621 | $msgTransition = __('What transition should be applied to this media item?'); |
2511 | 1619 | $msgDuration = __('The duration for this transition, in milliseconds.'); | 1622 | $msgDuration = __('The duration for this transition, in milliseconds.'); |
2513 | 1620 | $msgDirection = __('The direction for this transtion.'); | 1623 | $msgDirection = __('The direction for this transition.'); |
2514 | 1621 | 1624 | ||
2515 | 1622 | // Construct the form | 1625 | // Construct the form |
2516 | 1623 | $form = <<<END | 1626 | $form = <<<END |
2517 | @@ -1625,6 +1628,7 @@ | |||
2518 | 1625 | <input type="hidden" name="type" value="$type"> | 1628 | <input type="hidden" name="type" value="$type"> |
2519 | 1626 | <input type="hidden" name="layoutid" value="$this->layoutid"> | 1629 | <input type="hidden" name="layoutid" value="$this->layoutid"> |
2520 | 1627 | <input type="hidden" name="mediaid" value="$this->mediaid"> | 1630 | <input type="hidden" name="mediaid" value="$this->mediaid"> |
2521 | 1631 | <input type="hidden" name="lkid" value="$this->lkid"> | ||
2522 | 1628 | <input type="hidden" id="iRegionId" name="regionid" value="$this->regionid"> | 1632 | <input type="hidden" id="iRegionId" name="regionid" value="$this->regionid"> |
2523 | 1629 | <input type="hidden" name="showRegionOptions" value="$this->showRegionOptions" /> | 1633 | <input type="hidden" name="showRegionOptions" value="$this->showRegionOptions" /> |
2524 | 1630 | 1634 | ||
2525 | 1631 | 1635 | ||
2526 | === modified file 'server/lib/pages/content.class.php' | |||
2527 | --- server/lib/pages/content.class.php 2014-02-13 10:48:57 +0000 | |||
2528 | +++ server/lib/pages/content.class.php 2014-03-29 13:09:24 +0000 | |||
2529 | @@ -180,7 +180,7 @@ | |||
2530 | 180 | $response = new ResponseManager(); | 180 | $response = new ResponseManager(); |
2531 | 181 | 181 | ||
2532 | 182 | // Get a list of the enabled modules and then create buttons for them | 182 | // Get a list of the enabled modules and then create buttons for them |
2534 | 183 | if (!$enabledModules = new ModuleManager($db, $user, 0)) | 183 | if (!$enabledModules = new ModuleManager($db, $user, 0, '', -1)) |
2535 | 184 | trigger_error($enabledModules->message, E_USER_ERROR); | 184 | trigger_error($enabledModules->message, E_USER_ERROR); |
2536 | 185 | 185 | ||
2537 | 186 | $buttons = array(); | 186 | $buttons = array(); |
2538 | @@ -226,7 +226,16 @@ | |||
2539 | 226 | Theme::Set('pager', ResponseManager::Pager($id)); | 226 | Theme::Set('pager', ResponseManager::Pager($id)); |
2540 | 227 | 227 | ||
2541 | 228 | // Module types filter | 228 | // Module types filter |
2543 | 229 | $types = $db->GetArray("SELECT Module AS moduleid, Name AS module FROM `module` WHERE RegionSpecific = 0 AND Enabled = 1 ORDER BY 2"); | 229 | $modules = $this->user->ModuleAuth(0, '', 1); |
2544 | 230 | $types = array(); | ||
2545 | 231 | |||
2546 | 232 | foreach ($modules as $module) { | ||
2547 | 233 | $type['moduleid'] = $module['Module']; | ||
2548 | 234 | $type['module'] = $module['Name']; | ||
2549 | 235 | |||
2550 | 236 | $types[] = $type; | ||
2551 | 237 | } | ||
2552 | 238 | |||
2553 | 230 | array_unshift($types, array('moduleid' => '', 'module' => 'All')); | 239 | array_unshift($types, array('moduleid' => '', 'module' => 'All')); |
2554 | 231 | Theme::Set('module_field_list', $types); | 240 | Theme::Set('module_field_list', $types); |
2555 | 232 | 241 | ||
2556 | 233 | 242 | ||
2557 | === modified file 'server/lib/pages/display.class.php' | |||
2558 | --- server/lib/pages/display.class.php 2014-01-18 09:47:41 +0000 | |||
2559 | +++ server/lib/pages/display.class.php 2014-03-29 13:09:24 +0000 | |||
2560 | @@ -302,7 +302,7 @@ | |||
2561 | 302 | if ($linkTarget == '') | 302 | if ($linkTarget == '') |
2562 | 303 | $linkTarget = '_top'; | 303 | $linkTarget = '_top'; |
2563 | 304 | 304 | ||
2565 | 305 | $row['display'] = sprintf('<a href="' . $vncTemplate . '" title="VNC to ' . $row['display'] . '" target="' . $linkTarget . '">' . $row['display'] . '</a>', $row['clientaddress']); | 305 | $row['display'] = sprintf('<a href="' . $vncTemplate . '" title="VNC to ' . $row['display'] . '" target="' . $linkTarget . '">' . Theme::Prepare($row['display']) . '</a>', $row['clientaddress']); |
2566 | 306 | } | 306 | } |
2567 | 307 | 307 | ||
2568 | 308 | // Format last accessed | 308 | // Format last accessed |
2569 | @@ -351,6 +351,13 @@ | |||
2570 | 351 | 'url' => 'index.php?p=display&q=WakeOnLanForm&DisplayId=' . $row['displayid'], | 351 | 'url' => 'index.php?p=display&q=WakeOnLanForm&DisplayId=' . $row['displayid'], |
2571 | 352 | 'text' => __('Wake on LAN') | 352 | 'text' => __('Wake on LAN') |
2572 | 353 | ); | 353 | ); |
2573 | 354 | |||
2574 | 355 | // File Associations | ||
2575 | 356 | $row['buttons'][] = array( | ||
2576 | 357 | 'id' => 'displaygroup_button_fileassociations', | ||
2577 | 358 | 'url' => 'index.php?p=displaygroup&q=FileAssociations&DisplayGroupID=' . $row['displaygroupid'], | ||
2578 | 359 | 'text' => __('Assign Files') | ||
2579 | 360 | ); | ||
2580 | 354 | } | 361 | } |
2581 | 355 | 362 | ||
2582 | 356 | if ($row['del'] == 1) { | 363 | if ($row['del'] == 1) { |
2583 | @@ -378,6 +385,13 @@ | |||
2584 | 378 | 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'], | 385 | 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'], |
2585 | 379 | 'text' => __('Permissions') | 386 | 'text' => __('Permissions') |
2586 | 380 | ); | 387 | ); |
2587 | 388 | |||
2588 | 389 | // Version Information | ||
2589 | 390 | $row['buttons'][] = array( | ||
2590 | 391 | 'id' => 'display_button_version_instructions', | ||
2591 | 392 | 'url' => 'index.php?p=displaygroup&q=VersionInstructionsForm&displaygroupid=' . $row['displaygroupid'] . '&displayid=' . $row['displayid'], | ||
2592 | 393 | 'text' => __('Version Information') | ||
2593 | 394 | ); | ||
2594 | 381 | } | 395 | } |
2595 | 382 | 396 | ||
2596 | 383 | // Assign this to the table row | 397 | // Assign this to the table row |
2597 | @@ -833,6 +847,6 @@ | |||
2598 | 833 | 847 | ||
2599 | 834 | $response->SetFormSubmitResponse(__('Wake on Lan command sent.')); | 848 | $response->SetFormSubmitResponse(__('Wake on Lan command sent.')); |
2600 | 835 | $response->Respond(); | 849 | $response->Respond(); |
2602 | 836 | } | 850 | } |
2603 | 837 | } | 851 | } |
2604 | 838 | ?> | 852 | ?> |
2605 | 839 | 853 | ||
2606 | === modified file 'server/lib/pages/displaygroup.class.php' | |||
2607 | --- server/lib/pages/displaygroup.class.php 2014-01-18 09:47:41 +0000 | |||
2608 | +++ server/lib/pages/displaygroup.class.php 2014-03-29 13:09:24 +0000 | |||
2609 | @@ -22,24 +22,24 @@ | |||
2610 | 22 | 22 | ||
2611 | 23 | class displaygroupDAO | 23 | class displaygroupDAO |
2612 | 24 | { | 24 | { |
2631 | 25 | private $db; | 25 | private $db; |
2632 | 26 | private $user; | 26 | private $user; |
2633 | 27 | 27 | ||
2634 | 28 | function __construct(database $db, user $user) | 28 | function __construct(database $db, user $user) |
2635 | 29 | { | 29 | { |
2636 | 30 | $this->db =& $db; | 30 | $this->db =& $db; |
2637 | 31 | $this->user =& $user; | 31 | $this->user =& $user; |
2638 | 32 | 32 | ||
2639 | 33 | include_once('lib/data/displaygroup.data.class.php'); | 33 | include_once('lib/data/displaygroup.data.class.php'); |
2640 | 34 | include_once('lib/data/displaygroupsecurity.data.class.php'); | 34 | include_once('lib/data/displaygroupsecurity.data.class.php'); |
2641 | 35 | } | 35 | } |
2642 | 36 | 36 | ||
2643 | 37 | /** | 37 | /** |
2644 | 38 | * Display Group Page Render | 38 | * Display Group Page Render |
2645 | 39 | */ | 39 | */ |
2646 | 40 | public function displayPage() | 40 | public function displayPage() |
2647 | 41 | { | 41 | { |
2648 | 42 | // Configure the theme | 42 | // Configure the theme |
2649 | 43 | $id = uniqid(); | 43 | $id = uniqid(); |
2650 | 44 | Theme::Set('id', $id); | 44 | Theme::Set('id', $id); |
2651 | 45 | Theme::Set('displaygroup_form_add_url', 'index.php?p=displaygroup&q=AddForm'); | 45 | Theme::Set('displaygroup_form_add_url', 'index.php?p=displaygroup&q=AddForm'); |
2652 | @@ -49,67 +49,81 @@ | |||
2653 | 49 | 49 | ||
2654 | 50 | // Render the Theme and output | 50 | // Render the Theme and output |
2655 | 51 | Theme::Render('displaygroup_page'); | 51 | Theme::Render('displaygroup_page'); |
2664 | 52 | } | 52 | } |
2665 | 53 | 53 | ||
2666 | 54 | /** | 54 | /** |
2667 | 55 | * Shows the Display groups | 55 | * Shows the Display groups |
2668 | 56 | * @return | 56 | * @return |
2669 | 57 | */ | 57 | */ |
2670 | 58 | public function Grid() | 58 | public function Grid() |
2671 | 59 | { | 59 | { |
2672 | 60 | $db =& $this->db; | 60 | $db =& $this->db; |
2673 | 61 | $user =& $this->user; | 61 | $user =& $this->user; |
2675 | 62 | $response = new ResponseManager(); | 62 | $response = new ResponseManager(); |
2676 | 63 | 63 | ||
2677 | 64 | $displayGroups = $this->user->DisplayGroupList(); | 64 | $displayGroups = $this->user->DisplayGroupList(); |
2678 | 65 | 65 | ||
2679 | 66 | if (!is_array($displayGroups)) | 66 | if (!is_array($displayGroups)) |
2680 | 67 | trigger_error(__('Cannot get list of display groups.'), E_USER_ERROR); | 67 | trigger_error(__('Cannot get list of display groups.'), E_USER_ERROR); |
2681 | 68 | 68 | ||
2683 | 69 | $rows = array(); | 69 | $rows = array(); |
2684 | 70 | 70 | ||
2686 | 71 | foreach ($displayGroups as $row) | 71 | foreach ($displayGroups as $row) |
2687 | 72 | { | 72 | { |
2689 | 73 | if ($row['isdisplayspecific'] != 0) | 73 | if ($row['isdisplayspecific'] != 0) |
2690 | 74 | continue; | 74 | continue; |
2691 | 75 | 75 | ||
2693 | 76 | if ($row['edit'] == 1) | 76 | if ($row['edit'] == 1) |
2694 | 77 | { | 77 | { |
2695 | 78 | // Show the edit button, members button | 78 | // Show the edit button, members button |
2696 | 79 | 79 | ||
2697 | 80 | // Group Members | 80 | // Group Members |
2710 | 81 | $row['buttons'][] = array( | 81 | $row['buttons'][] = array( |
2711 | 82 | 'id' => 'displaygroup_button_group_members', | 82 | 'id' => 'displaygroup_button_group_members', |
2712 | 83 | 'url' => 'index.php?p=displaygroup&q=MembersForm&DisplayGroupID=' . $row['displaygroupid'] . '&DisplayGroup=' . $row['displaygroup'], | 83 | 'url' => 'index.php?p=displaygroup&q=MembersForm&DisplayGroupID=' . $row['displaygroupid'] . '&DisplayGroup=' . $row['displaygroup'], |
2713 | 84 | 'text' => __('Group Members') | 84 | 'text' => __('Group Members') |
2714 | 85 | ); | 85 | ); |
2715 | 86 | 86 | ||
2716 | 87 | // Edit | 87 | // Edit |
2717 | 88 | $row['buttons'][] = array( | 88 | $row['buttons'][] = array( |
2718 | 89 | 'id' => 'displaygroup_button_edit', | 89 | 'id' => 'displaygroup_button_edit', |
2719 | 90 | 'url' => 'index.php?p=displaygroup&q=EditForm&DisplayGroupID=' . $row['displaygroupid'], | 90 | 'url' => 'index.php?p=displaygroup&q=EditForm&DisplayGroupID=' . $row['displaygroupid'], |
2720 | 91 | 'text' => __('Edit') | 91 | 'text' => __('Edit') |
2721 | 92 | ); | 92 | ); |
2722 | 93 | |||
2723 | 94 | // File Associations | ||
2724 | 95 | $row['buttons'][] = array( | ||
2725 | 96 | 'id' => 'displaygroup_button_fileassociations', | ||
2726 | 97 | 'url' => 'index.php?p=displaygroup&q=FileAssociations&DisplayGroupID=' . $row['displaygroupid'], | ||
2727 | 98 | 'text' => __('Assign Files') | ||
2728 | 99 | ); | ||
2729 | 93 | } | 100 | } |
2730 | 94 | 101 | ||
2731 | 95 | if ($row['del'] == 1) | 102 | if ($row['del'] == 1) |
2732 | 96 | { | 103 | { |
2733 | 97 | // Show the delete button | 104 | // Show the delete button |
2739 | 98 | $row['buttons'][] = array( | 105 | $row['buttons'][] = array( |
2740 | 99 | 'id' => 'displaygroup_button_delete', | 106 | 'id' => 'displaygroup_button_delete', |
2741 | 100 | 'url' => 'index.php?p=displaygroup&q=DeleteForm&DisplayGroupID=' . $row['displaygroupid'], | 107 | 'url' => 'index.php?p=displaygroup&q=DeleteForm&DisplayGroupID=' . $row['displaygroupid'], |
2742 | 101 | 'text' => __('Delete') | 108 | 'text' => __('Delete') |
2743 | 102 | ); | 109 | ); |
2744 | 103 | } | 110 | } |
2745 | 104 | 111 | ||
2746 | 105 | if ($row['modifypermissions'] == 1) | 112 | if ($row['modifypermissions'] == 1) |
2747 | 106 | { | 113 | { |
2748 | 107 | // Show the modify permissions button | 114 | // Show the modify permissions button |
2754 | 108 | $row['buttons'][] = array( | 115 | $row['buttons'][] = array( |
2755 | 109 | 'id' => 'displaygroup_button_permissions', | 116 | 'id' => 'displaygroup_button_permissions', |
2756 | 110 | 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'], | 117 | 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'], |
2757 | 111 | 'text' => __('Permissions') | 118 | 'text' => __('Permissions') |
2758 | 112 | ); | 119 | ); |
2759 | 120 | |||
2760 | 121 | // Version Information | ||
2761 | 122 | $row['buttons'][] = array( | ||
2762 | 123 | 'id' => 'display_button_version_instructions', | ||
2763 | 124 | 'url' => 'index.php?p=displaygroup&q=VersionInstructionsForm&displaygroupid=' . $row['displaygroupid'], | ||
2764 | 125 | 'text' => __('Version Information') | ||
2765 | 126 | ); | ||
2766 | 113 | } | 127 | } |
2767 | 114 | 128 | ||
2768 | 115 | // Assign this to the table row | 129 | // Assign this to the table row |
2769 | @@ -122,135 +136,135 @@ | |||
2770 | 122 | 136 | ||
2771 | 123 | $response->SetGridResponse($output); | 137 | $response->SetGridResponse($output); |
2772 | 124 | $response->Respond(); | 138 | $response->Respond(); |
2785 | 125 | } | 139 | } |
2786 | 126 | 140 | ||
2787 | 127 | /** | 141 | /** |
2788 | 128 | * Shows an add form for a display group | 142 | * Shows an add form for a display group |
2789 | 129 | */ | 143 | */ |
2790 | 130 | public function AddForm() | 144 | public function AddForm() |
2791 | 131 | { | 145 | { |
2792 | 132 | $db =& $this->db; | 146 | $db =& $this->db; |
2793 | 133 | $user =& $this->user; | 147 | $user =& $this->user; |
2794 | 134 | $response = new ResponseManager(); | 148 | $response = new ResponseManager(); |
2795 | 135 | 149 | ||
2796 | 136 | Theme::Set('form_id', 'DisplayGroupAddForm'); | 150 | Theme::Set('form_id', 'DisplayGroupAddForm'); |
2797 | 137 | Theme::Set('form_action', 'index.php?p=displaygroup&q=Add'); | 151 | Theme::Set('form_action', 'index.php?p=displaygroup&q=Add'); |
2798 | 138 | 152 | ||
2799 | 139 | $form = Theme::RenderReturn('displaygroup_form_add'); | 153 | $form = Theme::RenderReturn('displaygroup_form_add'); |
2800 | 140 | 154 | ||
2819 | 141 | $response->SetFormRequestResponse($form, __('Add Display Group'), '350px', '275px'); | 155 | $response->SetFormRequestResponse($form, __('Add Display Group'), '350px', '275px'); |
2820 | 142 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Add') . '")'); | 156 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Add') . '")'); |
2821 | 143 | $response->AddButton(__('Cancel'), 'XiboDialogClose()'); | 157 | $response->AddButton(__('Cancel'), 'XiboDialogClose()'); |
2822 | 144 | $response->AddButton(__('Save'), '$("#DisplayGroupAddForm").submit()'); | 158 | $response->AddButton(__('Save'), '$("#DisplayGroupAddForm").submit()'); |
2823 | 145 | $response->Respond(); | 159 | $response->Respond(); |
2824 | 146 | } | 160 | } |
2825 | 147 | 161 | ||
2826 | 148 | /** | 162 | /** |
2827 | 149 | * Shows an edit form for a display group | 163 | * Shows an edit form for a display group |
2828 | 150 | */ | 164 | */ |
2829 | 151 | public function EditForm() | 165 | public function EditForm() |
2830 | 152 | { | 166 | { |
2831 | 153 | $db =& $this->db; | 167 | $db =& $this->db; |
2832 | 154 | $user =& $this->user; | 168 | $user =& $this->user; |
2833 | 155 | $response = new ResponseManager(); | 169 | $response = new ResponseManager(); |
2834 | 156 | $helpManager = new HelpManager($db, $user); | 170 | $helpManager = new HelpManager($db, $user); |
2835 | 157 | 171 | ||
2836 | 158 | $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT); | 172 | $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT); |
2837 | 159 | 173 | ||
2838 | 160 | // Auth | 174 | // Auth |
2839 | 161 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); | 175 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); |
2840 | 162 | if (!$auth->edit) | 176 | if (!$auth->edit) |
2841 | 163 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); | 177 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); |
2861 | 164 | 178 | ||
2862 | 165 | // Pull the currently known info from the DB | 179 | // Pull the currently known info from the DB |
2863 | 166 | $SQL = "SELECT DisplayGroupID, DisplayGroup, Description FROM displaygroup WHERE DisplayGroupID = %d AND IsDisplaySpecific = 0"; | 180 | $SQL = "SELECT DisplayGroupID, DisplayGroup, Description FROM displaygroup WHERE DisplayGroupID = %d AND IsDisplaySpecific = 0"; |
2864 | 167 | $SQL = sprintf($SQL, $displayGroupID); | 181 | $SQL = sprintf($SQL, $displayGroupID); |
2865 | 168 | 182 | ||
2866 | 169 | if (!$row = $db->GetSingleRow($SQL)) | 183 | if (!$row = $db->GetSingleRow($SQL)) |
2867 | 170 | { | 184 | { |
2868 | 171 | trigger_error($db->error()); | 185 | trigger_error($db->error()); |
2869 | 172 | trigger_error(__('Error getting Display Group'), E_USER_ERROR); | 186 | trigger_error(__('Error getting Display Group'), E_USER_ERROR); |
2870 | 173 | } | 187 | } |
2871 | 174 | 188 | ||
2872 | 175 | // Pull out these columns | 189 | // Pull out these columns |
2873 | 176 | if (count($row) <= 0) | 190 | if (count($row) <= 0) |
2874 | 177 | trigger_error(__('No display group found.'), E_USER_ERROR); | 191 | trigger_error(__('No display group found.'), E_USER_ERROR); |
2875 | 178 | 192 | ||
2876 | 179 | Theme::Set('displaygroup', Kit::ValidateParam($row['DisplayGroup'], _STRING)); | 193 | Theme::Set('displaygroup', Kit::ValidateParam($row['DisplayGroup'], _STRING)); |
2877 | 180 | Theme::Set('description', Kit::ValidateParam($row['Description'], _STRING)); | 194 | Theme::Set('description', Kit::ValidateParam($row['Description'], _STRING)); |
2878 | 181 | 195 | ||
2879 | 182 | // Set some information about the form | 196 | // Set some information about the form |
2880 | 183 | Theme::Set('form_id', 'DisplayGroupEditForm'); | 197 | Theme::Set('form_id', 'DisplayGroupEditForm'); |
2881 | 184 | Theme::Set('form_action', 'index.php?p=displaygroup&q=Edit'); | 198 | Theme::Set('form_action', 'index.php?p=displaygroup&q=Edit'); |
2882 | 185 | Theme::Set('form_meta', '<input type="hidden" name="DisplayGroupID" value="' . $displayGroupID . '" />'); | 199 | Theme::Set('form_meta', '<input type="hidden" name="DisplayGroupID" value="' . $displayGroupID . '" />'); |
2883 | 186 | 200 | ||
2884 | 187 | $form = Theme::RenderReturn('displaygroup_form_edit'); | 201 | $form = Theme::RenderReturn('displaygroup_form_edit'); |
2885 | 188 | 202 | ||
2901 | 189 | $response->SetFormRequestResponse($form, __('Edit Display Group'), '350px', '275px'); | 203 | $response->SetFormRequestResponse($form, __('Edit Display Group'), '350px', '275px'); |
2902 | 190 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Edit') . '")'); | 204 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Edit') . '")'); |
2903 | 191 | $response->AddButton(__('Cancel'), 'XiboDialogClose()'); | 205 | $response->AddButton(__('Cancel'), 'XiboDialogClose()'); |
2904 | 192 | $response->AddButton(__('Save'), '$("#DisplayGroupEditForm").submit()'); | 206 | $response->AddButton(__('Save'), '$("#DisplayGroupEditForm").submit()'); |
2905 | 193 | $response->Respond(); | 207 | $response->Respond(); |
2906 | 194 | } | 208 | } |
2907 | 195 | 209 | ||
2908 | 196 | /** | 210 | /** |
2909 | 197 | * Shows the Delete Group Form | 211 | * Shows the Delete Group Form |
2910 | 198 | */ | 212 | */ |
2911 | 199 | function DeleteForm() | 213 | function DeleteForm() |
2912 | 200 | { | 214 | { |
2913 | 201 | $db =& $this->db; | 215 | $db =& $this->db; |
2914 | 202 | $response = new ResponseManager(); | 216 | $response = new ResponseManager(); |
2915 | 203 | $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT); | 217 | $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT); |
2916 | 204 | 218 | ||
2917 | 205 | // Auth | 219 | // Auth |
2918 | 206 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); | 220 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); |
2919 | 207 | if (!$auth->del) | 221 | if (!$auth->del) |
2920 | 208 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); | 222 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); |
2923 | 209 | 223 | ||
2924 | 210 | // Set some information about the form | 224 | // Set some information about the form |
2925 | 211 | Theme::Set('form_id', 'DisplayGroupDeleteForm'); | 225 | Theme::Set('form_id', 'DisplayGroupDeleteForm'); |
2926 | 212 | Theme::Set('form_action', 'index.php?p=displaygroup&q=Delete'); | 226 | Theme::Set('form_action', 'index.php?p=displaygroup&q=Delete'); |
2927 | 213 | Theme::Set('form_meta', '<input type="hidden" name="DisplayGroupID" value="' . $displayGroupID . '" />'); | 227 | Theme::Set('form_meta', '<input type="hidden" name="DisplayGroupID" value="' . $displayGroupID . '" />'); |
2928 | 214 | 228 | ||
2929 | 215 | $form = Theme::RenderReturn('displaygroup_form_delete'); | 229 | $form = Theme::RenderReturn('displaygroup_form_delete'); |
2950 | 216 | 230 | ||
2951 | 217 | $response->SetFormRequestResponse($form, __('Delete Display Group'), '350px', '175px'); | 231 | $response->SetFormRequestResponse($form, __('Delete Display Group'), '350px', '175px'); |
2952 | 218 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Delete') . '")'); | 232 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Delete') . '")'); |
2953 | 219 | $response->AddButton(__('No'), 'XiboDialogClose()'); | 233 | $response->AddButton(__('No'), 'XiboDialogClose()'); |
2954 | 220 | $response->AddButton(__('Yes'), '$("#DisplayGroupDeleteForm").submit()'); | 234 | $response->AddButton(__('Yes'), '$("#DisplayGroupDeleteForm").submit()'); |
2955 | 221 | $response->Respond(); | 235 | $response->Respond(); |
2956 | 222 | } | 236 | } |
2957 | 223 | 237 | ||
2958 | 224 | /** | 238 | /** |
2959 | 225 | * Display Group Members form | 239 | * Display Group Members form |
2960 | 226 | */ | 240 | */ |
2961 | 227 | public function MembersForm() | 241 | public function MembersForm() |
2962 | 228 | { | 242 | { |
2963 | 229 | $db =& $this->db; | 243 | $db =& $this->db; |
2964 | 230 | $response = new ResponseManager(); | 244 | $response = new ResponseManager(); |
2965 | 231 | $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT); | 245 | $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT); |
2966 | 232 | 246 | ||
2967 | 233 | // There needs to be two lists here. | 247 | // There needs to be two lists here. |
2968 | 234 | // One of which is the Displays currently assigned to this group | 248 | // One of which is the Displays currently assigned to this group |
2969 | 235 | // The other is a list of displays that are available to be assigned (i.e. the opposite of the first list) | 249 | // The other is a list of displays that are available to be assigned (i.e. the opposite of the first list) |
2970 | 236 | 250 | ||
2972 | 237 | // Set some information about the form | 251 | // Set some information about the form |
2973 | 238 | Theme::Set('displays_assigned_id', 'displaysIn'); | 252 | Theme::Set('displays_assigned_id', 'displaysIn'); |
2974 | 239 | Theme::Set('displays_available_id', 'displaysOut'); | 253 | Theme::Set('displays_available_id', 'displaysOut'); |
2975 | 240 | Theme::Set('displays_assigned_url', 'index.php?p=displaygroup&q=SetMembers&DisplayGroupID=' . $displayGroupID); | 254 | Theme::Set('displays_assigned_url', 'index.php?p=displaygroup&q=SetMembers&DisplayGroupID=' . $displayGroupID); |
2976 | 241 | 255 | ||
2989 | 242 | // Displays in group | 256 | // Displays in group |
2990 | 243 | $SQL = ""; | 257 | $SQL = ""; |
2991 | 244 | $SQL .= "SELECT display.DisplayID, "; | 258 | $SQL .= "SELECT display.DisplayID, "; |
2992 | 245 | $SQL .= " display.Display, "; | 259 | $SQL .= " display.Display, "; |
2993 | 246 | $SQL .= " CONCAT('DisplayID_', display.DisplayID) AS list_id "; | 260 | $SQL .= " CONCAT('DisplayID_', display.DisplayID) AS list_id "; |
2994 | 247 | $SQL .= "FROM display "; | 261 | $SQL .= "FROM display "; |
2995 | 248 | $SQL .= " INNER JOIN lkdisplaydg "; | 262 | $SQL .= " INNER JOIN lkdisplaydg "; |
2996 | 249 | $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID "; | 263 | $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID "; |
2997 | 250 | $SQL .= sprintf("WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID); | 264 | $SQL .= sprintf("WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID); |
2998 | 251 | $SQL .= " ORDER BY display.Display "; | 265 | $SQL .= " ORDER BY display.Display "; |
2999 | 252 | 266 | ||
3000 | 253 | $displaysAssigned = $db->GetArray($SQL); | 267 | $displaysAssigned = $db->GetArray($SQL); |
3001 | 254 | 268 | ||
3002 | 255 | if (!is_array($displaysAssigned)) | 269 | if (!is_array($displaysAssigned)) |
3003 | 256 | { | 270 | { |
3004 | @@ -259,198 +273,203 @@ | |||
3005 | 259 | } | 273 | } |
3006 | 260 | 274 | ||
3007 | 261 | Theme::Set('displays_assigned', $displaysAssigned); | 275 | Theme::Set('displays_assigned', $displaysAssigned); |
3023 | 262 | 276 | ||
3024 | 263 | // Displays not in group | 277 | // Displays not in group |
3025 | 264 | $SQL = ""; | 278 | $SQL = ""; |
3026 | 265 | $SQL .= "SELECT display.DisplayID, "; | 279 | $SQL .= "SELECT display.DisplayID, "; |
3027 | 266 | $SQL .= " display.Display, "; | 280 | $SQL .= " display.Display, "; |
3028 | 267 | $SQL .= " CONCAT('DisplayID_', display.DisplayID) AS list_id "; | 281 | $SQL .= " CONCAT('DisplayID_', display.DisplayID) AS list_id "; |
3029 | 268 | $SQL .= "FROM display "; | 282 | $SQL .= "FROM display "; |
3030 | 269 | $SQL .= " WHERE display.DisplayID NOT IN "; | 283 | $SQL .= " WHERE display.DisplayID NOT IN "; |
3031 | 270 | $SQL .= " (SELECT display.DisplayID "; | 284 | $SQL .= " (SELECT display.DisplayID "; |
3032 | 271 | $SQL .= " FROM display "; | 285 | $SQL .= " FROM display "; |
3033 | 272 | $SQL .= " INNER JOIN lkdisplaydg "; | 286 | $SQL .= " INNER JOIN lkdisplaydg "; |
3034 | 273 | $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID "; | 287 | $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID "; |
3035 | 274 | $SQL .= sprintf(" WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID); | 288 | $SQL .= sprintf(" WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID); |
3036 | 275 | $SQL .= " )"; | 289 | $SQL .= " )"; |
3037 | 276 | $SQL .= " ORDER BY display.Display "; | 290 | $SQL .= " ORDER BY display.Display "; |
3038 | 277 | 291 | ||
3042 | 278 | $displaysAvailable = $db->GetArray($SQL); | 292 | $displaysAvailable = $db->GetArray($SQL); |
3043 | 279 | 293 | ||
3044 | 280 | if (!is_array($displaysAvailable)) | 294 | if (!is_array($displaysAvailable)) |
3045 | 281 | { | 295 | { |
3046 | 282 | trigger_error($db->error()); | 296 | trigger_error($db->error()); |
3047 | 283 | trigger_error(__('Error getting Displays'), E_USER_ERROR); | 297 | trigger_error(__('Error getting Displays'), E_USER_ERROR); |
3048 | 284 | } | 298 | } |
3049 | 285 | 299 | ||
3050 | 286 | Theme::Set('displays_available', $displaysAvailable); | 300 | Theme::Set('displays_available', $displaysAvailable); |
3053 | 287 | 301 | ||
3054 | 288 | 302 | ||
3055 | 289 | $form = Theme::RenderReturn('displaygroup_form_display_assign'); | 303 | $form = Theme::RenderReturn('displaygroup_form_display_assign'); |
3056 | 290 | 304 | ||
3107 | 291 | $response->SetFormRequestResponse($form, __('Manage Membership'), '400', '375', 'DisplayGroupManageMembersCallBack'); | 305 | $response->SetFormRequestResponse($form, __('Manage Membership'), '400', '375', 'DisplayGroupManageMembersCallBack'); |
3108 | 292 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Members') . '")'); | 306 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Members') . '")'); |
3109 | 293 | $response->AddButton(__('Cancel'), 'XiboDialogClose()'); | 307 | $response->AddButton(__('Cancel'), 'XiboDialogClose()'); |
3110 | 294 | $response->AddButton(__('Save'), 'DisplayGroupMembersSubmit()'); | 308 | $response->AddButton(__('Save'), 'DisplayGroupMembersSubmit()'); |
3111 | 295 | $response->Respond(); | 309 | $response->Respond(); |
3112 | 296 | } | 310 | } |
3113 | 297 | 311 | ||
3114 | 298 | /** | 312 | /** |
3115 | 299 | * Adds a Display Group | 313 | * Adds a Display Group |
3116 | 300 | * @return | 314 | * @return |
3117 | 301 | */ | 315 | */ |
3118 | 302 | public function Add() | 316 | public function Add() |
3119 | 303 | { | 317 | { |
3120 | 304 | // Check the token | 318 | // Check the token |
3121 | 305 | if (!Kit::CheckToken()) | 319 | if (!Kit::CheckToken()) |
3122 | 306 | trigger_error('Token does not match', E_USER_ERROR); | 320 | trigger_error('Token does not match', E_USER_ERROR); |
3123 | 307 | 321 | ||
3124 | 308 | $db =& $this->db; | 322 | $db =& $this->db; |
3125 | 309 | $response = new ResponseManager(); | 323 | $response = new ResponseManager(); |
3126 | 310 | 324 | ||
3127 | 311 | $displayGroup = Kit::GetParam('group', _POST, _STRING); | 325 | $displayGroup = Kit::GetParam('group', _POST, _STRING); |
3128 | 312 | $description = Kit::GetParam('desc', _POST, _STRING); | 326 | $description = Kit::GetParam('desc', _POST, _STRING); |
3129 | 313 | 327 | ||
3130 | 314 | $displayGroupObject = new DisplayGroup($db); | 328 | $displayGroupObject = new DisplayGroup($db); |
3131 | 315 | 329 | ||
3132 | 316 | if (!$displayGroupObject->Add($displayGroup, 0, $description)) | 330 | if (!$displayGroupObject->Add($displayGroup, 0, $description)) |
3133 | 317 | { | 331 | { |
3134 | 318 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); | 332 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); |
3135 | 319 | } | 333 | } |
3136 | 320 | 334 | ||
3137 | 321 | $response->SetFormSubmitResponse(__('Display Group Added'), false); | 335 | $response->SetFormSubmitResponse(__('Display Group Added'), false); |
3138 | 322 | $response->Respond(); | 336 | $response->Respond(); |
3139 | 323 | } | 337 | } |
3140 | 324 | 338 | ||
3141 | 325 | /** | 339 | /** |
3142 | 326 | * Edits a Display Group | 340 | * Edits a Display Group |
3143 | 327 | * @return | 341 | * @return |
3144 | 328 | */ | 342 | */ |
3145 | 329 | public function Edit() | 343 | public function Edit() |
3146 | 330 | { | 344 | { |
3147 | 331 | // Check the token | 345 | // Check the token |
3148 | 332 | if (!Kit::CheckToken()) | 346 | if (!Kit::CheckToken()) |
3149 | 333 | trigger_error('Token does not match', E_USER_ERROR); | 347 | trigger_error('Token does not match', E_USER_ERROR); |
3150 | 334 | 348 | ||
3151 | 335 | $db =& $this->db; | 349 | $db =& $this->db; |
3152 | 336 | $response = new ResponseManager(); | 350 | $response = new ResponseManager(); |
3153 | 337 | 351 | ||
3154 | 338 | $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT); | 352 | $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT); |
3155 | 339 | $displayGroup = Kit::GetParam('group', _POST, _STRING); | 353 | $displayGroup = Kit::GetParam('group', _POST, _STRING); |
3156 | 340 | $description = Kit::GetParam('desc', _POST, _STRING); | 354 | $description = Kit::GetParam('desc', _POST, _STRING); |
3157 | 341 | 355 | ||
3158 | 342 | // Auth | 356 | // Auth |
3159 | 343 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); | 357 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); |
3160 | 344 | if (!$auth->edit) | 358 | if (!$auth->edit) |
3161 | 345 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); | 359 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); |
3181 | 346 | 360 | ||
3182 | 347 | // Deal with the Edit | 361 | // Deal with the Edit |
3183 | 348 | $displayGroupObject = new DisplayGroup($db); | 362 | $displayGroupObject = new DisplayGroup($db); |
3184 | 349 | 363 | ||
3185 | 350 | if (!$displayGroupObject->Edit($displayGroupID, $displayGroup, $description)) | 364 | if (!$displayGroupObject->Edit($displayGroupID, $displayGroup, $description)) |
3186 | 351 | { | 365 | { |
3187 | 352 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); | 366 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); |
3188 | 353 | } | 367 | } |
3189 | 354 | 368 | ||
3190 | 355 | $response->SetFormSubmitResponse(__('Display Group Edited'), false); | 369 | $response->SetFormSubmitResponse(__('Display Group Edited'), false); |
3191 | 356 | $response->Respond(); | 370 | $response->Respond(); |
3192 | 357 | } | 371 | } |
3193 | 358 | 372 | ||
3194 | 359 | /** | 373 | /** |
3195 | 360 | * Deletes a Group | 374 | * Deletes a Group |
3196 | 361 | * @return | 375 | * @return |
3197 | 362 | */ | 376 | */ |
3198 | 363 | function Delete() | 377 | function Delete() |
3199 | 364 | { | 378 | { |
3200 | 365 | // Check the token | 379 | // Check the token |
3201 | 366 | if (!Kit::CheckToken()) | 380 | if (!Kit::CheckToken()) |
3202 | 367 | trigger_error('Token does not match', E_USER_ERROR); | 381 | trigger_error('Token does not match', E_USER_ERROR); |
3203 | 368 | 382 | ||
3289 | 369 | $db =& $this->db; | 383 | $db =& $this->db; |
3290 | 370 | $response = new ResponseManager(); | 384 | $response = new ResponseManager(); |
3291 | 371 | 385 | ||
3292 | 372 | $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT); | 386 | $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT); |
3293 | 373 | 387 | ||
3294 | 374 | // Auth | 388 | // Auth |
3295 | 375 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); | 389 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); |
3296 | 376 | if (!$auth->del) | 390 | if (!$auth->del) |
3297 | 377 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); | 391 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); |
3298 | 378 | 392 | ||
3299 | 379 | // Deal with the Delete | 393 | // Deal with the Delete |
3300 | 380 | $displayGroupObject = new DisplayGroup($db); | 394 | $displayGroupObject = new DisplayGroup($db); |
3301 | 381 | 395 | ||
3302 | 382 | if (!$displayGroupObject->Delete($displayGroupID)) | 396 | if (!$displayGroupObject->Delete($displayGroupID)) |
3303 | 383 | { | 397 | { |
3304 | 384 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); | 398 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); |
3305 | 385 | } | 399 | } |
3306 | 386 | 400 | ||
3307 | 387 | $response->SetFormSubmitResponse(__('Display Group Deleted'), false); | 401 | $response->SetFormSubmitResponse(__('Display Group Deleted'), false); |
3308 | 388 | $response->Respond(); | 402 | $response->Respond(); |
3309 | 389 | } | 403 | } |
3310 | 390 | 404 | ||
3311 | 391 | /** | 405 | /** |
3312 | 392 | * Sets the Members of a group | 406 | * Sets the Members of a group |
3313 | 393 | * @return | 407 | * @return |
3314 | 394 | */ | 408 | */ |
3315 | 395 | public function SetMembers() | 409 | public function SetMembers() |
3316 | 396 | { | 410 | { |
3317 | 397 | $db =& $this->db; | 411 | $db =& $this->db; |
3318 | 398 | $response = new ResponseManager(); | 412 | $response = new ResponseManager(); |
3319 | 399 | $displayGroupObject = new DisplayGroup($db); | 413 | $displayGroupObject = new DisplayGroup($db); |
3320 | 400 | 414 | ||
3321 | 401 | $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT); | 415 | $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT); |
3322 | 402 | $displays = Kit::GetParam('DisplayID', _POST, _ARRAY, array()); | 416 | $displays = Kit::GetParam('DisplayID', _POST, _ARRAY, array()); |
3323 | 403 | $members = array(); | 417 | $members = array(); |
3324 | 404 | 418 | ||
3325 | 405 | // Get a list of current members | 419 | // Auth |
3326 | 406 | $SQL = ""; | 420 | $auth = $this->user->DisplayGroupAuth($displayGroupID, true); |
3327 | 407 | $SQL .= "SELECT display.DisplayID "; | 421 | if (!$auth->del) |
3328 | 408 | $SQL .= "FROM display "; | 422 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); |
3329 | 409 | $SQL .= " INNER JOIN lkdisplaydg "; | 423 | |
3330 | 410 | $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID "; | 424 | // Get a list of current members |
3331 | 411 | $SQL .= sprintf("WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID); | 425 | $SQL = ""; |
3332 | 412 | 426 | $SQL .= "SELECT display.DisplayID "; | |
3333 | 413 | if(!$resultIn = $db->query($SQL)) | 427 | $SQL .= "FROM display "; |
3334 | 414 | { | 428 | $SQL .= " INNER JOIN lkdisplaydg "; |
3335 | 415 | trigger_error($db->error()); | 429 | $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID "; |
3336 | 416 | trigger_error(__('Error getting Displays'), E_USER_ERROR); | 430 | $SQL .= sprintf("WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID); |
3337 | 417 | } | 431 | |
3338 | 418 | 432 | if(!$resultIn = $db->query($SQL)) | |
3339 | 419 | while($row = $db->get_assoc_row($resultIn)) | 433 | { |
3340 | 420 | { | 434 | trigger_error($db->error()); |
3341 | 421 | // Test whether this ID is in the array or not | 435 | trigger_error(__('Error getting Displays'), E_USER_ERROR); |
3342 | 422 | $displayID = Kit::ValidateParam($row['DisplayID'], _INT); | 436 | } |
3343 | 423 | 437 | ||
3344 | 424 | if(!in_array($displayID, $displays)) | 438 | while($row = $db->get_assoc_row($resultIn)) |
3345 | 425 | { | 439 | { |
3346 | 426 | // Its currently assigned but not in the $displays array | 440 | // Test whether this ID is in the array or not |
3347 | 427 | // so we unassign | 441 | $displayID = Kit::ValidateParam($row['DisplayID'], _INT); |
3348 | 428 | if (!$displayGroupObject->Unlink($displayGroupID, $displayID)) | 442 | |
3349 | 429 | { | 443 | if(!in_array($displayID, $displays)) |
3350 | 430 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); | 444 | { |
3351 | 431 | } | 445 | // Its currently assigned but not in the $displays array |
3352 | 432 | } | 446 | // so we unassign |
3353 | 433 | else | 447 | if (!$displayGroupObject->Unlink($displayGroupID, $displayID)) |
3354 | 434 | { | 448 | { |
3355 | 435 | $members[] = $displayID; | 449 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); |
3356 | 436 | } | 450 | } |
3357 | 437 | } | 451 | } |
3358 | 438 | 452 | else | |
3359 | 439 | foreach($displays as $displayID) | 453 | { |
3360 | 440 | { | 454 | $members[] = $displayID; |
3361 | 441 | // Add any that are missing | 455 | } |
3362 | 442 | if(!in_array($displayID, $members)) | 456 | } |
3363 | 443 | { | 457 | |
3364 | 444 | if (!$displayGroupObject->Link($displayGroupID, $displayID)) | 458 | foreach($displays as $displayID) |
3365 | 445 | { | 459 | { |
3366 | 446 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); | 460 | // Add any that are missing |
3367 | 447 | } | 461 | if(!in_array($displayID, $members)) |
3368 | 448 | } | 462 | { |
3369 | 449 | } | 463 | if (!$displayGroupObject->Link($displayGroupID, $displayID)) |
3370 | 450 | 464 | { | |
3371 | 451 | $response->SetFormSubmitResponse(__('Group membership set'), false); | 465 | trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); |
3372 | 452 | $response->Respond(); | 466 | } |
3373 | 453 | } | 467 | } |
3374 | 468 | } | ||
3375 | 469 | |||
3376 | 470 | $response->SetFormSubmitResponse(__('Group membership set'), false); | ||
3377 | 471 | $response->Respond(); | ||
3378 | 472 | } | ||
3379 | 454 | 473 | ||
3380 | 455 | /** | 474 | /** |
3381 | 456 | * Show the Permissions for this Display Group | 475 | * Show the Permissions for this Display Group |
3382 | @@ -471,7 +490,7 @@ | |||
3383 | 471 | 490 | ||
3384 | 472 | // Set some information about the form | 491 | // Set some information about the form |
3385 | 473 | Theme::Set('form_id', 'DisplayGroupPermissionsForm'); | 492 | Theme::Set('form_id', 'DisplayGroupPermissionsForm'); |
3387 | 474 | Theme::Set('form_action', 'index.php?p=displaygroup&q=Permissions'); | 493 | Theme::Set('form_action', 'index.php?p=displaygroup&q=Permissions'); |
3388 | 475 | Theme::Set('form_meta', '<input type="hidden" name="displayGroupId" value="' . $displayGroupId . '" />'); | 494 | Theme::Set('form_meta', '<input type="hidden" name="displayGroupId" value="' . $displayGroupId . '" />'); |
3389 | 476 | 495 | ||
3390 | 477 | // List of all Groups with a view/edit/delete checkbox | 496 | // List of all Groups with a view/edit/delete checkbox |
3391 | @@ -543,7 +562,7 @@ | |||
3392 | 543 | $auth = $this->user->DisplayGroupAuth($displayGroupId, true); | 562 | $auth = $this->user->DisplayGroupAuth($displayGroupId, true); |
3393 | 544 | 563 | ||
3394 | 545 | if (!$auth->modifyPermissions) | 564 | if (!$auth->modifyPermissions) |
3396 | 546 | trigger_error(__('You do not have permissions to edit this dataset'), E_USER_ERROR); | 565 | trigger_error(__('You do not have permissions to edit this display group'), E_USER_ERROR); |
3397 | 547 | 566 | ||
3398 | 548 | // Unlink all | 567 | // Unlink all |
3399 | 549 | $security = new DisplayGroupSecurity($db); | 568 | $security = new DisplayGroupSecurity($db); |
3400 | @@ -610,5 +629,257 @@ | |||
3401 | 610 | $response->SetFormSubmitResponse(__('Permissions Changed')); | 629 | $response->SetFormSubmitResponse(__('Permissions Changed')); |
3402 | 611 | $response->Respond(); | 630 | $response->Respond(); |
3403 | 612 | } | 631 | } |
3404 | 632 | |||
3405 | 633 | public function FileAssociations() { | ||
3406 | 634 | |||
3407 | 635 | $displayGroupId = Kit::GetParam('DisplayGroupID', _GET, _INT); | ||
3408 | 636 | |||
3409 | 637 | // Auth | ||
3410 | 638 | $auth = $this->user->DisplayGroupAuth($displayGroupId, true); | ||
3411 | 639 | if (!$auth->edit) | ||
3412 | 640 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); | ||
3413 | 641 | |||
3414 | 642 | $id = uniqid(); | ||
3415 | 643 | Theme::Set('id', $id); | ||
3416 | 644 | Theme::Set('form_meta', '<input type="hidden" name="p" value="displaygroup"><input type="hidden" name="q" value="FileAssociationsView"><input type="hidden" name="displaygroupid" value="' . $displayGroupId . '">'); | ||
3417 | 645 | Theme::Set('pager', ResponseManager::Pager($id)); | ||
3418 | 646 | |||
3419 | 647 | // Module types filter | ||
3420 | 648 | $modules = $this->user->ModuleAuth(0, '', -1); | ||
3421 | 649 | $types = array(); | ||
3422 | 650 | |||
3423 | 651 | foreach ($modules as $module) { | ||
3424 | 652 | $type['moduleid'] = $module['Module']; | ||
3425 | 653 | $type['module'] = $module['Name']; | ||
3426 | 654 | |||
3427 | 655 | $types[] = $type; | ||
3428 | 656 | } | ||
3429 | 657 | |||
3430 | 658 | array_unshift($types, array('moduleid' => '', 'module' => 'All')); | ||
3431 | 659 | Theme::Set('module_field_list', $types); | ||
3432 | 660 | |||
3433 | 661 | // Get the currently associated media items and put them in the top bar | ||
3434 | 662 | $existing = array(); | ||
3435 | 663 | |||
3436 | 664 | try { | ||
3437 | 665 | $dbh = PDOConnect::init(); | ||
3438 | 666 | |||
3439 | 667 | $sth = $dbh->prepare(' | ||
3440 | 668 | SELECT media.MediaID, media.Name | ||
3441 | 669 | FROM `media` | ||
3442 | 670 | INNER JOIN `lkmediadisplaygroup` | ||
3443 | 671 | ON lkmediadisplaygroup.mediaid = media.mediaid | ||
3444 | 672 | WHERE lkmediadisplaygroup.displaygroupid = :displaygroupid | ||
3445 | 673 | '); | ||
3446 | 674 | |||
3447 | 675 | $sth->execute(array('displaygroupid' => $displayGroupId)); | ||
3448 | 676 | |||
3449 | 677 | $existing = $sth->fetchAll(); | ||
3450 | 678 | } | ||
3451 | 679 | catch (Exception $e) { | ||
3452 | 680 | |||
3453 | 681 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
3454 | 682 | |||
3455 | 683 | trigger_error(__('Unable to get existing assignments.'), E_USER_ERROR); | ||
3456 | 684 | } | ||
3457 | 685 | |||
3458 | 686 | Theme::Set('existing_associations', $existing); | ||
3459 | 687 | |||
3460 | 688 | // Call to render the template | ||
3461 | 689 | $output = Theme::RenderReturn('displaygroup_fileassociations_form_assign'); | ||
3462 | 690 | |||
3463 | 691 | // Construct the Response | ||
3464 | 692 | $response = new ResponseManager(); | ||
3465 | 693 | $response->html = $output; | ||
3466 | 694 | $response->success = true; | ||
3467 | 695 | $response->dialogSize = true; | ||
3468 | 696 | $response->dialogClass = 'modal-big'; | ||
3469 | 697 | $response->dialogWidth = '780px'; | ||
3470 | 698 | $response->dialogHeight = '580px'; | ||
3471 | 699 | $response->dialogTitle = __('Associate an item from the Library'); | ||
3472 | 700 | |||
3473 | 701 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'FileAssociations') . '")'); | ||
3474 | 702 | $response->AddButton(__('Cancel'), 'XiboDialogClose()'); | ||
3475 | 703 | $response->AddButton(__('Assign'), 'FileAssociationsSubmit(' . $displayGroupId . ')'); | ||
3476 | 704 | $response->Respond(); | ||
3477 | 705 | } | ||
3478 | 706 | |||
3479 | 707 | public function FileAssociationsView() { | ||
3480 | 708 | $user =& $this->user; | ||
3481 | 709 | |||
3482 | 710 | //Input vars | ||
3483 | 711 | $mediatype = Kit::GetParam('filter_type', _POST, _STRING); | ||
3484 | 712 | $name = Kit::GetParam('filter_name', _POST, _STRING); | ||
3485 | 713 | $displaygroupid = Kit::GetParam('displaygroupid', _POST, _INT); | ||
3486 | 714 | |||
3487 | 715 | // Get the currently associated media items and put them in the top bar | ||
3488 | 716 | $existing = array(); | ||
3489 | 717 | |||
3490 | 718 | try { | ||
3491 | 719 | $dbh = PDOConnect::init(); | ||
3492 | 720 | |||
3493 | 721 | $sth = $dbh->prepare(' | ||
3494 | 722 | SELECT mediaid | ||
3495 | 723 | FROM `lkmediadisplaygroup` | ||
3496 | 724 | WHERE displaygroupid = :displaygroupid | ||
3497 | 725 | '); | ||
3498 | 726 | |||
3499 | 727 | $sth->execute(array('displaygroupid' => $displaygroupid)); | ||
3500 | 728 | |||
3501 | 729 | while ($existing[] = $sth->fetchColumn()); | ||
3502 | 730 | } | ||
3503 | 731 | catch (Exception $e) { | ||
3504 | 732 | |||
3505 | 733 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
3506 | 734 | |||
3507 | 735 | trigger_error(__('Unable to get existing assignments.'), E_USER_ERROR); | ||
3508 | 736 | } | ||
3509 | 737 | |||
3510 | 738 | // Get a list of media | ||
3511 | 739 | $mediaList = $user->MediaList($mediatype, $name); | ||
3512 | 740 | |||
3513 | 741 | $rows = array(); | ||
3514 | 742 | |||
3515 | 743 | // Add some extra information | ||
3516 | 744 | foreach ($mediaList as $row) { | ||
3517 | 745 | |||
3518 | 746 | if (in_array($row['mediaid'], $existing)) | ||
3519 | 747 | continue; | ||
3520 | 748 | |||
3521 | 749 | $row['list_id'] = 'MediaID_' . $row['mediaid']; | ||
3522 | 750 | |||
3523 | 751 | $rows[] = $row; | ||
3524 | 752 | } | ||
3525 | 753 | |||
3526 | 754 | Theme::Set('table_rows', $rows); | ||
3527 | 755 | |||
3528 | 756 | // Render the Theme | ||
3529 | 757 | $response = new ResponseManager(); | ||
3530 | 758 | $response->SetGridResponse(Theme::RenderReturn('displaygroup_fileassociations_form_assign_list')); | ||
3531 | 759 | $response->callBack = 'FileAssociationsCallback'; | ||
3532 | 760 | $response->pageSize = 5; | ||
3533 | 761 | $response->Respond(); | ||
3534 | 762 | } | ||
3535 | 763 | |||
3536 | 764 | public function SetFileAssociations() { | ||
3537 | 765 | $user =& $this->user; | ||
3538 | 766 | $response = new ResponseManager(); | ||
3539 | 767 | |||
3540 | 768 | $displayGroupId = Kit::GetParam('displaygroupid', _GET, _INT); | ||
3541 | 769 | $mediaList = Kit::GetParam('MediaID', _POST, _ARRAY_INT, array(), false); | ||
3542 | 770 | |||
3543 | 771 | if ($displayGroupId == 0) | ||
3544 | 772 | trigger_error(__('Display Group not selected'), E_USER_ERROR); | ||
3545 | 773 | |||
3546 | 774 | // Auth | ||
3547 | 775 | $auth = $this->user->DisplayGroupAuth($displayGroupId, true); | ||
3548 | 776 | if (!$auth->del) | ||
3549 | 777 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); | ||
3550 | 778 | |||
3551 | 779 | Kit::ClassLoader('displaygroup'); | ||
3552 | 780 | $displayGroup = new DisplayGroup($this->db); | ||
3553 | 781 | |||
3554 | 782 | if (!$displayGroup->AssociateFiles($this->user, $displayGroupId, $mediaList)) | ||
3555 | 783 | trigger_error($displayGroup->GetErrorMessage(), E_USER_ERROR); | ||
3556 | 784 | |||
3557 | 785 | // Success | ||
3558 | 786 | $response->SetFormSubmitResponse(sprintf(__('%d Media Items Assigned'), count($mediaList))); | ||
3559 | 787 | $response->Respond(); | ||
3560 | 788 | } | ||
3561 | 789 | |||
3562 | 790 | public function VersionInstructionsForm() { | ||
3563 | 791 | $response = new ResponseManager(); | ||
3564 | 792 | |||
3565 | 793 | $displayGroupId = Kit::GetParam('displaygroupid', _GET, _INT); | ||
3566 | 794 | $displayId = Kit::GetParam('displayid', _GET, _INT); | ||
3567 | 795 | Theme::Set('installer_file_id', 0); | ||
3568 | 796 | |||
3569 | 797 | // List of effected displays | ||
3570 | 798 | $rows = array(); | ||
3571 | 799 | |||
3572 | 800 | if ($displayId != 0) { | ||
3573 | 801 | // Get some version information about this display. | ||
3574 | 802 | if (!$displays = $this->user->DisplayList(array('display'), array('displayid' => $displayId))) | ||
3575 | 803 | trigger_error(__('Unknown Display'), E_USER_ERROR); | ||
3576 | 804 | } | ||
3577 | 805 | else { | ||
3578 | 806 | // Get a list of displays with their version information? | ||
3579 | 807 | if (!$displays = $this->user->DisplayList(array('display'), array('displaygroupid' => $displayGroupId))) | ||
3580 | 808 | trigger_error(__('Unknown Display'), E_USER_ERROR); | ||
3581 | 809 | } | ||
3582 | 810 | |||
3583 | 811 | foreach ($displays as $display) { | ||
3584 | 812 | $rows[] = array( | ||
3585 | 813 | 'display' => Theme::Prepare($display['display']), | ||
3586 | 814 | 'client_type' => Theme::Prepare($display['client_type']), | ||
3587 | 815 | 'client_version' => Theme::Prepare($display['client_version']), | ||
3588 | 816 | 'client_code' => Theme::Prepare($display['client_code']) | ||
3589 | 817 | ); | ||
3590 | 818 | } | ||
3591 | 819 | |||
3592 | 820 | // Store this for use in the theme | ||
3593 | 821 | Theme::Set('displays', $displays); | ||
3594 | 822 | |||
3595 | 823 | // Present a list of possible files to choose from (generic file module) | ||
3596 | 824 | $mediaList = $this->user->MediaList('genericfile'); | ||
3597 | 825 | array_unshift($mediaList, array('mediaid' => 0, 'media' => '')); | ||
3598 | 826 | Theme::Set('media_field_list', $mediaList); | ||
3599 | 827 | |||
3600 | 828 | // Set some information about the form | ||
3601 | 829 | Theme::Set('form_id', 'VersionInstructions'); | ||
3602 | 830 | Theme::Set('form_action', 'index.php?p=displaygroup&q=VersionInstructions'); | ||
3603 | 831 | Theme::Set('form_meta', '<input type="hidden" name="displaygroupid" value="' . $displayGroupId . '">'); | ||
3604 | 832 | |||
3605 | 833 | $form = Theme::RenderReturn('display_form_version_instructions'); | ||
3606 | 834 | |||
3607 | 835 | $response->SetFormRequestResponse($form, __('Set Instructions for Upgrading this client'), '300px', '250px'); | ||
3608 | 836 | $response->AddButton(__('Cancel'), 'XiboDialogClose()'); | ||
3609 | 837 | $response->AddButton(__('Save'), '$("#VersionInstructions").submit()'); | ||
3610 | 838 | $response->Respond(); | ||
3611 | 839 | } | ||
3612 | 840 | |||
3613 | 841 | public function VersionInstructions() { | ||
3614 | 842 | $response = new ResponseManager(); | ||
3615 | 843 | |||
3616 | 844 | Kit::ClassLoader('media'); | ||
3617 | 845 | Kit::ClassLoader('display'); | ||
3618 | 846 | Kit::ClassLoader('lkmediadisplaygroup'); | ||
3619 | 847 | |||
3620 | 848 | $displayGroupId = Kit::GetParam('displaygroupid', _POST, _INT); | ||
3621 | 849 | $mediaId = Kit::GetParam('mediaid', _POST, _INT); | ||
3622 | 850 | |||
3623 | 851 | // Make sure we have permission to do this to this display | ||
3624 | 852 | $auth = $this->user->DisplayGroupAuth($displayGroupId, true); | ||
3625 | 853 | if (!$auth->edit) | ||
3626 | 854 | trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); | ||
3627 | 855 | |||
3628 | 856 | // Make sure we have permission to use this file | ||
3629 | 857 | $mediaAuth = $this->user->MediaAuth($mediaId, true); | ||
3630 | 858 | |||
3631 | 859 | if (!$mediaAuth->view) | ||
3632 | 860 | trigger_error(__('You have selected media that you no longer have permission to use. Please reload the form.'), E_USER_ERROR); | ||
3633 | 861 | |||
3634 | 862 | // Make sure this file is assigned to this display group | ||
3635 | 863 | $link = new LkMediaDisplayGroup($this->db); | ||
3636 | 864 | if (!$link->Link($displayGroupId, $mediaId)) | ||
3637 | 865 | trigger_error($display->GetErrorMessage(), E_USER_ERROR); | ||
3638 | 866 | |||
3639 | 867 | // Get the "StoredAs" for this media item | ||
3640 | 868 | $media = new Media($this->db); | ||
3641 | 869 | $storedAs = $media->GetStoredAs($mediaId); | ||
3642 | 870 | |||
3643 | 871 | // Get a list of displays for this group | ||
3644 | 872 | $displays = $this->user->DisplayList(array('displayid'), array('displaygroupid' => $displayGroupId)); | ||
3645 | 873 | |||
3646 | 874 | foreach ($displays as $display) { | ||
3647 | 875 | // Update the Display with the new instructions | ||
3648 | 876 | $displayObject = new Display($this->db); | ||
3649 | 877 | if (!$displayObject->SetVersionInstructions($display['displayid'], $mediaId, $storedAs)) | ||
3650 | 878 | trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR); | ||
3651 | 879 | } | ||
3652 | 880 | |||
3653 | 881 | $response->SetFormSubmitResponse(__('Version Instructions Set')); | ||
3654 | 882 | $response->Respond(); | ||
3655 | 883 | } | ||
3656 | 613 | } | 884 | } |
3657 | 614 | ?> | 885 | ?> |
3658 | 615 | \ No newline at end of file | 886 | \ No newline at end of file |
3659 | 616 | 887 | ||
3660 | === modified file 'server/lib/pages/layout.class.php' | |||
3661 | --- server/lib/pages/layout.class.php 2014-02-13 10:48:57 +0000 | |||
3662 | +++ server/lib/pages/layout.class.php 2014-03-29 13:09:24 +0000 | |||
3663 | @@ -742,7 +742,7 @@ | |||
3664 | 742 | $regionHtml .= ' </button>'; | 742 | $regionHtml .= ' </button>'; |
3665 | 743 | $regionHtml .= ' <ul class="dropdown-menu">'; | 743 | $regionHtml .= ' <ul class="dropdown-menu">'; |
3666 | 744 | $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=Timeline&layoutid=' . $this->layoutid . '®ionid=' . $regionid . '" title="' . __('Timeline') . '">' . __('Edit Timeline') . '</a></li>'; | 744 | $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=Timeline&layoutid=' . $this->layoutid . '®ionid=' . $regionid . '" title="' . __('Timeline') . '">' . __('Edit Timeline') . '</a></li>'; |
3668 | 745 | $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=ManualRegionPositionForm&layoutid=' . $this->layoutid . '®ionid=' . $regionid . '&top=' . $regionTop . '&left=' . $regionLeft . '&width=' . $regionWidth . '&height=' . $regionHeight . '&scale=' . $scaleFactor . '&layoutWidth=' . $width . '&layoutHeight= ' . $height . '" title="' . __('Options') . '">' . __('Options') . '</a></li>'; | 745 | $regionHtml .= ' <li><a class="RegionOptionsMenuItem" href="#" title="' . __('Options') . '">' . __('Options') . '</a></li>'; |
3669 | 746 | $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=DeleteRegionForm&layoutid=' . $this->layoutid . '®ionid=' . $regionid . '" title="' . __('Delete') . '">' . __('Delete') . '</a></li>'; | 746 | $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=DeleteRegionForm&layoutid=' . $this->layoutid . '®ionid=' . $regionid . '" title="' . __('Delete') . '">' . __('Delete') . '</a></li>'; |
3670 | 747 | $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=RegionPermissionsForm&layoutid=' . $this->layoutid . '®ionid=' . $regionid . '" title="' . __('Permissions') . '">' . __('Permissions') . '</a></li>'; | 747 | $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=RegionPermissionsForm&layoutid=' . $this->layoutid . '®ionid=' . $regionid . '" title="' . __('Permissions') . '">' . __('Permissions') . '</a></li>'; |
3671 | 748 | $regionHtml .= ' </ul>'; | 748 | $regionHtml .= ' </ul>'; |
3672 | @@ -766,7 +766,7 @@ | |||
3673 | 766 | //render the view pane | 766 | //render the view pane |
3674 | 767 | $surface = <<<HTML | 767 | $surface = <<<HTML |
3675 | 768 | 768 | ||
3677 | 769 | <div id="layout" layoutid="$this->layoutid" style="position:relative; width:$width; height:$height; border: 1px solid #000; background:$background_css;"> | 769 | <div id="layout" class="layout" layoutid="$this->layoutid" style="position:relative; width:$width; height:$height; border: 1px solid #000; background:$background_css;"> |
3678 | 770 | $regionHtml | 770 | $regionHtml |
3679 | 771 | </div> | 771 | </div> |
3680 | 772 | HTML; | 772 | HTML; |
3681 | 773 | 773 | ||
3682 | === modified file 'server/lib/pages/module.class.php' | |||
3683 | --- server/lib/pages/module.class.php 2014-02-12 20:32:00 +0000 | |||
3684 | +++ server/lib/pages/module.class.php 2014-03-29 13:09:24 +0000 | |||
3685 | @@ -1,7 +1,7 @@ | |||
3686 | 1 | <?php | 1 | <?php |
3687 | 2 | /* | 2 | /* |
3688 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk |
3690 | 4 | * Copyright (C) 2006-2013 Daniel Garner | 4 | * Copyright (C) 2006-2014 Daniel Garner |
3691 | 5 | * | 5 | * |
3692 | 6 | * This file is part of Xibo. | 6 | * This file is part of Xibo. |
3693 | 7 | * | 7 | * |
3694 | @@ -92,7 +92,8 @@ | |||
3695 | 92 | $SQL .= ' RegionSpecific, '; | 92 | $SQL .= ' RegionSpecific, '; |
3696 | 93 | $SQL .= ' ValidExtensions, '; | 93 | $SQL .= ' ValidExtensions, '; |
3697 | 94 | $SQL .= ' ImageUri, '; | 94 | $SQL .= ' ImageUri, '; |
3699 | 95 | $SQL .= ' PreviewEnabled '; | 95 | $SQL .= ' PreviewEnabled, '; |
3700 | 96 | $SQL .= ' assignable '; | ||
3701 | 96 | $SQL .= ' FROM `module` '; | 97 | $SQL .= ' FROM `module` '; |
3702 | 97 | $SQL .= ' ORDER BY Name '; | 98 | $SQL .= ' ORDER BY Name '; |
3703 | 98 | 99 | ||
3704 | @@ -115,9 +116,11 @@ | |||
3705 | 115 | $row['imageuri'] = Kit::ValidateParam($module['ImageUri'], _STRING); | 116 | $row['imageuri'] = Kit::ValidateParam($module['ImageUri'], _STRING); |
3706 | 116 | $row['enabled'] = Kit::ValidateParam($module['Enabled'], _INT); | 117 | $row['enabled'] = Kit::ValidateParam($module['Enabled'], _INT); |
3707 | 117 | $row['preview_enabled'] = Kit::ValidateParam($module['PreviewEnabled'], _INT); | 118 | $row['preview_enabled'] = Kit::ValidateParam($module['PreviewEnabled'], _INT); |
3708 | 119 | $row['assignable'] = Kit::ValidateParam($module['assignable'], _INT); | ||
3709 | 118 | $row['isregionspecific_image'] = ($row['isregionspecific'] == 0) ? 'icon-ok' : 'icon-remove'; | 120 | $row['isregionspecific_image'] = ($row['isregionspecific'] == 0) ? 'icon-ok' : 'icon-remove'; |
3710 | 119 | $row['enabled_image'] = ($row['enabled'] == 1) ? 'icon-ok' : 'icon-remove'; | 121 | $row['enabled_image'] = ($row['enabled'] == 1) ? 'icon-ok' : 'icon-remove'; |
3711 | 120 | $row['preview_enabled_image'] = ($row['preview_enabled'] == 1) ? 'icon-ok' : 'icon-remove'; | 122 | $row['preview_enabled_image'] = ($row['preview_enabled'] == 1) ? 'icon-ok' : 'icon-remove'; |
3712 | 123 | $row['assignable_image'] = ($row['assignable'] == 1) ? 'icon-ok' : 'icon-remove'; | ||
3713 | 121 | 124 | ||
3714 | 122 | // Initialise array of buttons, because we might not have any | 125 | // Initialise array of buttons, because we might not have any |
3715 | 123 | $row['buttons'] = array(); | 126 | $row['buttons'] = array(); |
3716 | 124 | 127 | ||
3717 | === modified file 'server/lib/pages/schedule.class.php' | |||
3718 | --- server/lib/pages/schedule.class.php 2014-01-18 14:29:25 +0000 | |||
3719 | +++ server/lib/pages/schedule.class.php 2014-03-29 13:09:24 +0000 | |||
3720 | @@ -1,7 +1,7 @@ | |||
3721 | 1 | <?php | 1 | <?php |
3722 | 2 | /* | 2 | /* |
3723 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk |
3725 | 4 | * Copyright (C) 2006-2013 Daniel Garner | 4 | * Copyright (C) 2006-2014 Daniel Garner |
3726 | 5 | * | 5 | * |
3727 | 6 | * This file is part of Xibo. | 6 | * This file is part of Xibo. |
3728 | 7 | * | 7 | * |
3729 | @@ -1157,7 +1157,7 @@ | |||
3730 | 1157 | </div> | 1157 | </div> |
3731 | 1158 | HTML; | 1158 | HTML; |
3732 | 1159 | 1159 | ||
3734 | 1160 | $id = uniqid(); | 1160 | $id = Kit::uniqueId(); |
3735 | 1161 | $pager = ResponseManager::Pager($id); | 1161 | $pager = ResponseManager::Pager($id); |
3736 | 1162 | 1162 | ||
3737 | 1163 | $xiboGrid = <<<HTML | 1163 | $xiboGrid = <<<HTML |
3738 | @@ -1277,7 +1277,7 @@ | |||
3739 | 1277 | </div> | 1277 | </div> |
3740 | 1278 | HTML; | 1278 | HTML; |
3741 | 1279 | 1279 | ||
3743 | 1280 | $id = uniqid(); | 1280 | $id = Kit::uniqueId(); |
3744 | 1281 | $pager = ResponseManager::Pager($id); | 1281 | $pager = ResponseManager::Pager($id); |
3745 | 1282 | 1282 | ||
3746 | 1283 | $xiboGrid = <<<HTML | 1283 | $xiboGrid = <<<HTML |
3747 | 1284 | 1284 | ||
3748 | === modified file 'server/lib/pages/stats.class.php' | |||
3749 | --- server/lib/pages/stats.class.php 2014-01-18 09:47:41 +0000 | |||
3750 | +++ server/lib/pages/stats.class.php 2014-03-29 13:09:24 +0000 | |||
3751 | @@ -82,7 +82,7 @@ | |||
3752 | 82 | $SQL .= ' FROM stat '; | 82 | $SQL .= ' FROM stat '; |
3753 | 83 | $SQL .= ' INNER JOIN layout ON layout.LayoutID = stat.LayoutID '; | 83 | $SQL .= ' INNER JOIN layout ON layout.LayoutID = stat.LayoutID '; |
3754 | 84 | $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID '; | 84 | $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID '; |
3756 | 85 | $SQL .= ' WHERE 1 = 1 '; | 85 | $SQL .= " WHERE stat.type = 'layout' "; |
3757 | 86 | $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt); | 86 | $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt); |
3758 | 87 | $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt); | 87 | $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt); |
3759 | 88 | 88 | ||
3760 | @@ -120,7 +120,7 @@ | |||
3761 | 120 | $SQL .= ' FROM stat '; | 120 | $SQL .= ' FROM stat '; |
3762 | 121 | $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID '; | 121 | $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID '; |
3763 | 122 | $SQL .= ' INNER JOIN media ON media.MediaID = stat.MediaID '; | 122 | $SQL .= ' INNER JOIN media ON media.MediaID = stat.MediaID '; |
3765 | 123 | $SQL .= ' WHERE 1 = 1 '; | 123 | $SQL .= " WHERE stat.type = 'media' "; |
3766 | 124 | $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt); | 124 | $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt); |
3767 | 125 | $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt); | 125 | $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt); |
3768 | 126 | 126 | ||
3769 | @@ -162,7 +162,7 @@ | |||
3770 | 162 | $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID '; | 162 | $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID '; |
3771 | 163 | $SQL .= ' INNER JOIN layout ON layout.LayoutID = stat.LayoutID '; | 163 | $SQL .= ' INNER JOIN layout ON layout.LayoutID = stat.LayoutID '; |
3772 | 164 | $SQL .= ' LEFT OUTER JOIN media ON media.MediaID = stat.MediaID '; | 164 | $SQL .= ' LEFT OUTER JOIN media ON media.MediaID = stat.MediaID '; |
3774 | 165 | $SQL .= ' WHERE 1 = 1 '; | 165 | $SQL .= " WHERE stat.type = 'media' "; |
3775 | 166 | $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt); | 166 | $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt); |
3776 | 167 | $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt); | 167 | $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt); |
3777 | 168 | 168 | ||
3778 | 169 | 169 | ||
3779 | === modified file 'server/lib/pages/statusdashboard.class.php' | |||
3780 | --- server/lib/pages/statusdashboard.class.php 2014-02-15 10:32:44 +0000 | |||
3781 | +++ server/lib/pages/statusdashboard.class.php 2014-03-29 13:09:24 +0000 | |||
3782 | @@ -36,7 +36,7 @@ | |||
3783 | 36 | try { | 36 | try { |
3784 | 37 | $dbh = PDOConnect::init(); | 37 | $dbh = PDOConnect::init(); |
3785 | 38 | 38 | ||
3787 | 39 | $sth = $dbh->prepare('SELECT MONTHNAME(FROM_UNIXTIME(month)) AS month, IFNULL(SUM(Size), 0) AS size FROM `bandwidth` WHERE month > :month GROUP BY MONTHNAME(FROM_UNIXTIME(month));'); | 39 | $sth = $dbh->prepare('SELECT MONTHNAME(FROM_UNIXTIME(month)) AS month, IFNULL(SUM(Size), 0) AS size FROM `bandwidth` WHERE month > :month GROUP BY MONTHNAME(FROM_UNIXTIME(month)) ORDER BY MIN(month);'); |
3788 | 40 | $sth->execute(array('month' => time() - (86400 * 365))); | 40 | $sth->execute(array('month' => time() - (86400 * 365))); |
3789 | 41 | 41 | ||
3790 | 42 | $results = $sth->fetchAll(); | 42 | $results = $sth->fetchAll(); |
3791 | 43 | 43 | ||
3792 | === modified file 'server/lib/service/xmdssoap.class.php' | |||
3793 | --- server/lib/service/xmdssoap.class.php 2014-02-09 15:03:19 +0000 | |||
3794 | +++ server/lib/service/xmdssoap.class.php 2014-03-29 13:09:24 +0000 | |||
3795 | @@ -30,6 +30,7 @@ | |||
3796 | 30 | private $isAuditing; | 30 | private $isAuditing; |
3797 | 31 | private $displayId; | 31 | private $displayId; |
3798 | 32 | private $defaultLayoutId; | 32 | private $defaultLayoutId; |
3799 | 33 | private $version_instructions; | ||
3800 | 33 | 34 | ||
3801 | 34 | public function __construct() | 35 | public function __construct() |
3802 | 35 | { | 36 | { |
3803 | @@ -161,6 +162,7 @@ | |||
3804 | 161 | 162 | ||
3805 | 162 | $requiredFilesXml = new DOMDocument("1.0"); | 163 | $requiredFilesXml = new DOMDocument("1.0"); |
3806 | 163 | $fileElements = $requiredFilesXml->createElement("files"); | 164 | $fileElements = $requiredFilesXml->createElement("files"); |
3807 | 165 | $fileElements->setAttribute('version_instructions', $this->version_instructions); | ||
3808 | 164 | 166 | ||
3809 | 165 | $requiredFilesXml->appendChild($fileElements); | 167 | $requiredFilesXml->appendChild($fileElements); |
3810 | 166 | 168 | ||
3811 | @@ -189,11 +191,15 @@ | |||
3812 | 189 | } | 191 | } |
3813 | 190 | 192 | ||
3814 | 191 | // Our layout list will always include the default layout | 193 | // Our layout list will always include the default layout |
3816 | 192 | $layoutIdList = $this->defaultLayoutId; | 194 | $layouts = array(); |
3817 | 195 | $layouts[] = $this->defaultLayoutId; | ||
3818 | 193 | 196 | ||
3820 | 194 | // Build up the other layouts into a comma seperated list. | 197 | // Build up the other layouts into an array |
3821 | 195 | while ($row = $db->get_assoc_row($results)) | 198 | while ($row = $db->get_assoc_row($results)) |
3823 | 196 | $layoutIdList .= ',' . Kit::ValidateParam($row['layoutID'], _INT); | 199 | $layouts[] = Kit::ValidateParam($row['layoutID'], _INT); |
3824 | 200 | |||
3825 | 201 | // Create a comma separated list to pass into the query which gets file nodes | ||
3826 | 202 | $layoutIdList = implode(',', $layouts); | ||
3827 | 197 | 203 | ||
3828 | 198 | // Add file nodes to the $fileElements | 204 | // Add file nodes to the $fileElements |
3829 | 199 | $SQL = " SELECT 'layout' AS RecordType, layout.layoutID AS path, layout.layoutID AS id, MD5(layout.xml) AS `MD5`, NULL AS FileSize, layout.background, layout.xml AS xml "; | 205 | $SQL = " SELECT 'layout' AS RecordType, layout.layoutID AS path, layout.layoutID AS id, MD5(layout.xml) AS `MD5`, NULL AS FileSize, layout.background, layout.xml AS xml "; |
3830 | @@ -207,6 +213,18 @@ | |||
3831 | 207 | $SQL .= " INNER JOIN layout "; | 213 | $SQL .= " INNER JOIN layout "; |
3832 | 208 | $SQL .= " ON layout.LayoutID = lklayoutmedia.LayoutID"; | 214 | $SQL .= " ON layout.LayoutID = lklayoutmedia.LayoutID"; |
3833 | 209 | $SQL .= sprintf(" WHERE layout.layoutid IN (%s) ", $layoutIdList); | 215 | $SQL .= sprintf(" WHERE layout.layoutid IN (%s) ", $layoutIdList); |
3834 | 216 | $SQL .= " | ||
3835 | 217 | UNION | ||
3836 | 218 | SELECT 'media' AS RecordType, storedAs AS path, media.mediaID AS id, media.`MD5`, media.FileSize, NULL AS background, NULL AS xml | ||
3837 | 219 | FROM `media` | ||
3838 | 220 | INNER JOIN `lkmediadisplaygroup` | ||
3839 | 221 | ON lkmediadisplaygroup.mediaid = media.MediaID | ||
3840 | 222 | INNER JOIN lkdisplaydg | ||
3841 | 223 | ON lkdisplaydg.DisplayGroupID = lkmediadisplaygroup.DisplayGroupID | ||
3842 | 224 | INNER JOIN display | ||
3843 | 225 | ON lkdisplaydg.DisplayID = display.displayID | ||
3844 | 226 | "; | ||
3845 | 227 | $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); | ||
3846 | 210 | $SQL .= " ORDER BY RecordType DESC"; | 228 | $SQL .= " ORDER BY RecordType DESC"; |
3847 | 211 | 229 | ||
3848 | 212 | if ($this->isAuditing == 1) Debug::LogEntry("audit", $SQL, "xmds", "RequiredFiles"); | 230 | if ($this->isAuditing == 1) Debug::LogEntry("audit", $SQL, "xmds", "RequiredFiles"); |
3849 | @@ -282,6 +300,32 @@ | |||
3850 | 282 | } | 300 | } |
3851 | 283 | } | 301 | } |
3852 | 284 | 302 | ||
3853 | 303 | Kit::ClassLoader('layout'); | ||
3854 | 304 | |||
3855 | 305 | // Go through each layout and see if we need to supply any resource nodes. | ||
3856 | 306 | foreach ($layouts as $layoutId) { | ||
3857 | 307 | // Load the layout XML and work out if we have any ticker / text / dataset media items | ||
3858 | 308 | $layout = new Layout($db); | ||
3859 | 309 | |||
3860 | 310 | $layoutInformation = $layout->LayoutInformation($layoutId); | ||
3861 | 311 | |||
3862 | 312 | foreach($layoutInformation['regions'] as $region) { | ||
3863 | 313 | foreach($region['media'] as $media) { | ||
3864 | 314 | if ($media['mediatype'] == 'ticker' || $media['mediatype'] == 'text' || $media['mediatype'] == 'dataset') { | ||
3865 | 315 | // Append this item to required files | ||
3866 | 316 | $file = $requiredFilesXml->createElement("file"); | ||
3867 | 317 | $file->setAttribute('type', 'resource'); | ||
3868 | 318 | $file->setAttribute('id', rand()); | ||
3869 | 319 | $file->setAttribute('layoutid', $layoutId); | ||
3870 | 320 | $file->setAttribute('regionid', $region['regionid']); | ||
3871 | 321 | $file->setAttribute('mediaid', $media['mediaid']); | ||
3872 | 322 | |||
3873 | 323 | $fileElements->appendChild($file); | ||
3874 | 324 | } | ||
3875 | 325 | } | ||
3876 | 326 | } | ||
3877 | 327 | } | ||
3878 | 328 | |||
3879 | 285 | // Add a blacklist node | 329 | // Add a blacklist node |
3880 | 286 | $blackList = $requiredFilesXml->createElement("file"); | 330 | $blackList = $requiredFilesXml->createElement("file"); |
3881 | 287 | $blackList->setAttribute("type", "blacklist"); | 331 | $blackList->setAttribute("type", "blacklist"); |
3882 | @@ -309,62 +353,8 @@ | |||
3883 | 309 | $blackList->appendChild($file); | 353 | $blackList->appendChild($file); |
3884 | 310 | } | 354 | } |
3885 | 311 | 355 | ||
3942 | 312 | // PHONE_HOME if required. | 356 | // Phone Home? |
3943 | 313 | if (Config::GetSetting('PHONE_HOME') == 'On') | 357 | $this->PhoneHome(); |
3888 | 314 | { | ||
3889 | 315 | // Find out when we last PHONED_HOME :D | ||
3890 | 316 | // If it's been > 28 days since last PHONE_HOME then | ||
3891 | 317 | if (Config::GetSetting('PHONE_HOME_DATE') < (time() - (60 * 60 * 24 * 28))) | ||
3892 | 318 | { | ||
3893 | 319 | if ($this->isAuditing == 1) | ||
3894 | 320 | { | ||
3895 | 321 | Debug::LogEntry("audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles"); | ||
3896 | 322 | } | ||
3897 | 323 | |||
3898 | 324 | // Retrieve number of displays | ||
3899 | 325 | $SQL = "SELECT COUNT(*) | ||
3900 | 326 | FROM `display` | ||
3901 | 327 | WHERE `licensed` = '1'"; | ||
3902 | 328 | |||
3903 | 329 | if (!$results = $db->query($SQL)) | ||
3904 | 330 | { | ||
3905 | 331 | trigger_error($db->error()); | ||
3906 | 332 | } | ||
3907 | 333 | while ($row = $db->get_row($results)) | ||
3908 | 334 | { | ||
3909 | 335 | $PHONE_HOME_CLIENTS = Kit::ValidateParam($row[0],_INT); | ||
3910 | 336 | } | ||
3911 | 337 | |||
3912 | 338 | // Retrieve version number | ||
3913 | 339 | $PHONE_HOME_VERSION = Config::Version('app_ver'); | ||
3914 | 340 | |||
3915 | 341 | $PHONE_HOME_URL = Config::GetSetting('PHONE_HOME_URL') . "?id=" . urlencode(Config::GetSetting('PHONE_HOME_KEY')) . "&version=" . urlencode($PHONE_HOME_VERSION) . "&numClients=" . urlencode($PHONE_HOME_CLIENTS); | ||
3916 | 342 | |||
3917 | 343 | if ($this->isAuditing == 1) | ||
3918 | 344 | { | ||
3919 | 345 | Debug::LogEntry("audit", "PHONE_HOME_URL " . $PHONE_HOME_URL , "xmds", "RequiredFiles"); | ||
3920 | 346 | } | ||
3921 | 347 | |||
3922 | 348 | // Set PHONE_HOME_TIME to NOW. | ||
3923 | 349 | $SQL = "UPDATE `setting` | ||
3924 | 350 | SET `value` = '" . time() . "' | ||
3925 | 351 | WHERE `setting`.`setting` = 'PHONE_HOME_DATE' LIMIT 1"; | ||
3926 | 352 | |||
3927 | 353 | if (!$results = $db->query($SQL)) | ||
3928 | 354 | { | ||
3929 | 355 | trigger_error($db->error()); | ||
3930 | 356 | } | ||
3931 | 357 | |||
3932 | 358 | @file_get_contents($PHONE_HOME_URL); | ||
3933 | 359 | |||
3934 | 360 | if ($this->isAuditing == 1) | ||
3935 | 361 | { | ||
3936 | 362 | Debug::LogEntry("audit", "PHONE_HOME [OUT]", "xmds", "RequiredFiles"); | ||
3937 | 363 | } | ||
3938 | 364 | //endif | ||
3939 | 365 | } | ||
3940 | 366 | } | ||
3941 | 367 | // END OF PHONE_HOME CODE | ||
3944 | 368 | 358 | ||
3945 | 369 | if ($this->isAuditing == 1) | 359 | if ($this->isAuditing == 1) |
3946 | 370 | { | 360 | { |
3947 | @@ -944,13 +934,17 @@ | |||
3948 | 944 | $document = new DOMDocument("1.0"); | 934 | $document = new DOMDocument("1.0"); |
3949 | 945 | $document->loadXML($inventory); | 935 | $document->loadXML($inventory); |
3950 | 946 | 936 | ||
3952 | 947 | $macAddress = $document->documentElement->getAttribute('macAddress'); | 937 | // Get some information from the media inventory XML and update the display record with it. |
3953 | 938 | $macAddress = Kit::ValidateParam($document->documentElement->getAttribute('macAddress'), _STRING); | ||
3954 | 939 | $clientType = Kit::ValidateParam($document->documentElement->getAttribute('clientType'), _STRING); | ||
3955 | 940 | $clientVersion = Kit::ValidateParam($document->documentElement->getAttribute('clientVersion'), _STRING); | ||
3956 | 941 | $clientCode = Kit::ValidateParam($document->documentElement->getAttribute('clientCode'), _INT); | ||
3957 | 948 | 942 | ||
3958 | 949 | // Assume we are complete (but we are getting some) | 943 | // Assume we are complete (but we are getting some) |
3959 | 950 | $mediaInventoryComplete = 1; | 944 | $mediaInventoryComplete = 1; |
3960 | 951 | 945 | ||
3961 | 952 | $xpath = new DOMXPath($document); | 946 | $xpath = new DOMXPath($document); |
3963 | 953 | $fileNodes = $xpath->query("//file"); | 947 | $fileNodes = $xpath->query("//file"); |
3964 | 954 | 948 | ||
3965 | 955 | foreach ($fileNodes as $node) | 949 | foreach ($fileNodes as $node) |
3966 | 956 | { | 950 | { |
3967 | @@ -968,7 +962,7 @@ | |||
3968 | 968 | 962 | ||
3969 | 969 | // Touch the display record | 963 | // Touch the display record |
3970 | 970 | $displayObject = new Display($db); | 964 | $displayObject = new Display($db); |
3972 | 971 | $displayObject->Touch($hardwareKey, '', $mediaInventoryComplete, $inventory, $macAddress); | 965 | $displayObject->Touch($hardwareKey, '', $mediaInventoryComplete, $inventory, $macAddress, $clientType, $clientVersion, $clientCode); |
3973 | 972 | 966 | ||
3974 | 973 | return true; | 967 | return true; |
3975 | 974 | } | 968 | } |
3976 | @@ -1037,6 +1031,61 @@ | |||
3977 | 1037 | } | 1031 | } |
3978 | 1038 | 1032 | ||
3979 | 1039 | /** | 1033 | /** |
3980 | 1034 | * PHONE_HOME if required | ||
3981 | 1035 | */ | ||
3982 | 1036 | private function PhoneHome() { | ||
3983 | 1037 | |||
3984 | 1038 | if (Config::GetSetting('PHONE_HOME') == 'On') | ||
3985 | 1039 | { | ||
3986 | 1040 | // Find out when we last PHONED_HOME :D | ||
3987 | 1041 | // If it's been > 28 days since last PHONE_HOME then | ||
3988 | 1042 | if (Config::GetSetting('PHONE_HOME_DATE') < (time() - (60 * 60 * 24 * 28))) | ||
3989 | 1043 | { | ||
3990 | 1044 | if ($this->isAuditing == 1) | ||
3991 | 1045 | { | ||
3992 | 1046 | Debug::LogEntry("audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles"); | ||
3993 | 1047 | } | ||
3994 | 1048 | |||
3995 | 1049 | try { | ||
3996 | 1050 | $dbh = PDOConnect::init(); | ||
3997 | 1051 | |||
3998 | 1052 | // Retrieve number of displays | ||
3999 | 1053 | $sth = $dbh->prepare('SELECT COUNT(*) AS Cnt FROM `display` WHERE `licensed` = 1'); | ||
4000 | 1054 | $sth->execute(); | ||
4001 | 1055 | |||
4002 | 1056 | $PHONE_HOME_CLIENTS = $sth->fetchColumn(); | ||
4003 | 1057 | |||
4004 | 1058 | // Retrieve version number | ||
4005 | 1059 | $PHONE_HOME_VERSION = Config::Version('app_ver'); | ||
4006 | 1060 | |||
4007 | 1061 | $PHONE_HOME_URL = Config::GetSetting('PHONE_HOME_URL') . "?id=" . urlencode(Config::GetSetting('PHONE_HOME_KEY')) . "&version=" . urlencode($PHONE_HOME_VERSION) . "&numClients=" . urlencode($PHONE_HOME_CLIENTS); | ||
4008 | 1062 | |||
4009 | 1063 | if ($this->isAuditing == 1) | ||
4010 | 1064 | Debug::LogEntry("audit", "PHONE_HOME_URL " . $PHONE_HOME_URL , "xmds", "RequiredFiles"); | ||
4011 | 1065 | |||
4012 | 1066 | // Set PHONE_HOME_TIME to NOW. | ||
4013 | 1067 | $sth = $dbh->prepare('UPDATE `setting` SET `value` = :time WHERE `setting`.`setting` = :setting LIMIT 1'); | ||
4014 | 1068 | $sth->execute(array( | ||
4015 | 1069 | 'time' => time(), | ||
4016 | 1070 | 'setting' => 'PHONE_HOME_DATE' | ||
4017 | 1071 | )); | ||
4018 | 1072 | |||
4019 | 1073 | @file_get_contents($PHONE_HOME_URL); | ||
4020 | 1074 | |||
4021 | 1075 | if ($this->isAuditing == 1) | ||
4022 | 1076 | Debug::LogEntry("audit", "PHONE_HOME [OUT]", "xmds", "RequiredFiles"); | ||
4023 | 1077 | } | ||
4024 | 1078 | catch (Exception $e) { | ||
4025 | 1079 | |||
4026 | 1080 | Debug::LogEntry('error', $e->getMessage()); | ||
4027 | 1081 | |||
4028 | 1082 | return false; | ||
4029 | 1083 | } | ||
4030 | 1084 | } | ||
4031 | 1085 | } | ||
4032 | 1086 | } | ||
4033 | 1087 | |||
4034 | 1088 | /** | ||
4035 | 1040 | * Authenticates the display | 1089 | * Authenticates the display |
4036 | 1041 | * @param <type> $hardwareKey | 1090 | * @param <type> $hardwareKey |
4037 | 1042 | * @return <type> | 1091 | * @return <type> |
4038 | @@ -1046,7 +1095,7 @@ | |||
4039 | 1046 | $db =& $this->db; | 1095 | $db =& $this->db; |
4040 | 1047 | 1096 | ||
4041 | 1048 | // check in the database for this hardwareKey | 1097 | // check in the database for this hardwareKey |
4043 | 1049 | $SQL = "SELECT licensed, inc_schedule, isAuditing, displayID, defaultlayoutid, loggedin, email_alert, display FROM display WHERE license = '$hardwareKey'"; | 1098 | $SQL = "SELECT licensed, inc_schedule, isAuditing, displayID, defaultlayoutid, loggedin, email_alert, display, version_instructions FROM display WHERE license = '$hardwareKey'"; |
4044 | 1050 | 1099 | ||
4045 | 1051 | if (!$result = $db->query($SQL)) | 1100 | if (!$result = $db->query($SQL)) |
4046 | 1052 | { | 1101 | { |
4047 | @@ -1090,6 +1139,7 @@ | |||
4048 | 1090 | $this->isAuditing = $row[2]; | 1139 | $this->isAuditing = $row[2]; |
4049 | 1091 | $this->displayId = $row[3]; | 1140 | $this->displayId = $row[3]; |
4050 | 1092 | $this->defaultLayoutId = $row[4]; | 1141 | $this->defaultLayoutId = $row[4]; |
4051 | 1142 | $this->version_instructions = $row[8]; | ||
4052 | 1093 | 1143 | ||
4053 | 1094 | return true; | 1144 | return true; |
4054 | 1095 | } | 1145 | } |
4055 | 1096 | 1146 | ||
4056 | === modified file 'server/locale/dbtranslate.php' | |||
4057 | --- server/locale/dbtranslate.php 2014-02-12 18:11:45 +0000 | |||
4058 | +++ server/locale/dbtranslate.php 2014-03-29 13:09:24 +0000 | |||
4059 | @@ -54,6 +54,7 @@ | |||
4060 | 54 | echo __('Campaigns'); | 54 | echo __('Campaigns'); |
4061 | 55 | echo __('Transitions'); | 55 | echo __('Transitions'); |
4062 | 56 | echo __('Resolutions'); | 56 | echo __('Resolutions'); |
4063 | 57 | echo __('User Groups'); | ||
4064 | 57 | 58 | ||
4065 | 58 | // Settings translations | 59 | // Settings translations |
4066 | 59 | echo __('jpg_length'); | 60 | echo __('jpg_length'); |
4067 | @@ -97,6 +98,9 @@ | |||
4068 | 97 | echo __('SETTING_IMPORT_ENABLED'); | 98 | echo __('SETTING_IMPORT_ENABLED'); |
4069 | 98 | echo __('SETTING_LIBRARY_TIDY_ENABLED'); | 99 | echo __('SETTING_LIBRARY_TIDY_ENABLED'); |
4070 | 99 | echo __('EMBEDDED_STATUS_WIDGET'); | 100 | echo __('EMBEDDED_STATUS_WIDGET'); |
4071 | 101 | echo __('PROXY_HOST'); | ||
4072 | 102 | echo __('PROXY_PORT'); | ||
4073 | 103 | echo __('PROXY_AUTH'); | ||
4074 | 100 | 104 | ||
4075 | 101 | // Transitions | 105 | // Transitions |
4076 | 102 | echo __('Fade In'); | 106 | echo __('Fade In'); |
4077 | 103 | 107 | ||
4078 | === added file 'server/manual/content/admin/file_associations_form.png' | |||
4079 | 104 | Binary files server/manual/content/admin/file_associations_form.png 1970-01-01 00:00:00 +0000 and server/manual/content/admin/file_associations_form.png 2014-03-29 13:09:24 +0000 differ | 108 | Binary files server/manual/content/admin/file_associations_form.png 1970-01-01 00:00:00 +0000 and server/manual/content/admin/file_associations_form.png 2014-03-29 13:09:24 +0000 differ |
4080 | === added file 'server/manual/content/admin/file_associations_menu.png' | |||
4081 | 105 | Binary files server/manual/content/admin/file_associations_menu.png 1970-01-01 00:00:00 +0000 and server/manual/content/admin/file_associations_menu.png 2014-03-29 13:09:24 +0000 differ | 109 | Binary files server/manual/content/admin/file_associations_menu.png 1970-01-01 00:00:00 +0000 and server/manual/content/admin/file_associations_menu.png 2014-03-29 13:09:24 +0000 differ |
4082 | === added file 'server/manual/content/admin/fileassociations.php' | |||
4083 | --- server/manual/content/admin/fileassociations.php 1970-01-01 00:00:00 +0000 | |||
4084 | +++ server/manual/content/admin/fileassociations.php 2014-03-29 13:09:24 +0000 | |||
4085 | @@ -0,0 +1,33 @@ | |||
4086 | 1 | <?php | ||
4087 | 2 | /* | ||
4088 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | ||
4089 | 4 | * Copyright (C) 2006-2014 Daniel Garner | ||
4090 | 5 | * | ||
4091 | 6 | * This file is part of Xibo. | ||
4092 | 7 | * | ||
4093 | 8 | * Xibo is free software: you can redistribute it and/or modify | ||
4094 | 9 | * it under the terms of the GNU Affero General Public License as published by | ||
4095 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4096 | 11 | * any later version. | ||
4097 | 12 | * | ||
4098 | 13 | * Xibo is distributed in the hope that it will be useful, | ||
4099 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4100 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4101 | 16 | * GNU Affero General Public License for more details. | ||
4102 | 17 | * | ||
4103 | 18 | * You should have received a copy of the GNU Affero General Public License | ||
4104 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | ||
4105 | 20 | */ | ||
4106 | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | ||
4107 | 22 | ?> | ||
4108 | 23 | <h1 id="File_Associations">File Associations</h1> | ||
4109 | 24 | <p>Occasionally it may be necessary to associate a file directly with a display group or display so that the file is transferred to the display for use locally. It may also be desirable to do this without having the media file assigned to a layout.</p> | ||
4110 | 25 | |||
4111 | 26 | <p>The CMS fully caters for this requirement using the File Associations functionality. This functionality enables a simple "Assign Files" menu on the Display and Display Group Administration pages.</p> | ||
4112 | 27 | |||
4113 | 28 | <p><img class="img-thumbnail" alt="Display Administration" src="content/admin/file_associations_menu.png"></p> | ||
4114 | 29 | |||
4115 | 30 | <p>Selecting the Assign Files menu item will open a form showing all stored menu items (video, jpg, etc) which can be selected for assignment.</p> | ||
4116 | 31 | <p><img class="img-thumbnail" alt="Display Administration" src="content/admin/file_associations_form.png"></p> | ||
4117 | 32 | |||
4118 | 33 | <p class="alert alert-info">Associating a file in this manner will automatically download that file to the client at the next collection interval.</p> | ||
4119 | 0 | \ No newline at end of file | 34 | \ No newline at end of file |
4120 | 1 | 35 | ||
4121 | === added file 'server/manual/content/content/content_genericfile.php' | |||
4122 | --- server/manual/content/content/content_genericfile.php 1970-01-01 00:00:00 +0000 | |||
4123 | +++ server/manual/content/content/content_genericfile.php 2014-03-29 13:09:24 +0000 | |||
4124 | @@ -0,0 +1,25 @@ | |||
4125 | 1 | <?php | ||
4126 | 2 | /* | ||
4127 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | ||
4128 | 4 | * Copyright (C) 2006-2014 Daniel Garner | ||
4129 | 5 | * | ||
4130 | 6 | * This file is part of Xibo. | ||
4131 | 7 | * | ||
4132 | 8 | * Xibo is free software: you can redistribute it and/or modify | ||
4133 | 9 | * it under the terms of the GNU Affero General Public License as published by | ||
4134 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4135 | 11 | * any later version. | ||
4136 | 12 | * | ||
4137 | 13 | * Xibo is distributed in the hope that it will be useful, | ||
4138 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4139 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4140 | 16 | * GNU Affero General Public License for more details. | ||
4141 | 17 | * | ||
4142 | 18 | * You should have received a copy of the GNU Affero General Public License | ||
4143 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | ||
4144 | 20 | */ | ||
4145 | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | ||
4146 | 22 | ?> | ||
4147 | 23 | <h1>Generic Files</h1> | ||
4148 | 24 | |||
4149 | 25 | <p>The Generic File module allows for files to be uploaded that are not directly supported by the modules available in the CMS. This could be required for a variety of reasons - such a HTML file to be referenced by the Embedded Media Type.</p> | ||
4150 | 0 | 26 | ||
4151 | === modified file 'server/manual/content/routes.php' | |||
4152 | --- server/manual/content/routes.php 2014-02-09 22:47:01 +0000 | |||
4153 | +++ server/manual/content/routes.php 2014-03-29 13:09:24 +0000 | |||
4154 | @@ -61,6 +61,7 @@ | |||
4155 | 61 | 'content/content_powerpoint', | 61 | 'content/content_powerpoint', |
4156 | 62 | 'content/content_flash', | 62 | 'content/content_flash', |
4157 | 63 | 'content/content_dataset', | 63 | 'content/content_dataset', |
4158 | 64 | 'content/content_genericfile', | ||
4159 | 64 | 'admin/modules', | 65 | 'admin/modules', |
4160 | 65 | 'layout/overview', | 66 | 'layout/overview', |
4161 | 66 | 'layout/layoutdesigner', | 67 | 'layout/layoutdesigner', |
4162 | @@ -110,6 +111,7 @@ | |||
4163 | 110 | 'admin/blueprints', | 111 | 'admin/blueprints', |
4164 | 111 | 'admin/advanced', | 112 | 'admin/advanced', |
4165 | 112 | 'admin/contributing', | 113 | 'admin/contributing', |
4166 | 114 | 'admin/fileassociations', | ||
4167 | 113 | 'admin/database_model', | 115 | 'admin/database_model', |
4168 | 114 | 'admin/release_notes', | 116 | 'admin/release_notes', |
4169 | 115 | 'admin/release_notes_archive', | 117 | 'admin/release_notes_archive', |
4170 | 116 | 118 | ||
4171 | === modified file 'server/manual/content/toc_library.php' | |||
4172 | --- server/manual/content/toc_library.php 2013-12-31 14:20:43 +0000 | |||
4173 | +++ server/manual/content/toc_library.php 2014-03-29 13:09:24 +0000 | |||
4174 | @@ -8,5 +8,6 @@ | |||
4175 | 8 | <a class="list-group-item" href="index.php?toc=library&p=content/content_image">Image</a> | 8 | <a class="list-group-item" href="index.php?toc=library&p=content/content_image">Image</a> |
4176 | 9 | <a class="list-group-item" href="index.php?toc=library&p=content/content_powerpoint">PowerPoint</a> | 9 | <a class="list-group-item" href="index.php?toc=library&p=content/content_powerpoint">PowerPoint</a> |
4177 | 10 | <a class="list-group-item" href="index.php?toc=library&p=content/content_dataset">DataSets</a> | 10 | <a class="list-group-item" href="index.php?toc=library&p=content/content_dataset">DataSets</a> |
4178 | 11 | <a class="list-group-item" href="index.php?toc=library&p=content/content_genericfile">Generic File</a> | ||
4179 | 11 | <a class="list-group-item" href="index.php?toc=library&p=admin/modules">Media Modules</a> | 12 | <a class="list-group-item" href="index.php?toc=library&p=admin/modules">Media Modules</a> |
4180 | 12 | </div> | 13 | </div> |
4181 | 13 | \ No newline at end of file | 14 | \ No newline at end of file |
4182 | 14 | 15 | ||
4183 | === modified file 'server/manual/content/toc_user_and_display.php' | |||
4184 | --- server/manual/content/toc_user_and_display.php 2013-12-30 19:53:51 +0000 | |||
4185 | +++ server/manual/content/toc_user_and_display.php 2014-03-29 13:09:24 +0000 | |||
4186 | @@ -9,4 +9,5 @@ | |||
4187 | 9 | <a class="list-group-item" href="index.php?toc=user_and_display&p=admin/displaygroups">Display Groups</a> | 9 | <a class="list-group-item" href="index.php?toc=user_and_display&p=admin/displaygroups">Display Groups</a> |
4188 | 10 | <a class="list-group-item" href="index.php?toc=user_and_display&p=admin/displaystats">Display Statistics</a> | 10 | <a class="list-group-item" href="index.php?toc=user_and_display&p=admin/displaystats">Display Statistics</a> |
4189 | 11 | <a class="list-group-item" href="index.php?toc=user_and_display&p=admin/display_wakeonlan">Display Wake on LAN</a> | 11 | <a class="list-group-item" href="index.php?toc=user_and_display&p=admin/display_wakeonlan">Display Wake on LAN</a> |
4190 | 12 | <a class="list-group-item" href="index.php?toc=user_and_display&p=admin/fileassociations">File Associations</a> | ||
4191 | 12 | </div> | 13 | </div> |
4192 | 13 | \ No newline at end of file | 14 | \ No newline at end of file |
4193 | 14 | 15 | ||
4194 | === modified file 'server/modules/datasetview.module.php' | |||
4195 | --- server/modules/datasetview.module.php 2014-01-18 09:47:41 +0000 | |||
4196 | +++ server/modules/datasetview.module.php 2014-03-29 13:09:24 +0000 | |||
4197 | @@ -410,13 +410,22 @@ | |||
4198 | 410 | $styleSheet = $rawNode->nodeValue; | 410 | $styleSheet = $rawNode->nodeValue; |
4199 | 411 | } | 411 | } |
4200 | 412 | 412 | ||
4208 | 413 | $headContent = '<style type="text/css">' . $styleSheet . '</style>'; | 413 | $options = array( |
4209 | 414 | 414 | 'duration' => $this->duration, | |
4210 | 415 | if ($this->GetOption('rowsPerPage') != 0) { | 415 | 'originalWidth' => $this->width, |
4211 | 416 | 416 | 'originalHeight' => $this->height, | |
4212 | 417 | // Include some JavaScript to kick off the cycle plugin | 417 | 'rowsPerPage' => $this->GetOption('rowsPerPage'), |
4213 | 418 | $headContent .= '<script type="text/javascript">function init() { $("#DataSetTableContainer").dataSetRender({duration: ' . $this->GetOption('duration') . '}); }</script>'; | 418 | 'previewWidth' => Kit::GetParam('width', _GET, _INT, 0), |
4214 | 419 | } | 419 | 'previewHeight' => Kit::GetParam('height', _GET, _INT, 0) |
4215 | 420 | ); | ||
4216 | 421 | |||
4217 | 422 | $headContent = '<style type="text/css">' . $styleSheet . '</style>'; | ||
4218 | 423 | $headContent .= '<script type="text/javascript">'; | ||
4219 | 424 | $headContent .= ' function init() { '; | ||
4220 | 425 | $headContent .= ' $("#DataSetTableContainer").dataSetRender(options);'; | ||
4221 | 426 | $headContent .= ' } '; | ||
4222 | 427 | $headContent .= ' var options = ' . json_encode($options) . ';'; | ||
4223 | 428 | $headContent .= '</script>'; | ||
4224 | 420 | 429 | ||
4225 | 421 | // Load the HtmlTemplate | 430 | // Load the HtmlTemplate |
4226 | 422 | $template = file_get_contents('modules/preview/HtmlTemplateForGetResource.html'); | 431 | $template = file_get_contents('modules/preview/HtmlTemplateForGetResource.html'); |
4227 | 423 | 432 | ||
4228 | === added file 'server/modules/genericfile.module.php' | |||
4229 | --- server/modules/genericfile.module.php 1970-01-01 00:00:00 +0000 | |||
4230 | +++ server/modules/genericfile.module.php 2014-03-29 13:09:24 +0000 | |||
4231 | @@ -0,0 +1,128 @@ | |||
4232 | 1 | <?php | ||
4233 | 2 | /* | ||
4234 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | ||
4235 | 4 | * Copyright (C) 2014 Daniel Garner | ||
4236 | 5 | * | ||
4237 | 6 | * This file is part of Xibo. | ||
4238 | 7 | * | ||
4239 | 8 | * Xibo is free software: you can redistribute it and/or modify | ||
4240 | 9 | * it under the terms of the GNU Affero General Public License as published by | ||
4241 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4242 | 11 | * any later version. | ||
4243 | 12 | * | ||
4244 | 13 | * Xibo is distributed in the hope that it will be useful, | ||
4245 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4246 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4247 | 16 | * GNU Affero General Public License for more details. | ||
4248 | 17 | * | ||
4249 | 18 | * You should have received a copy of the GNU Affero General Public License | ||
4250 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | ||
4251 | 20 | */ | ||
4252 | 21 | class genericfile extends Module | ||
4253 | 22 | { | ||
4254 | 23 | // Custom Media information | ||
4255 | 24 | protected $maxFileSize; | ||
4256 | 25 | protected $maxFileSizeBytes; | ||
4257 | 26 | |||
4258 | 27 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '', $lkid = '') | ||
4259 | 28 | { | ||
4260 | 29 | // Must set the type of the class | ||
4261 | 30 | $this->type= 'genericfile'; | ||
4262 | 31 | $this->displayType = __('Generic File'); | ||
4263 | 32 | |||
4264 | 33 | // Get the max upload size from PHP | ||
4265 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | ||
4266 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | ||
4267 | 36 | |||
4268 | 37 | // Must call the parent class | ||
4269 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid, $lkid); | ||
4270 | 39 | } | ||
4271 | 40 | |||
4272 | 41 | /** | ||
4273 | 42 | * Sets the Layout and Region Information | ||
4274 | 43 | * it will then fill in any blanks it has about this media if it can | ||
4275 | 44 | * @return | ||
4276 | 45 | * @param $layoutid Object | ||
4277 | 46 | * @param $regionid Object | ||
4278 | 47 | * @param $mediaid Object | ||
4279 | 48 | */ | ||
4280 | 49 | public function SetRegionInformation($layoutid, $regionid) | ||
4281 | 50 | { | ||
4282 | 51 | $db =& $this->db; | ||
4283 | 52 | $this->layoutid = $layoutid; | ||
4284 | 53 | $this->regionid = $regionid; | ||
4285 | 54 | $mediaid = $this->mediaid; | ||
4286 | 55 | $this->existingMedia = false; | ||
4287 | 56 | |||
4288 | 57 | if ($this->regionSpecific == 1) | ||
4289 | 58 | return; | ||
4290 | 59 | |||
4291 | 60 | try { | ||
4292 | 61 | $dbh = PDOConnect::init(); | ||
4293 | 62 | |||
4294 | 63 | // Load what we know about this media into the object | ||
4295 | 64 | $sth = $dbh->prepare('SELECT storedAs FROM media WHERE mediaID = :mediaid'); | ||
4296 | 65 | $sth->execute(array('mediaid' => $mediaid)); | ||
4297 | 66 | |||
4298 | 67 | if (!$storedAs = $sth->fetchColumn()) | ||
4299 | 68 | return false; | ||
4300 | 69 | |||
4301 | 70 | $this->SetOption('uri', $storedAs); | ||
4302 | 71 | } | ||
4303 | 72 | catch (Exception $e) { | ||
4304 | 73 | |||
4305 | 74 | Debug::LogEntry('error', $e->getMessage()); | ||
4306 | 75 | |||
4307 | 76 | return false; | ||
4308 | 77 | } | ||
4309 | 78 | |||
4310 | 79 | return true; | ||
4311 | 80 | } | ||
4312 | 81 | |||
4313 | 82 | /** | ||
4314 | 83 | * Return the Add Form as HTML | ||
4315 | 84 | * @return | ||
4316 | 85 | */ | ||
4317 | 86 | public function AddForm() | ||
4318 | 87 | { | ||
4319 | 88 | return $this->AddFormForLibraryMedia(); | ||
4320 | 89 | } | ||
4321 | 90 | |||
4322 | 91 | /** | ||
4323 | 92 | * Return the Edit Form as HTML | ||
4324 | 93 | * @return | ||
4325 | 94 | */ | ||
4326 | 95 | public function EditForm() | ||
4327 | 96 | { | ||
4328 | 97 | return $this->EditFormForLibraryMedia(); | ||
4329 | 98 | } | ||
4330 | 99 | |||
4331 | 100 | /** | ||
4332 | 101 | * Add Media to the Database | ||
4333 | 102 | * @return | ||
4334 | 103 | */ | ||
4335 | 104 | public function AddMedia() | ||
4336 | 105 | { | ||
4337 | 106 | return $this->AddLibraryMedia(); | ||
4338 | 107 | } | ||
4339 | 108 | |||
4340 | 109 | /** | ||
4341 | 110 | * Edit Media in the Database | ||
4342 | 111 | * @return | ||
4343 | 112 | */ | ||
4344 | 113 | public function EditMedia() | ||
4345 | 114 | { | ||
4346 | 115 | return $this->EditLibraryMedia(); | ||
4347 | 116 | } | ||
4348 | 117 | |||
4349 | 118 | /** | ||
4350 | 119 | * Get Resource | ||
4351 | 120 | */ | ||
4352 | 121 | public function GetResource($displayId = 0) | ||
4353 | 122 | { | ||
4354 | 123 | $this->ReturnFile(); | ||
4355 | 124 | |||
4356 | 125 | exit(); | ||
4357 | 126 | } | ||
4358 | 127 | } | ||
4359 | 128 | ?> | ||
4360 | 0 | 129 | ||
4361 | === modified file 'server/modules/module_user_general.php' | |||
4362 | --- server/modules/module_user_general.php 2014-02-15 11:25:09 +0000 | |||
4363 | +++ server/modules/module_user_general.php 2014-03-29 13:09:24 +0000 | |||
4364 | @@ -1,7 +1,7 @@ | |||
4365 | 1 | <?php | 1 | <?php |
4366 | 2 | /* | 2 | /* |
4367 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk |
4369 | 4 | * Copyright (C) 2006-2013 Daniel Garner and James Packer | 4 | * Copyright (C) 2006-2014 Daniel Garner |
4370 | 5 | * | 5 | * |
4371 | 6 | * This file is part of Xibo. | 6 | * This file is part of Xibo. |
4372 | 7 | * | 7 | * |
4373 | @@ -22,147 +22,147 @@ | |||
4374 | 22 | 22 | ||
4375 | 23 | class User | 23 | class User |
4376 | 24 | { | 24 | { |
4378 | 25 | private $db; | 25 | private $db; |
4379 | 26 | 26 | ||
4390 | 27 | public $userid; | 27 | public $userid; |
4391 | 28 | public $usertypeid; | 28 | public $usertypeid; |
4392 | 29 | public $userName; | 29 | public $userName; |
4393 | 30 | public $homePage; | 30 | public $homePage; |
4394 | 31 | 31 | ||
4395 | 32 | public function __construct(database $db) | 32 | public function __construct(database $db) |
4396 | 33 | { | 33 | { |
4397 | 34 | $this->db =& $db; | 34 | $this->db =& $db; |
4398 | 35 | $this->userid = Kit::GetParam('userid', _SESSION, _INT); | 35 | $this->userid = Kit::GetParam('userid', _SESSION, _INT); |
4399 | 36 | $this->usertypeid = Kit::GetParam('usertype', _SESSION, _INT); | 36 | $this->usertypeid = Kit::GetParam('usertype', _SESSION, _INT); |
4400 | 37 | 37 | ||
4413 | 38 | // We havent authed yet | 38 | // We havent authed yet |
4414 | 39 | $this->authedDisplayGroupIDs = false; | 39 | $this->authedDisplayGroupIDs = false; |
4415 | 40 | } | 40 | } |
4416 | 41 | 41 | ||
4417 | 42 | /** | 42 | /** |
4418 | 43 | * Validate the User is Logged In | 43 | * Validate the User is Logged In |
4419 | 44 | * @param $ajax Object[optional] Indicates if this request came from an AJAX call or otherwise | 44 | * @param $ajax Object[optional] Indicates if this request came from an AJAX call or otherwise |
4420 | 45 | */ | 45 | */ |
4421 | 46 | function attempt_login($ajax = false) | 46 | function attempt_login($ajax = false) |
4422 | 47 | { | 47 | { |
4423 | 48 | $db =& $this->db; | 48 | $db =& $this->db; |
4424 | 49 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 49 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
4425 | 50 | 50 | ||
4426 | 51 | // Referring Page is anything after the ? | 51 | // Referring Page is anything after the ? |
4434 | 52 | $requestUri = rawurlencode(Kit::GetCurrentPage()); | 52 | $requestUri = rawurlencode(Kit::GetCurrentPage()); |
4435 | 53 | 53 | ||
4436 | 54 | if (!$this->checkforUserid()) | 54 | if (!$this->checkforUserid()) |
4437 | 55 | { | 55 | { |
4438 | 56 | // Log out the user | 56 | // Log out the user |
4439 | 57 | if ($userid != 0) | 57 | if ($userid != 0) |
4440 | 58 | $db->query(sprintf("UPDATE user SET loggedin = 0 WHERE userid = %d ", $userid)); | 58 | $db->query(sprintf("UPDATE user SET loggedin = 0 WHERE userid = %d ", $userid)); |
4441 | 59 | 59 | ||
4445 | 60 | // AJAX calls that fail the login test cause a page redirect | 60 | // AJAX calls that fail the login test cause a page redirect |
4446 | 61 | if ($ajax) | 61 | if ($ajax) |
4447 | 62 | { | 62 | { |
4448 | 63 | //create the AJAX request object | 63 | //create the AJAX request object |
4449 | 64 | $response = new ResponseManager(); | 64 | $response = new ResponseManager(); |
4450 | 65 | 65 | ||
4451 | 66 | $response->Login(); | 66 | $response->Login(); |
4452 | 67 | $response->Respond(); | 67 | $response->Respond(); |
4460 | 68 | } | 68 | } |
4461 | 69 | else | 69 | else |
4462 | 70 | { | 70 | { |
4463 | 71 | Theme::Set('form_meta', '<input type="hidden" name="token" value="' . CreateFormToken() . '" />'); | 71 | Theme::Set('form_meta', '<input type="hidden" name="token" value="' . CreateFormToken() . '" />'); |
4464 | 72 | Theme::Set('form_action', 'index.php?q=login&referingPage=' . $requestUri); | 72 | Theme::Set('form_action', 'index.php?q=login&referingPage=' . $requestUri); |
4465 | 73 | Theme::Set('about_url', 'index.php?p=index&q=About'); | 73 | Theme::Set('about_url', 'index.php?p=index&q=About'); |
4466 | 74 | Theme::Set('source_url', 'https://launchpad.net/xibo/1.6'); | 74 | Theme::Set('source_url', 'https://launchpad.net/xibo/1.6'); |
4467 | 75 | 75 | ||
4471 | 76 | // Message (either from the URL or the session) | 76 | // Message (either from the URL or the session) |
4472 | 77 | $message = Kit::GetParam('message', _GET, _STRING, Kit::GetParam('message', _SESSION, _STRING, '')); | 77 | $message = Kit::GetParam('message', _GET, _STRING, Kit::GetParam('message', _SESSION, _STRING, '')); |
4473 | 78 | Theme::Set('login_message', $message); | 78 | Theme::Set('login_message', $message); |
4474 | 79 | Theme::Render('login_page'); | 79 | Theme::Render('login_page'); |
4475 | 80 | 80 | ||
4478 | 81 | // Clear the session message | 81 | // Clear the session message |
4479 | 82 | $_SESSION['message'] = ''; | 82 | $_SESSION['message'] = ''; |
4480 | 83 | exit; | 83 | exit; |
4491 | 84 | } | 84 | } |
4492 | 85 | 85 | ||
4493 | 86 | return false; | 86 | return false; |
4494 | 87 | } | 87 | } |
4495 | 88 | else | 88 | else |
4496 | 89 | { | 89 | { |
4497 | 90 | //write out to the db that the logged in user has accessed the page still | 90 | //write out to the db that the logged in user has accessed the page still |
4498 | 91 | $SQL = sprintf("UPDATE user SET lastaccessed = '" . date("Y-m-d H:i:s") . "', loggedin = 1 WHERE userid = %d ", $userid); | 91 | $SQL = sprintf("UPDATE user SET lastaccessed = '" . date("Y-m-d H:i:s") . "', loggedin = 1 WHERE userid = %d ", $userid); |
4499 | 92 | 92 | ||
4500 | 93 | $results = $db->query($SQL) or trigger_error("Can not write last accessed info.", E_USER_ERROR); | 93 | $results = $db->query($SQL) or trigger_error("Can not write last accessed info.", E_USER_ERROR); |
4501 | 94 | 94 | ||
4502 | 95 | // Load the information about this user | 95 | // Load the information about this user |
4545 | 96 | $this->LoginServices($userid); | 96 | $this->LoginServices($userid); |
4546 | 97 | 97 | ||
4547 | 98 | return true; | 98 | return true; |
4548 | 99 | } | 99 | } |
4549 | 100 | } | 100 | } |
4550 | 101 | 101 | ||
4551 | 102 | /** | 102 | /** |
4552 | 103 | * Login a user | 103 | * Login a user |
4553 | 104 | * @return | 104 | * @return |
4554 | 105 | * @param $username Object | 105 | * @param $username Object |
4555 | 106 | * @param $password Object | 106 | * @param $password Object |
4556 | 107 | */ | 107 | */ |
4557 | 108 | function login($username, $password) | 108 | function login($username, $password) |
4558 | 109 | { | 109 | { |
4559 | 110 | $db =& $this->db; | 110 | $db =& $this->db; |
4560 | 111 | 111 | ||
4561 | 112 | Kit::ClassLoader('userdata'); | 112 | Kit::ClassLoader('userdata'); |
4562 | 113 | 113 | ||
4563 | 114 | // Get the SALT for this username | 114 | // Get the SALT for this username |
4564 | 115 | if (!$userInfo = $db->GetSingleRow(sprintf("SELECT UserID, UserName, UserPassword, UserTypeID, CSPRNG FROM `user` WHERE UserName = '%s'", $db->escape_string($username)))) { | 115 | if (!$userInfo = $db->GetSingleRow(sprintf("SELECT UserID, UserName, UserPassword, UserTypeID, CSPRNG FROM `user` WHERE UserName = '%s'", $db->escape_string($username)))) { |
4565 | 116 | setMessage(__('Username or Password incorrect')); | 116 | setMessage(__('Username or Password incorrect')); |
4566 | 117 | return false; | 117 | return false; |
4567 | 118 | } | 118 | } |
4568 | 119 | 119 | ||
4569 | 120 | // User Data Object to check the password | 120 | // User Data Object to check the password |
4570 | 121 | $userData = new Userdata($db); | 121 | $userData = new Userdata($db); |
4571 | 122 | 122 | ||
4572 | 123 | // Is SALT empty | 123 | // Is SALT empty |
4573 | 124 | if ($userInfo['CSPRNG'] == 0) { | 124 | if ($userInfo['CSPRNG'] == 0) { |
4574 | 125 | 125 | ||
4575 | 126 | // Check the password using a MD5 | 126 | // Check the password using a MD5 |
4576 | 127 | if ($userInfo['UserPassword'] != md5($password)) { | 127 | if ($userInfo['UserPassword'] != md5($password)) { |
4577 | 128 | setMessage(__('Username or Password incorrect')); | 128 | setMessage(__('Username or Password incorrect')); |
4578 | 129 | return false; | 129 | return false; |
4579 | 130 | } | 130 | } |
4580 | 131 | 131 | ||
4581 | 132 | // Now that we are validated, generate a new SALT and set the users password. | 132 | // Now that we are validated, generate a new SALT and set the users password. |
4582 | 133 | $userData->ChangePassword(Kit::ValidateParam($userInfo['UserID'], _INT), null, $password, $password, true /* Force Change */); | 133 | $userData->ChangePassword(Kit::ValidateParam($userInfo['UserID'], _INT), null, $password, $password, true /* Force Change */); |
4583 | 134 | } | 134 | } |
4584 | 135 | else { | 135 | else { |
4585 | 136 | 136 | ||
4586 | 137 | // Check the users password using the random SALTED password | 137 | // Check the users password using the random SALTED password |
4587 | 138 | if ($userData->validate_password($password, $userInfo['UserPassword']) === false) { | 138 | if ($userData->validate_password($password, $userInfo['UserPassword']) === false) { |
4590 | 139 | setMessage(__('Username or Password incorrect')); | 139 | setMessage(__('Username or Password incorrect')); |
4591 | 140 | return false; | 140 | return false; |
4592 | 141 | } | 141 | } |
4617 | 142 | } | 142 | } |
4618 | 143 | 143 | ||
4619 | 144 | // there is a result so we store the userID in the session variable | 144 | // there is a result so we store the userID in the session variable |
4620 | 145 | $_SESSION['userid'] = Kit::ValidateParam($userInfo['UserID'], _INT); | 145 | $_SESSION['userid'] = Kit::ValidateParam($userInfo['UserID'], _INT); |
4621 | 146 | $_SESSION['username'] = Kit::ValidateParam($userInfo['UserName'], _USERNAME); | 146 | $_SESSION['username'] = Kit::ValidateParam($userInfo['UserName'], _USERNAME); |
4622 | 147 | $_SESSION['usertype'] = Kit::ValidateParam($userInfo['UserTypeID'], _INT); | 147 | $_SESSION['usertype'] = Kit::ValidateParam($userInfo['UserTypeID'], _INT); |
4623 | 148 | 148 | ||
4624 | 149 | // Set the User Object | 149 | // Set the User Object |
4625 | 150 | $this->usertypeid = $_SESSION['usertype']; | 150 | $this->usertypeid = $_SESSION['usertype']; |
4626 | 151 | $this->userid = $_SESSION['userid']; | 151 | $this->userid = $_SESSION['userid']; |
4627 | 152 | 152 | ||
4628 | 153 | // update the db | 153 | // update the db |
4629 | 154 | // write out to the db that the logged in user has accessed the page | 154 | // write out to the db that the logged in user has accessed the page |
4630 | 155 | $SQL = sprintf("UPDATE user SET lastaccessed = '" . date("Y-m-d H:i:s") . "', loggedin = 1 WHERE userid = %d", $_SESSION['userid']); | 155 | $SQL = sprintf("UPDATE user SET lastaccessed = '" . date("Y-m-d H:i:s") . "', loggedin = 1 WHERE userid = %d", $_SESSION['userid']); |
4631 | 156 | 156 | ||
4632 | 157 | $db->query($SQL) or trigger_error(__('Can not write last accessed info.'), E_USER_ERROR); | 157 | $db->query($SQL) or trigger_error(__('Can not write last accessed info.'), E_USER_ERROR); |
4633 | 158 | 158 | ||
4634 | 159 | // Switch Session ID's | 159 | // Switch Session ID's |
4635 | 160 | global $session; | 160 | global $session; |
4636 | 161 | $session->setIsExpired(0); | 161 | $session->setIsExpired(0); |
4637 | 162 | $session->RegenerateSessionID(session_id()); | 162 | $session->RegenerateSessionID(session_id()); |
4638 | 163 | 163 | ||
4639 | 164 | return true; | 164 | return true; |
4640 | 165 | } | 165 | } |
4641 | 166 | 166 | ||
4642 | 167 | /** | 167 | /** |
4643 | 168 | * Logs in a specific userID | 168 | * Logs in a specific userID |
4644 | @@ -178,99 +178,99 @@ | |||
4645 | 178 | return false; | 178 | return false; |
4646 | 179 | 179 | ||
4647 | 180 | $this->userName = Kit::ValidateParam($results['UserName'], _USERNAME); | 180 | $this->userName = Kit::ValidateParam($results['UserName'], _USERNAME); |
4650 | 181 | $this->usertypeid = Kit::ValidateParam($results['usertypeid'], _INT); | 181 | $this->usertypeid = Kit::ValidateParam($results['usertypeid'], _INT); |
4651 | 182 | $this->userid = $userID; | 182 | $this->userid = $userID; |
4652 | 183 | $this->homePage = Kit::ValidateParam($results['homepage'], _WORD); | 183 | $this->homePage = Kit::ValidateParam($results['homepage'], _WORD); |
4653 | 184 | 184 | ||
4654 | 185 | return true; | 185 | return true; |
4655 | 186 | } | 186 | } |
4656 | 187 | 187 | ||
4743 | 188 | /** | 188 | /** |
4744 | 189 | * Logout the user associated with this user object | 189 | * Logout the user associated with this user object |
4745 | 190 | * @return | 190 | * @return |
4746 | 191 | */ | 191 | */ |
4747 | 192 | function logout() | 192 | function logout() |
4748 | 193 | { | 193 | { |
4749 | 194 | $db =& $this->db; | 194 | $db =& $this->db; |
4750 | 195 | global $session; | 195 | global $session; |
4751 | 196 | 196 | ||
4752 | 197 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 197 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
4753 | 198 | 198 | ||
4754 | 199 | //write out to the db that the logged in user has accessed the page still | 199 | //write out to the db that the logged in user has accessed the page still |
4755 | 200 | $SQL = sprintf("UPDATE user SET loggedin = 0 WHERE userid = %d", $userid); | 200 | $SQL = sprintf("UPDATE user SET loggedin = 0 WHERE userid = %d", $userid); |
4756 | 201 | if(!$results = $db->query($SQL)) trigger_error("Can not write last accessed info.", E_USER_ERROR); | 201 | if(!$results = $db->query($SQL)) trigger_error("Can not write last accessed info.", E_USER_ERROR); |
4757 | 202 | 202 | ||
4758 | 203 | //to log out a user we need only to clear out some session vars | 203 | //to log out a user we need only to clear out some session vars |
4759 | 204 | unset($_SESSION['userid']); | 204 | unset($_SESSION['userid']); |
4760 | 205 | unset($_SESSION['username']); | 205 | unset($_SESSION['username']); |
4761 | 206 | unset($_SESSION['password']); | 206 | unset($_SESSION['password']); |
4762 | 207 | 207 | ||
4763 | 208 | $session->setIsExpired(1); | 208 | $session->setIsExpired(1); |
4764 | 209 | 209 | ||
4765 | 210 | return true; | 210 | return true; |
4766 | 211 | } | 211 | } |
4767 | 212 | 212 | ||
4768 | 213 | //Check to see if a user id is in the session information | 213 | //Check to see if a user id is in the session information |
4769 | 214 | function checkforUserid() | 214 | function checkforUserid() |
4770 | 215 | { | 215 | { |
4771 | 216 | $db =& $this->db; | 216 | $db =& $this->db; |
4772 | 217 | global $session; | 217 | global $session; |
4773 | 218 | 218 | ||
4774 | 219 | $userid = Kit::GetParam('userid', _SESSION, _INT, 0); | 219 | $userid = Kit::GetParam('userid', _SESSION, _INT, 0); |
4775 | 220 | 220 | ||
4776 | 221 | // Checks for a user ID in the session variable | 221 | // Checks for a user ID in the session variable |
4777 | 222 | if($userid == 0) | 222 | if($userid == 0) |
4778 | 223 | { | 223 | { |
4779 | 224 | return false; | 224 | return false; |
4780 | 225 | } | 225 | } |
4781 | 226 | else | 226 | else |
4782 | 227 | { | 227 | { |
4783 | 228 | if(!is_numeric($_SESSION['userid'])) | 228 | if(!is_numeric($_SESSION['userid'])) |
4784 | 229 | { | 229 | { |
4785 | 230 | unset($_SESSION['userid']); | 230 | unset($_SESSION['userid']); |
4786 | 231 | return false; | 231 | return false; |
4787 | 232 | } | 232 | } |
4788 | 233 | elseif ($session->isExpired == 1) | 233 | elseif ($session->isExpired == 1) |
4789 | 234 | { | 234 | { |
4790 | 235 | unset($_SESSION['userid']); | 235 | unset($_SESSION['userid']); |
4791 | 236 | return false; | 236 | return false; |
4792 | 237 | } | 237 | } |
4793 | 238 | else | 238 | else |
4794 | 239 | { | 239 | { |
4795 | 240 | // check to see that the ID is still valid | 240 | // check to see that the ID is still valid |
4796 | 241 | $SQL = sprintf("SELECT UserID FROM user WHERE loggedin = 1 AND userid = %d", $userid); | 241 | $SQL = sprintf("SELECT UserID FROM user WHERE loggedin = 1 AND userid = %d", $userid); |
4797 | 242 | 242 | ||
4798 | 243 | $result = $db->query($SQL) or trigger_error($db->error(), E_USER_ERROR); | 243 | $result = $db->query($SQL) or trigger_error($db->error(), E_USER_ERROR); |
4799 | 244 | 244 | ||
4800 | 245 | if($db->num_rows($result)==0) | 245 | if($db->num_rows($result)==0) |
4801 | 246 | { | 246 | { |
4802 | 247 | unset($_SESSION['userid']); | 247 | unset($_SESSION['userid']); |
4803 | 248 | return false; | 248 | return false; |
4804 | 249 | } | 249 | } |
4805 | 250 | return true; | 250 | return true; |
4806 | 251 | } | 251 | } |
4807 | 252 | } | 252 | } |
4808 | 253 | } | 253 | } |
4809 | 254 | 254 | ||
4810 | 255 | function getNameFromID($id) | 255 | function getNameFromID($id) |
4811 | 256 | { | 256 | { |
4812 | 257 | $db =& $this->db; | 257 | $db =& $this->db; |
4813 | 258 | 258 | ||
4814 | 259 | $SQL = sprintf("SELECT username FROM user WHERE userid = %d", $id); | 259 | $SQL = sprintf("SELECT username FROM user WHERE userid = %d", $id); |
4815 | 260 | 260 | ||
4816 | 261 | if(!$results = $db->query($SQL)) trigger_error("Unknown user id in the system", E_USER_NOTICE); | 261 | if(!$results = $db->query($SQL)) trigger_error("Unknown user id in the system", E_USER_NOTICE); |
4817 | 262 | 262 | ||
4818 | 263 | // if no user is returned | 263 | // if no user is returned |
4819 | 264 | if ($db->num_rows($results) == 0) | 264 | if ($db->num_rows($results) == 0) |
4820 | 265 | { | 265 | { |
4821 | 266 | // assume that is the xibo_admin | 266 | // assume that is the xibo_admin |
4822 | 267 | return "None"; | 267 | return "None"; |
4823 | 268 | } | 268 | } |
4824 | 269 | 269 | ||
4825 | 270 | $row = $db->get_row($results); | 270 | $row = $db->get_row($results); |
4826 | 271 | 271 | ||
4827 | 272 | return $row[0]; | 272 | return $row[0]; |
4828 | 273 | } | 273 | } |
4829 | 274 | 274 | ||
4830 | 275 | /** | 275 | /** |
4831 | 276 | * Get an array of user groups for the given user id | 276 | * Get an array of user groups for the given user id |
4832 | @@ -279,7 +279,7 @@ | |||
4833 | 279 | * @return <array> | 279 | * @return <array> |
4834 | 280 | */ | 280 | */ |
4835 | 281 | public function GetUserGroups($id, $returnID = false) | 281 | public function GetUserGroups($id, $returnID = false) |
4837 | 282 | { | 282 | { |
4838 | 283 | $db =& $this->db; | 283 | $db =& $this->db; |
4839 | 284 | 284 | ||
4840 | 285 | $groupIDs = array(); | 285 | $groupIDs = array(); |
4841 | @@ -335,12 +335,12 @@ | |||
4842 | 335 | 335 | ||
4843 | 336 | 336 | ||
4844 | 337 | return $groups; | 337 | return $groups; |
4846 | 338 | } | 338 | } |
4847 | 339 | 339 | ||
4850 | 340 | function getGroupFromID($id, $returnID = false) | 340 | function getGroupFromID($id, $returnID = false) |
4851 | 341 | { | 341 | { |
4852 | 342 | $db =& $this->db; | 342 | $db =& $this->db; |
4854 | 343 | 343 | ||
4855 | 344 | $SQL = ""; | 344 | $SQL = ""; |
4856 | 345 | $SQL .= "SELECT group.group, "; | 345 | $SQL .= "SELECT group.group, "; |
4857 | 346 | $SQL .= " group.groupID "; | 346 | $SQL .= " group.groupID "; |
4858 | @@ -351,13 +351,13 @@ | |||
4859 | 351 | $SQL .= " ON group.groupID = lkusergroup.GroupID "; | 351 | $SQL .= " ON group.groupID = lkusergroup.GroupID "; |
4860 | 352 | $SQL .= sprintf("WHERE `user`.userid = %d ", $id); | 352 | $SQL .= sprintf("WHERE `user`.userid = %d ", $id); |
4861 | 353 | $SQL .= "AND `group`.IsUserSpecific = 1"; | 353 | $SQL .= "AND `group`.IsUserSpecific = 1"; |
4863 | 354 | 354 | ||
4864 | 355 | if(!$results = $db->query($SQL)) | 355 | if(!$results = $db->query($SQL)) |
4865 | 356 | { | 356 | { |
4866 | 357 | trigger_error($db->error()); | 357 | trigger_error($db->error()); |
4867 | 358 | trigger_error("Error looking up user information (group)", E_USER_ERROR); | 358 | trigger_error("Error looking up user information (group)", E_USER_ERROR); |
4868 | 359 | } | 359 | } |
4870 | 360 | 360 | ||
4871 | 361 | if ($db->num_rows($results) == 0) | 361 | if ($db->num_rows($results) == 0) |
4872 | 362 | { | 362 | { |
4873 | 363 | // Every user should have a group? | 363 | // Every user should have a group? |
4874 | @@ -387,68 +387,68 @@ | |||
4875 | 387 | return $row[1]; | 387 | return $row[1]; |
4876 | 388 | } | 388 | } |
4877 | 389 | return $row[0]; | 389 | return $row[0]; |
4933 | 390 | } | 390 | } |
4934 | 391 | 391 | ||
4935 | 392 | function getUserTypeFromID($id, $returnID = false) | 392 | function getUserTypeFromID($id, $returnID = false) |
4936 | 393 | { | 393 | { |
4937 | 394 | $db =& $this->db; | 394 | $db =& $this->db; |
4938 | 395 | 395 | ||
4939 | 396 | $SQL = sprintf("SELECT usertype.usertype, usertype.usertypeid FROM user INNER JOIN usertype ON usertype.usertypeid = user.usertypeid WHERE userid = %d", $id); | 396 | $SQL = sprintf("SELECT usertype.usertype, usertype.usertypeid FROM user INNER JOIN usertype ON usertype.usertypeid = user.usertypeid WHERE userid = %d", $id); |
4940 | 397 | 397 | ||
4941 | 398 | if(!$results = $db->query($SQL)) | 398 | if(!$results = $db->query($SQL)) |
4942 | 399 | { | 399 | { |
4943 | 400 | trigger_error("Error looking up user information (usertype)"); | 400 | trigger_error("Error looking up user information (usertype)"); |
4944 | 401 | trigger_error($db->error()); | 401 | trigger_error($db->error()); |
4945 | 402 | } | 402 | } |
4946 | 403 | 403 | ||
4947 | 404 | if ($db->num_rows($results)==0) | 404 | if ($db->num_rows($results)==0) |
4948 | 405 | { | 405 | { |
4949 | 406 | if ($returnID) | 406 | if ($returnID) |
4950 | 407 | { | 407 | { |
4951 | 408 | return "3"; | 408 | return "3"; |
4952 | 409 | } | 409 | } |
4953 | 410 | return "User"; | 410 | return "User"; |
4954 | 411 | } | 411 | } |
4955 | 412 | 412 | ||
4956 | 413 | $row = $db->get_row($results); | 413 | $row = $db->get_row($results); |
4957 | 414 | 414 | ||
4958 | 415 | if ($returnID) | 415 | if ($returnID) |
4959 | 416 | { | 416 | { |
4960 | 417 | return $row[1]; | 417 | return $row[1]; |
4961 | 418 | } | 418 | } |
4962 | 419 | return $row[0]; | 419 | return $row[0]; |
4963 | 420 | } | 420 | } |
4964 | 421 | 421 | ||
4965 | 422 | function getEmailFromID($id) | 422 | function getEmailFromID($id) |
4966 | 423 | { | 423 | { |
4967 | 424 | $db =& $this->db; | 424 | $db =& $this->db; |
4968 | 425 | 425 | ||
4969 | 426 | $SQL = sprintf("SELECT email FROM user WHERE userid = %d", $id); | 426 | $SQL = sprintf("SELECT email FROM user WHERE userid = %d", $id); |
4970 | 427 | 427 | ||
4971 | 428 | if(!$results = $db->query($SQL)) trigger_error("Unknown user id in the system", E_USER_NOTICE); | 428 | if(!$results = $db->query($SQL)) trigger_error("Unknown user id in the system", E_USER_NOTICE); |
4972 | 429 | 429 | ||
4973 | 430 | if ($db->num_rows($results)==0) | 430 | if ($db->num_rows($results)==0) |
4974 | 431 | { | 431 | { |
4975 | 432 | $SQL = "SELECT email FROM user WHERE userid = 1"; | 432 | $SQL = "SELECT email FROM user WHERE userid = 1"; |
4976 | 433 | 433 | ||
4977 | 434 | if(!$results = $db->query($SQL)) | 434 | if(!$results = $db->query($SQL)) |
4978 | 435 | { | 435 | { |
4979 | 436 | trigger_error("Unknown user id in the system [$id]"); | 436 | trigger_error("Unknown user id in the system [$id]"); |
4980 | 437 | } | 437 | } |
4981 | 438 | } | 438 | } |
4982 | 439 | 439 | ||
4983 | 440 | $row = $db->get_row($results); | 440 | $row = $db->get_row($results); |
4984 | 441 | return $row[1]; | 441 | return $row[1]; |
4985 | 442 | } | 442 | } |
4986 | 443 | 443 | ||
4987 | 444 | /** | 444 | /** |
4988 | 445 | * Gets the homepage for the given userid | 445 | * Gets the homepage for the given userid |
4989 | 446 | * @param <type> $userId | 446 | * @param <type> $userId |
4990 | 447 | * @return <type> | 447 | * @return <type> |
4991 | 448 | */ | 448 | */ |
4995 | 449 | function GetHomePage($userId) | 449 | function GetHomePage($userId) |
4996 | 450 | { | 450 | { |
4997 | 451 | $db =& $this->db; | 451 | $db =& $this->db; |
4998 | 452 | 452 | ||
4999 | 453 | $SQL = sprintf("SELECT homepage FROM `user` WHERE userid = %d", $userId); | 453 | $SQL = sprintf("SELECT homepage FROM `user` WHERE userid = %d", $userId); |
5000 | 454 | 454 |
The diff has been truncated for viewing.