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

Subscribers

People subscribed via source and target branches

to all changes: