Merge lp:~dangarner/xibo/server-160rc2 into lp:xibo/1.6

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
Reviewer Review Type Date Requested Status
Xibo Maintainters Pending
Review via email: mp+213360@code.launchpad.net
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
=== modified file 'server/3rdparty/simplepie/library/SimplePie/File.php'
--- server/3rdparty/simplepie/library/SimplePie/File.php 2013-05-11 15:26:38 +0000
+++ server/3rdparty/simplepie/library/SimplePie/File.php 2014-03-29 13:09:24 +0000
@@ -113,6 +113,15 @@
113 curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);113 curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
114 }114 }
115115
116 // Dan Garner PATCH
117 if (Config::GetSetting('PROXY_HOST') != '') {
118 curl_setopt($fp, CURLOPT_PROXY, Config::GetSetting('PROXY_HOST'));
119 curl_setopt($fp, CURLOPT_PROXYPORT, Config::GetSetting('PROXY_PORT'));
120
121 if (Config::GetSetting('PROXY_AUTH') != '')
122 curl_setopt($fp, CURLOPT_PROXYUSERPWD, Config::GetSetting('PROXY_AUTH'));
123 }
124
116 $this->headers = curl_exec($fp);125 $this->headers = curl_exec($fp);
117 if (curl_errno($fp) === 23 || curl_errno($fp) === 61)126 if (curl_errno($fp) === 23 || curl_errno($fp) === 61)
118 {127 {
119128
=== removed file 'server/install.php'
--- server/install.php 2013-08-21 22:27:13 +0000
+++ server/install.php 1970-01-01 00:00:00 +0000
@@ -1,748 +0,0 @@
1<?php
2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2009-2013 Alex Harrington
5 *
6 * This file is part of Xibo.
7 *
8 * Xibo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * Xibo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
20 */
21DEFINE('XIBO', true);
22
23if (! checkPHP())
24{
25 die('Xibo requires PHP 5.2.4 or later');
26}
27
28error_reporting(0);
29ini_set('display_errors', 0);
30
31include('lib/app/kit.class.php');
32include('install/header.inc');
33include('config/config.class.php');
34include('config/db_config.php');
35
36// Setup for the Translations using Gettext.
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)
38// Would be nice to include a method on the TranslationEngine that did this for us - but without the debugging
39// The actual translation function __() is included later in this file.
40$langs = Kit::GetParam('HTTP_ACCEPT_LANGUAGE', $_SERVER, _STRING);
41$lang = 'en-gb'; // Default language
42$encoding = ''; // We do not seem to need an encoding, but I read somewhere that we might - left as a reminder of this.
43
44if ($langs != '')
45{
46 $langs = explode(',', $langs);
47 $lang = $langs[0];
48}
49
50// For windows
51putenv('LANG='.$lang.'.'.$encoding);
52putenv('LANGUAGE='.$lang.'.'.$encoding);
53putenv('LC_ALL='.$lang.'.'.$encoding);
54
55// Set local
56setlocale(LC_ALL, $lang.'.'.$encoding);
57
58// Translations have been setup.
59
60$fault = false;
61
62$xibo_step = Kit::GetParam('xibo_step',_POST,_INT,'0');
63
64if (!isset($xibo_step) || $xibo_step == 0) {
65 # First step of the process.
66 # Show a welcome screen and next button
67 ?>
68 <?php echo __("Welcome to the Xibo Installer!"); ?><br /><br />
69 <?php echo __("The installer will take you through setting up Xibo one step at a time."); ?><br /><br />
70 <?php echo __("Lets get started!"); ?><br /><br />
71 <form action="install.php" method="POST">
72 <input type="hidden" name="xibo_step" value="1" />
73 <div class="loginbutton"><button type="submit"><?php echo __("Next"); ?> ></button></div>
74 </form>
75 <?php
76}
77elseif ($xibo_step == 1) {
78 # Check environment
79 $db = new Database();
80 $cObj = new Config();
81 ?>
82 <p><?php echo __("First we need to check if your server meets Xibo's requirements."); ?></p>
83 <div class="checks">
84 <?php
85 echo $cObj->CheckEnvironment();
86 if ($cObj->EnvironmentFault()) {
87 ?>
88 <form action="install.php" method="POST">
89 <input type="hidden" name="xibo_step" value="1" />
90 <div class="loginbutton"><button type="submit"><?php echo __("Retest"); ?></button></div>
91 </form>
92 <?php
93 }
94 else if ($cObj->EnvironmentWarning()) {
95 ?>
96 <form action="install.php" method="POST">
97 <input type="hidden" name="xibo_step" value="1" />
98 <div class="loginbutton"><button type="submit"><?php echo __("Retest"); ?></button></div>
99 </form>
100 <form action="install.php" method="POST">
101 <input type="hidden" name="xibo_step" value="2" />
102 <div class="loginbutton"><button type="submit"><?php echo __("Next"); ?> ></button></div>
103 </form>
104 <?php
105 }
106 else {
107 ?>
108 <form action="install.php" method="POST">
109 <input type="hidden" name="xibo_step" value="2" />
110 <div class="loginbutton"><button type="submit"><?php echo __("Next"); ?> ></button></div>
111 </form>
112 <?php
113 }
114}
115elseif ($xibo_step == 2) {
116# Create database
117## Does database exist already?
118
119 ?>
120 <div class="info">
121 <p><?php echo __("Xibo needs to setup a new database."); ?></p>
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>
123 <p><i><?php echo __("Note that any existing database must be empty"); ?></i></p>
124 </div>
125 <form action="install.php" method="POST">
126 <input type="hidden" name="xibo_step" value="3" />
127 <button type="submit"><?php echo __("Create New"); ?></button>
128 </form>
129 <form action="install.php" method="POST">
130 <input type="hidden" name="xibo_step" value="4" />
131 <button type="submit"><?php echo __("Use Existing"); ?></button>
132 </form>
133 <?php
134}
135elseif ($xibo_step == 3) {
136## If not, gather admin password and use to create empty db and new user.
137?>
138<div class="info">
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>
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>
141<form action="install.php" method="POST">
142<input type="hidden" name="xibo_step" value="5" />
143<input type="hidden" name="db_create" value="On" />
144<div class="install_table">
145 <p><label for="host"><?php echo __("Host:"); ?>&nbsp;</label><input class="username" type="text" id="host" name="host" size="12" value="localhost" /></p>
146 <p><label for="admin_username"><?php echo __("Admin Username:"); ?>&nbsp;</label><input class="username" type="text" id="admin_username" name="admin_username" size="12" /></p>
147 <p><label for="admin_password"><?php echo __("Admin Password:"); ?>&nbsp;</label><input class="username" type="password" id="admin_password" name="admin_password" size="12" /></p>
148 <p><label for="db_name"><?php echo __("Xibo Database Name:"); ?>&nbsp;</label><input class="username" type="text" id="db_name" name="db_name" size="12" value="xibo" /></p>
149 <p><label for="db_username"><?php echo __("Xibo Database Username:"); ?>&nbsp;</label><input class="username" type="text" id="db_username" name="db_username" size="12" value="xibo" /></p>
150 <p><label for="db_password"><?php echo __("Xibo Database Password:"); ?>&nbsp;</label><input class="username" type="password" id="db_password" name="db_password" size="12" /></p>
151</div>
152</div>
153<button type="submit"><?php echo __("Create"); ?></button>
154</form>
155<?php
156}
157elseif ($xibo_step == 4) {
158## Get details of db that's been created already for us
159?>
160<div class="info">
161<p><?php echo __("Please enter the details of the database and user you have created for Xibo."); ?></p>
162<form action="install.php" method="POST">
163<input type="hidden" name="xibo_step" value="5" />
164<input type="hidden" name="db_create" value="Off" />
165<div class="install_table">
166 <p><label for="host"><?php echo __("Host:"); ?>&nbsp;</label><input class="username" type="text" id="host" name="host" size="12" value="localhost" /></p>
167 <p><label for="db_name"><?php echo __("Xibo Database Name:"); ?>&nbsp;</label><input class="username" type="text" id="db_name" name="db_name" size="12" value="xibo" /></p>
168 <p><label for="db_username"><?php echo __("Xibo Database Username:"); ?>&nbsp;</label><input class="username" type="text" id="db_username" name="db_username" size="12" value="xibo" /></p>
169 <p><label for="db_password"><?php echo __("Xibo Database Password:"); ?>&nbsp;</label><input class="username" type="password" id="db_password" name="db_password" size="12" /></p>
170</div>
171</div>
172<button type="submit"><?php echo __("Create"); ?></button>
173</form>
174<?php
175}
176elseif ($xibo_step == 5) {
177
178 $db_create = Kit::GetParam('db_create',_POST,_STRING);
179
180 if (!isset($db_create)) {
181 reportError("2",__("Something went wrong"));
182 }
183 else {
184 $db_host = Kit::GetParam('host',_POST,_STRING,'localhost');
185 $db_user = Kit::GetParam('db_username',_POST,_PASSWORD);
186 $db_pass = Kit::GetParam('db_password',_POST,_PASSWORD);
187 $db_name = Kit::GetParam('db_name',_POST,_PASSWORD);
188 ?>
189 <div class="info">
190 <?php
191 if ($db_create == 'On') {
192 $db_admin_user = Kit::GetParam('admin_username',_POST,_PASSWORD);
193 $db_admin_pass = Kit::GetParam('admin_password',_POST,_PASSWORD);
194
195 if (! ($db_host && $db_name && $db_user && $db_admin_user)) {
196 # Something was blank.
197 # Throw an error.
198 reportError("3", __("A field was blank. Please fill in all fields."));
199 }
200
201 $db = @mysql_connect($db_host,$db_admin_user,$db_admin_pass);
202
203 if (! $db) {
204 reportError("3", __("Could not connect to MySQL with the administrator details. Please check and try again.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error());
205 }
206
207 ?>
208 <p><?php echo __("Creating new database."); ?></p>
209 <?php
210 flush();
211
212 $SQL = sprintf("CREATE DATABASE `%s`",
213 mysql_real_escape_string($db_name));
214 if (! @mysql_query($SQL, $db)) {
215 # Create database and user
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());
217 }
218
219 # Choose the MySQL DB to create a user
220 @mysql_select_db("mysql", $db);
221
222 # Make $db_host lowercase so it matches "localhost" if required.
223 $db_host = strtolower($db_host);
224
225 ?>
226 <p><?php echo __("Creating new user"); ?></p>
227 <?php
228 flush();
229
230 if ($db_host == 'localhost') {
231 $SQL = sprintf("GRANT ALL PRIVILEGES ON `%s`.* to '%s'@'%s' IDENTIFIED BY '%s'",
232 mysql_real_escape_string($db_name),
233 mysql_real_escape_string($db_user),
234 mysql_real_escape_string($db_host),
235 mysql_real_escape_string($db_pass));
236 }
237 else {
238 $SQL = sprintf("GRANT ALL PRIVILEGES ON `%s`.* to '%s'@'%%' IDENTIFIED BY '%s'",
239 mysql_real_escape_string($db_name),
240 mysql_real_escape_string($db_user),
241 mysql_real_escape_string($db_pass));
242 }
243 if (! @mysql_query($SQL, $db)) {
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());
245 }
246
247
248 @mysql_query("FLUSH PRIVILEGES", $db);
249 @mysql_close($db);
250
251 }
252 else {
253 if (! ($db_host && $db_name && $db_user && $db_pass)) {
254 # Something was blank
255 # Throw an error.
256 reportError("4", __("A field was blank. Please fill in all fields.") . " " . $db_host . " " . $db_name . " " . $db_user . " " . $db_pass);
257 }
258 }
259 ## Populate database
260
261 $db = @mysql_connect($db_host,$db_user,$db_pass);
262
263 if (! $db) {
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());
265 }
266
267 @mysql_select_db($db_name,$db);
268
269 ?>
270 <p>Populating the database</p>
271 <?php
272 flush();
273
274 # Load from sql files to db - HOW?
275 $sql_files = array('structure.sql', 'data.sql');
276
277 $sqlStatementCount = 0;
278
279 foreach ($sql_files as $filename) {
280 ?>
281 <p>Loading from <?php print $filename; ?>
282 <?php
283 flush();
284
285 $delimiter = ';';
286 $sql_file = @file_get_contents('install/master/' . $filename);
287 $sql_file = remove_remarks($sql_file);
288 $sql_file = split_sql_file($sql_file, $delimiter);
289
290 foreach ($sql_file as $sql) {
291 print ".";
292 $sqlStatementCount++;
293 flush();
294 if (! @mysql_query($sql,$db)) {
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);
296 }
297 }
298 print "</p>";
299 }
300 @mysql_close($db);
301 }
302 # Write out a new settings.php
303 $fh = fopen("settings.php", 'wt');
304
305 if (! $fh) {
306 reportError("0", __("Unable to write to settings.php. We already checked this was possible earlier, so something changed."));
307 }
308
309 settings_strings();
310
311 $settings_content = '$dbhost = \'' . $db_host . '\';' . "\n";
312 $settings_content .= '$dbuser = \'' . $db_user . '\';' . "\n";
313 $settings_content .= '$dbpass = \'' . $db_pass . '\';' . "\n";
314 $settings_content .= '$dbname = \'' . $db_name . '\';' . "\n\n";
315 $settings_content .= 'define(\'SECRET_KEY\',\'' . gen_secret() . '\');' . "\n";
316
317 if (! fwrite($fh, $settings_header . $settings_content . $settings_footer)) {
318 reportError("0", __("Unable to write to settings.php. We already checked this was possible earlier, so something changed."));
319 }
320
321 fclose($fh);
322
323 ?>
324 </div>
325 <div class="install_table">
326 <form action="install.php" method="POST">
327 <input type="hidden" name="xibo_step" value="6" />
328 </div>
329 <button type="submit"><?php echo __("Next"); ?> ></button>
330 </form>
331 <?php
332}
333elseif ($xibo_step == 6) {
334 # Form to get new admin password
335 ?>
336 <div class="info">
337 <p><?php echo __("Xibo needs to set the \"xibo_admin\" user password. Please enter a password for this account below."); ?></p>
338 </div>
339 <div class="install_table">
340 <form action="install.php" method="POST">
341 <input type="hidden" name="xibo_step" value="7" />
342 <p><label for="password1"><?php echo __("Password:"); ?>&nbsp;</label><input type="password" name="password1" size="12" /></p>
343 <p><label for="password2"><?php echo __("Retype Password:"); ?>&nbsp;</label><input type="password" name="password2" size="12" /></p>
344 </div>
345 <button type="submit"><?php echo __("Next"); ?> ></button>
346 </form>
347 <?php
348}
349elseif ($xibo_step == 7) {
350 # Setup xibo_admin password
351 $password1 = Kit::GetParam('password1',_POST,_PASSWORD);
352 $password2 = Kit::GetParam('password2',_POST,_PASSWORD);
353
354 if (!(($password1 && $password2) && ($password1 == $password2))) {
355 reportError("6", __("Please input a new password. Ensure both password fields are identical."));
356 }
357
358 include('settings.php');
359
360 $password_hash = md5($password1);
361
362 $db = @mysql_connect($dbhost,$dbuser,$dbpass);
363
364 if (! $db) {
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());
366 }
367
368 @mysql_select_db($dbname,$db);
369
370 $SQL = sprintf("UPDATE `user` SET UserPassword = '%s' WHERE UserID = 1 LIMIT 1",
371 mysql_real_escape_string($password_hash));
372 if (! @mysql_query($SQL, $db)) {
373 reportError("6", __("An error occured changing the xibo_admin password.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error());
374 }
375
376 @mysql_close($db);
377
378 ?>
379 <div class="info">
380 <?php echo __("Successfully changed the xibo_admin password. We're nearly there now. Just a couple more steps!"); ?>
381 </div>
382 <form action="install.php" method="POST">
383 <input type="hidden" name="xibo_step" value="8" />
384 <button type="submit"><?php echo __("Next"); ?> ></button>
385 </form>
386 <?php
387}
388elseif ($xibo_step == 8) {
389 # Configure paths and keys
390 ## nuSoap
391 ## libraries
392 ## server_key
393 ?>
394 <div class="info">
395 <p><b><?php echo __("Library Location"); ?></b></p>
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>
397 <form action="install.php" method="POST">
398 <div class="install_table">
399 <p><label for="library_location"><?php echo __("Library Location:"); ?>&nbsp;</label><input type="text" name="library_location" value="" /></p>
400 </div>
401 <p><b><?php echo __("Server Key"); ?></b></p>
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>
403 <div class="install_table">
404 <p><label for="server_key"><?php echo __("Server Key:"); ?> </label><input type="text" name="server_key" value="" /></p>
405 </div>
406 <p><b><?php echo __("Statistics"); ?></b></p>
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>
408 <div class="install_table">
409 <p><label for="stats"><?php echo __("Anonymous Statistics:"); ?>&nbsp;</label><input type="checkbox" name="stats" value="true" checked /></p>
410 </div>
411 <input type="hidden" name="xibo_step" value="9" />
412 </div>
413 <button type="submit"><?php echo __("Next"); ?> ></button>
414 </form>
415 <?php
416}
417elseif ($xibo_step == 9) {
418
419 $server_key = Kit::GetParam('server_key',_POST,_STRING);
420 $library_location = Kit::GetParam('library_location',_POST,_STRING);
421 $stats = Kit::GetParam('stats',_POST,_BOOL);
422
423 // Remove trailing whitespace from the path given.
424 $library_location = trim($library_location);
425
426 // Check both fields were completed
427 if (! ($server_key && $library_location)) {
428 reportError("8", __("A field was blank. Please make sure you complete all fields"));
429 }
430
431 if ($stats) {
432 $stats="On"; // Fixme: translate ?
433 }
434 else {
435 $stats="Off"; //Fixme : translate ?
436 }
437
438 // Does library_location exist already?
439 if (! is_dir($library_location)) {
440 if (is_file($library_location)) {
441 reportError("8", __("A file exists with the name you gave for the Library Location. Please choose another location"));
442 }
443
444 // Directory does not exist. Attempt to make it
445 // Using mkdir recursively, so it will attempt to make any
446 // intermediate folders required.
447 if (! mkdir($library_location,0755,true)) {
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."));
449 }
450
451 }
452
453 // Is library_location writable?
454 if (! is_writable($library_location)) {
455 // Directory is not writable.
456 reportError("8", __("The Library Location you gave is not writable by the webserver. Please fix the permissions and try again."));
457 }
458
459 // Is library_location empty?
460 if (count(ls("*",$library_location,true)) > 0) {
461 reportError("8", __("The Library Location you gave is not empty. Please give the location of an empty folder"));
462 }
463
464 // Check if the user has added a trailing slash.
465 // If not, add one.
466 if (!((substr($library_location, -1) == '/') || (substr($library_location, -1) == '\\'))) {
467 $library_location = $library_location . '/';
468 }
469
470 include('settings.php');
471
472 $db = @mysql_connect($dbhost,$dbuser,$dbpass);
473
474 if (! $db) {
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());
476 }
477
478 @mysql_select_db($dbname,$db);
479
480 $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'LIBRARY_LOCATION' LIMIT 1",
481 mysql_real_escape_string($library_location));
482 if (! @mysql_query($SQL, $db)) {
483 reportError("8", __("An error occured changing the library location.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error());
484 }
485
486 $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'SERVER_KEY' LIMIT 1",
487 mysql_real_escape_string($server_key));
488 if (! @mysql_query($SQL, $db)) {
489 reportError("8", __("An error occured changing the server key.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error());
490 }
491
492 $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'defaultTimezone' LIMIT 1",
493 mysql_real_escape_string(date_default_timezone_get()));
494 if (! @mysql_query($SQL, $db)) {
495 reportError("8", __("An error occured setting the default timezone.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error());
496 }
497
498 $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'PHONE_HOME' LIMIT 1",
499 mysql_real_escape_string($stats));
500 if (! @mysql_query($SQL, $db)) {
501 reportError("8", __("An error occured setting anonymous statistics.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error());
502 }
503 $SQL = "UPDATE `setting` SET `value` = '" . md5(uniqid(rand(), true)) . "' WHERE `setting`.`setting` = 'PHONE_HOME_KEY' LIMIT 1";
504 if (! @mysql_query($SQL, $db)) {
505 reportError("8", __("An error occured setting anonymous statistics.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error());
506 }
507
508 @mysql_close($db);
509
510 ?>
511 <div class="info">
512 <p><?php echo __("Successfully set library location and server key."); ?></p>
513 </div>
514 <form action="install.php" method="POST">
515 <input type="hidden" name="xibo_step" value="10" />
516 <button type="submit"><?php echo __("Next"); ?> ></button>
517 </form>
518 <?php
519}
520elseif ($xibo_step == 10) {
521# Delete install.php
522# Redirect to login page.
523 if (! unlink('install.php')) {
524 reportError("10", __("Unable to delete install.php. Please ensure the webserver has permission to unlink this file and retry"), __("Retry")); // Fixme : translate "Retry" ?
525 }
526 if (! unlink('upgrade.php')) {
527 reportError("10", __("Unable to delete upgrade.php. Please ensure the webserver has permission to unlink this file and retry"), __("Retry")); // Fixme : translate "Retry" ?
528 }
529 ?>
530 <div class="info">
531 <p><b><?php echo __("Xibo was successfully installed."); ?></b></p>
532 <p><?php echo __("Please click"); ?>&nbsp;<a href="index.php"><?php echo __("here"); ?></a>&nbsp;<?php echo __("to logon to Xibo as \"xibo_admin\" with the password you chose earlier."); ?></p>
533 </div>
534 <?php
535}
536else {
537 reportError("0", __("A required parameter was missing. Please go through the installer sequentially!"), __("Start Again")); // Fixme : translate "Start Again" ?
538}
539
540include('install/footer.inc');
541
542# Functions
543function checkFsPermissions() {
544 # Check for appropriate filesystem permissions
545 return ((is_writable("install.php") && (is_writable("settings.php")) && (is_writable("upgrade.php")) || is_writable(".")));
546}
547
548function checkMySQL() {
549 # Check PHP has MySQL module installed
550 return extension_loaded("mysql");
551}
552
553function checkJson() {
554 # Check PHP has JSON module installed
555 return extension_loaded("json");
556}
557
558function checkGd() {
559 # Check PHP has JSON module installed
560 return extension_loaded("gd");
561}
562
563function checkCal() {
564 # Check PHP has JSON module installed
565 return extension_loaded("calendar");
566}
567
568function reportError($step, $message, $button_text="&lt; Back") { // fixme : translate ?
569?>
570 <div class="info">
571 <?php print $message; ?>
572 </div>
573 <form action="install.php" method="POST">
574 <input type="hidden" name="xibo_step" value="<?php print $step; ?>"/>
575 <button type="submit"><?php print $button_text; ?></button>
576 </form>
577 <?php
578 include('install/footer.inc');
579 die();
580}
581
582// Taken from http://forums.devshed.com/php-development-5/php-wont-load-sql-from-file-515902.html
583// By Crackster
584/**
585 * remove_remarks will strip the sql comment lines out of an uploaded sql file
586 */
587function remove_remarks($sql){
588 $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^[-].*$/m', "\n", $sql));
589 $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
590 return $sql;
591}
592
593// Taken from http://forums.devshed.com/php-development-5/php-wont-load-sql-from-file-515902.html
594// By Crackster
595/**
596 * split_sql_file will split an uploaded sql file into single sql statements.
597 * Note: expects trim() to have already been run on $sql.
598 */
599function split_sql_file($sql, $delimiter){
600 $sql = str_replace("\r" , '', $sql);
601 $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql);
602 $data = array_map('trim', $data);
603 // The empty case
604 $end_data = end($data);
605 if (empty($end_data))
606 {
607 unset($data[key($data)]);
608 }
609 return $data;
610}
611
612/**
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
614 * all files in that folder.
615 * Link : http://www.bin-co.com/php/scripts/filesystem/ls/
616 * License : BSD
617 * Arguments : $pattern - The pattern to look out for [OPTIONAL]
618 * $folder - The path of the directory of which's directory list you want [OPTIONAL]
619 * $recursivly - The funtion will traverse the folder tree recursivly if this is true. Defaults to false. [OPTIONAL]
620 * $options - An array of values 'return_files' or 'return_folders' or both
621 * Returns : A flat list with the path of all the files(no folders) that matches the condition given.
622 */
623function ls($pattern="*", $folder="", $recursivly=false, $options=array('return_files','return_folders')) {
624 if($folder) {
625 $current_folder = realpath('.');
626 if(in_array('quiet', $options)) { // If quiet is on, we will suppress the 'no such folder' error
627 if(!file_exists($folder)) return array();
628 }
629
630 if(!chdir($folder)) return array();
631 }
632
633
634 $get_files = in_array('return_files', $options);
635 $get_folders= in_array('return_folders', $options);
636 $both = array();
637 $folders = array();
638
639 // Get the all files and folders in the given directory.
640 if($get_files) $both = glob($pattern, GLOB_BRACE + GLOB_MARK);
641 if($recursivly or $get_folders) $folders = glob("*", GLOB_ONLYDIR + GLOB_MARK);
642
643 //If a pattern is specified, make sure even the folders match that pattern.
644 $matching_folders = array();
645 if($pattern !== '*') $matching_folders = glob($pattern, GLOB_ONLYDIR + GLOB_MARK);
646
647 //Get just the files by removing the folders from the list of all files.
648 $all = array_values(array_diff($both,$folders));
649
650 if($recursivly or $get_folders) {
651 foreach ($folders as $this_folder) {
652 if($get_folders) {
653 //If a pattern is specified, make sure even the folders match that pattern.
654 if($pattern !== '*') {
655 if(in_array($this_folder, $matching_folders)) array_push($all, $this_folder);
656 }
657 else array_push($all, $this_folder);
658 }
659
660 if($recursivly) {
661 // Continue calling this function for all the folders
662 $deep_items = ls($pattern, $this_folder, $recursivly, $options); # :RECURSION:
663 foreach ($deep_items as $item) {
664 array_push($all, $this_folder . $item);
665 }
666 }
667 }
668 }
669
670 if($folder) chdir($current_folder);
671 return $all;
672}
673
674function gen_secret() {
675 # Generates a random 12 character alphanumeric string to use as a salt
676 mt_srand((double)microtime()*1000000);
677 $key = "";
678 for ($i=0; $i < 12; $i++) {
679 $c = mt_rand(0,2);
680 if ($c == 0) {
681 $key .= chr(mt_rand(65,90));
682 }
683 elseif ($c == 1) {
684 $key .= chr(mt_rand(97,122));
685 }
686 else {
687 $key .= chr(mt_rand(48,57));
688 }
689 }
690
691 return $key;
692}
693
694function checkPHP()
695{
696 return (version_compare("5.2.4",phpversion(), "<="));
697}
698
699function CheckGettext()
700{
701 return extension_loaded("gettext");
702}
703
704// Setup the translations for gettext
705function __($string)
706{
707 if (CheckGettext())
708 {
709 return _($string);
710 }
711 else
712 {
713 return $string;
714 }
715}
716
717function settings_strings() {
718global $settings_header;
719global $settings_footer;
720
721 $settings_header = <<<END
722<?php
723
724/*
725 * Xibo - Digital Signage - http://www.xibo.org.uk
726 *
727 * This file is part of Xibo - and is automatically generated by the installer
728 *
729 * You should not need to edit this file, unless your SQL connection details have changed.
730 */
731
732defined('XIBO') or die(__("Sorry, you are not allowed to directly access this page.") . "<br />" . __("Please press the back button in your browser."));
733
734global \$dbhost;
735global \$dbuser;
736global \$dbpass;
737global \$dbname;
738
739
740END;
741
742$settings_footer = <<<END
743?>
744END;
745
746 return;
747}
748?>
7490
=== modified file 'server/install/database/46.php'
--- server/install/database/46.php 2013-08-21 09:07:09 +0000
+++ server/install/database/46.php 2014-03-29 13:09:24 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
2include('lib/data/data.class.php');2include_once('lib/data/data.class.php');
3include('lib/data/campaign.data.class.php');3include_once('lib/data/campaign.data.class.php');
4include('lib/data/campaignsecurity.data.class.php');4include_once('lib/data/campaignsecurity.data.class.php');
55
6class Step46 extends UpgradeStep6class Step46 extends UpgradeStep
7{7{
88
=== modified file 'server/install/database/66.sql'
--- server/install/database/66.sql 2014-02-16 13:43:52 +0000
+++ server/install/database/66.sql 2014-03-29 13:09:24 +0000
@@ -90,9 +90,9 @@
90`userChange`90`userChange`
91)91)
92VALUES (92VALUES (
93NULL , 'SETTING_IMPORT_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0'93NULL , 'SETTING_IMPORT_ENABLED', 'On', 'dropdown', NULL , 'On|Off', 'general', '1'
94), (94), (
95NULL , 'SETTING_LIBRARY_TIDY_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0'95NULL , 'SETTING_LIBRARY_TIDY_ENABLED', 'On', 'dropdown', NULL , 'On|Off', 'general', '1'
96), (96), (
97NULL, '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');97NULL, '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');
9898
9999
=== added file 'server/install/database/67.sql'
--- server/install/database/67.sql 1970-01-01 00:00:00 +0000
+++ server/install/database/67.sql 2014-03-29 13:09:24 +0000
@@ -0,0 +1,30 @@
1ALTER TABLE `module` ADD `assignable` TINYINT NOT NULL DEFAULT '1';
2
3INSERT 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');
4
5ALTER TABLE `media` CHANGE `type` `type` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
6
7CREATE TABLE IF NOT EXISTS `lkmediadisplaygroup` (
8 `id` int(11) NOT NULL AUTO_INCREMENT,
9 `mediaid` int(11) NOT NULL,
10 `displaygroupid` int(11) NOT NULL,
11 PRIMARY KEY (`id`)
12) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='File associations directly to Display Groups' AUTO_INCREMENT=1 ;
13
14ALTER TABLE `display` ADD `version_instructions` VARCHAR( 255 ) NULL,
15 ADD `client_type` VARCHAR( 20 ) NULL ,
16 ADD `client_version` VARCHAR( 5 ) NULL ,
17 ADD `client_code` SMALLINT NULL;
18
19INSERT INTO `help` (`HelpID`, `Topic`, `Category`, `Link`) VALUES
20(1, 'DisplayGroup', 'FileAssociations', 'manual/single.php?p=admin/fileassociations');
21
22INSERT INTO `setting` (`settingid`, `setting`, `value`, `type`, `helptext`, `options`, `cat`, `userChange`)
23 VALUES
24 (NULL, 'PROXY_HOST', '', 'text', 'The Proxy URL', NULL, 'general', '1'),
25 (NULL, 'PROXY_PORT', '', 'text', 'The Proxy Port', NULL, 'general', '1'),
26 (NULL, 'PROXY_AUTH', '', 'text', 'The Authentication information for this proxy. username:password', NULL, 'general', '1');
27
28UPDATE `version` SET `app_ver` = '1.6.0', `XmdsVersion` = 3;
29UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
30UPDATE `version` SET `DBVersion` = '67';
031
=== modified file 'server/install/master/data.sql'
--- server/install/master/data.sql 2014-02-16 13:43:52 +0000
+++ server/install/master/data.sql 2014-03-29 13:09:24 +0000
@@ -1,5 +1,5 @@
1INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES1INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES
2('1.6.0-rc1', 3, 1, 66);2('1.6.0', 3, 1, 67);
33
4INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`) VALUES4INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`) VALUES
5(1, 'Users', 0, 0),5(1, 'Users', 0, 0),
@@ -83,7 +83,8 @@
83(77, 'Transition', 'Edit', 'manual/single.php?p=layout/transitions'),83(77, 'Transition', 'Edit', 'manual/single.php?p=layout/transitions'),
84(78, 'User', 'SetPassword', 'manual/single.php?p=users/users#Set_Password'),84(78, 'User', 'SetPassword', 'manual/single.php?p=users/users#Set_Password'),
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'),
86(80, 'Statusdashboard', 'General', 'manual/single.php?p=coreconcepts/dashboard#Status_Dashboard');86(80, 'DisplayGroup', 'FileAssociations', 'manual/single.php?p=admin/fileassociations'),
87(81, 'Statusdashboard', 'General', 'manual/single.php?p=coreconcepts/dashboard#Status_Dashboard');
8788
88INSERT INTO `menu` (`MenuID`, `Menu`) VALUES89INSERT INTO `menu` (`MenuID`, `Menu`) VALUES
89(8, 'Administration Menu'),90(8, 'Administration Menu'),
@@ -107,7 +108,8 @@
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),
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),
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),
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),
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);
111113
112INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES114INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES
113(1, 'Schedule'),115(1, 'Schedule'),
@@ -258,7 +260,10 @@
258(67, 'SETTING_IMPORT_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0'), 260(67, 'SETTING_IMPORT_ENABLED', 'Off', 'dropdown', NULL , 'On|Off', 'general', '0'),
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'),
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'),
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'),
264(71, 'PROXY_HOST', '', 'text', 'The Proxy URL' , NULL, 'general', '1'),
265(72, 'PROXY_PORT', '', 'text', 'The Proxy Port' , NULL, 'general', '1'),
266(73, 'PROXY_AUTH', '', 'text', 'The Authentication information for this proxy. username:password' , NULL, 'general', '1');
262267
263INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES268INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES
264(1, 'Super Admin'),269(1, 'Super Admin'),
265270
=== modified file 'server/install/master/structure.sql'
--- server/install/master/structure.sql 2014-02-12 18:11:45 +0000
+++ server/install/master/structure.sql 2014-03-29 13:09:24 +0000
@@ -85,6 +85,10 @@
85 `SecureOn` varchar(17) DEFAULT NULL,85 `SecureOn` varchar(17) DEFAULT NULL,
86 `Cidr` smallint(6) DEFAULT NULL,86 `Cidr` smallint(6) DEFAULT NULL,
87 `GeoLocation` POINT NULL,87 `GeoLocation` POINT NULL,
88 `version_instructions` varchar(255) NULL,
89 `client_type` VARCHAR( 20 ) NULL ,
90 `client_version` VARCHAR( 5 ) NULL ,
91 `client_code` SMALLINT NULL,
88 PRIMARY KEY (`displayid`),92 PRIMARY KEY (`displayid`),
89 KEY `defaultplaylistid` (`defaultlayoutid`)93 KEY `defaultplaylistid` (`defaultlayoutid`)
90) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;94) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
@@ -303,7 +307,7 @@
303CREATE TABLE IF NOT EXISTS `media` (307CREATE TABLE IF NOT EXISTS `media` (
304 `mediaID` int(11) NOT NULL AUTO_INCREMENT,308 `mediaID` int(11) NOT NULL AUTO_INCREMENT,
305 `name` varchar(100) NOT NULL,309 `name` varchar(100) NOT NULL,
306 `type` varchar(10) NOT NULL,310 `type` varchar(15) NOT NULL,
307 `duration` int(11) NOT NULL,311 `duration` int(11) NOT NULL,
308 `originalFilename` varchar(254) DEFAULT NULL,312 `originalFilename` varchar(254) DEFAULT NULL,
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',
@@ -349,6 +353,7 @@
349 `SchemaVersion` int(11) NOT NULL DEFAULT '1',353 `SchemaVersion` int(11) NOT NULL DEFAULT '1',
350 `ValidExtensions` varchar(254) DEFAULT NULL,354 `ValidExtensions` varchar(254) DEFAULT NULL,
351 `PreviewEnabled` tinyint(4) NOT NULL DEFAULT '1',355 `PreviewEnabled` tinyint(4) NOT NULL DEFAULT '1',
356 `assignable` tinyint(4) NOT NULL DEFAULT '1',
352 PRIMARY KEY (`ModuleID`)357 PRIMARY KEY (`ModuleID`)
353) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Functional Modules' AUTO_INCREMENT=14 ;358) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Functional Modules' AUTO_INCREMENT=14 ;
354359
@@ -589,6 +594,14 @@
589 `DataSetColumnType` varchar(100) NOT NULL594 `DataSetColumnType` varchar(100) NOT NULL
590) ENGINE=InnoDB DEFAULT CHARSET=utf8;595) ENGINE=InnoDB DEFAULT CHARSET=utf8;
591596
597
598CREATE TABLE IF NOT EXISTS `lkmediadisplaygroup` (
599 `id` int(11) NOT NULL AUTO_INCREMENT,
600 `mediaid` int(11) NOT NULL,
601 `displaygroupid` int(11) NOT NULL,
602 PRIMARY KEY (`id`)
603) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='File associations directly to Display Groups' AUTO_INCREMENT=1 ;
604
592--605--
593-- Constraints for dumped tables606-- Constraints for dumped tables
594--607--
595608
=== modified file 'server/lib/app/kit.class.php'
--- server/lib/app/kit.class.php 2014-02-15 11:25:09 +0000
+++ server/lib/app/kit.class.php 2014-03-29 13:09:24 +0000
@@ -34,6 +34,7 @@
34define('_BOOLEAN', "bool");34define('_BOOLEAN', "bool");
35define('_WORD', "word");35define('_WORD', "word");
36define('_ARRAY', "array");36define('_ARRAY', "array");
37define('_ARRAY_INT', "array_int");
37define('_USERNAME', "username");38define('_USERNAME', "username");
38define('_CHECKBOX', "checkbox");39define('_CHECKBOX', "checkbox");
39define('_FILENAME', "filename");40define('_FILENAME', "filename");
@@ -77,7 +78,7 @@
77 * @param $type Object[optional]78 * @param $type Object[optional]
78 * @param $default Object[optional]79 * @param $default Object[optional]
79 */80 */
80 static public function GetParam($param, $source = _POST, $type = _STRING, $default = '')81 static public function GetParam($param, $source = _POST, $type = _STRING, $default = '', $sanitize = true)
81 {82 {
82 // lower case param (we dont care)83 // lower case param (we dont care)
83 $param = strtolower($param);84 $param = strtolower($param);
@@ -204,7 +205,7 @@
204 }205 }
205 206
206 // Validate this param 207 // Validate this param
207 return Kit::ValidateParam($return, $type);208 return Kit::ValidateParam($return, $type, $sanitize);
208 }209 }
209 210
210 /**211 /**
@@ -214,9 +215,13 @@
214 * @param $param Object215 * @param $param Object
215 * @param $type Object216 * @param $type Object
216 */217 */
217 static function ValidateParam($param, $type)218 static function ValidateParam($param, $type, $sanitize = true)
218 {219 {
219 // If we are a NULL always return a null220 // If we are a NULL always return a null??
221 //if ($param == NULL || $param == '')
222 // return NULL;
223
224 // Store in return var
220 $return = $param;225 $return = $param;
221 226
222 // Validate227 // Validate
@@ -224,30 +229,35 @@
224 switch ($type)229 switch ($type)
225 {230 {
226 case _INT :231 case _INT :
227 // Only use the first integer value232
228 if ($return == '')233 if ($sanitize) {
229 return 0;234 // Only use the first integer value
230 235 if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_INT))
231 if (preg_match('/-?[0-9]+/', $return, $matches) == 0)236 $return = 0;
232 trigger_error(sprintf(__('No integer match found for %s, and return value is not an int'), $param), E_USER_ERROR);237 }
233238 else {
234 $return = @ (int) $matches[0];239 if (!$return = filter_var($return, FILTER_VALIDATE_INT))
240 trigger_error(sprintf(__('No integer match found for [%s] and return value is not an integer'), $param), E_USER_ERROR);
241 }
242
235 break;243 break;
236244
237 case _DOUBLE :245 case _DOUBLE :
238 if ($return == '')
239 {
240 $return = 0;
241 break;
242 }
243 246
244 // Only use the first floating point value247 if ($sanitize) {
245 @ preg_match('/-?[0-9]+(\.[0-9]+)?/', $return, $matches);248 // Only use the first integer value
246 $return = @ (float) $matches[0];249 if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION))
250 $return = 0;
251 }
252 else {
253 if (!$return = filter_var($return, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_FRACTION))
254 trigger_error(sprintf(__('No integer match found for %s, and return value is not an integer'), $param), E_USER_ERROR);
255 }
256
247 break;257 break;
248258
249 case _BOOL :259 case _BOOL :
250 $return = (bool) $return;260 $return = filter_var($return, FILTER_VALIDATE_BOOLEAN);
251 break;261 break;
252262
253 case _ARRAY :263 case _ARRAY :
@@ -259,67 +269,55 @@
259 269
260 if (!is_array($return)) 270 if (!is_array($return))
261 {271 {
262 $return = array ($return);272 $return = array($return);
273 }
274 break;
275
276 case _ARRAY_INT:
277
278 if ($return == '') {
279 $return = array();
280 }
281 else {
282 if ($sanitize) {
283 // Only use the first integer value
284 if (!$return = filter_var_array($return, FILTER_SANITIZE_NUMBER_INT))
285 $return = array();
286 }
287 else {
288 if (!$return = filter_var_array($return, FILTER_VALIDATE_INT))
289 trigger_error(sprintf(__('No integer found for %s, and return value is not an integer'), $param), E_USER_ERROR);
290 }
263 }291 }
264 break;292 break;
265293
266 case _STRING :294 case _STRING :
267 if ($return == '')
268 {
269 $return = '';
270 break;
271 }
272
273 $return = preg_replace('/&#(\d+);/me', "chr(\\1)", $return); // decimal notation
274 // convert hex
275 $return = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $return); // hex notation
276 $return = htmlspecialchars($return);
277 $return = (string) $return;
278 break;
279
280 case _PASSWORD :295 case _PASSWORD :
281 if ($return == '')296 $return = filter_var($return, FILTER_SANITIZE_STRING);
282 {
283 $return = '';
284 break;
285 }
286
287 $return = preg_replace('/&#(\d+);/me', "chr(\\1)", $return); // decimal notation
288 // convert hex
289 $return = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $return); // hex notation
290 $return = (string) $return;
291 break;297 break;
292 298
293 case _HTMLSTRING :299 case _HTMLSTRING :
294 if ($return == '')
295 {
296 $return = '';
297 break;
298 }
299 300
300 $return = preg_replace('/&#(\d+);/me', "chr(\\1)", $return); // decimal notation301 // decimal notation
302 $return = preg_replace_callback('/&#(\d+);/m', function($m){
303 return chr($m[1]);
304 }, $return);
305
301 // convert hex306 // convert hex
302 $return = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $return); // hex notation307 $return = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){
308 return chr("0x".$m[1]);
309 }, $return);
310
303 $return = (string) $return;311 $return = (string) $return;
304 break;312 break;
305313
306 case _WORD :314 case _WORD :
307 if ($return == '')315 $return = filter_var($return, FILTER_SANITIZE_STRING);
308 {
309 $return = '';
310 break;
311 }
312
313 $return = (string) preg_replace( '/[^A-Z_\-]/i', '', $return );316 $return = (string) preg_replace( '/[^A-Z_\-]/i', '', $return );
314 break;317 break;
315 318
316 case _USERNAME :319 case _USERNAME :
317 if ($return == '')320 $return = filter_var($return, FILTER_SANITIZE_STRING);
318 {
319 $return = '';
320 break;
321 }
322
323 $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return );321 $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return );
324 $return = strtolower($return);322 $return = strtolower($return);
325 break;323 break;
@@ -353,6 +351,9 @@
353351
354 default :352 default :
355 // No casting necessary353 // No casting necessary
354 if (!$sanitize)
355 trigger_error(sprintf(__('Unknown Type %s'), $type), E_USER_ERROR);
356
356 break;357 break;
357 }358 }
358 359
@@ -629,5 +630,9 @@
629630
630 return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];631 return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
631 }632 }
633
634 public static function uniqueId() {
635 return uniqid(rand());
636 }
632}637}
633?>638?>
634639
=== modified file 'server/lib/app/modulemanager.class.php'
--- server/lib/app/modulemanager.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/app/modulemanager.class.php 2014-03-29 13:09:24 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
2/*2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2006-2012 Daniel Garner4 * Copyright (C) 2006-2014 Daniel Garner
5 *5 *
6 * This file is part of Xibo.6 * This file is part of Xibo.
7 *7 *
@@ -22,84 +22,84 @@
2222
23class ModuleManager23class ModuleManager
24{24{
25 private $db;25 private $db;
26 private $user;26 private $user;
27 27
28 public $message;28 public $message;
29 29
30 private $theMenu;30 private $theMenu;
31 private $current;31 private $current;
32 private $numberItems;32 private $numberItems;
33 33
34 /**34 /**
35 * Constructs the Module Manager.35 * Constructs the Module Manager.
36 * @return 36 * @return
37 * @param $db Object37 * @param $db Object
38 * @param $user Object38 * @param $user Object
39 */39 */
40 public function __construct(database $db, User $user, $regionSpecific = -1, $module = '')40 public function __construct(database $db, User $user, $regionSpecific = -1, $module = '', $assignable = 1)
41 {41 {
42 $this->db =& $db;42 $this->db =& $db;
43 $this->user =& $user;43 $this->user =& $user;
44 44
45 if (!$this->theMenu = $user->ModuleAuth($regionSpecific, $module))45 if (!$this->theMenu = $user->ModuleAuth($regionSpecific, $module, $assignable))
46 {46 {
47 $this->message = 'No enabled modules.';47 $this->message = 'No enabled modules.';
48 return false;48 return false;
49 }49 }
5050
51 // Set some information about this menu 51 // Set some information about this menu
52 $this->current = 0;52 $this->current = 0;
53 $this->numberItems = count($this->theMenu);53 $this->numberItems = count($this->theMenu);
54 54
55 // We dont want to do 0 items55 // We dont want to do 0 items
56 if ($this->numberItems == 0) $this->numberItems = -1;56 if ($this->numberItems == 0) $this->numberItems = -1;
57 57
58 $this->message = $this->numberItems . ' modules loaded';58 $this->message = $this->numberItems . ' modules loaded';
5959
60 return true;60 return true;
61 }61 }
62 62
63 /**63 /**
64 * Returns the internal message64 * Returns the internal message
65 * @return 65 * @return
66 */66 */
67 public function GetMessage()67 public function GetMessage()
68 {68 {
69 return $this->message;69 return $this->message;
70 }70 }
71 71
72 /**72 /**
73 * Gets the next menu item in the queue73 * Gets the next menu item in the queue
74 * @return 74 * @return
75 */75 */
76 public function GetNextModule()76 public function GetNextModule()
77 {77 {
78 if (!$item = $this->GetModule($this->current))78 if (!$item = $this->GetModule($this->current))
79 {79 {
80 $message = 'No more modules.';80 $message = 'No more modules.';
81 return false;81 return false;
82 }82 }
83 83
84 $this->current++;84 $this->current++;
85 85
86 return $item;86 return $item;
87 }87 }
88 88
89 /**89 /**
90 * Gets the menu item at position i90 * Gets the menu item at position i
91 * @return 91 * @return
92 * @param $i Object92 * @param $i Object
93 */93 */
94 public function GetModule($i)94 public function GetModule($i)
95 {95 {
96 if ($i >= $this->numberItems)96 if ($i >= $this->numberItems)
97 {97 {
98 $this->message = 'There are only ' . $this->numberItems . ' modules.';98 $this->message = 'There are only ' . $this->numberItems . ' modules.';
99 return false;99 return false;
100 }100 }
101 101
102 return $this->theMenu[$i];102 return $this->theMenu[$i];
103 }103 }
104}104}
105?>105?>
106106
=== modified file 'server/lib/app/pagemanager.class.php'
--- server/lib/app/pagemanager.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/app/pagemanager.class.php 2014-03-29 13:09:24 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
2/*2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2006-2013 Daniel Garner4 * Copyright (C) 2006-2014 Daniel Garner
5 *5 *
6 * This file is part of Xibo.6 * This file is part of Xibo.
7 *7 *
@@ -52,7 +52,7 @@
52 $this->q = Kit::GetParam('q', _REQUEST, _WORD);52 $this->q = Kit::GetParam('q', _REQUEST, _WORD);
53 $this->userid = $this->user->userid;53 $this->userid = $this->user->userid;
54 54
55 // Default not authourised55 // Default not authorised
56 $this->authed = false;56 $this->authed = false;
5757
58 // Create a theme58 // Create a theme
@@ -94,11 +94,13 @@
94 $user =& $this->user;94 $user =& $this->user;
9595
96 if (!$this->authed)96 if (!$this->authed)
97 {97 throw new Exception(__('You do not have permission to access this page.'));
98 // Output some message to say that we are not authed98
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
100 exit;100 // this check should be redundant, because the page should have been validated against the pages in the DB first.
101 }101 // do it just in case...
102 if (!file_exists($this->path))
103 throw new Exception(__('The requested page does not exist'));
102 104
103 // Load the file in question105 // Load the file in question
104 if (!class_exists($this->page)) 106 if (!class_exists($this->page))
105107
=== modified file 'server/lib/app/thememanager.class.php'
--- server/lib/app/thememanager.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/app/thememanager.class.php 2014-03-29 13:09:24 +0000
@@ -173,15 +173,18 @@
173 $return = null;173 $return = null;
174 else174 else
175 $return = $theme->vars[$key];175 $return = $theme->vars[$key];
176176
177 if ($key == 'form_meta') {177 if ($key == 'form_meta') {
178 // Append a token to the end178 // Append a token to the end
179 $return = $return . Kit::Token();179 $return = $return . Kit::Token();
180 }180 }
181
182 return $return;181 return $return;
183 }182 }
184183
184 public static function Prepare($string) {
185 return htmlspecialchars($string);
186 }
187
185 public static function SetPagename($pageName) {188 public static function SetPagename($pageName) {
186 Theme::GetInstance()->pageName = $pageName;189 Theme::GetInstance()->pageName = $pageName;
187 }190 }
188191
=== modified file 'server/lib/data/display.data.class.php'
--- server/lib/data/display.data.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/data/display.data.class.php 2014-03-29 13:09:24 +0000
@@ -321,12 +321,17 @@
321 }321 }
322 322
323 /**323 /**
324 * Sets the information required on the display to indicate324 * Sets the information required on the display to indicate that it is still logged in
325 * that it is still logged in325 * @param string $license The display licence key
326 * @return 326 * @param string $clientAddress The client IP address
327 * @param $license Object327 * @param integer $mediaInventoryComplete The Media Inventory Status
328 */328 * @param string $mediaInventoryXml The Media Inventory XML
329 public function Touch($license, $clientAddress = '', $mediaInventoryComplete = 0, $mediaInventoryXml = '', $macAddress = '')329 * @param string $macAddress The Client Mac Address
330 * @param string $clientType The Client Type
331 * @param string $clientVersion The Client Version
332 * @param integer $clientCode The Client Version Code
333 */
334 public function Touch($license, $clientAddress = '', $mediaInventoryComplete = 0, $mediaInventoryXml = '', $macAddress = '', $clientType = '', $clientVersion = '', $clientCode = 0)
330 {335 {
331 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Touch');336 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Touch');
332 337
@@ -359,6 +364,22 @@
359 $params['mediainventoryxml'] = $mediaInventoryXml;364 $params['mediainventoryxml'] = $mediaInventoryXml;
360 }365 }
361366
367 // Client information if present
368 if ($clientType != '') {
369 $SQL .= " , client_type = :client_type ";
370 $params['client_type'] = $clientType;
371 }
372
373 if ($clientVersion != '') {
374 $SQL .= " , client_version = :client_version ";
375 $params['client_version'] = $clientVersion;
376 }
377
378 if ($clientCode != '') {
379 $SQL .= " , client_code = :client_code ";
380 $params['client_code'] = $clientCode;
381 }
382
362 // Mac address storage383 // Mac address storage
363 if ($macAddress != '')384 if ($macAddress != '')
364 {385 {
@@ -402,7 +423,7 @@
402 * Flags a display as being incomplete423 * Flags a display as being incomplete
403 * @param <type> $displayId424 * @param <type> $displayId
404 */425 */
405 private function FlagIncomplete($displayId)426 public function FlagIncomplete($displayId)
406 {427 {
407 Debug::LogEntry('audit', sprintf('Flag DisplayID %d incomplete.', $displayId), 'display', 'NotifyDisplays');428 Debug::LogEntry('audit', sprintf('Flag DisplayID %d incomplete.', $displayId), 'display', 'NotifyDisplays');
408429
@@ -508,6 +529,37 @@
508 }529 }
509 }530 }
510531
532 public function SetVersionInstructions($displayId, $mediaId, $storedAs) {
533 Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
534
535 try {
536 $dbh = PDOConnect::init();
537
538 // Set the instructions
539 $version_instructions = array();
540 $version_instructions['id'] = $mediaId;
541 $version_instructions['file'] = $storedAs;
542
543 $sth = $dbh->prepare('UPDATE `display` SET version_instructions = :version_instructions WHERE displayid = :displayid');
544 $sth->execute(array(
545 'displayid' => $displayId,
546 'version_instructions' => json_encode($version_instructions)
547 ));
548
549 return true;
550 }
551 catch (Exception $e) {
552
553 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
554
555 if (!$this->IsError())
556 $this->SetError(1, __('Unknown Error'));
557
558 return false;
559 }
560
561 }
562
511 /**563 /**
512 * Wake this display using a WOL command564 * Wake this display using a WOL command
513 * @param <int> $displayId565 * @param <int> $displayId
@@ -560,11 +612,11 @@
560 /**612 /**
561 * Wake On Lan Script613 * Wake On Lan Script
562 * // Version: 2614 * // Version: 2
563 // Author of this application:615 * // Author of this application:
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)
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.
566 // More info: http://wolviaphp.sourceforge.net618 * // More info: http://wolviaphp.sourceforge.net
567 // License: GPLv2.0619 * // License: GPLv2.0
568 *620 *
569 * Modified for use with the Xibo project by Dan Garner.621 * Modified for use with the Xibo project by Dan Garner.
570 */622 */
571623
=== modified file 'server/lib/data/displaygroup.data.class.php'
--- server/lib/data/displaygroup.data.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/data/displaygroup.data.class.php 2014-03-29 13:09:24 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
2/*2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2009-13 Daniel Garner4 * Copyright (C) 2009-14 Daniel Garner
5 *5 *
6 * This file is part of Xibo.6 * This file is part of Xibo.
7 *7 *
@@ -22,36 +22,36 @@
2222
23class DisplayGroup extends Data23class DisplayGroup extends Data
24{24{
25 public function __construct(database $db)25 public function __construct(database $db)
26 {26 {
27 include_once('lib/data/schedule.data.class.php');27 include_once('lib/data/schedule.data.class.php');
28 include_once('lib/data/displaygroupsecurity.data.class.php');28 include_once('lib/data/displaygroupsecurity.data.class.php');
29 29
30 parent::__construct($db);30 parent::__construct($db);
31 }31 }
32 32
33 /**33 /**
34 * Adds a Display Group to Xibo34 * Adds a Display Group to Xibo
35 * @return 35 * @return
36 * @param $displayGroup string36 * @param $displayGroup string
37 * @param $isDisplaySpecific int37 * @param $isDisplaySpecific int
38 * @param $description string[optional]38 * @param $description string[optional]
39 */39 */
40 public function Add($displayGroup, $isDisplaySpecific, $description = '')40 public function Add($displayGroup, $isDisplaySpecific, $description = '')
41 {41 {
42 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Add');42 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Add');
4343
44 try {44 try {
45 $dbh = PDOConnect::init();45 $dbh = PDOConnect::init();
4646
47 // Validation47 // Validation
48 if ($displayGroup == '')48 if ($displayGroup == '')
49 $this->ThrowError(__('Please enter a display group name'));49 $this->ThrowError(__('Please enter a display group name'));
50 50
51 if (strlen($description) > 254) 51 if (strlen($description) > 254)
52 $this->ThrowError(__("Description can not be longer than 254 characters"));52 $this->ThrowError(__("Description can not be longer than 254 characters"));
5353
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');
55 $sth->execute(array(55 $sth->execute(array(
56 'displaygroup' => $displayGroup56 'displaygroup' => $displayGroup
57 ));57 ));
@@ -59,10 +59,10 @@
59 if ($row = $sth->fetch())59 if ($row = $sth->fetch())
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));
6161
62 // End Validation62 // End Validation
63 63
64 // Insert the display group64 // Insert the display group
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)');
66 $sth->execute(array(66 $sth->execute(array(
67 'displaygroup' => $displayGroup,67 'displaygroup' => $displayGroup,
68 'isdisplayspecific' => $isDisplaySpecific,68 'isdisplayspecific' => $isDisplaySpecific,
@@ -70,11 +70,11 @@
70 ));70 ));
7171
72 $displayGroupID = $dbh->lastInsertId();72 $displayGroupID = $dbh->lastInsertId();
73 73
74 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Add');74 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Add');
7575
76 return $displayGroupID;76 return $displayGroupID;
77 }77 }
78 catch (Exception $e) {78 catch (Exception $e) {
7979
80 Debug::LogEntry('error', $e->getMessage());80 Debug::LogEntry('error', $e->getMessage());
@@ -84,33 +84,33 @@
8484
85 return false;85 return false;
86 }86 }
87 }87 }
88 88
89 /**89 /**
90 * Edits an existing Xibo Display Group90 * Edits an existing Xibo Display Group
91 * @return 91 * @return
92 * @param $displayGroupID Object92 * @param $displayGroupID Object
93 * @param $displayGroup Object93 * @param $displayGroup Object
94 * @param $description Object94 * @param $description Object
95 */95 */
96 public function Edit($displayGroupID, $displayGroup, $description)96 public function Edit($displayGroupID, $displayGroup, $description)
97 {97 {
98 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Edit');98 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Edit');
9999
100 try {100 try {
101 $dbh = PDOConnect::init();101 $dbh = PDOConnect::init();
102102
103 // Validation103 // Validation
104 if ($displayGroupID == 0) 104 if ($displayGroupID == 0)
105 $this->ThrowError(__('No Display Group Selected'));105 $this->ThrowError(__('No Display Group Selected'));
106 106
107 if ($displayGroup == '')107 if ($displayGroup == '')
108 $this->ThrowError(__('Please enter a display group name'));108 $this->ThrowError(__('Please enter a display group name'));
109 109
110 if (strlen($description) > 254) 110 if (strlen($description) > 254)
111 $this->ThrowError(__("Description can not be longer than 254 characters"));111 $this->ThrowError(__("Description can not be longer than 254 characters"));
112112
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');
114 $sth->execute(array(114 $sth->execute(array(
115 'displaygroup' => $displayGroup,115 'displaygroup' => $displayGroup,
116 'displaygroupid' => $displayGroupID116 'displaygroupid' => $displayGroupID
@@ -118,21 +118,21 @@
118118
119 if ($row = $sth->fetch())119 if ($row = $sth->fetch())
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));
121 121
122 // End Validation122 // End Validation
123 123
124 // Update the DisplayGroup124 // Update the DisplayGroup
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');
126 $sth->execute(array(126 $sth->execute(array(
127 'displaygroup' => $displayGroup,127 'displaygroup' => $displayGroup,
128 'description' => $description,128 'description' => $description,
129 'displaygroupid' => $displayGroupID129 'displaygroupid' => $displayGroupID
130 ));130 ));
131 131
132 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Edit'); 132 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Edit');
133 133
134 return true;134 return true;
135 }135 }
136 catch (Exception $e) {136 catch (Exception $e) {
137 137
138 Debug::LogEntry('error', $e->getMessage());138 Debug::LogEntry('error', $e->getMessage());
@@ -142,36 +142,36 @@
142142
143 return false;143 return false;
144 }144 }
145 }145 }
146 146
147 /**147 /**
148 * Deletes an Xibo Display Group148 * Deletes an Xibo Display Group
149 * @return 149 * @return
150 * @param $displayGroupID Object150 * @param $displayGroupID Object
151 */151 */
152 public function Delete($displayGroupID)152 public function Delete($displayGroupID)
153 {153 {
154 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Delete');154 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Delete');
155155
156 try {156 try {
157 $dbh = PDOConnect::init();157 $dbh = PDOConnect::init();
158158
159 // Tidy up the schedule detail records.159 // Tidy up the schedule detail records.
160 $schedule = new Schedule($this->db);160 $schedule = new Schedule($this->db);
161 161
162 if (!$schedule->DeleteScheduleForDisplayGroup($displayGroupID))162 if (!$schedule->DeleteScheduleForDisplayGroup($displayGroupID))
163 throw new Exception('Unable to DeleteScheduleForDisplayGroup');163 throw new Exception('Unable to DeleteScheduleForDisplayGroup');
164164
165 // Delete the Display Group165 // Delete the Display Group
166 $sth = $dbh->prepare('DELETE FROM displaygroup WHERE DisplayGroupID = :displaygroupid');166 $sth = $dbh->prepare('DELETE FROM displaygroup WHERE DisplayGroupID = :displaygroupid');
167 $sth->execute(array(167 $sth->execute(array(
168 'displaygroupid' => $displayGroupID168 'displaygroupid' => $displayGroupID
169 ));169 ));
170170
171 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Delete');171 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Delete');
172 172
173 return true;173 return true;
174 }174 }
175 catch (Exception $e) {175 catch (Exception $e) {
176 176
177 Debug::LogEntry('error', $e->getMessage());177 Debug::LogEntry('error', $e->getMessage());
@@ -181,47 +181,54 @@
181181
182 return false;182 return false;
183 }183 }
184 }184 }
185 185
186 /**186 /**
187 * Deletes all Display Group records associated with a display.187 * Deletes all Display Group records associated with a display.
188 * @return 188 * @return
189 * @param $displayID Object189 * @param $displayID Object
190 */190 */
191 public function DeleteDisplay($displayID)191 public function DeleteDisplay($displayID)
192 {192 {
193 try {193 Kit::ClassLoader('lkmediadisplaygroup');
194
195 try {
194 $dbh = PDOConnect::init();196 $dbh = PDOConnect::init();
195 197
196 // Get the DisplaySpecific Group for this Display198 // Get the DisplaySpecific Group for this Display
197 $SQL = "";199 $SQL = "";
198 $SQL .= "SELECT displaygroup.DisplayGroupID ";200 $SQL .= "SELECT displaygroup.DisplayGroupID ";
199 $SQL .= "FROM displaygroup ";201 $SQL .= "FROM displaygroup ";
200 $SQL .= " INNER JOIN lkdisplaydg ";202 $SQL .= " INNER JOIN lkdisplaydg ";
201 $SQL .= " ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID ";203 $SQL .= " ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID ";
202 $SQL .= "WHERE displaygroup.IsDisplaySpecific = 1 ";204 $SQL .= "WHERE displaygroup.IsDisplaySpecific = 1 ";
203 $SQL .= " AND lkdisplaydg.DisplayID = :displayid";205 $SQL .= " AND lkdisplaydg.DisplayID = :displayid";
204206
205 $sth = $dbh->prepare($SQL);207 $sth = $dbh->prepare($SQL);
206 $sth->execute(array(208 $sth->execute(array(
207 'displayid' => $displayID209 'displayid' => $displayID
208 ));210 ));
209211
210 if (!$row = $sth->fetch())212 if (!$row = $sth->fetch())
211 $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display'));213 $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display'));
212 214
213 // Get the Display Group ID215 // Get the Display Group ID
214 $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT);216 $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT);
215 217
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?
217 if ($displayGroupID == 0)219 if ($displayGroupID == 0)
218 $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display'));220 $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display'));
219 221
220 // Delete the Schedule for this Display Group222 // Delete the Schedule for this Display Group
221 $scheduleObject = new Schedule($this->db);223 $scheduleObject = new Schedule($this->db);
222224
223 if (!$scheduleObject->DeleteScheduleForDisplayGroup($displayGroupID))225 if (!$scheduleObject->DeleteScheduleForDisplayGroup($displayGroupID))
224 $this->ThrowError(25006, __('Unable to delete Schedule records for this DisplayGroup.'));226 $this->ThrowError(25006, __('Unable to delete Schedule records for this DisplayGroup.'));
227
228 // Drop all current assignments
229 $link = new LkMediaDisplayGroup($this->db);
230 if (!$link->UnlinkAllFromDisplayGroup($displayGroupId))
231 $this->ThrowError(__('Unable to drop file assignments during display delete.'));
225232
226 // Unlink all Display Groups from this Display233 // Unlink all Display Groups from this Display
227 $sth = $dbh->prepare('DELETE FROM lkdisplaydg WHERE DisplayID = :displayid');234 $sth = $dbh->prepare('DELETE FROM lkdisplaydg WHERE DisplayID = :displayid');
@@ -240,8 +247,8 @@
240 // An error will already be set - so just drop out247 // An error will already be set - so just drop out
241 throw new Exception('Unable to delete');248 throw new Exception('Unable to delete');
242249
243 return true;250 return true;
244 }251 }
245 catch (Exception $e) {252 catch (Exception $e) {
246 253
247 Debug::LogEntry('error', $e->getMessage());254 Debug::LogEntry('error', $e->getMessage());
@@ -251,48 +258,48 @@
251258
252 return false;259 return false;
253 }260 }
254 }261 }
255 262
256 /**263 /**
257 * Links a Display to a Display Group264 * Links a Display to a Display Group
258 * @return 265 * @return
259 * @param $displayGroupID Object266 * @param $displayGroupID Object
260 * @param $displayID Object267 * @param $displayID Object
261 */268 */
262 public function Link($displayGroupID, $displayID)269 public function Link($displayGroupID, $displayID)
263 {270 {
264 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Link');271 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Link');
265 272
266 try {273 try {
267 $dbh = PDOConnect::init();274 $dbh = PDOConnect::init();
268 275
269 $sth = $dbh->prepare('INSERT INTO lkdisplaydg (DisplayGroupID, DisplayID) VALUES (:displaygroupid, :displayid)');276 $sth = $dbh->prepare('INSERT INTO lkdisplaydg (DisplayGroupID, DisplayID) VALUES (:displaygroupid, :displayid)');
270 $sth->execute(array(277 $sth->execute(array(
271 'displaygroupid' => $displayGroupID,278 'displaygroupid' => $displayGroupID,
272 'displayid' => $displayID279 'displayid' => $displayID
273 ));280 ));
274281
275 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Link');282 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Link');
276 283
277 return true;284 return true;
278 }285 }
279 catch (Exception $e) {286 catch (Exception $e) {
280 Debug::LogEntry('error', $e->getMessage());287 Debug::LogEntry('error', $e->getMessage());
281 return $this->SetError(25005, __('Could not Link Display Group to Display'));288 return $this->SetError(25005, __('Could not Link Display Group to Display'));
282 }289 }
283 }290 }
284 291
285 /**292 /**
286 * Unlinks a Display from a Display Group293 * Unlinks a Display from a Display Group
287 * @return 294 * @return
288 * @param $displayGroupID Object295 * @param $displayGroupID Object
289 * @param $displayID Object296 * @param $displayID Object
290 */297 */
291 public function Unlink($displayGroupID, $displayID)298 public function Unlink($displayGroupID, $displayID)
292 {299 {
293 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Unlink');300 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'Unlink');
294 301
295 try {302 try {
296 $dbh = PDOConnect::init();303 $dbh = PDOConnect::init();
297304
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');
@@ -301,75 +308,75 @@
301 'displayid' => $displayID308 'displayid' => $displayID
302 ));309 ));
303310
304 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Unlink');311 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'Unlink');
305 312
306 return true;313 return true;
307 }314 }
308 catch (Exception $e) {315 catch (Exception $e) {
309 Debug::LogEntry('error', $e->getMessage());316 Debug::LogEntry('error', $e->getMessage());
310 return $this->SetError(25007, __('Could not Unlink Display Group from Display'));317 return $this->SetError(25007, __('Could not Unlink Display Group from Display'));
311 }318 }
312 }319 }
313 320
314 /**321 /**
315 * Edits the Display Group associated with a Display322 * Edits the Display Group associated with a Display
316 * @return 323 * @return
317 * @param $displayID Object324 * @param $displayID Object
318 * @param $display Object325 * @param $display Object
319 */326 */
320 public function EditDisplayGroup($displayID, $display)327 public function EditDisplayGroup($displayID, $display)
321 {328 {
322 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'EditDisplayGroup');329 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'EditDisplayGroup');
323 330
324 try {331 try {
325 $dbh = PDOConnect::init();332 $dbh = PDOConnect::init();
326333
327 // Get the DisplayGroupID for this DisplayID334 // Get the DisplayGroupID for this DisplayID
328 $SQL = "";335 $SQL = "";
329 $SQL .= "SELECT displaygroup.DisplayGroupID ";336 $SQL .= "SELECT displaygroup.DisplayGroupID ";
330 $SQL .= "FROM displaygroup ";337 $SQL .= "FROM displaygroup ";
331 $SQL .= " INNER JOIN lkdisplaydg ";338 $SQL .= " INNER JOIN lkdisplaydg ";
332 $SQL .= " ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID ";339 $SQL .= " ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID ";
333 $SQL .= "WHERE displaygroup.IsDisplaySpecific = 1 ";340 $SQL .= "WHERE displaygroup.IsDisplaySpecific = 1 ";
334 $SQL .= " AND lkdisplaydg.DisplayID = :displayid";341 $SQL .= " AND lkdisplaydg.DisplayID = :displayid";
335 342
336 $sth = $dbh->prepare($SQL);343 $sth = $dbh->prepare($SQL);
337 $sth->execute(array(344 $sth->execute(array(
338 'displayid' => $displayID345 'displayid' => $displayID
339 ));346 ));
340347
341 if (!$row = $sth->fetch())348 if (!$row = $sth->fetch())
342 $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display'));349 $this->ThrowError(25005, __('Unable to get the DisplayGroup for this Display'));
343 350
344 // Get the Display Group ID351 // Get the Display Group ID
345 $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT);352 $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT);
346 353
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?
348 if ($displayGroupID == 0) {355 if ($displayGroupID == 0) {
349 // We should always have 1 display specific DisplayGroup for a display.356 // We should always have 1 display specific DisplayGroup for a display.
350 // Do we a) Error here and give up?357 // Do we a) Error here and give up?
351 // b) Create one and link it up?358 // b) Create one and link it up?
352 // $this->SetError(25006, __('Unable to get the DisplayGroup for this Display'));359 // $this->SetError(25006, __('Unable to get the DisplayGroup for this Display'));
353 360
354 if (!$displayGroupID = $this->Add($display, 1))361 if (!$displayGroupID = $this->Add($display, 1))
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.'));
356 363
357 // Link the Two together364 // Link the Two together
358 if (!$this->Link($displayGroupID, $displayID))365 if (!$this->Link($displayGroupID, $displayID))
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.'));
360 }367 }
361 368
362 // Update the Display group name369 // Update the Display group name
363 $sth = $dbh->prepare('UPDATE displaygroup SET DisplayGroup = :displaygroup WHERE DisplayGroupID = :displaygroupid');370 $sth = $dbh->prepare('UPDATE displaygroup SET DisplayGroup = :displaygroup WHERE DisplayGroupID = :displaygroupid');
364 $sth->execute(array(371 $sth->execute(array(
365 'displaygroupid' => $displayGroupID,372 'displaygroupid' => $displayGroupID,
366 'displaygroup' => $display373 'displaygroup' => $display
367 ));374 ));
368 375
369 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'EditDisplayGroup');376 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'EditDisplayGroup');
370 377
371 return true;378 return true;
372 }379 }
373 catch (Exception $e) {380 catch (Exception $e) {
374 381
375 Debug::LogEntry('error', $e->getMessage());382 Debug::LogEntry('error', $e->getMessage());
@@ -379,8 +386,8 @@
379386
380 return false;387 return false;
381 }388 }
382 }389 }
383 390
384 /**391 /**
385 * DEPRICATED: Removed in 1.2.0. Sets the Default Layout on display linked groups392 * DEPRICATED: Removed in 1.2.0. Sets the Default Layout on display linked groups
386 * @return393 * @return
@@ -389,10 +396,104 @@
389 */396 */
390 public function SetDefaultLayout($displayID, $layoutID)397 public function SetDefaultLayout($displayID, $layoutID)
391 {398 {
392 $db =& $this->db;
393
394 Debug::LogEntry('audit', 'Depricated method called.', 'DisplayGroup', 'SetDefaultLayout');399 Debug::LogEntry('audit', 'Depricated method called.', 'DisplayGroup', 'SetDefaultLayout');
395 return true;400 return true;
396 }401 }
402
403 /**
404 * Associate the list of provided media with this display group
405 * @param user $user The logged in user
406 * @param int $displayGroupId The Display Group to Assign to
407 * @param array $mediaList The Media to Assign
408 */
409 public function AssociateFiles($user, $displayGroupId, $mediaList) {
410 Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
411
412 Kit::ClassLoader('lkmediadisplaygroup');
413 $link = new LkMediaDisplayGroup($this->db);
414
415 try {
416 $dbh = PDOConnect::init();
417
418 // Check that some media assignments have been made
419 if (count($mediaList) == 0)
420 $this->ThrowError(25006, __('No media to assign'));
421
422 // Drop all current assignments
423 if (!$link->UnlinkAllFromDisplayGroup($displayGroupId))
424 $this->ThrowError(__('Unable to make this assignment during preparation.'));
425
426 // Loop through all the media
427 foreach ($mediaList as $mediaId)
428 {
429 $mediaId = Kit::ValidateParam($mediaId, _INT);
430
431 // Check we have permissions to use this media (we will use this to copy the media later)
432 $mediaAuth = $user->MediaAuth($mediaId, true);
433
434 if (!$mediaAuth->view)
435 $this->ThrowError(__('You have selected media that you no longer have permission to use. Please reload the form.'));
436
437 // Create the link
438 if (!$link->Link($displayGroupId, $mediaId))
439 $this->ThrowError(__('Unable to make this assignment'));
440 }
441
442 // Flag this display group as incomplete
443 $this->FlagIncomplete($displayGroupId);
444
445 return true;
446 }
447 catch (Exception $e) {
448
449 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
450
451 if (!$this->IsError())
452 $this->SetError(1, __('Unknown Error'));
453
454 return false;
455 }
456 }
457
458 /**
459 * Flag this display group as incomplete. Also flags all child displays.
460 * @param int $displayGroupId The Display Group ID
461 */
462 public function FlagIncomplete($displayGroupId) {
463 Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
464
465 Kit::ClassLoader('display');
466 $display = new Display($this->db);
467
468 try {
469 $dbh = PDOConnect::init();
470
471 // Which displays does a change to this layout effect?
472 $sth = $dbh->prepare('
473 SELECT DISTINCT display.DisplayID
474 FROM lkdisplaydg
475 INNER JOIN display
476 ON lkdisplaydg.DisplayID = display.displayID
477 WHERE lkdisplaydg.displaygroupid = :displaygroupid
478 ');
479
480 $sth->execute(array('displaygroupid' => $displayGroupId));
481
482 while ($id = $sth->fetchColumn()) {
483 $display->FlagIncomplete($id);
484 }
485
486 return true;
487 }
488 catch (Exception $e) {
489
490 Debug::LogEntry('error', $e->getMessage());
491
492 if (!$this->IsError())
493 $this->SetError(1, __('Unknown Error'));
494
495 return false;
496 }
497 }
397}498}
398?>499?>
399\ No newline at end of file500\ No newline at end of file
400501
=== modified file 'server/lib/data/layout.data.class.php'
--- server/lib/data/layout.data.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/data/layout.data.class.php 2014-03-29 13:09:24 +0000
@@ -1028,5 +1028,56 @@
1028 return false;1028 return false;
1029 }1029 }
1030 }1030 }
1031
1032 /**
1033 * Returns an array containing all the layouts particulars
1034 * @param int $layoutId The layout ID
1035 */
1036 public function LayoutInformation($layoutId) {
1037 Debug::LogEntry('audit', '[IN]', 'layout', 'LayoutInformation');
1038
1039 // The array to ultimately return
1040 $info = array();
1041 $info['regions'] = array();
1042
1043 // Use the Region class to help
1044 Kit::ClassLoader('region');
1045
1046 // Dummy User Object
1047 $user = new User($this->db);
1048 $user->userid = 0;
1049 $user->usertypeid = 1;
1050
1051 // Take the layout, loop through its regions, check them and call LayoutInformation on all media in them.
1052 $info['regions'] = $this->GetRegionList($layoutId);
1053
1054 if (count($info['regions']) <= 0)
1055 return $info;
1056
1057 // Loop through each and build an array
1058 foreach ($info['regions'] as &$region) {
1059
1060 $region['media'] = array();
1061
1062 Debug::LogEntry('audit', 'Assessing Region: ' . $region['regionid'], 'layout', 'LayoutInformation');
1063
1064 // Create a layout object
1065 $regionObject = new Region($this->db);
1066 $mediaNodes = $regionObject->GetMediaNodeList($layoutId, $region['regionid']);
1067
1068 foreach($mediaNodes as $mediaNode) {
1069 // Put this node vertically in the region timeline
1070 $region['media'][] = array(
1071 'mediaid' => $mediaNode->getAttribute('id'),
1072 'lkid' => $mediaNode->getAttribute('lkid'),
1073 'mediatype' => $mediaNode->getAttribute('type')
1074 );
1075 }
1076
1077 Debug::LogEntry('audit', 'Finished with Region', 'layout', 'LayoutInformation');
1078 }
1079
1080 return $info;
1081 }
1031}1082}
1032?>1083?>
10331084
=== added file 'server/lib/data/lkmediadisplaygroup.data.class.php'
--- server/lib/data/lkmediadisplaygroup.data.class.php 1970-01-01 00:00:00 +0000
+++ server/lib/data/lkmediadisplaygroup.data.class.php 2014-03-29 13:09:24 +0000
@@ -0,0 +1,113 @@
1<?php
2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2006-2013 Daniel Garner
5 *
6 * This file is part of Xibo.
7 *
8 * Xibo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * Xibo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
20 */
21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
22
23class LkMediaDisplayGroup extends Data {
24
25 /**
26 * Link display group and media item
27 * @param int $displaygroupid The Display Group ID
28 * @param int $mediaid The Media ID
29 */
30 public function Link($displaygroupid, $mediaid) {
31 Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
32
33 try {
34 $dbh = PDOConnect::init();
35
36 $displaygroupid = Kit::ValidateParam($displaygroupid, _INT, false);
37 $mediaid = Kit::ValidateParam($mediaid, _INT, false);
38
39 $sth = $dbh->prepare('INSERT INTO `lkmediadisplaygroup` (mediaid, displaygroupid) VALUES (:mediaid, :displaygroupid)');
40 $sth->execute(array(
41 'mediaid' => $mediaid,
42 'displaygroupid' => $displaygroupid
43 ));
44
45 return true;
46 }
47 catch (Exception $e) {
48
49 Debug::LogEntry('error', $e->getMessage());
50
51 if (!$this->IsError())
52 $this->SetError(1, __('Unknown Error'));
53
54 return false;
55 }
56 }
57
58 /**
59 * Unlink all media from the provided display group
60 * @param int $displaygroupid The display group to unlink from
61 */
62 public function UnlinkAllFromDisplayGroup($displaygroupid) {
63 Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
64
65 try {
66 $dbh = PDOConnect::init();
67
68 $displaygroupid = Kit::ValidateParam($displaygroupid, _INT, false);
69
70 $sth = $dbh->prepare('DELETE FROM `lkmediadisplaygroup` WHERE displaygroupid = :displaygroupid');
71 $sth->execute(array('displaygroupid' => $displaygroupid));
72
73 return true;
74 }
75 catch (Exception $e) {
76
77 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
78
79 if (!$this->IsError())
80 $this->SetError(1, __('Unknown Error'));
81
82 return false;
83 }
84 }
85
86 /**
87 * Unlink all media from the provided media item
88 * @param int $mediaid The media item to unlink from
89 */
90 public function UnlinkAllFromMedia($mediaid) {
91 Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
92
93 try {
94 $dbh = PDOConnect::init();
95
96 $mediaid = Kit::ValidateParam($mediaid, _INT, false);
97
98 $sth = $dbh->prepare('DELETE FROM `lkmediadisplaygroup` WHERE mediaid = :mediaid');
99 $sth->execute(array('mediaid' => $mediaid));
100
101 return true;
102 }
103 catch (Exception $e) {
104
105 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
106
107 if (!$this->IsError())
108 $this->SetError(1, __('Unknown Error'));
109
110 return false;
111 }
112 }
113}
0114
=== modified file 'server/lib/data/media.data.class.php'
--- server/lib/data/media.data.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/data/media.data.class.php 2014-03-29 13:09:24 +0000
@@ -77,7 +77,7 @@
77 $this->ThrowError(10, __('The name cannot be longer than 100 characters'));77 $this->ThrowError(10, __('The name cannot be longer than 100 characters'));
78 78
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)
80 if ($duration == 0 && $type != 'video' && $type != 'localvideo')80 if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile')
81 $this->ThrowError(11, __('You must enter a duration.'));81 $this->ThrowError(11, __('You must enter a duration.'));
82 82
83 // Check the naming of this item to ensure it doesnt conflict83 // Check the naming of this item to ensure it doesnt conflict
@@ -186,7 +186,7 @@
186 if (strlen($name) > 100)186 if (strlen($name) > 100)
187 $this->ThrowError(10, __('The name cannot be longer than 100 characters'));187 $this->ThrowError(10, __('The name cannot be longer than 100 characters'));
188 188
189 if ($duration == 0 && $type != 'video' && $type != 'localvideo')189 if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile')
190 $this->ThrowError(11, __('You must enter a duration.'));190 $this->ThrowError(11, __('You must enter a duration.'));
191 191
192 // Any media (not this one) already has this name?192 // Any media (not this one) already has this name?
@@ -322,6 +322,8 @@
322 public function Delete($mediaId)322 public function Delete($mediaId)
323 {323 {
324 Debug::LogEntry('audit', 'IN', 'Media', 'Delete');324 Debug::LogEntry('audit', 'IN', 'Media', 'Delete');
325
326 Kit::ClassLoader('lkmediadisplaygroup');
325327
326 try {328 try {
327 $dbh = PDOConnect::init();329 $dbh = PDOConnect::init();
@@ -353,6 +355,11 @@
353 355
354 if (!$security->UnlinkAll($mediaId))356 if (!$security->UnlinkAll($mediaId))
355 throw new Exception("Error Processing Request", 1);357 throw new Exception("Error Processing Request", 1);
358
359 // Delete any assignments
360 $link = new LkMediaDisplayGroup($this->db);
361 if (!$link->UnlinkAllFromDisplayGroup($mediaId))
362 $this->ThrowError(__('Unable to drop file assignments during display delete.'));
356 363
357 // Delete the media364 // Delete the media
358 $sth = $dbh->prepare('DELETE FROM media WHERE MediaID = :mediaid');365 $sth = $dbh->prepare('DELETE FROM media WHERE MediaID = :mediaid');
@@ -393,6 +400,28 @@
393 }400 }
394 }401 }
395402
403 public function GetStoredAs($mediaId) {
404 Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
405
406 try {
407 $dbh = PDOConnect::init();
408
409 $sth = $dbh->prepare('SELECT storedas FROM `media` WHERE mediaid = :id');
410 $sth->execute(array('id' => $mediaId));
411
412 return $sth->fetchColumn();
413 }
414 catch (Exception $e) {
415
416 Debug::LogEntry('error', $e->getMessage());
417
418 if (!$this->IsError())
419 $this->SetError(1, __('Unknown Error'));
420
421 return false;
422 }
423 }
424
396 public function DeleteMediaFile($fileName)425 public function DeleteMediaFile($fileName)
397 {426 {
398 Debug::LogEntry('audit', 'IN', 'Media', 'DeleteMediaFile');427 Debug::LogEntry('audit', 'IN', 'Media', 'DeleteMediaFile');
399428
=== modified file 'server/lib/data/schedule.data.class.php'
--- server/lib/data/schedule.data.class.php 2014-01-19 14:06:56 +0000
+++ server/lib/data/schedule.data.class.php 2014-03-29 13:09:24 +0000
@@ -131,8 +131,8 @@
131 break;131 break;
132 132
133 case 'Week':133 case 'Week':
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));
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));
136 break;136 break;
137 137
138 case 'Month':138 case 'Month':
139139
=== modified file 'server/lib/include.php'
--- server/lib/include.php 2014-01-18 09:47:41 +0000
+++ server/lib/include.php 2014-03-29 13:09:24 +0000
@@ -20,7 +20,7 @@
20 */20 */
21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
2222
23define('WEBSITE_VERSION', 66);23define('WEBSITE_VERSION', 67);
2424
25// No errors reported until we read the settings from the DB25// No errors reported until we read the settings from the DB
26error_reporting(0);26error_reporting(0);
2727
=== modified file 'server/lib/modules/module.class.php'
--- server/lib/modules/module.class.php 2014-02-15 11:25:09 +0000
+++ server/lib/modules/module.class.php 2014-03-29 13:09:24 +0000
@@ -96,6 +96,7 @@
96 $this->existingMedia = false;96 $this->existingMedia = false;
97 $this->assignedMedia = false;97 $this->assignedMedia = false;
98 $this->deleteFromRegion = false;98 $this->deleteFromRegion = false;
99 $this->assignable = true;
99 $this->duration = '';100 $this->duration = '';
100101
101 // Members used by forms (routed through the CMS)102 // Members used by forms (routed through the CMS)
@@ -142,6 +143,7 @@
142 $this->validExtensions = explode(',', $this->validExtensionsText);143 $this->validExtensions = explode(',', $this->validExtensionsText);
143 $this->validExtensionsText = str_replace(',', ', ', $this->validExtensionsText);144 $this->validExtensionsText = str_replace(',', ', ', $this->validExtensionsText);
144 $this->previewEnabled = Kit::ValidateParam($row['PreviewEnabled'], _INT);145 $this->previewEnabled = Kit::ValidateParam($row['PreviewEnabled'], _INT);
146 $this->assignable = Kit::ValidateParam($row['assignable'], _INT);
145147
146 return true;148 return true;
147 }149 }
@@ -806,12 +808,12 @@
806808
807 $session->setSecurityToken($securityToken);809 $session->setSecurityToken($securityToken);
808810
809 //Get the default value for the shared list811 // Set some defaults based on the type of media we are
810 $default = Config::GetSetting('defaultMedia');812 // TODO: this should be passed in
811
812 switch ($this->type) {813 switch ($this->type) {
813 case 'video':814 case 'video':
814 case 'localvideo':815 case 'localvideo':
816 case 'genericfile':
815 $defaultDuration = 0;817 $defaultDuration = 0;
816 break;818 break;
817819
@@ -860,7 +862,7 @@
860 // Setup the theme862 // Setup the theme
861 Theme::Set('form_upload_id', 'fileupload');863 Theme::Set('form_upload_id', 'fileupload');
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);
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 . '">');
864 Theme::Set('form_valid_ext', '/(\.|\/)' . implode('|', $this->validExtensions) . '$/i');866 Theme::Set('form_valid_ext', '/(\.|\/)' . implode('|', $this->validExtensions) . '$/i');
865 Theme::Set('form_max_size', Kit::ReturnBytes($this->maxFileSize));867 Theme::Set('form_max_size', Kit::ReturnBytes($this->maxFileSize));
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);
@@ -976,6 +978,7 @@
976 Theme::Set('is_duration_field_enabled', $durationFieldEnabled);978 Theme::Set('is_duration_field_enabled', $durationFieldEnabled);
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);
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' : ''));
981 Theme::Set('is_assignable', $this->assignable);
979982
980 $form = Theme::RenderReturn('library_form_media_edit');983 $form = Theme::RenderReturn('library_form_media_edit');
981984
@@ -1617,7 +1620,7 @@
1617 // Some messages for the form1620 // Some messages for the form
1618 $msgTransition = __('What transition should be applied to this media item?');1621 $msgTransition = __('What transition should be applied to this media item?');
1619 $msgDuration = __('The duration for this transition, in milliseconds.');1622 $msgDuration = __('The duration for this transition, in milliseconds.');
1620 $msgDirection = __('The direction for this transtion.');1623 $msgDirection = __('The direction for this transition.');
1621 1624
1622 // Construct the form1625 // Construct the form
1623 $form = <<<END1626 $form = <<<END
@@ -1625,6 +1628,7 @@
1625 <input type="hidden" name="type" value="$type">1628 <input type="hidden" name="type" value="$type">
1626 <input type="hidden" name="layoutid" value="$this->layoutid">1629 <input type="hidden" name="layoutid" value="$this->layoutid">
1627 <input type="hidden" name="mediaid" value="$this->mediaid">1630 <input type="hidden" name="mediaid" value="$this->mediaid">
1631 <input type="hidden" name="lkid" value="$this->lkid">
1628 <input type="hidden" id="iRegionId" name="regionid" value="$this->regionid">1632 <input type="hidden" id="iRegionId" name="regionid" value="$this->regionid">
1629 <input type="hidden" name="showRegionOptions" value="$this->showRegionOptions" /> 1633 <input type="hidden" name="showRegionOptions" value="$this->showRegionOptions" />
1630 1634
16311635
=== modified file 'server/lib/pages/content.class.php'
--- server/lib/pages/content.class.php 2014-02-13 10:48:57 +0000
+++ server/lib/pages/content.class.php 2014-03-29 13:09:24 +0000
@@ -180,7 +180,7 @@
180 $response = new ResponseManager();180 $response = new ResponseManager();
181 181
182 // Get a list of the enabled modules and then create buttons for them182 // Get a list of the enabled modules and then create buttons for them
183 if (!$enabledModules = new ModuleManager($db, $user, 0)) 183 if (!$enabledModules = new ModuleManager($db, $user, 0, '', -1))
184 trigger_error($enabledModules->message, E_USER_ERROR);184 trigger_error($enabledModules->message, E_USER_ERROR);
185 185
186 $buttons = array();186 $buttons = array();
@@ -226,7 +226,16 @@
226 Theme::Set('pager', ResponseManager::Pager($id));226 Theme::Set('pager', ResponseManager::Pager($id));
227 227
228 // Module types filter228 // Module types filter
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);
230 $types = array();
231
232 foreach ($modules as $module) {
233 $type['moduleid'] = $module['Module'];
234 $type['module'] = $module['Name'];
235
236 $types[] = $type;
237 }
238
230 array_unshift($types, array('moduleid' => '', 'module' => 'All'));239 array_unshift($types, array('moduleid' => '', 'module' => 'All'));
231 Theme::Set('module_field_list', $types);240 Theme::Set('module_field_list', $types);
232241
233242
=== modified file 'server/lib/pages/display.class.php'
--- server/lib/pages/display.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/pages/display.class.php 2014-03-29 13:09:24 +0000
@@ -302,7 +302,7 @@
302 if ($linkTarget == '')302 if ($linkTarget == '')
303 $linkTarget = '_top';303 $linkTarget = '_top';
304304
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']);
306 }306 }
307307
308 // Format last accessed308 // Format last accessed
@@ -351,6 +351,13 @@
351 'url' => 'index.php?p=display&q=WakeOnLanForm&DisplayId=' . $row['displayid'],351 'url' => 'index.php?p=display&q=WakeOnLanForm&DisplayId=' . $row['displayid'],
352 'text' => __('Wake on LAN')352 'text' => __('Wake on LAN')
353 );353 );
354
355 // File Associations
356 $row['buttons'][] = array(
357 'id' => 'displaygroup_button_fileassociations',
358 'url' => 'index.php?p=displaygroup&q=FileAssociations&DisplayGroupID=' . $row['displaygroupid'],
359 'text' => __('Assign Files')
360 );
354 }361 }
355362
356 if ($row['del'] == 1) {363 if ($row['del'] == 1) {
@@ -378,6 +385,13 @@
378 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'],385 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'],
379 'text' => __('Permissions')386 'text' => __('Permissions')
380 );387 );
388
389 // Version Information
390 $row['buttons'][] = array(
391 'id' => 'display_button_version_instructions',
392 'url' => 'index.php?p=displaygroup&q=VersionInstructionsForm&displaygroupid=' . $row['displaygroupid'] . '&displayid=' . $row['displayid'],
393 'text' => __('Version Information')
394 );
381 }395 }
382396
383 // Assign this to the table row397 // Assign this to the table row
@@ -833,6 +847,6 @@
833847
834 $response->SetFormSubmitResponse(__('Wake on Lan command sent.'));848 $response->SetFormSubmitResponse(__('Wake on Lan command sent.'));
835 $response->Respond();849 $response->Respond();
836 }850 }
837}851}
838?>852?>
839853
=== modified file 'server/lib/pages/displaygroup.class.php'
--- server/lib/pages/displaygroup.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/pages/displaygroup.class.php 2014-03-29 13:09:24 +0000
@@ -22,24 +22,24 @@
2222
23class displaygroupDAO23class displaygroupDAO
24{24{
25 private $db;25 private $db;
26 private $user;26 private $user;
27 27
28 function __construct(database $db, user $user) 28 function __construct(database $db, user $user)
29 {29 {
30 $this->db =& $db;30 $this->db =& $db;
31 $this->user =& $user;31 $this->user =& $user;
32 32
33 include_once('lib/data/displaygroup.data.class.php');33 include_once('lib/data/displaygroup.data.class.php');
34 include_once('lib/data/displaygroupsecurity.data.class.php'); 34 include_once('lib/data/displaygroupsecurity.data.class.php');
35 }35 }
36 36
37 /**37 /**
38 * Display Group Page Render38 * Display Group Page Render
39 */39 */
40 public function displayPage()40 public function displayPage()
41 {41 {
42 // Configure the theme42 // Configure the theme
43 $id = uniqid();43 $id = uniqid();
44 Theme::Set('id', $id);44 Theme::Set('id', $id);
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');
@@ -49,67 +49,81 @@
4949
50 // Render the Theme and output50 // Render the Theme and output
51 Theme::Render('displaygroup_page');51 Theme::Render('displaygroup_page');
52 }52 }
53 53
54 /**54 /**
55 * Shows the Display groups55 * Shows the Display groups
56 * @return 56 * @return
57 */57 */
58 public function Grid()58 public function Grid()
59 {59 {
60 $db =& $this->db;60 $db =& $this->db;
61 $user =& $this->user;61 $user =& $this->user;
62 $response = new ResponseManager();62 $response = new ResponseManager();
6363
64 $displayGroups = $this->user->DisplayGroupList();64 $displayGroups = $this->user->DisplayGroupList();
6565
66 if (!is_array($displayGroups))66 if (!is_array($displayGroups))
67 trigger_error(__('Cannot get list of display groups.'), E_USER_ERROR);67 trigger_error(__('Cannot get list of display groups.'), E_USER_ERROR);
6868
69 $rows = array();69 $rows = array();
7070
71 foreach ($displayGroups as $row)71 foreach ($displayGroups as $row)
72 {72 {
73 if ($row['isdisplayspecific'] != 0)73 if ($row['isdisplayspecific'] != 0)
74 continue;74 continue;
7575
76 if ($row['edit'] == 1)76 if ($row['edit'] == 1)
77 {77 {
78 // Show the edit button, members button78 // Show the edit button, members button
79 79
80 // Group Members80 // Group Members
81 $row['buttons'][] = array(81 $row['buttons'][] = array(
82 'id' => 'displaygroup_button_group_members',82 'id' => 'displaygroup_button_group_members',
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'],
84 'text' => __('Group Members')84 'text' => __('Group Members')
85 );85 );
8686
87 // Edit87 // Edit
88 $row['buttons'][] = array(88 $row['buttons'][] = array(
89 'id' => 'displaygroup_button_edit',89 'id' => 'displaygroup_button_edit',
90 'url' => 'index.php?p=displaygroup&q=EditForm&DisplayGroupID=' . $row['displaygroupid'],90 'url' => 'index.php?p=displaygroup&q=EditForm&DisplayGroupID=' . $row['displaygroupid'],
91 'text' => __('Edit')91 'text' => __('Edit')
92 );92 );
93
94 // File Associations
95 $row['buttons'][] = array(
96 'id' => 'displaygroup_button_fileassociations',
97 'url' => 'index.php?p=displaygroup&q=FileAssociations&DisplayGroupID=' . $row['displaygroupid'],
98 'text' => __('Assign Files')
99 );
93 }100 }
94101
95 if ($row['del'] == 1)102 if ($row['del'] == 1)
96 {103 {
97 // Show the delete button104 // Show the delete button
98 $row['buttons'][] = array(105 $row['buttons'][] = array(
99 'id' => 'displaygroup_button_delete',106 'id' => 'displaygroup_button_delete',
100 'url' => 'index.php?p=displaygroup&q=DeleteForm&DisplayGroupID=' . $row['displaygroupid'],107 'url' => 'index.php?p=displaygroup&q=DeleteForm&DisplayGroupID=' . $row['displaygroupid'],
101 'text' => __('Delete')108 'text' => __('Delete')
102 );109 );
103 }110 }
104111
105 if ($row['modifypermissions'] == 1)112 if ($row['modifypermissions'] == 1)
106 {113 {
107 // Show the modify permissions button114 // Show the modify permissions button
108 $row['buttons'][] = array(115 $row['buttons'][] = array(
109 'id' => 'displaygroup_button_permissions',116 'id' => 'displaygroup_button_permissions',
110 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'],117 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'],
111 'text' => __('Permissions')118 'text' => __('Permissions')
112 );119 );
120
121 // Version Information
122 $row['buttons'][] = array(
123 'id' => 'display_button_version_instructions',
124 'url' => 'index.php?p=displaygroup&q=VersionInstructionsForm&displaygroupid=' . $row['displaygroupid'],
125 'text' => __('Version Information')
126 );
113 }127 }
114128
115 // Assign this to the table row129 // Assign this to the table row
@@ -122,135 +136,135 @@
122136
123 $response->SetGridResponse($output);137 $response->SetGridResponse($output);
124 $response->Respond();138 $response->Respond();
125 }139 }
126 140
127 /**141 /**
128 * Shows an add form for a display group142 * Shows an add form for a display group
129 */143 */
130 public function AddForm()144 public function AddForm()
131 {145 {
132 $db =& $this->db;146 $db =& $this->db;
133 $user =& $this->user;147 $user =& $this->user;
134 $response = new ResponseManager();148 $response = new ResponseManager();
135 149
136 Theme::Set('form_id', 'DisplayGroupAddForm');150 Theme::Set('form_id', 'DisplayGroupAddForm');
137 Theme::Set('form_action', 'index.php?p=displaygroup&q=Add');151 Theme::Set('form_action', 'index.php?p=displaygroup&q=Add');
138152
139 $form = Theme::RenderReturn('displaygroup_form_add');153 $form = Theme::RenderReturn('displaygroup_form_add');
140154
141 $response->SetFormRequestResponse($form, __('Add Display Group'), '350px', '275px');155 $response->SetFormRequestResponse($form, __('Add Display Group'), '350px', '275px');
142 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Add') . '")');156 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Add') . '")');
143 $response->AddButton(__('Cancel'), 'XiboDialogClose()');157 $response->AddButton(__('Cancel'), 'XiboDialogClose()');
144 $response->AddButton(__('Save'), '$("#DisplayGroupAddForm").submit()');158 $response->AddButton(__('Save'), '$("#DisplayGroupAddForm").submit()');
145 $response->Respond();159 $response->Respond();
146 }160 }
147 161
148 /**162 /**
149 * Shows an edit form for a display group163 * Shows an edit form for a display group
150 */164 */
151 public function EditForm()165 public function EditForm()
152 {166 {
153 $db =& $this->db;167 $db =& $this->db;
154 $user =& $this->user;168 $user =& $this->user;
155 $response = new ResponseManager();169 $response = new ResponseManager();
156 $helpManager = new HelpManager($db, $user);170 $helpManager = new HelpManager($db, $user);
157 171
158 $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT);172 $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT);
159173
160 // Auth174 // Auth
161 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);175 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);
162 if (!$auth->edit)176 if (!$auth->edit)
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);
164 178
165 // Pull the currently known info from the DB179 // Pull the currently known info from the DB
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";
167 $SQL = sprintf($SQL, $displayGroupID);181 $SQL = sprintf($SQL, $displayGroupID);
168 182
169 if (!$row = $db->GetSingleRow($SQL))183 if (!$row = $db->GetSingleRow($SQL))
170 {184 {
171 trigger_error($db->error());185 trigger_error($db->error());
172 trigger_error(__('Error getting Display Group'), E_USER_ERROR);186 trigger_error(__('Error getting Display Group'), E_USER_ERROR);
173 }187 }
174 188
175 // Pull out these columns189 // Pull out these columns
176 if (count($row) <= 0)190 if (count($row) <= 0)
177 trigger_error(__('No display group found.'), E_USER_ERROR);191 trigger_error(__('No display group found.'), E_USER_ERROR);
178 192
179 Theme::Set('displaygroup', Kit::ValidateParam($row['DisplayGroup'], _STRING));193 Theme::Set('displaygroup', Kit::ValidateParam($row['DisplayGroup'], _STRING));
180 Theme::Set('description', Kit::ValidateParam($row['Description'], _STRING));194 Theme::Set('description', Kit::ValidateParam($row['Description'], _STRING));
181 195
182 // Set some information about the form196 // Set some information about the form
183 Theme::Set('form_id', 'DisplayGroupEditForm');197 Theme::Set('form_id', 'DisplayGroupEditForm');
184 Theme::Set('form_action', 'index.php?p=displaygroup&q=Edit');198 Theme::Set('form_action', 'index.php?p=displaygroup&q=Edit');
185 Theme::Set('form_meta', '<input type="hidden" name="DisplayGroupID" value="' . $displayGroupID . '" />');199 Theme::Set('form_meta', '<input type="hidden" name="DisplayGroupID" value="' . $displayGroupID . '" />');
186 200
187 $form = Theme::RenderReturn('displaygroup_form_edit');201 $form = Theme::RenderReturn('displaygroup_form_edit');
188202
189 $response->SetFormRequestResponse($form, __('Edit Display Group'), '350px', '275px');203 $response->SetFormRequestResponse($form, __('Edit Display Group'), '350px', '275px');
190 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Edit') . '")');204 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Edit') . '")');
191 $response->AddButton(__('Cancel'), 'XiboDialogClose()');205 $response->AddButton(__('Cancel'), 'XiboDialogClose()');
192 $response->AddButton(__('Save'), '$("#DisplayGroupEditForm").submit()');206 $response->AddButton(__('Save'), '$("#DisplayGroupEditForm").submit()');
193 $response->Respond();207 $response->Respond();
194 }208 }
195 209
196 /**210 /**
197 * Shows the Delete Group Form211 * Shows the Delete Group Form
198 */212 */
199 function DeleteForm() 213 function DeleteForm()
200 {214 {
201 $db =& $this->db;215 $db =& $this->db;
202 $response = new ResponseManager();216 $response = new ResponseManager();
203 $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT);217 $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT);
204218
205 // Auth219 // Auth
206 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);220 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);
207 if (!$auth->del)221 if (!$auth->del)
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);
209 223
210 // Set some information about the form224 // Set some information about the form
211 Theme::Set('form_id', 'DisplayGroupDeleteForm');225 Theme::Set('form_id', 'DisplayGroupDeleteForm');
212 Theme::Set('form_action', 'index.php?p=displaygroup&q=Delete');226 Theme::Set('form_action', 'index.php?p=displaygroup&q=Delete');
213 Theme::Set('form_meta', '<input type="hidden" name="DisplayGroupID" value="' . $displayGroupID . '" />');227 Theme::Set('form_meta', '<input type="hidden" name="DisplayGroupID" value="' . $displayGroupID . '" />');
214228
215 $form = Theme::RenderReturn('displaygroup_form_delete');229 $form = Theme::RenderReturn('displaygroup_form_delete');
216 230
217 $response->SetFormRequestResponse($form, __('Delete Display Group'), '350px', '175px');231 $response->SetFormRequestResponse($form, __('Delete Display Group'), '350px', '175px');
218 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Delete') . '")');232 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Delete') . '")');
219 $response->AddButton(__('No'), 'XiboDialogClose()');233 $response->AddButton(__('No'), 'XiboDialogClose()');
220 $response->AddButton(__('Yes'), '$("#DisplayGroupDeleteForm").submit()');234 $response->AddButton(__('Yes'), '$("#DisplayGroupDeleteForm").submit()');
221 $response->Respond();235 $response->Respond();
222 }236 }
223 237
224 /**238 /**
225 * Display Group Members form239 * Display Group Members form
226 */240 */
227 public function MembersForm()241 public function MembersForm()
228 {242 {
229 $db =& $this->db;243 $db =& $this->db;
230 $response = new ResponseManager();244 $response = new ResponseManager();
231 $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT);245 $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT);
232 246
233 // There needs to be two lists here.247 // There needs to be two lists here.
234 // One of which is the Displays currently assigned to this group248 // One of which is the Displays currently assigned to this group
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)
236250
237 // Set some information about the form251 // Set some information about the form
238 Theme::Set('displays_assigned_id', 'displaysIn');252 Theme::Set('displays_assigned_id', 'displaysIn');
239 Theme::Set('displays_available_id', 'displaysOut');253 Theme::Set('displays_available_id', 'displaysOut');
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);
241255
242 // Displays in group256 // Displays in group
243 $SQL = "";257 $SQL = "";
244 $SQL .= "SELECT display.DisplayID, ";258 $SQL .= "SELECT display.DisplayID, ";
245 $SQL .= " display.Display, ";259 $SQL .= " display.Display, ";
246 $SQL .= " CONCAT('DisplayID_', display.DisplayID) AS list_id ";260 $SQL .= " CONCAT('DisplayID_', display.DisplayID) AS list_id ";
247 $SQL .= "FROM display ";261 $SQL .= "FROM display ";
248 $SQL .= " INNER JOIN lkdisplaydg ";262 $SQL .= " INNER JOIN lkdisplaydg ";
249 $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID ";263 $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID ";
250 $SQL .= sprintf("WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID);264 $SQL .= sprintf("WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID);
251 $SQL .= " ORDER BY display.Display ";265 $SQL .= " ORDER BY display.Display ";
252 266
253 $displaysAssigned = $db->GetArray($SQL);267 $displaysAssigned = $db->GetArray($SQL);
254268
255 if (!is_array($displaysAssigned))269 if (!is_array($displaysAssigned))
256 {270 {
@@ -259,198 +273,203 @@
259 }273 }
260274
261 Theme::Set('displays_assigned', $displaysAssigned);275 Theme::Set('displays_assigned', $displaysAssigned);
262 276
263 // Displays not in group277 // Displays not in group
264 $SQL = "";278 $SQL = "";
265 $SQL .= "SELECT display.DisplayID, ";279 $SQL .= "SELECT display.DisplayID, ";
266 $SQL .= " display.Display, ";280 $SQL .= " display.Display, ";
267 $SQL .= " CONCAT('DisplayID_', display.DisplayID) AS list_id ";281 $SQL .= " CONCAT('DisplayID_', display.DisplayID) AS list_id ";
268 $SQL .= "FROM display ";282 $SQL .= "FROM display ";
269 $SQL .= " WHERE display.DisplayID NOT IN ";283 $SQL .= " WHERE display.DisplayID NOT IN ";
270 $SQL .= " (SELECT display.DisplayID ";284 $SQL .= " (SELECT display.DisplayID ";
271 $SQL .= " FROM display ";285 $SQL .= " FROM display ";
272 $SQL .= " INNER JOIN lkdisplaydg ";286 $SQL .= " INNER JOIN lkdisplaydg ";
273 $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID ";287 $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID ";
274 $SQL .= sprintf(" WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID);288 $SQL .= sprintf(" WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID);
275 $SQL .= " )";289 $SQL .= " )";
276 $SQL .= " ORDER BY display.Display ";290 $SQL .= " ORDER BY display.Display ";
277291
278 $displaysAvailable = $db->GetArray($SQL);292 $displaysAvailable = $db->GetArray($SQL);
279 293
280 if (!is_array($displaysAvailable))294 if (!is_array($displaysAvailable))
281 {295 {
282 trigger_error($db->error());296 trigger_error($db->error());
283 trigger_error(__('Error getting Displays'), E_USER_ERROR);297 trigger_error(__('Error getting Displays'), E_USER_ERROR);
284 }298 }
285299
286 Theme::Set('displays_available', $displaysAvailable);300 Theme::Set('displays_available', $displaysAvailable);
287 301
288 302
289 $form = Theme::RenderReturn('displaygroup_form_display_assign');303 $form = Theme::RenderReturn('displaygroup_form_display_assign');
290304
291 $response->SetFormRequestResponse($form, __('Manage Membership'), '400', '375', 'DisplayGroupManageMembersCallBack');305 $response->SetFormRequestResponse($form, __('Manage Membership'), '400', '375', 'DisplayGroupManageMembersCallBack');
292 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Members') . '")');306 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Members') . '")');
293 $response->AddButton(__('Cancel'), 'XiboDialogClose()');307 $response->AddButton(__('Cancel'), 'XiboDialogClose()');
294 $response->AddButton(__('Save'), 'DisplayGroupMembersSubmit()');308 $response->AddButton(__('Save'), 'DisplayGroupMembersSubmit()');
295 $response->Respond();309 $response->Respond();
296 }310 }
297 311
298 /**312 /**
299 * Adds a Display Group313 * Adds a Display Group
300 * @return 314 * @return
301 */315 */
302 public function Add()316 public function Add()
303 {317 {
304 // Check the token318 // Check the token
305 if (!Kit::CheckToken())319 if (!Kit::CheckToken())
306 trigger_error('Token does not match', E_USER_ERROR);320 trigger_error('Token does not match', E_USER_ERROR);
307 321
308 $db =& $this->db;322 $db =& $this->db;
309 $response = new ResponseManager();323 $response = new ResponseManager();
310324
311 $displayGroup = Kit::GetParam('group', _POST, _STRING);325 $displayGroup = Kit::GetParam('group', _POST, _STRING);
312 $description = Kit::GetParam('desc', _POST, _STRING);326 $description = Kit::GetParam('desc', _POST, _STRING);
313 327
314 $displayGroupObject = new DisplayGroup($db);328 $displayGroupObject = new DisplayGroup($db);
315 329
316 if (!$displayGroupObject->Add($displayGroup, 0, $description))330 if (!$displayGroupObject->Add($displayGroup, 0, $description))
317 {331 {
318 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);332 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
319 }333 }
320 334
321 $response->SetFormSubmitResponse(__('Display Group Added'), false);335 $response->SetFormSubmitResponse(__('Display Group Added'), false);
322 $response->Respond();336 $response->Respond();
323 }337 }
324 338
325 /**339 /**
326 * Edits a Display Group340 * Edits a Display Group
327 * @return 341 * @return
328 */342 */
329 public function Edit()343 public function Edit()
330 {344 {
331 // Check the token345 // Check the token
332 if (!Kit::CheckToken())346 if (!Kit::CheckToken())
333 trigger_error('Token does not match', E_USER_ERROR);347 trigger_error('Token does not match', E_USER_ERROR);
334 348
335 $db =& $this->db;349 $db =& $this->db;
336 $response = new ResponseManager();350 $response = new ResponseManager();
337351
338 $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT);352 $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT);
339 $displayGroup = Kit::GetParam('group', _POST, _STRING);353 $displayGroup = Kit::GetParam('group', _POST, _STRING);
340 $description = Kit::GetParam('desc', _POST, _STRING);354 $description = Kit::GetParam('desc', _POST, _STRING);
341355
342 // Auth356 // Auth
343 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);357 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);
344 if (!$auth->edit)358 if (!$auth->edit)
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);
346 360
347 // Deal with the Edit361 // Deal with the Edit
348 $displayGroupObject = new DisplayGroup($db);362 $displayGroupObject = new DisplayGroup($db);
349 363
350 if (!$displayGroupObject->Edit($displayGroupID, $displayGroup, $description))364 if (!$displayGroupObject->Edit($displayGroupID, $displayGroup, $description))
351 {365 {
352 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);366 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
353 }367 }
354 368
355 $response->SetFormSubmitResponse(__('Display Group Edited'), false);369 $response->SetFormSubmitResponse(__('Display Group Edited'), false);
356 $response->Respond();370 $response->Respond();
357 }371 }
358 372
359 /**373 /**
360 * Deletes a Group374 * Deletes a Group
361 * @return 375 * @return
362 */376 */
363 function Delete() 377 function Delete()
364 {378 {
365 // Check the token379 // Check the token
366 if (!Kit::CheckToken())380 if (!Kit::CheckToken())
367 trigger_error('Token does not match', E_USER_ERROR);381 trigger_error('Token does not match', E_USER_ERROR);
368 382
369 $db =& $this->db; 383 $db =& $this->db;
370 $response = new ResponseManager();384 $response = new ResponseManager();
371 385
372 $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT);386 $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT);
373387
374 // Auth388 // Auth
375 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);389 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);
376 if (!$auth->del)390 if (!$auth->del)
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);
378392
379 // Deal with the Delete393 // Deal with the Delete
380 $displayGroupObject = new DisplayGroup($db);394 $displayGroupObject = new DisplayGroup($db);
381 395
382 if (!$displayGroupObject->Delete($displayGroupID))396 if (!$displayGroupObject->Delete($displayGroupID))
383 {397 {
384 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);398 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
385 }399 }
386 400
387 $response->SetFormSubmitResponse(__('Display Group Deleted'), false);401 $response->SetFormSubmitResponse(__('Display Group Deleted'), false);
388 $response->Respond();402 $response->Respond();
389 }403 }
390 404
391 /**405 /**
392 * Sets the Members of a group406 * Sets the Members of a group
393 * @return 407 * @return
394 */408 */
395 public function SetMembers()409 public function SetMembers()
396 {410 {
397 $db =& $this->db; 411 $db =& $this->db;
398 $response = new ResponseManager();412 $response = new ResponseManager();
399 $displayGroupObject = new DisplayGroup($db);413 $displayGroupObject = new DisplayGroup($db);
400 414
401 $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT);415 $displayGroupID = Kit::GetParam('DisplayGroupID', _REQUEST, _INT);
402 $displays = Kit::GetParam('DisplayID', _POST, _ARRAY, array());416 $displays = Kit::GetParam('DisplayID', _POST, _ARRAY, array());
403 $members = array();417 $members = array();
404 418
405 // Get a list of current members419 // Auth
406 $SQL = "";420 $auth = $this->user->DisplayGroupAuth($displayGroupID, true);
407 $SQL .= "SELECT display.DisplayID ";421 if (!$auth->del)
408 $SQL .= "FROM display ";422 trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR);
409 $SQL .= " INNER JOIN lkdisplaydg ";423
410 $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID ";424 // Get a list of current members
411 $SQL .= sprintf("WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID);425 $SQL = "";
412 426 $SQL .= "SELECT display.DisplayID ";
413 if(!$resultIn = $db->query($SQL))427 $SQL .= "FROM display ";
414 {428 $SQL .= " INNER JOIN lkdisplaydg ";
415 trigger_error($db->error());429 $SQL .= " ON lkdisplaydg.DisplayID = display.DisplayID ";
416 trigger_error(__('Error getting Displays'), E_USER_ERROR);430 $SQL .= sprintf("WHERE lkdisplaydg.DisplayGroupID = %d", $displayGroupID);
417 }431
418 432 if(!$resultIn = $db->query($SQL))
419 while($row = $db->get_assoc_row($resultIn))433 {
420 {434 trigger_error($db->error());
421 // Test whether this ID is in the array or not435 trigger_error(__('Error getting Displays'), E_USER_ERROR);
422 $displayID = Kit::ValidateParam($row['DisplayID'], _INT);436 }
423 437
424 if(!in_array($displayID, $displays))438 while($row = $db->get_assoc_row($resultIn))
425 {439 {
426 // Its currently assigned but not in the $displays array440 // Test whether this ID is in the array or not
427 // so we unassign441 $displayID = Kit::ValidateParam($row['DisplayID'], _INT);
428 if (!$displayGroupObject->Unlink($displayGroupID, $displayID))442
429 {443 if(!in_array($displayID, $displays))
430 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);444 {
431 }445 // Its currently assigned but not in the $displays array
432 }446 // so we unassign
433 else447 if (!$displayGroupObject->Unlink($displayGroupID, $displayID))
434 {448 {
435 $members[] = $displayID;449 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
436 }450 }
437 }451 }
438 452 else
439 foreach($displays as $displayID)453 {
440 {454 $members[] = $displayID;
441 // Add any that are missing455 }
442 if(!in_array($displayID, $members))456 }
443 {457
444 if (!$displayGroupObject->Link($displayGroupID, $displayID))458 foreach($displays as $displayID)
445 {459 {
446 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);460 // Add any that are missing
447 }461 if(!in_array($displayID, $members))
448 }462 {
449 }463 if (!$displayGroupObject->Link($displayGroupID, $displayID))
450 464 {
451 $response->SetFormSubmitResponse(__('Group membership set'), false);465 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
452 $response->Respond();466 }
453 }467 }
468 }
469
470 $response->SetFormSubmitResponse(__('Group membership set'), false);
471 $response->Respond();
472 }
454473
455 /**474 /**
456 * Show the Permissions for this Display Group475 * Show the Permissions for this Display Group
@@ -471,7 +490,7 @@
471490
472 // Set some information about the form491 // Set some information about the form
473 Theme::Set('form_id', 'DisplayGroupPermissionsForm');492 Theme::Set('form_id', 'DisplayGroupPermissionsForm');
474 Theme::Set('form_action', 'index.php?p=displaygroup&q=Permissions');493 Theme::Set('form_action', 'index.php?p=displaygroup&q=Permissions');
475 Theme::Set('form_meta', '<input type="hidden" name="displayGroupId" value="' . $displayGroupId . '" />');494 Theme::Set('form_meta', '<input type="hidden" name="displayGroupId" value="' . $displayGroupId . '" />');
476495
477 // List of all Groups with a view/edit/delete checkbox496 // List of all Groups with a view/edit/delete checkbox
@@ -543,7 +562,7 @@
543 $auth = $this->user->DisplayGroupAuth($displayGroupId, true);562 $auth = $this->user->DisplayGroupAuth($displayGroupId, true);
544563
545 if (!$auth->modifyPermissions)564 if (!$auth->modifyPermissions)
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);
547566
548 // Unlink all567 // Unlink all
549 $security = new DisplayGroupSecurity($db);568 $security = new DisplayGroupSecurity($db);
@@ -610,5 +629,257 @@
610 $response->SetFormSubmitResponse(__('Permissions Changed'));629 $response->SetFormSubmitResponse(__('Permissions Changed'));
611 $response->Respond();630 $response->Respond();
612 }631 }
632
633 public function FileAssociations() {
634
635 $displayGroupId = Kit::GetParam('DisplayGroupID', _GET, _INT);
636
637 // Auth
638 $auth = $this->user->DisplayGroupAuth($displayGroupId, true);
639 if (!$auth->edit)
640 trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR);
641
642 $id = uniqid();
643 Theme::Set('id', $id);
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 . '">');
645 Theme::Set('pager', ResponseManager::Pager($id));
646
647 // Module types filter
648 $modules = $this->user->ModuleAuth(0, '', -1);
649 $types = array();
650
651 foreach ($modules as $module) {
652 $type['moduleid'] = $module['Module'];
653 $type['module'] = $module['Name'];
654
655 $types[] = $type;
656 }
657
658 array_unshift($types, array('moduleid' => '', 'module' => 'All'));
659 Theme::Set('module_field_list', $types);
660
661 // Get the currently associated media items and put them in the top bar
662 $existing = array();
663
664 try {
665 $dbh = PDOConnect::init();
666
667 $sth = $dbh->prepare('
668 SELECT media.MediaID, media.Name
669 FROM `media`
670 INNER JOIN `lkmediadisplaygroup`
671 ON lkmediadisplaygroup.mediaid = media.mediaid
672 WHERE lkmediadisplaygroup.displaygroupid = :displaygroupid
673 ');
674
675 $sth->execute(array('displaygroupid' => $displayGroupId));
676
677 $existing = $sth->fetchAll();
678 }
679 catch (Exception $e) {
680
681 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
682
683 trigger_error(__('Unable to get existing assignments.'), E_USER_ERROR);
684 }
685
686 Theme::Set('existing_associations', $existing);
687
688 // Call to render the template
689 $output = Theme::RenderReturn('displaygroup_fileassociations_form_assign');
690
691 // Construct the Response
692 $response = new ResponseManager();
693 $response->html = $output;
694 $response->success = true;
695 $response->dialogSize = true;
696 $response->dialogClass = 'modal-big';
697 $response->dialogWidth = '780px';
698 $response->dialogHeight = '580px';
699 $response->dialogTitle = __('Associate an item from the Library');
700
701 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'FileAssociations') . '")');
702 $response->AddButton(__('Cancel'), 'XiboDialogClose()');
703 $response->AddButton(__('Assign'), 'FileAssociationsSubmit(' . $displayGroupId . ')');
704 $response->Respond();
705 }
706
707 public function FileAssociationsView() {
708 $user =& $this->user;
709
710 //Input vars
711 $mediatype = Kit::GetParam('filter_type', _POST, _STRING);
712 $name = Kit::GetParam('filter_name', _POST, _STRING);
713 $displaygroupid = Kit::GetParam('displaygroupid', _POST, _INT);
714
715 // Get the currently associated media items and put them in the top bar
716 $existing = array();
717
718 try {
719 $dbh = PDOConnect::init();
720
721 $sth = $dbh->prepare('
722 SELECT mediaid
723 FROM `lkmediadisplaygroup`
724 WHERE displaygroupid = :displaygroupid
725 ');
726
727 $sth->execute(array('displaygroupid' => $displaygroupid));
728
729 while ($existing[] = $sth->fetchColumn());
730 }
731 catch (Exception $e) {
732
733 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
734
735 trigger_error(__('Unable to get existing assignments.'), E_USER_ERROR);
736 }
737
738 // Get a list of media
739 $mediaList = $user->MediaList($mediatype, $name);
740
741 $rows = array();
742
743 // Add some extra information
744 foreach ($mediaList as $row) {
745
746 if (in_array($row['mediaid'], $existing))
747 continue;
748
749 $row['list_id'] = 'MediaID_' . $row['mediaid'];
750
751 $rows[] = $row;
752 }
753
754 Theme::Set('table_rows', $rows);
755
756 // Render the Theme
757 $response = new ResponseManager();
758 $response->SetGridResponse(Theme::RenderReturn('displaygroup_fileassociations_form_assign_list'));
759 $response->callBack = 'FileAssociationsCallback';
760 $response->pageSize = 5;
761 $response->Respond();
762 }
763
764 public function SetFileAssociations() {
765 $user =& $this->user;
766 $response = new ResponseManager();
767
768 $displayGroupId = Kit::GetParam('displaygroupid', _GET, _INT);
769 $mediaList = Kit::GetParam('MediaID', _POST, _ARRAY_INT, array(), false);
770
771 if ($displayGroupId == 0)
772 trigger_error(__('Display Group not selected'), E_USER_ERROR);
773
774 // Auth
775 $auth = $this->user->DisplayGroupAuth($displayGroupId, true);
776 if (!$auth->del)
777 trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR);
778
779 Kit::ClassLoader('displaygroup');
780 $displayGroup = new DisplayGroup($this->db);
781
782 if (!$displayGroup->AssociateFiles($this->user, $displayGroupId, $mediaList))
783 trigger_error($displayGroup->GetErrorMessage(), E_USER_ERROR);
784
785 // Success
786 $response->SetFormSubmitResponse(sprintf(__('%d Media Items Assigned'), count($mediaList)));
787 $response->Respond();
788 }
789
790 public function VersionInstructionsForm() {
791 $response = new ResponseManager();
792
793 $displayGroupId = Kit::GetParam('displaygroupid', _GET, _INT);
794 $displayId = Kit::GetParam('displayid', _GET, _INT);
795 Theme::Set('installer_file_id', 0);
796
797 // List of effected displays
798 $rows = array();
799
800 if ($displayId != 0) {
801 // Get some version information about this display.
802 if (!$displays = $this->user->DisplayList(array('display'), array('displayid' => $displayId)))
803 trigger_error(__('Unknown Display'), E_USER_ERROR);
804 }
805 else {
806 // Get a list of displays with their version information?
807 if (!$displays = $this->user->DisplayList(array('display'), array('displaygroupid' => $displayGroupId)))
808 trigger_error(__('Unknown Display'), E_USER_ERROR);
809 }
810
811 foreach ($displays as $display) {
812 $rows[] = array(
813 'display' => Theme::Prepare($display['display']),
814 'client_type' => Theme::Prepare($display['client_type']),
815 'client_version' => Theme::Prepare($display['client_version']),
816 'client_code' => Theme::Prepare($display['client_code'])
817 );
818 }
819
820 // Store this for use in the theme
821 Theme::Set('displays', $displays);
822
823 // Present a list of possible files to choose from (generic file module)
824 $mediaList = $this->user->MediaList('genericfile');
825 array_unshift($mediaList, array('mediaid' => 0, 'media' => ''));
826 Theme::Set('media_field_list', $mediaList);
827
828 // Set some information about the form
829 Theme::Set('form_id', 'VersionInstructions');
830 Theme::Set('form_action', 'index.php?p=displaygroup&q=VersionInstructions');
831 Theme::Set('form_meta', '<input type="hidden" name="displaygroupid" value="' . $displayGroupId . '">');
832
833 $form = Theme::RenderReturn('display_form_version_instructions');
834
835 $response->SetFormRequestResponse($form, __('Set Instructions for Upgrading this client'), '300px', '250px');
836 $response->AddButton(__('Cancel'), 'XiboDialogClose()');
837 $response->AddButton(__('Save'), '$("#VersionInstructions").submit()');
838 $response->Respond();
839 }
840
841 public function VersionInstructions() {
842 $response = new ResponseManager();
843
844 Kit::ClassLoader('media');
845 Kit::ClassLoader('display');
846 Kit::ClassLoader('lkmediadisplaygroup');
847
848 $displayGroupId = Kit::GetParam('displaygroupid', _POST, _INT);
849 $mediaId = Kit::GetParam('mediaid', _POST, _INT);
850
851 // Make sure we have permission to do this to this display
852 $auth = $this->user->DisplayGroupAuth($displayGroupId, true);
853 if (!$auth->edit)
854 trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR);
855
856 // Make sure we have permission to use this file
857 $mediaAuth = $this->user->MediaAuth($mediaId, true);
858
859 if (!$mediaAuth->view)
860 trigger_error(__('You have selected media that you no longer have permission to use. Please reload the form.'), E_USER_ERROR);
861
862 // Make sure this file is assigned to this display group
863 $link = new LkMediaDisplayGroup($this->db);
864 if (!$link->Link($displayGroupId, $mediaId))
865 trigger_error($display->GetErrorMessage(), E_USER_ERROR);
866
867 // Get the "StoredAs" for this media item
868 $media = new Media($this->db);
869 $storedAs = $media->GetStoredAs($mediaId);
870
871 // Get a list of displays for this group
872 $displays = $this->user->DisplayList(array('displayid'), array('displaygroupid' => $displayGroupId));
873
874 foreach ($displays as $display) {
875 // Update the Display with the new instructions
876 $displayObject = new Display($this->db);
877 if (!$displayObject->SetVersionInstructions($display['displayid'], $mediaId, $storedAs))
878 trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR);
879 }
880
881 $response->SetFormSubmitResponse(__('Version Instructions Set'));
882 $response->Respond();
883 }
613}884}
614?>885?>
615\ No newline at end of file886\ No newline at end of file
616887
=== modified file 'server/lib/pages/layout.class.php'
--- server/lib/pages/layout.class.php 2014-02-13 10:48:57 +0000
+++ server/lib/pages/layout.class.php 2014-03-29 13:09:24 +0000
@@ -742,7 +742,7 @@
742 $regionHtml .= ' </button>';742 $regionHtml .= ' </button>';
743 $regionHtml .= ' <ul class="dropdown-menu">';743 $regionHtml .= ' <ul class="dropdown-menu">';
744 $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=Timeline&layoutid=' . $this->layoutid . '&regionid=' . $regionid . '" title="' . __('Timeline') . '">' . __('Edit Timeline') . '</a></li>';744 $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=Timeline&layoutid=' . $this->layoutid . '&regionid=' . $regionid . '" title="' . __('Timeline') . '">' . __('Edit Timeline') . '</a></li>';
745 $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=ManualRegionPositionForm&layoutid=' . $this->layoutid . '&regionid=' . $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>';
746 $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=DeleteRegionForm&layoutid=' . $this->layoutid . '&regionid=' . $regionid . '" title="' . __('Delete') . '">' . __('Delete') . '</a></li>';746 $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=DeleteRegionForm&layoutid=' . $this->layoutid . '&regionid=' . $regionid . '" title="' . __('Delete') . '">' . __('Delete') . '</a></li>';
747 $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=RegionPermissionsForm&layoutid=' . $this->layoutid . '&regionid=' . $regionid . '" title="' . __('Permissions') . '">' . __('Permissions') . '</a></li>';747 $regionHtml .= ' <li><a class="XiboFormButton" href="index.php?p=timeline&q=RegionPermissionsForm&layoutid=' . $this->layoutid . '&regionid=' . $regionid . '" title="' . __('Permissions') . '">' . __('Permissions') . '</a></li>';
748 $regionHtml .= ' </ul>';748 $regionHtml .= ' </ul>';
@@ -766,7 +766,7 @@
766 //render the view pane766 //render the view pane
767 $surface = <<<HTML767 $surface = <<<HTML
768768
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;">
770 $regionHtml770 $regionHtml
771 </div>771 </div>
772HTML;772HTML;
773773
=== modified file 'server/lib/pages/module.class.php'
--- server/lib/pages/module.class.php 2014-02-12 20:32:00 +0000
+++ server/lib/pages/module.class.php 2014-03-29 13:09:24 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
2/*2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2006-2013 Daniel Garner4 * Copyright (C) 2006-2014 Daniel Garner
5 *5 *
6 * This file is part of Xibo.6 * This file is part of Xibo.
7 *7 *
@@ -92,7 +92,8 @@
92 $SQL .= ' RegionSpecific, ';92 $SQL .= ' RegionSpecific, ';
93 $SQL .= ' ValidExtensions, ';93 $SQL .= ' ValidExtensions, ';
94 $SQL .= ' ImageUri, ';94 $SQL .= ' ImageUri, ';
95 $SQL .= ' PreviewEnabled ';95 $SQL .= ' PreviewEnabled, ';
96 $SQL .= ' assignable ';
96 $SQL .= ' FROM `module` ';97 $SQL .= ' FROM `module` ';
97 $SQL .= ' ORDER BY Name ';98 $SQL .= ' ORDER BY Name ';
9899
@@ -115,9 +116,11 @@
115 $row['imageuri'] = Kit::ValidateParam($module['ImageUri'], _STRING);116 $row['imageuri'] = Kit::ValidateParam($module['ImageUri'], _STRING);
116 $row['enabled'] = Kit::ValidateParam($module['Enabled'], _INT);117 $row['enabled'] = Kit::ValidateParam($module['Enabled'], _INT);
117 $row['preview_enabled'] = Kit::ValidateParam($module['PreviewEnabled'], _INT);118 $row['preview_enabled'] = Kit::ValidateParam($module['PreviewEnabled'], _INT);
119 $row['assignable'] = Kit::ValidateParam($module['assignable'], _INT);
118 $row['isregionspecific_image'] = ($row['isregionspecific'] == 0) ? 'icon-ok' : 'icon-remove';120 $row['isregionspecific_image'] = ($row['isregionspecific'] == 0) ? 'icon-ok' : 'icon-remove';
119 $row['enabled_image'] = ($row['enabled'] == 1) ? 'icon-ok' : 'icon-remove';121 $row['enabled_image'] = ($row['enabled'] == 1) ? 'icon-ok' : 'icon-remove';
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';
123 $row['assignable_image'] = ($row['assignable'] == 1) ? 'icon-ok' : 'icon-remove';
121124
122 // Initialise array of buttons, because we might not have any125 // Initialise array of buttons, because we might not have any
123 $row['buttons'] = array();126 $row['buttons'] = array();
124127
=== modified file 'server/lib/pages/schedule.class.php'
--- server/lib/pages/schedule.class.php 2014-01-18 14:29:25 +0000
+++ server/lib/pages/schedule.class.php 2014-03-29 13:09:24 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
2/*2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2006-2013 Daniel Garner4 * Copyright (C) 2006-2014 Daniel Garner
5 *5 *
6 * This file is part of Xibo.6 * This file is part of Xibo.
7 *7 *
@@ -1157,7 +1157,7 @@
1157 </div>1157 </div>
1158HTML;1158HTML;
1159 1159
1160 $id = uniqid();1160 $id = Kit::uniqueId();
1161 $pager = ResponseManager::Pager($id);1161 $pager = ResponseManager::Pager($id);
11621162
1163 $xiboGrid = <<<HTML1163 $xiboGrid = <<<HTML
@@ -1277,7 +1277,7 @@
1277 </div>1277 </div>
1278HTML;1278HTML;
1279 1279
1280 $id = uniqid();1280 $id = Kit::uniqueId();
1281 $pager = ResponseManager::Pager($id);1281 $pager = ResponseManager::Pager($id);
12821282
1283 $xiboGrid = <<<HTML1283 $xiboGrid = <<<HTML
12841284
=== modified file 'server/lib/pages/stats.class.php'
--- server/lib/pages/stats.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/pages/stats.class.php 2014-03-29 13:09:24 +0000
@@ -82,7 +82,7 @@
82 $SQL .= ' FROM stat ';82 $SQL .= ' FROM stat ';
83 $SQL .= ' INNER JOIN layout ON layout.LayoutID = stat.LayoutID ';83 $SQL .= ' INNER JOIN layout ON layout.LayoutID = stat.LayoutID ';
84 $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID ';84 $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID ';
85 $SQL .= ' WHERE 1 = 1 ';85 $SQL .= " WHERE stat.type = 'layout' ";
86 $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt);86 $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt);
87 $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt);87 $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt);
8888
@@ -120,7 +120,7 @@
120 $SQL .= ' FROM stat ';120 $SQL .= ' FROM stat ';
121 $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID ';121 $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID ';
122 $SQL .= ' INNER JOIN media ON media.MediaID = stat.MediaID ';122 $SQL .= ' INNER JOIN media ON media.MediaID = stat.MediaID ';
123 $SQL .= ' WHERE 1 = 1 ';123 $SQL .= " WHERE stat.type = 'media' ";
124 $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt);124 $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt);
125 $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt);125 $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt);
126126
@@ -162,7 +162,7 @@
162 $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID ';162 $SQL .= ' INNER JOIN display ON stat.DisplayID = display.DisplayID ';
163 $SQL .= ' INNER JOIN layout ON layout.LayoutID = stat.LayoutID ';163 $SQL .= ' INNER JOIN layout ON layout.LayoutID = stat.LayoutID ';
164 $SQL .= ' LEFT OUTER JOIN media ON media.MediaID = stat.MediaID ';164 $SQL .= ' LEFT OUTER JOIN media ON media.MediaID = stat.MediaID ';
165 $SQL .= ' WHERE 1 = 1 ';165 $SQL .= " WHERE stat.type = 'media' ";
166 $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt);166 $SQL .= sprintf(" AND stat.end > '%s' ", $fromDt);
167 $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt);167 $SQL .= sprintf(" AND stat.start <= '%s' ", $toDt);
168168
169169
=== modified file 'server/lib/pages/statusdashboard.class.php'
--- server/lib/pages/statusdashboard.class.php 2014-02-15 10:32:44 +0000
+++ server/lib/pages/statusdashboard.class.php 2014-03-29 13:09:24 +0000
@@ -36,7 +36,7 @@
36 try {36 try {
37 $dbh = PDOConnect::init();37 $dbh = PDOConnect::init();
38 38
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);');
40 $sth->execute(array('month' => time() - (86400 * 365)));40 $sth->execute(array('month' => time() - (86400 * 365)));
4141
42 $results = $sth->fetchAll();42 $results = $sth->fetchAll();
4343
=== modified file 'server/lib/service/xmdssoap.class.php'
--- server/lib/service/xmdssoap.class.php 2014-02-09 15:03:19 +0000
+++ server/lib/service/xmdssoap.class.php 2014-03-29 13:09:24 +0000
@@ -30,6 +30,7 @@
30 private $isAuditing;30 private $isAuditing;
31 private $displayId;31 private $displayId;
32 private $defaultLayoutId;32 private $defaultLayoutId;
33 private $version_instructions;
3334
34 public function __construct()35 public function __construct()
35 {36 {
@@ -161,6 +162,7 @@
161162
162 $requiredFilesXml = new DOMDocument("1.0");163 $requiredFilesXml = new DOMDocument("1.0");
163 $fileElements = $requiredFilesXml->createElement("files");164 $fileElements = $requiredFilesXml->createElement("files");
165 $fileElements->setAttribute('version_instructions', $this->version_instructions);
164166
165 $requiredFilesXml->appendChild($fileElements);167 $requiredFilesXml->appendChild($fileElements);
166168
@@ -189,11 +191,15 @@
189 }191 }
190192
191 // Our layout list will always include the default layout193 // Our layout list will always include the default layout
192 $layoutIdList = $this->defaultLayoutId;194 $layouts = array();
195 $layouts[] = $this->defaultLayoutId;
193196
194 // Build up the other layouts into a comma seperated list.197 // Build up the other layouts into an array
195 while ($row = $db->get_assoc_row($results))198 while ($row = $db->get_assoc_row($results))
196 $layoutIdList .= ',' . Kit::ValidateParam($row['layoutID'], _INT);199 $layouts[] = Kit::ValidateParam($row['layoutID'], _INT);
200
201 // Create a comma separated list to pass into the query which gets file nodes
202 $layoutIdList = implode(',', $layouts);
197203
198 // Add file nodes to the $fileElements204 // Add file nodes to the $fileElements
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 ";
@@ -207,6 +213,18 @@
207 $SQL .= " INNER JOIN layout ";213 $SQL .= " INNER JOIN layout ";
208 $SQL .= " ON layout.LayoutID = lklayoutmedia.LayoutID";214 $SQL .= " ON layout.LayoutID = lklayoutmedia.LayoutID";
209 $SQL .= sprintf(" WHERE layout.layoutid IN (%s) ", $layoutIdList);215 $SQL .= sprintf(" WHERE layout.layoutid IN (%s) ", $layoutIdList);
216 $SQL .= "
217 UNION
218 SELECT 'media' AS RecordType, storedAs AS path, media.mediaID AS id, media.`MD5`, media.FileSize, NULL AS background, NULL AS xml
219 FROM `media`
220 INNER JOIN `lkmediadisplaygroup`
221 ON lkmediadisplaygroup.mediaid = media.MediaID
222 INNER JOIN lkdisplaydg
223 ON lkdisplaydg.DisplayGroupID = lkmediadisplaygroup.DisplayGroupID
224 INNER JOIN display
225 ON lkdisplaydg.DisplayID = display.displayID
226 ";
227 $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey);
210 $SQL .= " ORDER BY RecordType DESC";228 $SQL .= " ORDER BY RecordType DESC";
211229
212 if ($this->isAuditing == 1) Debug::LogEntry("audit", $SQL, "xmds", "RequiredFiles");230 if ($this->isAuditing == 1) Debug::LogEntry("audit", $SQL, "xmds", "RequiredFiles");
@@ -282,6 +300,32 @@
282 }300 }
283 }301 }
284302
303 Kit::ClassLoader('layout');
304
305 // Go through each layout and see if we need to supply any resource nodes.
306 foreach ($layouts as $layoutId) {
307 // Load the layout XML and work out if we have any ticker / text / dataset media items
308 $layout = new Layout($db);
309
310 $layoutInformation = $layout->LayoutInformation($layoutId);
311
312 foreach($layoutInformation['regions'] as $region) {
313 foreach($region['media'] as $media) {
314 if ($media['mediatype'] == 'ticker' || $media['mediatype'] == 'text' || $media['mediatype'] == 'dataset') {
315 // Append this item to required files
316 $file = $requiredFilesXml->createElement("file");
317 $file->setAttribute('type', 'resource');
318 $file->setAttribute('id', rand());
319 $file->setAttribute('layoutid', $layoutId);
320 $file->setAttribute('regionid', $region['regionid']);
321 $file->setAttribute('mediaid', $media['mediaid']);
322
323 $fileElements->appendChild($file);
324 }
325 }
326 }
327 }
328
285 // Add a blacklist node329 // Add a blacklist node
286 $blackList = $requiredFilesXml->createElement("file");330 $blackList = $requiredFilesXml->createElement("file");
287 $blackList->setAttribute("type", "blacklist");331 $blackList->setAttribute("type", "blacklist");
@@ -309,62 +353,8 @@
309 $blackList->appendChild($file);353 $blackList->appendChild($file);
310 }354 }
311355
312 // PHONE_HOME if required.356 // Phone Home?
313 if (Config::GetSetting('PHONE_HOME') == 'On')357 $this->PhoneHome();
314 {
315 // Find out when we last PHONED_HOME :D
316 // If it's been > 28 days since last PHONE_HOME then
317 if (Config::GetSetting('PHONE_HOME_DATE') < (time() - (60 * 60 * 24 * 28)))
318 {
319 if ($this->isAuditing == 1)
320 {
321 Debug::LogEntry("audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles");
322 }
323
324 // Retrieve number of displays
325 $SQL = "SELECT COUNT(*)
326 FROM `display`
327 WHERE `licensed` = '1'";
328
329 if (!$results = $db->query($SQL))
330 {
331 trigger_error($db->error());
332 }
333 while ($row = $db->get_row($results))
334 {
335 $PHONE_HOME_CLIENTS = Kit::ValidateParam($row[0],_INT);
336 }
337
338 // Retrieve version number
339 $PHONE_HOME_VERSION = Config::Version('app_ver');
340
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);
342
343 if ($this->isAuditing == 1)
344 {
345 Debug::LogEntry("audit", "PHONE_HOME_URL " . $PHONE_HOME_URL , "xmds", "RequiredFiles");
346 }
347
348 // Set PHONE_HOME_TIME to NOW.
349 $SQL = "UPDATE `setting`
350 SET `value` = '" . time() . "'
351 WHERE `setting`.`setting` = 'PHONE_HOME_DATE' LIMIT 1";
352
353 if (!$results = $db->query($SQL))
354 {
355 trigger_error($db->error());
356 }
357
358 @file_get_contents($PHONE_HOME_URL);
359
360 if ($this->isAuditing == 1)
361 {
362 Debug::LogEntry("audit", "PHONE_HOME [OUT]", "xmds", "RequiredFiles");
363 }
364 //endif
365 }
366 }
367 // END OF PHONE_HOME CODE
368358
369 if ($this->isAuditing == 1)359 if ($this->isAuditing == 1)
370 {360 {
@@ -944,13 +934,17 @@
944 $document = new DOMDocument("1.0");934 $document = new DOMDocument("1.0");
945 $document->loadXML($inventory);935 $document->loadXML($inventory);
946936
947 $macAddress = $document->documentElement->getAttribute('macAddress');937 // Get some information from the media inventory XML and update the display record with it.
938 $macAddress = Kit::ValidateParam($document->documentElement->getAttribute('macAddress'), _STRING);
939 $clientType = Kit::ValidateParam($document->documentElement->getAttribute('clientType'), _STRING);
940 $clientVersion = Kit::ValidateParam($document->documentElement->getAttribute('clientVersion'), _STRING);
941 $clientCode = Kit::ValidateParam($document->documentElement->getAttribute('clientCode'), _INT);
948942
949 // Assume we are complete (but we are getting some)943 // Assume we are complete (but we are getting some)
950 $mediaInventoryComplete = 1;944 $mediaInventoryComplete = 1;
951945
952 $xpath = new DOMXPath($document);946 $xpath = new DOMXPath($document);
953 $fileNodes = $xpath->query("//file");947 $fileNodes = $xpath->query("//file");
954948
955 foreach ($fileNodes as $node)949 foreach ($fileNodes as $node)
956 {950 {
@@ -968,7 +962,7 @@
968962
969 // Touch the display record963 // Touch the display record
970 $displayObject = new Display($db);964 $displayObject = new Display($db);
971 $displayObject->Touch($hardwareKey, '', $mediaInventoryComplete, $inventory, $macAddress);965 $displayObject->Touch($hardwareKey, '', $mediaInventoryComplete, $inventory, $macAddress, $clientType, $clientVersion, $clientCode);
972966
973 return true;967 return true;
974 }968 }
@@ -1037,6 +1031,61 @@
1037 }1031 }
10381032
1039 /**1033 /**
1034 * PHONE_HOME if required
1035 */
1036 private function PhoneHome() {
1037
1038 if (Config::GetSetting('PHONE_HOME') == 'On')
1039 {
1040 // Find out when we last PHONED_HOME :D
1041 // If it's been > 28 days since last PHONE_HOME then
1042 if (Config::GetSetting('PHONE_HOME_DATE') < (time() - (60 * 60 * 24 * 28)))
1043 {
1044 if ($this->isAuditing == 1)
1045 {
1046 Debug::LogEntry("audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles");
1047 }
1048
1049 try {
1050 $dbh = PDOConnect::init();
1051
1052 // Retrieve number of displays
1053 $sth = $dbh->prepare('SELECT COUNT(*) AS Cnt FROM `display` WHERE `licensed` = 1');
1054 $sth->execute();
1055
1056 $PHONE_HOME_CLIENTS = $sth->fetchColumn();
1057
1058 // Retrieve version number
1059 $PHONE_HOME_VERSION = Config::Version('app_ver');
1060
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);
1062
1063 if ($this->isAuditing == 1)
1064 Debug::LogEntry("audit", "PHONE_HOME_URL " . $PHONE_HOME_URL , "xmds", "RequiredFiles");
1065
1066 // Set PHONE_HOME_TIME to NOW.
1067 $sth = $dbh->prepare('UPDATE `setting` SET `value` = :time WHERE `setting`.`setting` = :setting LIMIT 1');
1068 $sth->execute(array(
1069 'time' => time(),
1070 'setting' => 'PHONE_HOME_DATE'
1071 ));
1072
1073 @file_get_contents($PHONE_HOME_URL);
1074
1075 if ($this->isAuditing == 1)
1076 Debug::LogEntry("audit", "PHONE_HOME [OUT]", "xmds", "RequiredFiles");
1077 }
1078 catch (Exception $e) {
1079
1080 Debug::LogEntry('error', $e->getMessage());
1081
1082 return false;
1083 }
1084 }
1085 }
1086 }
1087
1088 /**
1040 * Authenticates the display1089 * Authenticates the display
1041 * @param <type> $hardwareKey1090 * @param <type> $hardwareKey
1042 * @return <type>1091 * @return <type>
@@ -1046,7 +1095,7 @@
1046 $db =& $this->db;1095 $db =& $this->db;
10471096
1048 // check in the database for this hardwareKey1097 // check in the database for this hardwareKey
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'";
10501099
1051 if (!$result = $db->query($SQL))1100 if (!$result = $db->query($SQL))
1052 {1101 {
@@ -1090,6 +1139,7 @@
1090 $this->isAuditing = $row[2];1139 $this->isAuditing = $row[2];
1091 $this->displayId = $row[3];1140 $this->displayId = $row[3];
1092 $this->defaultLayoutId = $row[4];1141 $this->defaultLayoutId = $row[4];
1142 $this->version_instructions = $row[8];
1093 1143
1094 return true;1144 return true;
1095 }1145 }
10961146
=== modified file 'server/locale/dbtranslate.php'
--- server/locale/dbtranslate.php 2014-02-12 18:11:45 +0000
+++ server/locale/dbtranslate.php 2014-03-29 13:09:24 +0000
@@ -54,6 +54,7 @@
54echo __('Campaigns');54echo __('Campaigns');
55echo __('Transitions');55echo __('Transitions');
56echo __('Resolutions');56echo __('Resolutions');
57echo __('User Groups');
5758
58// Settings translations59// Settings translations
59echo __('jpg_length');60echo __('jpg_length');
@@ -97,6 +98,9 @@
97echo __('SETTING_IMPORT_ENABLED');98echo __('SETTING_IMPORT_ENABLED');
98echo __('SETTING_LIBRARY_TIDY_ENABLED');99echo __('SETTING_LIBRARY_TIDY_ENABLED');
99echo __('EMBEDDED_STATUS_WIDGET');100echo __('EMBEDDED_STATUS_WIDGET');
101echo __('PROXY_HOST');
102echo __('PROXY_PORT');
103echo __('PROXY_AUTH');
100104
101// Transitions105// Transitions
102echo __('Fade In');106echo __('Fade In');
103107
=== added file 'server/manual/content/admin/file_associations_form.png'
104Binary 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 differ108Binary 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
=== added file 'server/manual/content/admin/file_associations_menu.png'
105Binary 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 differ109Binary 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
=== added file 'server/manual/content/admin/fileassociations.php'
--- server/manual/content/admin/fileassociations.php 1970-01-01 00:00:00 +0000
+++ server/manual/content/admin/fileassociations.php 2014-03-29 13:09:24 +0000
@@ -0,0 +1,33 @@
1<?php
2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2006-2014 Daniel Garner
5 *
6 * This file is part of Xibo.
7 *
8 * Xibo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * Xibo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
20 */
21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
22?>
23<h1 id="File_Associations">File Associations</h1>
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>
25
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>
27
28<p><img class="img-thumbnail" alt="Display Administration" src="content/admin/file_associations_menu.png"></p>
29
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>
31<p><img class="img-thumbnail" alt="Display Administration" src="content/admin/file_associations_form.png"></p>
32
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>
0\ No newline at end of file34\ No newline at end of file
135
=== added file 'server/manual/content/content/content_genericfile.php'
--- server/manual/content/content/content_genericfile.php 1970-01-01 00:00:00 +0000
+++ server/manual/content/content/content_genericfile.php 2014-03-29 13:09:24 +0000
@@ -0,0 +1,25 @@
1<?php
2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2006-2014 Daniel Garner
5 *
6 * This file is part of Xibo.
7 *
8 * Xibo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * Xibo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
20 */
21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
22?>
23<h1>Generic Files</h1>
24
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>
026
=== modified file 'server/manual/content/routes.php'
--- server/manual/content/routes.php 2014-02-09 22:47:01 +0000
+++ server/manual/content/routes.php 2014-03-29 13:09:24 +0000
@@ -61,6 +61,7 @@
61 'content/content_powerpoint',61 'content/content_powerpoint',
62 'content/content_flash',62 'content/content_flash',
63 'content/content_dataset',63 'content/content_dataset',
64 'content/content_genericfile',
64 'admin/modules',65 'admin/modules',
65 'layout/overview',66 'layout/overview',
66 'layout/layoutdesigner',67 'layout/layoutdesigner',
@@ -110,6 +111,7 @@
110 'admin/blueprints',111 'admin/blueprints',
111 'admin/advanced',112 'admin/advanced',
112 'admin/contributing',113 'admin/contributing',
114 'admin/fileassociations',
113 'admin/database_model',115 'admin/database_model',
114 'admin/release_notes',116 'admin/release_notes',
115 'admin/release_notes_archive',117 'admin/release_notes_archive',
116118
=== modified file 'server/manual/content/toc_library.php'
--- server/manual/content/toc_library.php 2013-12-31 14:20:43 +0000
+++ server/manual/content/toc_library.php 2014-03-29 13:09:24 +0000
@@ -8,5 +8,6 @@
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>
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>
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>
11 <a class="list-group-item" href="index.php?toc=library&p=content/content_genericfile">Generic File</a>
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>
12</div>13</div>
13\ No newline at end of file14\ No newline at end of file
1415
=== modified file 'server/manual/content/toc_user_and_display.php'
--- server/manual/content/toc_user_and_display.php 2013-12-30 19:53:51 +0000
+++ server/manual/content/toc_user_and_display.php 2014-03-29 13:09:24 +0000
@@ -9,4 +9,5 @@
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>
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>
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>
12 <a class="list-group-item" href="index.php?toc=user_and_display&p=admin/fileassociations">File Associations</a>
12</div>13</div>
13\ No newline at end of file14\ No newline at end of file
1415
=== modified file 'server/modules/datasetview.module.php'
--- server/modules/datasetview.module.php 2014-01-18 09:47:41 +0000
+++ server/modules/datasetview.module.php 2014-03-29 13:09:24 +0000
@@ -410,13 +410,22 @@
410 $styleSheet = $rawNode->nodeValue;410 $styleSheet = $rawNode->nodeValue;
411 }411 }
412412
413 $headContent = '<style type="text/css">' . $styleSheet . '</style>';413 $options = array(
414414 'duration' => $this->duration,
415 if ($this->GetOption('rowsPerPage') != 0) {415 'originalWidth' => $this->width,
416416 'originalHeight' => $this->height,
417 // Include some JavaScript to kick off the cycle plugin417 'rowsPerPage' => $this->GetOption('rowsPerPage'),
418 $headContent .= '<script type="text/javascript">function init() { $("#DataSetTableContainer").dataSetRender({duration: ' . $this->GetOption('duration') . '}); }</script>';418 'previewWidth' => Kit::GetParam('width', _GET, _INT, 0),
419 }419 'previewHeight' => Kit::GetParam('height', _GET, _INT, 0)
420 );
421
422 $headContent = '<style type="text/css">' . $styleSheet . '</style>';
423 $headContent .= '<script type="text/javascript">';
424 $headContent .= ' function init() { ';
425 $headContent .= ' $("#DataSetTableContainer").dataSetRender(options);';
426 $headContent .= ' } ';
427 $headContent .= ' var options = ' . json_encode($options) . ';';
428 $headContent .= '</script>';
420429
421 // Load the HtmlTemplate430 // Load the HtmlTemplate
422 $template = file_get_contents('modules/preview/HtmlTemplateForGetResource.html');431 $template = file_get_contents('modules/preview/HtmlTemplateForGetResource.html');
423432
=== added file 'server/modules/genericfile.module.php'
--- server/modules/genericfile.module.php 1970-01-01 00:00:00 +0000
+++ server/modules/genericfile.module.php 2014-03-29 13:09:24 +0000
@@ -0,0 +1,128 @@
1<?php
2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2014 Daniel Garner
5 *
6 * This file is part of Xibo.
7 *
8 * Xibo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * Xibo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
20 */
21class genericfile extends Module
22{
23 // Custom Media information
24 protected $maxFileSize;
25 protected $maxFileSizeBytes;
26
27 public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '', $lkid = '')
28 {
29 // Must set the type of the class
30 $this->type= 'genericfile';
31 $this->displayType = __('Generic File');
32
33 // Get the max upload size from PHP
34 $this->maxFileSize = ini_get('upload_max_filesize');
35 $this->maxFileSizeBytes = convertBytes($this->maxFileSize);
36
37 // Must call the parent class
38 parent::__construct($db, $user, $mediaid, $layoutid, $regionid, $lkid);
39 }
40
41 /**
42 * Sets the Layout and Region Information
43 * it will then fill in any blanks it has about this media if it can
44 * @return
45 * @param $layoutid Object
46 * @param $regionid Object
47 * @param $mediaid Object
48 */
49 public function SetRegionInformation($layoutid, $regionid)
50 {
51 $db =& $this->db;
52 $this->layoutid = $layoutid;
53 $this->regionid = $regionid;
54 $mediaid = $this->mediaid;
55 $this->existingMedia = false;
56
57 if ($this->regionSpecific == 1)
58 return;
59
60 try {
61 $dbh = PDOConnect::init();
62
63 // Load what we know about this media into the object
64 $sth = $dbh->prepare('SELECT storedAs FROM media WHERE mediaID = :mediaid');
65 $sth->execute(array('mediaid' => $mediaid));
66
67 if (!$storedAs = $sth->fetchColumn())
68 return false;
69
70 $this->SetOption('uri', $storedAs);
71 }
72 catch (Exception $e) {
73
74 Debug::LogEntry('error', $e->getMessage());
75
76 return false;
77 }
78
79 return true;
80 }
81
82 /**
83 * Return the Add Form as HTML
84 * @return
85 */
86 public function AddForm()
87 {
88 return $this->AddFormForLibraryMedia();
89 }
90
91 /**
92 * Return the Edit Form as HTML
93 * @return
94 */
95 public function EditForm()
96 {
97 return $this->EditFormForLibraryMedia();
98 }
99
100 /**
101 * Add Media to the Database
102 * @return
103 */
104 public function AddMedia()
105 {
106 return $this->AddLibraryMedia();
107 }
108
109 /**
110 * Edit Media in the Database
111 * @return
112 */
113 public function EditMedia()
114 {
115 return $this->EditLibraryMedia();
116 }
117
118 /**
119 * Get Resource
120 */
121 public function GetResource($displayId = 0)
122 {
123 $this->ReturnFile();
124
125 exit();
126 }
127}
128?>
0129
=== modified file 'server/modules/module_user_general.php'
--- server/modules/module_user_general.php 2014-02-15 11:25:09 +0000
+++ server/modules/module_user_general.php 2014-03-29 13:09:24 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
2/*2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2006-2013 Daniel Garner and James Packer4 * Copyright (C) 2006-2014 Daniel Garner
5 *5 *
6 * This file is part of Xibo.6 * This file is part of Xibo.
7 *7 *
@@ -22,147 +22,147 @@
22 22
23 class User 23 class User
24 {24 {
25 private $db;25 private $db;
26 26
27 public $userid;27 public $userid;
28 public $usertypeid;28 public $usertypeid;
29 public $userName;29 public $userName;
30 public $homePage;30 public $homePage;
31 31
32 public function __construct(database $db)32 public function __construct(database $db)
33 {33 {
34 $this->db =& $db;34 $this->db =& $db;
35 $this->userid = Kit::GetParam('userid', _SESSION, _INT);35 $this->userid = Kit::GetParam('userid', _SESSION, _INT);
36 $this->usertypeid = Kit::GetParam('usertype', _SESSION, _INT);36 $this->usertypeid = Kit::GetParam('usertype', _SESSION, _INT);
3737
38 // We havent authed yet38 // We havent authed yet
39 $this->authedDisplayGroupIDs = false;39 $this->authedDisplayGroupIDs = false;
40 }40 }
41 41
42 /**42 /**
43 * Validate the User is Logged In43 * Validate the User is Logged In
44 * @param $ajax Object[optional] Indicates if this request came from an AJAX call or otherwise44 * @param $ajax Object[optional] Indicates if this request came from an AJAX call or otherwise
45 */45 */
46 function attempt_login($ajax = false) 46 function attempt_login($ajax = false)
47 {47 {
48 $db =& $this->db;48 $db =& $this->db;
49 $userid = Kit::GetParam('userid', _SESSION, _INT);49 $userid = Kit::GetParam('userid', _SESSION, _INT);
5050
51 // Referring Page is anything after the ?51 // Referring Page is anything after the ?
52 $requestUri = rawurlencode(Kit::GetCurrentPage());52 $requestUri = rawurlencode(Kit::GetCurrentPage());
53 53
54 if (!$this->checkforUserid()) 54 if (!$this->checkforUserid())
55 {55 {
56 // Log out the user56 // Log out the user
57 if ($userid != 0)57 if ($userid != 0)
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));
5959
60 // AJAX calls that fail the login test cause a page redirect60 // AJAX calls that fail the login test cause a page redirect
61 if ($ajax) 61 if ($ajax)
62 {62 {
63 //create the AJAX request object63 //create the AJAX request object
64 $response = new ResponseManager();64 $response = new ResponseManager();
6565
66 $response->Login();66 $response->Login();
67 $response->Respond();67 $response->Respond();
68 }68 }
69 else 69 else
70 {70 {
71 Theme::Set('form_meta', '<input type="hidden" name="token" value="' . CreateFormToken() . '" />');71 Theme::Set('form_meta', '<input type="hidden" name="token" value="' . CreateFormToken() . '" />');
72 Theme::Set('form_action', 'index.php?q=login&referingPage=' . $requestUri);72 Theme::Set('form_action', 'index.php?q=login&referingPage=' . $requestUri);
73 Theme::Set('about_url', 'index.php?p=index&q=About');73 Theme::Set('about_url', 'index.php?p=index&q=About');
74 Theme::Set('source_url', 'https://launchpad.net/xibo/1.6');74 Theme::Set('source_url', 'https://launchpad.net/xibo/1.6');
7575
76 // Message (either from the URL or the session)76 // Message (either from the URL or the session)
77 $message = Kit::GetParam('message', _GET, _STRING, Kit::GetParam('message', _SESSION, _STRING, ''));77 $message = Kit::GetParam('message', _GET, _STRING, Kit::GetParam('message', _SESSION, _STRING, ''));
78 Theme::Set('login_message', $message);78 Theme::Set('login_message', $message);
79 Theme::Render('login_page');79 Theme::Render('login_page');
80 80
81 // Clear the session message81 // Clear the session message
82 $_SESSION['message'] = '';82 $_SESSION['message'] = '';
83 exit;83 exit;
84 }84 }
85 85
86 return false;86 return false;
87 }87 }
88 else 88 else
89 {89 {
90 //write out to the db that the logged in user has accessed the page still90 //write out to the db that the logged in user has accessed the page still
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);
92 92
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);
9494
95 // Load the information about this user95 // Load the information about this user
96 $this->LoginServices($userid);96 $this->LoginServices($userid);
97 97
98 return true;98 return true;
99 }99 }
100 }100 }
101101
102 /**102 /**
103 * Login a user103 * Login a user
104 * @return 104 * @return
105 * @param $username Object105 * @param $username Object
106 * @param $password Object106 * @param $password Object
107 */107 */
108 function login($username, $password) 108 function login($username, $password)
109 {109 {
110 $db =& $this->db;110 $db =& $this->db;
111111
112 Kit::ClassLoader('userdata');112 Kit::ClassLoader('userdata');
113 113
114 // Get the SALT for this username114 // Get the SALT for this username
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)))) {
116 setMessage(__('Username or Password incorrect'));116 setMessage(__('Username or Password incorrect'));
117 return false;117 return false;
118 }118 }
119119
120 // User Data Object to check the password120 // User Data Object to check the password
121 $userData = new Userdata($db);121 $userData = new Userdata($db);
122122
123 // Is SALT empty123 // Is SALT empty
124 if ($userInfo['CSPRNG'] == 0) {124 if ($userInfo['CSPRNG'] == 0) {
125125
126 // Check the password using a MD5126 // Check the password using a MD5
127 if ($userInfo['UserPassword'] != md5($password)) {127 if ($userInfo['UserPassword'] != md5($password)) {
128 setMessage(__('Username or Password incorrect'));128 setMessage(__('Username or Password incorrect'));
129 return false;129 return false;
130 }130 }
131131
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.
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 */);
134 }134 }
135 else {135 else {
136 136
137 // Check the users password using the random SALTED password137 // Check the users password using the random SALTED password
138 if ($userData->validate_password($password, $userInfo['UserPassword']) === false) {138 if ($userData->validate_password($password, $userInfo['UserPassword']) === false) {
139 setMessage(__('Username or Password incorrect'));139 setMessage(__('Username or Password incorrect'));
140 return false;140 return false;
141 }141 }
142 }142 }
143 143
144 // there is a result so we store the userID in the session variable144 // there is a result so we store the userID in the session variable
145 $_SESSION['userid'] = Kit::ValidateParam($userInfo['UserID'], _INT);145 $_SESSION['userid'] = Kit::ValidateParam($userInfo['UserID'], _INT);
146 $_SESSION['username'] = Kit::ValidateParam($userInfo['UserName'], _USERNAME);146 $_SESSION['username'] = Kit::ValidateParam($userInfo['UserName'], _USERNAME);
147 $_SESSION['usertype'] = Kit::ValidateParam($userInfo['UserTypeID'], _INT);147 $_SESSION['usertype'] = Kit::ValidateParam($userInfo['UserTypeID'], _INT);
148148
149 // Set the User Object149 // Set the User Object
150 $this->usertypeid = $_SESSION['usertype'];150 $this->usertypeid = $_SESSION['usertype'];
151 $this->userid = $_SESSION['userid'];151 $this->userid = $_SESSION['userid'];
152152
153 // update the db153 // update the db
154 // write out to the db that the logged in user has accessed the page154 // write out to the db that the logged in user has accessed the page
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']);
156 156
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);
158158
159 // Switch Session ID's159 // Switch Session ID's
160 global $session;160 global $session;
161 $session->setIsExpired(0);161 $session->setIsExpired(0);
162 $session->RegenerateSessionID(session_id());162 $session->RegenerateSessionID(session_id());
163163
164 return true;164 return true;
165 }165 }
166166
167 /**167 /**
168 * Logs in a specific userID168 * Logs in a specific userID
@@ -178,99 +178,99 @@
178 return false;178 return false;
179179
180 $this->userName = Kit::ValidateParam($results['UserName'], _USERNAME);180 $this->userName = Kit::ValidateParam($results['UserName'], _USERNAME);
181 $this->usertypeid = Kit::ValidateParam($results['usertypeid'], _INT);181 $this->usertypeid = Kit::ValidateParam($results['usertypeid'], _INT);
182 $this->userid = $userID;182 $this->userid = $userID;
183 $this->homePage = Kit::ValidateParam($results['homepage'], _WORD);183 $this->homePage = Kit::ValidateParam($results['homepage'], _WORD);
184184
185 return true;185 return true;
186 }186 }
187187
188 /**188 /**
189 * Logout the user associated with this user object189 * Logout the user associated with this user object
190 * @return 190 * @return
191 */191 */
192 function logout() 192 function logout()
193 {193 {
194 $db =& $this->db;194 $db =& $this->db;
195 global $session;195 global $session;
196 196
197 $userid = Kit::GetParam('userid', _SESSION, _INT);197 $userid = Kit::GetParam('userid', _SESSION, _INT);
198198
199 //write out to the db that the logged in user has accessed the page still199 //write out to the db that the logged in user has accessed the page still
200 $SQL = sprintf("UPDATE user SET loggedin = 0 WHERE userid = %d", $userid);200 $SQL = sprintf("UPDATE user SET loggedin = 0 WHERE userid = %d", $userid);
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);
202202
203 //to log out a user we need only to clear out some session vars203 //to log out a user we need only to clear out some session vars
204 unset($_SESSION['userid']);204 unset($_SESSION['userid']);
205 unset($_SESSION['username']);205 unset($_SESSION['username']);
206 unset($_SESSION['password']);206 unset($_SESSION['password']);
207 207
208 $session->setIsExpired(1);208 $session->setIsExpired(1);
209209
210 return true;210 return true;
211 }211 }
212212
213 //Check to see if a user id is in the session information213 //Check to see if a user id is in the session information
214 function checkforUserid() 214 function checkforUserid()
215 {215 {
216 $db =& $this->db;216 $db =& $this->db;
217 global $session;217 global $session;
218 218
219 $userid = Kit::GetParam('userid', _SESSION, _INT, 0);219 $userid = Kit::GetParam('userid', _SESSION, _INT, 0);
220 220
221 // Checks for a user ID in the session variable221 // Checks for a user ID in the session variable
222 if($userid == 0) 222 if($userid == 0)
223 {223 {
224 return false;224 return false;
225 }225 }
226 else 226 else
227 {227 {
228 if(!is_numeric($_SESSION['userid'])) 228 if(!is_numeric($_SESSION['userid']))
229 {229 {
230 unset($_SESSION['userid']);230 unset($_SESSION['userid']);
231 return false;231 return false;
232 }232 }
233 elseif ($session->isExpired == 1) 233 elseif ($session->isExpired == 1)
234 {234 {
235 unset($_SESSION['userid']);235 unset($_SESSION['userid']);
236 return false;236 return false;
237 }237 }
238 else 238 else
239 {239 {
240 // check to see that the ID is still valid240 // check to see that the ID is still valid
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);
242 242
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);
244 244
245 if($db->num_rows($result)==0) 245 if($db->num_rows($result)==0)
246 {246 {
247 unset($_SESSION['userid']);247 unset($_SESSION['userid']);
248 return false;248 return false;
249 }249 }
250 return true;250 return true;
251 }251 }
252 }252 }
253 }253 }
254 254
255 function getNameFromID($id) 255 function getNameFromID($id)
256 {256 {
257 $db =& $this->db;257 $db =& $this->db;
258 258
259 $SQL = sprintf("SELECT username FROM user WHERE userid = %d", $id);259 $SQL = sprintf("SELECT username FROM user WHERE userid = %d", $id);
260 260
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);
262 262
263 // if no user is returned263 // if no user is returned
264 if ($db->num_rows($results) == 0) 264 if ($db->num_rows($results) == 0)
265 {265 {
266 // assume that is the xibo_admin266 // assume that is the xibo_admin
267 return "None";267 return "None";
268 }268 }
269269
270 $row = $db->get_row($results);270 $row = $db->get_row($results);
271 271
272 return $row[0];272 return $row[0];
273 }273 }
274274
275 /**275 /**
276 * Get an array of user groups for the given user id276 * Get an array of user groups for the given user id
@@ -279,7 +279,7 @@
279 * @return <array>279 * @return <array>
280 */280 */
281 public function GetUserGroups($id, $returnID = false)281 public function GetUserGroups($id, $returnID = false)
282 {282 {
283 $db =& $this->db;283 $db =& $this->db;
284284
285 $groupIDs = array();285 $groupIDs = array();
@@ -335,12 +335,12 @@
335335
336336
337 return $groups;337 return $groups;
338 }338 }
339339
340 function getGroupFromID($id, $returnID = false) 340 function getGroupFromID($id, $returnID = false)
341 {341 {
342 $db =& $this->db;342 $db =& $this->db;
343 343
344 $SQL = "";344 $SQL = "";
345 $SQL .= "SELECT group.group, ";345 $SQL .= "SELECT group.group, ";
346 $SQL .= " group.groupID ";346 $SQL .= " group.groupID ";
@@ -351,13 +351,13 @@
351 $SQL .= " ON group.groupID = lkusergroup.GroupID ";351 $SQL .= " ON group.groupID = lkusergroup.GroupID ";
352 $SQL .= sprintf("WHERE `user`.userid = %d ", $id);352 $SQL .= sprintf("WHERE `user`.userid = %d ", $id);
353 $SQL .= "AND `group`.IsUserSpecific = 1";353 $SQL .= "AND `group`.IsUserSpecific = 1";
354 354
355 if(!$results = $db->query($SQL))355 if(!$results = $db->query($SQL))
356 {356 {
357 trigger_error($db->error());357 trigger_error($db->error());
358 trigger_error("Error looking up user information (group)", E_USER_ERROR);358 trigger_error("Error looking up user information (group)", E_USER_ERROR);
359 }359 }
360 360
361 if ($db->num_rows($results) == 0)361 if ($db->num_rows($results) == 0)
362 {362 {
363 // Every user should have a group?363 // Every user should have a group?
@@ -387,68 +387,68 @@
387 return $row[1];387 return $row[1];
388 }388 }
389 return $row[0];389 return $row[0];
390 }390 }
391 391
392 function getUserTypeFromID($id, $returnID = false) 392 function getUserTypeFromID($id, $returnID = false)
393 {393 {
394 $db =& $this->db;394 $db =& $this->db;
395 395
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);
397 397
398 if(!$results = $db->query($SQL)) 398 if(!$results = $db->query($SQL))
399 {399 {
400 trigger_error("Error looking up user information (usertype)");400 trigger_error("Error looking up user information (usertype)");
401 trigger_error($db->error());401 trigger_error($db->error());
402 }402 }
403 403
404 if ($db->num_rows($results)==0) 404 if ($db->num_rows($results)==0)
405 {405 {
406 if ($returnID) 406 if ($returnID)
407 {407 {
408 return "3";408 return "3";
409 }409 }
410 return "User";410 return "User";
411 }411 }
412 412
413 $row = $db->get_row($results);413 $row = $db->get_row($results);
414 414
415 if ($returnID) 415 if ($returnID)
416 {416 {
417 return $row[1];417 return $row[1];
418 }418 }
419 return $row[0];419 return $row[0];
420 }420 }
421 421
422 function getEmailFromID($id) 422 function getEmailFromID($id)
423 {423 {
424 $db =& $this->db;424 $db =& $this->db;
425 425
426 $SQL = sprintf("SELECT email FROM user WHERE userid = %d", $id);426 $SQL = sprintf("SELECT email FROM user WHERE userid = %d", $id);
427 427
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);
429 429
430 if ($db->num_rows($results)==0) 430 if ($db->num_rows($results)==0)
431 {431 {
432 $SQL = "SELECT email FROM user WHERE userid = 1";432 $SQL = "SELECT email FROM user WHERE userid = 1";
433 433
434 if(!$results = $db->query($SQL)) 434 if(!$results = $db->query($SQL))
435 {435 {
436 trigger_error("Unknown user id in the system [$id]");436 trigger_error("Unknown user id in the system [$id]");
437 }437 }
438 }438 }
439 439
440 $row = $db->get_row($results);440 $row = $db->get_row($results);
441 return $row[1];441 return $row[1];
442 }442 }
443 443
444 /**444 /**
445 * Gets the homepage for the given userid445 * Gets the homepage for the given userid
446 * @param <type> $userId446 * @param <type> $userId
447 * @return <type>447 * @return <type>
448 */448 */
449 function GetHomePage($userId)449 function GetHomePage($userId)
450 {450 {
451 $db =& $this->db;451 $db =& $this->db;
452452
453 $SQL = sprintf("SELECT homepage FROM `user` WHERE userid = %d", $userId);453 $SQL = sprintf("SELECT homepage FROM `user` WHERE userid = %d", $userId);
454454
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: