Merge lp:~dangarner/xibo/server-170-alpha2 into lp:xibo/1.7

Proposed by Dan Garner
Status: Merged
Merged at revision: 347
Proposed branch: lp:~dangarner/xibo/server-170-alpha2
Merge into: lp:xibo/1.7
Diff against target: 30604 lines (+23044/-3722)
174 files modified
example_oauth/index.php (+14/-11)
server/config/client.config.php (+1/-1)
server/config/config.class.php (+6/-4)
server/install/database/80.sql (+1/-6)
server/install/database/81.sql (+23/-0)
server/install/master/data.sql (+6/-7)
server/install/master/structure.sql (+5/-3)
server/lib/app/cache.class.php (+82/-0)
server/lib/app/debug.class.php (+180/-169)
server/lib/app/kit.class.php (+456/-445)
server/lib/app/modulemanager.class.php (+2/-5)
server/lib/app/permissionmanager.class.php (+1/-3)
server/lib/app/responsemanager.class.php (+3/-1)
server/lib/app/session.class.php (+11/-4)
server/lib/app/thememanager.class.php (+56/-0)
server/lib/app/translationengine.class.php (+69/-68)
server/lib/data/campaign.data.class.php (+3/-1)
server/lib/data/campaignsecurity.data.class.php (+9/-0)
server/lib/data/datasetdata.data.class.php (+4/-0)
server/lib/data/datasetgroupsecurity.data.class.php (+18/-40)
server/lib/data/display.data.class.php (+133/-2)
server/lib/data/displayprofile.data.class.php (+55/-0)
server/lib/data/layout.data.class.php (+10/-18)
server/lib/data/maintenance.data.class.php (+156/-15)
server/lib/data/media.data.class.php (+101/-5)
server/lib/data/region.data.class.php (+5/-10)
server/lib/data/schedule.data.class.php (+578/-516)
server/lib/data/stat.data.class.php (+121/-63)
server/lib/data/usergroup.data.class.php (+52/-0)
server/lib/include.php (+8/-2)
server/lib/modules/module.class.php (+53/-47)
server/lib/pages/admin.class.php (+37/-71)
server/lib/pages/campaign.class.php (+36/-29)
server/lib/pages/content.class.php (+6/-5)
server/lib/pages/display.class.php (+53/-73)
server/lib/pages/displaygroup.class.php (+15/-25)
server/lib/pages/index.class.php (+10/-0)
server/lib/pages/install.class.php (+7/-1)
server/lib/pages/layout.class.php (+102/-59)
server/lib/pages/log.class.php (+4/-2)
server/lib/pages/module.class.php (+5/-4)
server/lib/pages/oauth.class.php (+1/-0)
server/lib/pages/preview.class.php (+3/-1)
server/lib/pages/schedule.class.php (+13/-12)
server/lib/pages/stats.class.php (+153/-9)
server/lib/pages/template.class.php (+14/-25)
server/lib/pages/timeline.class.php (+239/-57)
server/lib/pages/user.class.php (+4/-3)
server/lib/service/rest.class.php (+15/-2)
server/lib/service/service.wsdl (+3/-2)
server/lib/service/xmdssoap.class.php (+120/-90)
server/lib/xmds.inc.php (+8/-5)
server/locale/dbtranslate.php (+4/-0)
server/maintenance.php (+119/-172)
server/manual/content/admin/release_notes_1.7.0-alpha2.php (+84/-0)
server/manual/content/routes.php (+1/-0)
server/manual/content/toc_developer_releasenotes.php (+1/-0)
server/manual/template.php (+1/-1)
server/modules/3rdparty/forecast.php (+38/-0)
server/modules/clock.module.php (+33/-48)
server/modules/datasetview.module.php (+41/-14)
server/modules/embedded.module.php (+247/-193)
server/modules/font.module.php (+187/-0)
server/modules/forecastio.module.php (+508/-0)
server/modules/module_user_general.php (+39/-14)
server/modules/preview/Html4TransitionalTemplate.html (+26/-0)
server/modules/preview/HtmlTemplate.html (+9/-3)
server/modules/preview/HtmlTemplateForGetResource.html (+0/-155)
server/modules/preview/HtmlTemplateSimple.html (+1/-1)
server/modules/preview/fonts.css (+11/-0)
server/modules/preview/html-preview.js (+1/-1)
server/modules/preview/vendor/jquery-cycle-2.1.6.min.js (+16/-0)
server/modules/preview/vendor/jquery.marquee.min.js (+5/-0)
server/modules/preview/xibo-dataset-render.js (+51/-0)
server/modules/preview/xibo-layout-scaler.js (+62/-0)
server/modules/preview/xibo-text-render.js (+43/-211)
server/modules/preview/xibo-webpage-render.js (+81/-69)
server/modules/text.module.php (+150/-102)
server/modules/theme/HtmlTemplateForClock.html (+1/-1)
server/modules/theme/HtmlTemplateForFlipClock.html (+1/-1)
server/modules/theme/forecastio/weather_icons/weather-icons.min.css (+23/-0)
server/modules/theme/forecastio/weather_icons/weathericons-regular-webfont.svg (+153/-0)
server/modules/ticker.module.php (+93/-39)
server/modules/webpage.module.php (+303/-189)
server/services.php (+4/-2)
server/theme/default/css/html-preview.css (+2/-2)
server/theme/default/html/campaign_form_layout_assign.php (+2/-19)
server/theme/default/html/campaign_form_layout_assign_list.php (+0/-39)
server/theme/default/html/footer.php (+27/-7)
server/theme/default/html/form_grid_pager.php (+0/-41)
server/theme/default/html/grid_pager.php (+14/-15)
server/theme/default/html/grid_render.php (+1/-0)
server/theme/default/html/header.php (+7/-6)
server/theme/default/html/layout_designer.php (+2/-5)
server/theme/default/html/schedule_page.php (+1/-1)
server/theme/default/html/settings_page.php (+103/-86)
server/theme/default/html/stats_page_availability.php (+47/-0)
server/theme/default/html/stats_page_grid.php (+0/-6)
server/theme/default/html/status_dashboard.php (+2/-2)
server/theme/default/html/table_render.php (+110/-48)
server/theme/default/js/xibo-calendar.js (+8/-7)
server/theme/default/js/xibo-cms.js (+347/-63)
server/theme/default/js/xibo-forms.js (+24/-10)
server/theme/default/libraries/bootstrap-ekko-lightbox/ekko-lightbox.min.css (+6/-0)
server/theme/default/libraries/bootstrap-ekko-lightbox/ekko-lightbox.min.js (+7/-0)
server/theme/default/libraries/calendar/js/language/de-DE.js (+0/-73)
server/theme/default/libraries/calendar/js/language/de.js (+73/-0)
server/theme/default/libraries/ckeditor/config.js (+4/-1)
server/theme/default/libraries/ckeditor/contents.css (+2/-2)
server/theme/default/libraries/jquery-message-queuing/jquery.ba-jqmq.min.js (+9/-0)
server/theme/default/libraries/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.css (+42/-0)
server/theme/default/libraries/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js (+958/-0)
server/theme/default/libraries/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.min.js (+2/-0)
server/theme/default/libraries/jquery-tablesorter/css/bootstrap.less (+316/-0)
server/theme/default/libraries/jquery-tablesorter/css/filter.formatter.css (+183/-0)
server/theme/default/libraries/jquery-tablesorter/css/metro.less (+351/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.black-ice.css (+186/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.blue.css (+221/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.bootstrap.css (+152/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.bootstrap_2.css (+150/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.dark.css (+187/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.default.css (+189/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.dropbox.css (+212/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.green.css (+203/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.grey.css (+245/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.ice.css (+201/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.jui.css (+156/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.less (+323/-0)
server/theme/default/libraries/jquery-tablesorter/css/theme.metro-dark.css (+192/-0)
server/theme/default/libraries/jquery-tablesorter/js/extras/jquery.quicksearch.js (+191/-0)
server/theme/default/libraries/jquery-tablesorter/js/extras/semver-mod.js (+1026/-0)
server/theme/default/libraries/jquery-tablesorter/js/extras/semver.js (+1011/-0)
server/theme/default/libraries/jquery-tablesorter/js/jquery.metadata.js (+116/-0)
server/theme/default/libraries/jquery-tablesorter/js/jquery.tablesorter.js (+1901/-0)
server/theme/default/libraries/jquery-tablesorter/js/jquery.tablesorter.min.js (+5/-0)
server/theme/default/libraries/jquery-tablesorter/js/jquery.tablesorter.widgets-filter-formatter-select2.js (+138/-0)
server/theme/default/libraries/jquery-tablesorter/js/jquery.tablesorter.widgets-filter-formatter.js (+1145/-0)
server/theme/default/libraries/jquery-tablesorter/js/jquery.tablesorter.widgets-filter-formatter.min.js (+6/-0)
server/theme/default/libraries/jquery-tablesorter/js/jquery.tablesorter.widgets.js (+1912/-0)
server/theme/default/libraries/jquery-tablesorter/js/jquery.tablesorter.widgets.min.js (+17/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-date-extract.js (+81/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-date-iso8601.js (+34/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-date-month.js (+33/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-date-two-digit-year.js (+74/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-date-weekday.js (+33/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-date.js (+36/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-duration.js (+40/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-feet-inch-fraction.js (+63/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-file-type.js (+73/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-ignore-articles.js (+61/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-image.js (+20/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-input-select.js (+161/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-ipv6.js (+76/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-metric.js (+77/-0)
server/theme/default/libraries/jquery-tablesorter/js/parsers/parser-roman.js (+117/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-alignChar.js (+145/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-build-table.js (+453/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-columnSelector.js (+317/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-cssStickyHeaders.js (+70/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-editable.js (+200/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-grouping.js (+249/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-headerTitles.js (+91/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-math.js (+413/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-output.js (+316/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-pager.js (+975/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-print.js (+123/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-reflow.js (+179/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-repeatheaders.js (+50/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-scroller.js (+218/-0)
server/theme/default/libraries/jquery-tablesorter/js/widgets/widget-staticRow.js (+124/-0)
server/theme/default/libraries/jquery/jquery.metadata.js (+0/-116)
server/theme/default/libraries/jquery/jquery.tablesorter.pack.js (+0/-6)
server/theme/default/libraries/jquery/jquery.tablesorter.pager.css (+0/-28)
server/theme/default/libraries/jquery/jquery.tablesorter.pager.js (+0/-2)
To merge this branch: bzr merge lp:~dangarner/xibo/server-170-alpha2
Reviewer Review Type Date Requested Status
Xibo Maintainters Pending
Review via email: mp+239095@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'example_oauth/index.php'
--- example_oauth/index.php 2014-07-12 13:54:51 +0000
+++ example_oauth/index.php 2014-10-21 16:06:16 +0000
@@ -1,4 +1,7 @@
1<?php1<?php
2error_reporting(E_ALL);
3ini_set('display_errors', 1);
4
2require_once('oauth-php/library/OAuthStore.php');5require_once('oauth-php/library/OAuthStore.php');
3require_once('oauth-php/library/OAuthRequester.php');6require_once('oauth-php/library/OAuthRequester.php');
4require_once('oauth-php/library/OAuthRequestLogger.php');7require_once('oauth-php/library/OAuthRequestLogger.php');
@@ -6,16 +9,16 @@
69
7DEFINE('OAUTH_LOG_REQUEST', true);10DEFINE('OAUTH_LOG_REQUEST', true);
811
9$connection = array('server' => 'localhost', 12$connection = new PDO('mysql:host=localhost;dbname=oauth_consumer', 'root', 'root');
10 'username' => 'root', 13$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
11 'password' => '', 14$connection->query("SET NAMES 'utf8'");
12 'database' => 'oauth_consumer');15
1316OAuthStore::instance('PDO', array('conn' => $connection));
14OAuthStore::instance('MySQL', $connection);17
1518DEFINE('LOCAL_BASE', 'http://172.28.128.3/example_oauth/index.php');
16DEFINE('SERVER_BASE', 'http://localhost/xibo/1.6/server-162/server/');19DEFINE('SERVER_BASE', 'http://unittest.xibo.co.uk/');
17DEFINE('CONSUMER_KEY', 'e982575d2ab70546923b92e50c5b96ca053b407a8');20DEFINE('CONSUMER_KEY', '9beeb94ea11bfa15da1ab7b2b0fb543205436b27b');
18DEFINE('CONSUMER_SECRET', 'a891f97e69985230a2e0e869b9f875e3');21DEFINE('CONSUMER_SECRET', 'fba59ef57d3331032a099cf04b1ebb2d');
19//DEFINE('SERVER_BASE', 'http://unittest2.xibo.org.uk/api/');22//DEFINE('SERVER_BASE', 'http://unittest2.xibo.org.uk/api/');
20//DEFINE('CONSUMER_KEY', '201798cda77e4e82e0488d0c8c2e43ae0519d180f');23//DEFINE('CONSUMER_KEY', '201798cda77e4e82e0488d0c8c2e43ae0519d180f');
21//DEFINE('CONSUMER_SECRET', '9eb4aa8a51e4a393b3fb5ad6f1a75bae');24//DEFINE('CONSUMER_SECRET', '9eb4aa8a51e4a393b3fb5ad6f1a75bae');
@@ -92,7 +95,7 @@
92 }95 }
9396
94 // Callback to our (consumer) site, will be called when the user finished the authorization at the server97 // Callback to our (consumer) site, will be called when the user finished the authorization at the server
95 $callback_uri = '?action=Exchange&consumer_key='.rawurlencode(CONSUMER_KEY).'&usr_id='.intval($user_id);98 $callback_uri = LOCAL_BASE . '?action=Exchange&consumer_key='.rawurlencode(CONSUMER_KEY).'&usr_id='.intval($user_id);
9699
97 // Now redirect to the autorization uri and get us authorized100 // Now redirect to the autorization uri and get us authorized
98 if (!empty($token['authorize_uri']))101 if (!empty($token['authorize_uri']))
99102
=== modified file 'server/config/client.config.php'
--- server/config/client.config.php 2014-09-16 16:41:43 +0000
+++ server/config/client.config.php 2014-10-21 16:06:16 +0000
@@ -272,7 +272,7 @@
272 'title' => __('Use CEF as the Web Browser'),272 'title' => __('Use CEF as the Web Browser'),
273 'type' => _CHECKBOX,273 'type' => _CHECKBOX,
274 'fieldType' => 'checkbox',274 'fieldType' => 'checkbox',
275 'default' => 1,275 'default' => 0,
276 'helpText' => __('CEF is Chrome Embedded and offers up to date web rendering. If unselected the default Internet Explorer control will be used.'),276 'helpText' => __('CEF is Chrome Embedded and offers up to date web rendering. If unselected the default Internet Explorer control will be used.'),
277 'enabled' => true,277 'enabled' => true,
278 'groupClass' => NULL278 'groupClass' => NULL
279279
=== modified file 'server/config/config.class.php'
--- server/config/config.class.php 2014-08-16 12:51:07 +0000
+++ server/config/config.class.php 2014-10-21 16:06:16 +0000
@@ -56,7 +56,7 @@
56 * @return 56 * @return
57 * @param $setting Object[optional]57 * @param $setting Object[optional]
58 */58 */
59 static function GetSetting($setting) 59 static function GetSetting($setting, $default = NULL)
60 { 60 {
61 try {61 try {
62 $dbh = PDOConnect::init();62 $dbh = PDOConnect::init();
@@ -65,12 +65,14 @@
65 $sth->execute(array('setting' => $setting));65 $sth->execute(array('setting' => $setting));
6666
67 if (!$result = $sth->fetch())67 if (!$result = $sth->fetch())
68 return false;68 return $default;
6969
70 //Debug::LogEntry('audit', 'Retrieved setting ' . $result['value'] . ' for ' . $setting, 'Config', 'GetSetting');70 //Debug::LogEntry('audit', 'Retrieved setting ' . $result['value'] . ' for ' . $setting, 'Config', 'GetSetting');
7171
72 // Validate as a string and return72 // Validate as a string and return
73 return Kit::ValidateParam($result['value'], _STRING);73 $result = Kit::ValidateParam($result['value'], _STRING);
74
75 return ($result == '') ? $default : $result;
74 }76 }
75 catch (Exception $e) {77 catch (Exception $e) {
76 trigger_error($e->getMessage());78 trigger_error($e->getMessage());
7779
=== modified file 'server/install/database/80.sql'
--- server/install/database/80.sql 2014-09-19 14:08:28 +0000
+++ server/install/database/80.sql 2014-10-21 16:06:16 +0000
@@ -41,11 +41,6 @@
41 PRIMARY KEY (`displayprofileid`)41 PRIMARY KEY (`displayprofileid`)
42) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;42) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
4343
44INSERT INTO `displayprofile` (`displayprofileid`, `name`, `type`, `config`, `isdefault`, `userid`) VALUES
45(1, 'Production', 'windows', '[{"name":"CollectInterval","value":"900","type":"int"},{"name":"PowerpointEnabled","value":0,"type":"checkbox"},{"name":"StatsEnabled","value":1,"type":"checkbox"},{"name":"SizeX","value":0,"type":"double"},{"name":"SizeY","value":0,"type":"double"},{"name":"OffsetX","value":0,"type":"double"},{"name":"OffsetY","value":0,"type":"double"},{"name":"ShowInTaskbar","value":1,"type":"checkbox"},{"name":"ClientInfomationCtrlKey","value":0,"type":"checkbox"},{"name":"ClientInformationKeyCode","value":"I","type":"word"},{"name":"CursorStartPosition","value":"Bottom Right","type":"string"},{"name":"DoubleBuffering","value":1,"type":"checkbox"},{"name":"EmptyLayoutDuration","value":"10","type":"int"},{"name":"EnableMouse","value":0,"type":"checkbox"},{"name":"EnableShellCommands","value":0,"type":"checkbox"},{"name":"ExpireModifiedLayouts","value":0,"type":"checkbox"},{"name":"LogLevel","value":"off","type":"word"},{"name":"LogToDiskLocation","value":"","type":"string"},{"name":"MaxConcurrentDownloads","value":"2","type":"int"},{"name":"ShellCommandAllowList","value":"","type":"string"},{"name":"UseCefWebBrowser","value":1,"type":"checkbox"},{"name":"SendCurrentLayoutAsStatusUpdate","value":0,"type":"checkbox"},{"name":"ScreenShotRequestInterval","value":0,"type":"int"}]', 1, 1),
46(2, 'Production', 'android', '[{"name":"emailAddress","value":"","type":"string"},{"name":"settingsPassword","value":"","type":"string"},{"name":"collectInterval","value":"600","type":"int"},{"name":"orientation","value":0,"type":"int"},{"name":"startOnBoot","value":1,"type":"checkbox"},{"name":"actionBarMode","value":"1","type":"int"},{"name":"actionBarDisplayDuration","value":"60","type":"int"},{"name":"screenDimensions","value":"","type":"string"},{"name":"autoRestart","value":1,"type":"checkbox"},{"name":"startOnBootDelay","value":"60","type":"int"},{"name":"blacklistVideo","value":1,"type":"checkbox"},{"name":"storeHtmlOnInternal","value":0,"type":"checkbox"}]', 1, 1);
47
48
49UPDATE layout SET background = SUBSTRING_INDEX(background, '.', 1) WHERE IFNULL(background, '') <> '';44UPDATE layout SET background = SUBSTRING_INDEX(background, '.', 1) WHERE IFNULL(background, '') <> '';
50ALTER TABLE `layout` CHANGE `background` `backgroundImageId` INT( 11 ) NULL DEFAULT NULL;45ALTER TABLE `layout` CHANGE `background` `backgroundImageId` INT( 11 ) NULL DEFAULT NULL;
5146
@@ -178,6 +173,6 @@
178('DisplayProfile', 'Delete', 'manual/single.php?p=admin/displayprofiles#delete');173('DisplayProfile', 'Delete', 'manual/single.php?p=admin/displayprofiles#delete');
179174
180175
181UPDATE `version` SET `app_ver` = '1.7.0-alpha', `XmdsVersion` = 4;176UPDATE `version` SET `app_ver` = '1.7.0-alpha', `XmdsVersion` = 4, `XlfVersion` = 2 ;
182UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';177UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
183UPDATE `version` SET `DBVersion` = '80';178UPDATE `version` SET `DBVersion` = '80';
184179
=== added file 'server/install/database/81.sql'
--- server/install/database/81.sql 1970-01-01 00:00:00 +0000
+++ server/install/database/81.sql 2014-10-21 16:06:16 +0000
@@ -0,0 +1,23 @@
1INSERT INTO `setting` (`setting` ,`value` ,`fieldType` ,`helptext` ,`options` ,`cat` ,`userChange` ,`title` ,`validation` ,`ordering` ,`default` ,`userSee` ,`type`)
2VALUES (
3 'DATE_FORMAT', 'Y-m-d', 'text', 'The Date Format to use when displaying dates in the CMS.', NULL , 'regional', '1', 'Date Format', 'required', '30', 'Y-m-d', '1', 'string'
4);
5
6INSERT INTO `setting` (`setting` ,`value` ,`fieldType` ,`helptext` ,`options` ,`cat` ,`userChange` ,`title` ,`validation` ,`ordering` ,`default` ,`userSee` ,`type`)
7VALUES (
8 'DETECT_LANGUAGE', '1', 'checkbox', 'Detect the browser language?', NULL , 'regional', '1', 'Detect Language', '', '40', '1', '1', 'checkbox'
9);
10
11ALTER TABLE `media` ADD `is_module` TINYINT NOT NULL DEFAULT '0';
12
13INSERT INTO `module` (`ModuleID`, `Module`, `Name`, `Enabled`, `RegionSpecific`, `Description`, `ImageUri`, `SchemaVersion`, `ValidExtensions`, `PreviewEnabled`, `assignable`) VALUES
14(NULL, 'font', 'Font', '1', '0', 'A font to use in other Modules', 'forms/library.gif', '1', 'ttf,otf,eot,svg,woff', '0', '0');
15
16ALTER TABLE `stat` ADD INDEX ( `statDate` );
17
18ALTER TABLE `stat` CHANGE `layoutID` `layoutID` INT( 8 ) NULL;
19ALTER TABLE `stat` CHANGE `end` `end` DATETIME NULL;
20
21UPDATE `version` SET `app_ver` = '1.7.0-alpha2', `XmdsVersion` = 4, `XlfVersion` = 2;
22UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
23UPDATE `version` SET `DBVersion` = '81';
0\ No newline at end of file24\ No newline at end of file
125
=== modified file 'server/install/master/data.sql'
--- server/install/master/data.sql 2014-09-19 12:55:15 +0000
+++ server/install/master/data.sql 2014-10-21 16:06:16 +0000
@@ -1,5 +1,5 @@
1INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES1INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES
2('1.7.0-alpha', 4, 1, 80);2('1.7.0-alpha2', 4, 2, 81);
33
4INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`) VALUES4INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`) VALUES
5(1, 'Users', 0, 0),5(1, 'Users', 0, 0),
@@ -113,7 +113,8 @@
113(12, 'shellcommand', 'Shell Command', 1, 1, 'Execute a shell command on the client', 'forms/shellcommand.gif', 1, NULL, 1, 1, NULL, NULL),113(12, 'shellcommand', 'Shell Command', 1, 1, 'Execute a shell command on the client', 'forms/shellcommand.gif', 1, NULL, 1, 1, NULL, NULL),
114(13, 'localvideo', 'Local Video', 1, 1, 'Play a video locally stored on the client', 'forms/video.gif', 1, NULL, 1, 1, NULL, NULL),114(13, 'localvideo', 'Local Video', 1, 1, 'Play a video locally stored on the client', 'forms/video.gif', 1, NULL, 1, 1, NULL, NULL),
115(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, NULL, NULL),115(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, NULL, NULL),
116(15, 'clock', 'Clock', 1, 1, 'Display a Clock', 'forms/library.gif', 1, NULL, 1, 1, 'html', '[]');116(15, 'clock', 'Clock', 1, 1, 'Display a Clock', 'forms/library.gif', 1, NULL, 1, 1, 'html', '[]'),
117(16, 'font', 'Font', 1, 0, 'A font to use in other Modules', 'forms/library.gif', 1, 'ttf,otf,eot,svg,woff', 0, 0, NULL, NULL);
117118
118INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES119INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES
119(1, 'Schedule'),120(1, 'Schedule'),
@@ -263,7 +264,9 @@
263(70, 'EMBEDDED_STATUS_WIDGET', '', 'text', 'HTML to embed in an iframe on the Status Dashboard', NULL, 'general', 0, 'Status Dashboard Widget', '', 70, '', 1, 'htmlstring'),264(70, 'EMBEDDED_STATUS_WIDGET', '', 'text', 'HTML to embed in an iframe on the Status Dashboard', NULL, 'general', 0, 'Status Dashboard Widget', '', 70, '', 1, 'htmlstring'),
264(71, 'PROXY_HOST', '', 'text', 'The Proxy URL', NULL, 'network', 1, 'Proxy URL', '', 10, '', 1, 'string'),265(71, 'PROXY_HOST', '', 'text', 'The Proxy URL', NULL, 'network', 1, 'Proxy URL', '', 10, '', 1, 'string'),
265(72, 'PROXY_PORT', '0', 'number', 'The Proxy Port', NULL, 'network', 1, 'Proxy Port', '', 20, '0', 1, 'int'),266(72, 'PROXY_PORT', '0', 'number', 'The Proxy Port', NULL, 'network', 1, 'Proxy Port', '', 20, '0', 1, 'int'),
266(73, 'PROXY_AUTH', '', 'text', 'The Authentication information for this proxy. username:password', NULL, 'network', 1, 'Proxy Credentials', '', 30, '', 1, 'string');267(73, 'PROXY_AUTH', '', 'text', 'The Authentication information for this proxy. username:password', NULL, 'network', 1, 'Proxy Credentials', '', 30, '', 1, 'string'),
268(74, 'DATE_FORMAT', 'Y-m-d', 'text', 'The Date Format to use when displaying dates in the CMS.', NULL , 'regional', '1', 'Date Format', 'required', 30, 'Y-m-d', '1', 'string'),
269(75, 'DETECT_LANGUAGE', '1', 'checkbox', 'Detect the browser language?', NULL , 'regional', '1', 'Detect Language', '', 40, '1', 1, 'checkbox');
267270
268INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES271INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES
269(1, 'Super Admin'),272(1, 'Super Admin'),
@@ -339,10 +342,6 @@
339(1, 'Value'),342(1, 'Value'),
340(2, 'Formula');343(2, 'Formula');
341344
342INSERT INTO `displayprofile` (`displayprofileid`, `name`, `type`, `config`, `isdefault`, `userid`) VALUES
343(1, 'Production', 'windows', '[{"name":"CollectInterval","value":"900","type":"int"},{"name":"PowerpointEnabled","value":0,"type":"checkbox"},{"name":"StatsEnabled","value":1,"type":"checkbox"},{"name":"SizeX","value":0,"type":"double"},{"name":"SizeY","value":0,"type":"double"},{"name":"OffsetX","value":0,"type":"double"},{"name":"OffsetY","value":0,"type":"double"},{"name":"ShowInTaskbar","value":1,"type":"checkbox"},{"name":"ClientInfomationCtrlKey","value":0,"type":"checkbox"},{"name":"ClientInformationKeyCode","value":"I","type":"word"},{"name":"CursorStartPosition","value":"Bottom Right","type":"string"},{"name":"DoubleBuffering","value":1,"type":"checkbox"},{"name":"EmptyLayoutDuration","value":"10","type":"int"},{"name":"EnableMouse","value":0,"type":"checkbox"},{"name":"EnableShellCommands","value":0,"type":"checkbox"},{"name":"ExpireModifiedLayouts","value":0,"type":"checkbox"},{"name":"LogLevel","value":"off","type":"word"},{"name":"LogToDiskLocation","value":"","type":"string"},{"name":"MaxConcurrentDownloads","value":"2","type":"int"},{"name":"ShellCommandAllowList","value":"","type":"string"},{"name":"UseCefWebBrowser","value":1,"type":"checkbox"},{"name":"SendCurrentLayoutAsStatusUpdate","value":0,"type":"checkbox"},{"name":"ScreenShotRequestInterval","value":0,"type":"int"}]', 1, 1),
344(2, 'Production', 'android', '[{"name":"emailAddress","value":"","type":"string"},{"name":"settingsPassword","value":"","type":"string"},{"name":"collectInterval","value":"600","type":"int"},{"name":"orientation","value":0,"type":"int"},{"name":"startOnBoot","value":1,"type":"checkbox"},{"name":"actionBarMode","value":"1","type":"int"},{"name":"actionBarDisplayDuration","value":"60","type":"int"},{"name":"screenDimensions","value":"","type":"string"},{"name":"autoRestart","value":1,"type":"checkbox"},{"name":"startOnBootDelay","value":"60","type":"int"},{"name":"blacklistVideo","value":1,"type":"checkbox"},{"name":"storeHtmlOnInternal","value":0,"type":"checkbox"}]', 1, 1);
345
346INSERT INTO `bandwidthtype` (`bandwidthtypeid`, `name`) VALUES345INSERT INTO `bandwidthtype` (`bandwidthtypeid`, `name`) VALUES
347(1, 'Register'),346(1, 'Register'),
348(2, 'Required Files'),347(2, 'Required Files'),
349348
=== modified file 'server/install/master/structure.sql'
--- server/install/master/structure.sql 2014-09-16 10:59:55 +0000
+++ server/install/master/structure.sql 2014-10-21 16:06:16 +0000
@@ -321,6 +321,7 @@
321 `retired` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Is retired?',321 `retired` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Is retired?',
322 `isEdited` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Is this the current record',322 `isEdited` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Is this the current record',
323 `editedMediaID` int(11) DEFAULT NULL COMMENT 'The Parent ID',323 `editedMediaID` int(11) DEFAULT NULL COMMENT 'The Parent ID',
324 `is_module` tinyint(4) NOT NULL DEFAULT '0',
324 PRIMARY KEY (`mediaID`)325 PRIMARY KEY (`mediaID`)
325) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;326) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
326327
@@ -530,12 +531,13 @@
530 `statDate` datetime NOT NULL COMMENT 'State entry date',531 `statDate` datetime NOT NULL COMMENT 'State entry date',
531 `scheduleID` int(8) NOT NULL,532 `scheduleID` int(8) NOT NULL,
532 `displayID` int(4) NOT NULL,533 `displayID` int(4) NOT NULL,
533 `layoutID` int(8) NOT NULL,534 `layoutID` int(8) NULL,
534 `mediaID` varchar(50) DEFAULT NULL,535 `mediaID` varchar(50) DEFAULT NULL,
535 `start` datetime NOT NULL,536 `start` datetime NOT NULL,
536 `end` datetime NOT NULL,537 `end` datetime NULL,
537 `Tag` varchar(254) DEFAULT NULL,538 `Tag` varchar(254) DEFAULT NULL,
538 PRIMARY KEY (`statID`)539 PRIMARY KEY (`statID`),
540 KEY `statDate` (`statDate`)
539) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;541) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
540542
541CREATE TABLE IF NOT EXISTS `template` (543CREATE TABLE IF NOT EXISTS `template` (
542544
=== added file 'server/lib/app/cache.class.php'
--- server/lib/app/cache.class.php 1970-01-01 00:00:00 +0000
+++ server/lib/app/cache.class.php 2014-10-21 16:06:16 +0000
@@ -0,0 +1,82 @@
1<?php
2/*
3 * Xibo - Digital Signage - http://www.xibo.org.uk
4 * Copyright (C) 2009-2013 Daniel Garner
5 *
6 * This file is part of Xibo.
7 *
8 * Xibo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * Xibo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
20 *
21 * A very simple file cache
22 */
23defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
24
25class Cache {
26
27 private static $_data;
28 private static $_location;
29
30 private function __construct() {}
31
32 public static function put($key, $value, $expires) {
33 if (!self::$_data)
34 self::load();
35
36 $expires = time() + $expires;
37
38 self::$_data[$key] = array('value' => $value, 'expires' => $expires);
39
40 self::save();
41 }
42
43 public static function get($key, $default = NULL) {
44 if (!self::$_data)
45 self::load();
46
47 if (!Cache::has($key))
48 return $default;
49
50 $data = self::$_data[$key];
51
52 if ($data['expires'] < time()) {
53 unset(self::$_data['key']);
54 return $default;
55 }
56 else
57 return $data['value'];
58 }
59
60 public static function has($key) {
61 if (!self::$_data)
62 self::load();
63
64 return (isset(self::$_data[$key]) && self::$_data[$key] != null && self::$_data[$key]['expires'] >= time());
65 }
66
67 private static function load() {
68 self::$_location = Config::GetSetting('LIBRARY_LOCATION') . 'cache/cache';
69
70 if (!file_exists(self::$_location))
71 self::$_data = array();
72 else
73 self::$_data = unserialize(file_get_contents(self::$_location));
74 }
75
76 private static function save() {
77 self::$_location = Config::GetSetting('LIBRARY_LOCATION') . 'cache/cache';
78
79 file_put_contents(self::$_location, serialize(self::$_data));
80 }
81}
82?>
083
=== modified file 'server/lib/app/debug.class.php'
--- server/lib/app/debug.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/app/debug.class.php 2014-10-21 16:06:16 +0000
@@ -22,174 +22,185 @@
2222
23class Debug23class Debug
24{24{
25 public function __construct()25 public function __construct()
26 {26 {
27 if (!defined('AUDIT'))27 if (!defined('AUDIT'))
28 {28 {
29 // Get the setting from the DB and define it29 // Get the setting from the DB and define it
30 if (Config::GetSetting('audit') != 'On')30 if (Config::GetSetting('audit') != 'On')
31 {31 {
32 define('AUDIT', false);32 define('AUDIT', false);
33 }33 }
34 else34 else
35 {35 {
36 define('AUDIT', true);36 define('AUDIT', true);
37 }37 }
38 }38 }
39 }39 }
40 40
41 public function ErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {41 public function ErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {
4242
43 // timestamp for the error entry43 // timestamp for the error entry
44 $dt = date("Y-m-d H:i:s (T)");44 $dt = date("Y-m-d H:i:s (T)");
4545
46 // define an assoc array of error string46 // define an assoc array of error string
47 // in reality the only entries we should47 // in reality the only entries we should
48 // consider are E_WARNING, E_NOTICE, E_USER_ERROR,48 // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
49 // E_USER_WARNING and E_USER_NOTICE49 // E_USER_WARNING and E_USER_NOTICE
50 $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE =>50 $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE =>
51 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error',51 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error',
52 E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error',52 E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error',
53 E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error',53 E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error',
54 E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT =>54 E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT =>
55 'Runtime Notice', E_RECOVERABLE_ERROR => 'Recoverable Error', 8192 => 'Deprecated Call');55 'Runtime Notice', E_RECOVERABLE_ERROR => 'Recoverable Error', 8192 => 'Deprecated Call');
5656
57 // set of errors for which a var trace will be saved57 // set of errors for which a var trace will be saved
58 $user_errors_halt = array(E_USER_ERROR);58 $user_errors_halt = array(E_USER_ERROR);
59 $user_errors_inline = array(E_USER_WARNING);59 $user_errors_inline = array(E_USER_WARNING);
6060
61 $err = "<errormsg>" . $errmsg . "</errormsg>\n";61 $err = "<errormsg>" . $errmsg . "</errormsg>\n";
62 $err .= "<errornum>" . $errno . "</errornum>\n";62 $err .= "<errornum>" . $errno . "</errornum>\n";
63 $err .= "<errortype>" . $errortype[$errno] . "</errortype>\n";63 $err .= "<errortype>" . $errortype[$errno] . "</errortype>\n";
64 $err .= "<scriptname>" . $filename . "</scriptname>\n";64 $err .= "<scriptname>" . $filename . "</scriptname>\n";
65 $err .= "<scriptlinenum>" . $linenum . "</scriptlinenum>\n";65 $err .= "<scriptlinenum>" . $linenum . "</scriptlinenum>\n";
6666
67 // Log everything67 // Log everything
68 Debug::LogEntry("error", $err);68 Debug::LogEntry("error", $err);
69 69
70 // Test to see if this is a HALT error or not (we do the same if we are in production or not!)70 // Test to see if this is a HALT error or not (we do the same if we are in production or not!)
71 if (in_array($errno, $user_errors_halt)) 71 if (in_array($errno, $user_errors_halt))
72 {72 {
73 // We have a halt error73 // We have a halt error
74 Debug::LogEntry('audit', 'Creating a Response Manager to deal with the HALT Error.');74 Debug::LogEntry('audit', 'Creating a Response Manager to deal with the HALT Error.');
7575
76 $response = new ResponseManager();76 $response = new ResponseManager();
77 77
78 $response->SetError($errmsg);78 $response->SetError($errmsg);
79 $response->Respond();79 $response->Respond();
80 }80 }
81 81
82 // Is Debug Enabled? (i.e. Development or Support)82 // Is Debug Enabled? (i.e. Development or Support)
83 if (error_reporting() != 0) 83 if (error_reporting() != 0)
84 {84 {
85 if (in_array($errno, $user_errors_inline)) 85 if (in_array($errno, $user_errors_inline))
86 {86 {
87 // This is an inline error - therefore we really want to pop up a message box with this in it - so we know?87 // This is an inline error - therefore we really want to pop up a message box with this in it - so we know?
88 // For now we treat this like a halt error? Or do we just try and output some javascript to pop up an error88 // For now we treat this like a halt error? Or do we just try and output some javascript to pop up an error
89 // surely the javascript idea wont work in ajax?89 // surely the javascript idea wont work in ajax?
90 // or prehaps we add this to the session errormessage so we see it at a later date?90 // or prehaps we add this to the session errormessage so we see it at a later date?
91 echo $errmsg;91 echo $errmsg;
92 die();92 die();
93 }93 }
94 }94 }
95 95
96 // Must return false96 // Must return false
97 return false;97 return false;
98 }98 }
99 99
100 /**100 /**
101 * Mail an error - currently disabled101 * Mail an error - currently disabled
102 * @return 102 * @return
103 * @param $errmsg Object103 * @param $errmsg Object
104 * @param $err Object104 * @param $err Object
105 */105 */
106 function MailError($errmsg, $err) 106 function MailError($errmsg, $err)
107 {107 {
108 return true;108 return true;
109109
110 $to = 'info@xibo.org.uk';110 $to = 'info@xibo.org.uk';
111 111
112 $from = Config::GetSetting("mail_from");112 $from = Config::GetSetting("mail_from");
113 if ($from == "") return true;113 if ($from == "") return true;
114 114
115 $subject = "Error message from Digital Signage System";115 $subject = "Error message from Digital Signage System";
116 $message = wordwrap("$errmsg\n$err");116 $message = wordwrap("$errmsg\n$err");
117117
118 $headers = "From: $from" . "\r\n" . "Reply-To: $from" . "\r\n" .118 $headers = "From: $from" . "\r\n" . "Reply-To: $from" . "\r\n" .
119 "X-Mailer: PHP/" . phpversion();119 "X-Mailer: PHP/" . phpversion();
120120
121 if (!mail($to, $subject, $message, $headers)) trigger_error("Mail not accepted", E_USER_NOTICE);121 if (!mail($to, $subject, $message, $headers)) trigger_error("Mail not accepted", E_USER_NOTICE);
122 return true;122 return true;
123 }123 }
124124
125 /**125 /**
126 * Write an Entry to the Log table126 * Write an Entry to the Log table
127 * @return 127 * @return
128 * @param $db Object128 * @param $db Object
129 * @param $type Object129 * @param $type Object
130 * @param $message Object130 * @param $message Object
131 * @param $page Object[optional]131 * @param $page Object[optional]
132 * @param $function Object[optional]132 * @param $function Object[optional]
133 * @param $logdate Object[optional]133 * @param $logdate Object[optional]
134 * @param $displayid Object[optional]134 * @param $displayid Object[optional]
135 * @param $scheduleID Object[optional]135 * @param $scheduleID Object[optional]
136 * @param $layoutid Object[optional]136 * @param $layoutid Object[optional]
137 * @param $mediaid Object[optional]137 * @param $mediaid Object[optional]
138 */ 138 */
139 static function LogEntry($type, $message, $page = "", $function = "", $logdate = "", $displayid = 0, $scheduleID = 0, $layoutid = 0, $mediaid = 0) 139 static function LogEntry($type, $message, $page = "", $function = "", $logdate = "", $displayid = 0, $scheduleID = 0, $layoutid = 0, $mediaid = 0)
140 {140 {
141 if ($type == 'audit' && !AUDIT)141 if ($type == 'audit' && !AUDIT)
142 return;142 return;
143143
144 $currentdate = date("Y-m-d H:i:s");144 $currentdate = date("Y-m-d H:i:s");
145 $requestUri = Kit::GetParam('REQUEST_URI', $_SERVER, _STRING, 'Not Supplied');145 $requestUri = Kit::GetParam('REQUEST_URI', $_SERVER, _STRING, 'Not Supplied');
146 $requestIp = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING, 'Not Supplied');146 $requestIp = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING, 'Not Supplied');
147 $requestUserAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'Not Supplied');147 $requestUserAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'Not Supplied');
148 $requestUserAgent = substr($requestUserAgent, 0, 253);148 $requestUserAgent = substr($requestUserAgent, 0, 253);
149 $userid = Kit::GetParam('userid', _SESSION, _INT, 0);149 $userid = Kit::GetParam('userid', _SESSION, _INT, 0);
150 $message = Kit::ValidateParam($message, _HTMLSTRING);150 $message = Kit::ValidateParam($message, _HTMLSTRING);
151 151
152 if ($logdate == "") 152 if ($logdate == "")
153 $logdate = $currentdate;153 $logdate = $currentdate;
154154
155 //Prepare the variables155 //Prepare the variables
156 if ($page == "")156 if ($page == "")
157 $page = Kit::GetParam('p', _GET, _WORD);157 $page = Kit::GetParam('p', _GET, _WORD);
158158
159 // Insert into the DB159 // Insert into the DB
160 try {160 try {
161 $dbh = PDOConnect::init();161 $dbh = PDOConnect::init();
162162
163 $SQL = 'INSERT INTO log (logdate, type, page, function, message, requesturi, remoteaddr, useragent, userid, displayid, scheduleid, layoutid, mediaid) ';163 $SQL = 'INSERT INTO log (logdate, type, page, function, message, requesturi, remoteaddr, useragent, userid, displayid, scheduleid, layoutid, mediaid) ';
164 $SQL .= ' VALUES (:logdate, :type, :page, :function, :message, :requesturi, :remoteaddr, :useragent, :userid, :displayid, :scheduleid, :layoutid, :mediaid) ';164 $SQL .= ' VALUES (:logdate, :type, :page, :function, :message, :requesturi, :remoteaddr, :useragent, :userid, :displayid, :scheduleid, :layoutid, :mediaid) ';
165165
166 $sth = $dbh->prepare($SQL);166 $sth = $dbh->prepare($SQL);
167167
168 $params = array(168 $params = array(
169 'logdate' => $currentdate,169 'logdate' => $currentdate,
170 'type' => $type,170 'type' => $type,
171 'page' => $page,171 'page' => $page,
172 'function' => $function,172 'function' => $function,
173 'message' => $message,173 'message' => $message,
174 'requesturi' => $requestUri,174 'requesturi' => $requestUri,
175 'remoteaddr' => $requestIp,175 'remoteaddr' => $requestIp,
176 'useragent' => $requestUserAgent,176 'useragent' => $requestUserAgent,
177 'userid' => $userid,177 'userid' => $userid,
178 'displayid' => $displayid,178 'displayid' => $displayid,
179 'scheduleid' => $scheduleID,179 'scheduleid' => $scheduleID,
180 'layoutid' => $layoutid,180 'layoutid' => $layoutid,
181 'mediaid' => $mediaid181 'mediaid' => $mediaid
182 );182 );
183183
184 $sth->execute($params);184 $sth->execute($params);
185 }185 }
186 catch (PDOException $e) {186 catch (PDOException $e) {
187 // In this case just silently log the error187 // In this case just silently log the error
188 error_log($message . '\n\n', 3, './err_log.xml');188 error_log($message . '\n\n', 3, './err_log.xml');
189 error_log($e->getMessage() . '\n\n', 3, './err_log.xml');189 error_log($e->getMessage() . '\n\n', 3, './err_log.xml');
190 }190 }
191191
192 return true;192 return true;
193 }193 }
194
195 public static function Audit($message) {
196 if (!AUDIT)
197 return;
198
199 // Get the calling class / function
200 $trace = debug_backtrace();
201 $caller = $trace[1];
202
203 Debug::LogEntry('audit', $message, (isset($caller['class'])) ? $caller['class'] : 'Global', $caller['function']);
204 }
194}205}
195?>
196\ No newline at end of file206\ No newline at end of file
207?>
197208
=== modified file 'server/lib/app/kit.class.php'
--- server/lib/app/kit.class.php 2014-09-19 12:55:15 +0000
+++ server/lib/app/kit.class.php 2014-10-21 16:06:16 +0000
@@ -45,381 +45,388 @@
4545
46class Kit 46class Kit
47{47{
48 // Ends the current execution and issues a redirect - should only be called before headers have been sent (i.e. no output)48 // Ends the current execution and issues a redirect - should only be called before headers have been sent (i.e. no output)
49 static function Redirect($page, $message = '')49 static function Redirect($page, $message = '')
50 {50 {
51 $url = $page;51 $url = $page;
52 $ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false);52 $ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false);
53 53
54 if ($ajax)54 if ($ajax)
55 {55 {
56 echo json_encode($page);56 echo json_encode($page);
57 die();57 die();
58 }58 }
59 59
60 // Header or JS redirect60 // Header or JS redirect
61 if (headers_sent()) 61 if (headers_sent())
62 {62 {
63 echo "<script>document.location.href='$url';</script>\n";63 echo "<script>document.location.href='$url';</script>\n";
64 } 64 }
65 else 65 else
66 {66 {
67 header( 'HTTP/1.1 302 Moved Temporarily' );67 header( 'HTTP/1.1 302 Moved Temporarily' );
68 header( 'Location: ' . $url );68 header( 'Location: ' . $url );
69 }69 }
70 70
71 die();71 die();
72 }72 }
73 73
74 /**74 /**
75 * Gets the appropriate Param, making sure its valid75 * Gets the appropriate Param, making sure its valid
76 * Based on code from Joomla! 1.576 * Based on code from Joomla! 1.5
77 * @return 77 * @return
78 * @param $param Object78 * @param $param Object
79 * @param $source Object[optional]79 * @param $source Object[optional]
80 * @param $type Object[optional]80 * @param $type Object[optional]
81 * @param $default Object[optional]81 * @param $default Object[optional]
82 */82 */
83 static public function GetParam($param, $source = _POST, $type = _STRING, $default = '', $sanitize = true)83 static public function GetParam($param, $source = _POST, $type = _STRING, $default = '', $sanitize = true)
84 {84 {
85 // lower case param (we dont care)85 // lower case param (we dont care)
86 $param = strtolower($param);86 $param = strtolower($param);
8787
88 if (is_array($source))88 if (is_array($source))
89 {89 {
90 $source = array_change_key_case($source);90 $source = array_change_key_case($source);
91 91
92 if(!isset($source[$param])) 92 if(!isset($source[$param]))
93 {93 {
94 $return = $default;94 $return = $default;
95 }95 }
96 else 96 else
97 {97 {
98 $return = $source[$param]; 98 $return = $source[$param];
99 }99 }
100 }100 }
101 else101 else
102 {102 {
103 switch ($source)103 switch ($source)
104 {104 {
105 case 'session':105 case 'session':
106106
107 if (isset($_SESSION))107 if (isset($_SESSION))
108 $_tempSESSION = array_change_key_case($_SESSION);108 $_tempSESSION = array_change_key_case($_SESSION);
109 109
110 if(!isset($_tempSESSION[$param])) 110 if(!isset($_tempSESSION[$param]))
111 {111 {
112 $return = $default;112 $return = $default;
113 }113 }
114 else if ($type == _CHECKBOX)114 else if ($type == _CHECKBOX)
115 {115 {
116 // this means that it was defined correctly and it was set116 // this means that it was defined correctly and it was set
117 $return = 1;117 $return = 1;
118 }118 }
119 else 119 else
120 {120 {
121 if ($_tempSESSION[$param] == '')121 if ($_tempSESSION[$param] == '')
122 {122 {
123 $return = $default;123 $return = $default;
124 } 124 }
125 else125 else
126 {126 {
127 $return = $_tempSESSION[$param];127 $return = $_tempSESSION[$param];
128 }128 }
129 }129 }
130 130
131 break;131 break;
132 132
133 case 'request':133 case 'request':
134134
135 $_tempREQUEST = array_change_key_case($_REQUEST);135 $_tempREQUEST = array_change_key_case($_REQUEST);
136 136
137 if(!isset($_tempREQUEST[$param])) 137 if(!isset($_tempREQUEST[$param]))
138 {138 {
139 $return = $default;139 $return = $default;
140 }140 }
141 else 141 else
142 {142 {
143 if ($_tempREQUEST[$param] == '')143 if ($_tempREQUEST[$param] == '')
144 {144 {
145 $return = $default;145 $return = $default;
146 } 146 }
147 else147 else
148 {148 {
149 $return = $_tempREQUEST[$param];149 $return = $_tempREQUEST[$param];
150 } 150 }
151 }151 }
152 152
153 break;153 break;
154 154
155 case 'get':155 case 'get':
156156
157 $_tempGET = array_change_key_case($_GET);157 $_tempGET = array_change_key_case($_GET);
158 158
159 if(!isset($_tempGET[$param])) 159 if(!isset($_tempGET[$param]))
160 {160 {
161 $return = $default;161 $return = $default;
162 }162 }
163 else 163 else
164 {164 {
165 if ($_tempGET[$param] == '')165 if ($_tempGET[$param] == '')
166 {166 {
167 $return = $default;167 $return = $default;
168 } 168 }
169 else169 else
170 {170 {
171 $return = $_tempGET[$param];171 $return = $_tempGET[$param];
172 } 172 }
173 }173 }
174 174
175 break;175 break;
176 176
177 case 'post':177 case 'post':
178178
179 $_tempPOST = array_change_key_case($_POST);179 $_tempPOST = array_change_key_case($_POST);
180 180
181 if(!isset($_tempPOST[$param])) 181 if(!isset($_tempPOST[$param]))
182 {182 {
183 $return = $default;183 $return = $default;
184 }184 }
185 else if ($type == _CHECKBOX)185 else if ($type == _CHECKBOX)
186 {186 {
187 // this means that it was defined correctly and it was set187 // this means that it was defined correctly and it was set
188 $return = 1;188 $return = 1;
189 }189 }
190 else 190 else
191 {191 {
192 if ($_tempPOST[$param] == '')192 if ($_tempPOST[$param] == '')
193 {193 {
194 $return = $default;194 $return = $default;
195 } 195 }
196 else196 else
197 {197 {
198 $return = $_tempPOST[$param];198 $return = $_tempPOST[$param];
199 } 199 }
200 }200 }
201 201
202 break;202 break;
203 203
204 default:204 default:
205 return $default;205 return $default;
206 }206 }
207 }207 }
208 208
209 // Validate this param 209 // Validate this param
210 return Kit::ValidateParam($return, $type, $sanitize);210 return Kit::ValidateParam($return, $type, $sanitize);
211 }211 }
212 212
213 /**213 /**
214 * Validates a Parameter214 * Validates a Parameter
215 * Based on code from Joomla! 1.5215 * Based on code from Joomla! 1.5
216 * @return 216 * @return
217 * @param $param Object217 * @param $param Object
218 * @param $type Object218 * @param $type Object
219 */219 */
220 static function ValidateParam($param, $type, $sanitize = true)220 static function ValidateParam($param, $type, $sanitize = true)
221 {221 {
222 // If we are a NULL always return a null??222 // If we are a NULL always return a null??
223 //if ($param == NULL || $param == '')223 //if ($param == NULL || $param == '')
224 // return NULL;224 // return NULL;
225225
226 // Store in return var226 // Store in return var
227 $return = $param;227 $return = $param;
228 228
229 // Validate229 // Validate
230 // Handle the type constraint230 // Handle the type constraint
231 switch ($type)231 switch ($type)
232 {232 {
233 case _INT :233 case _INT :
234234
235 if ($sanitize) {235 if ($sanitize) {
236 // Only use the first integer value236 // Only use the first integer value
237 if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_INT))237 if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_INT))
238 $return = 0;238 $return = 0;
239 }239 }
240 else {240 else {
241 if (!$return = filter_var($return, FILTER_VALIDATE_INT))241 if (!$return = filter_var($return, FILTER_VALIDATE_INT))
242 trigger_error(sprintf(__('No integer match found for [%s] and return value is not an integer'), $param), E_USER_ERROR);242 trigger_error(sprintf(__('No integer match found for [%s] and return value is not an integer'), $param), E_USER_ERROR);
243 }243 }
244244
245 break;245 break;
246246
247 case _DOUBLE :247 case _DOUBLE :
248 248
249 if ($sanitize) {249 if ($sanitize) {
250 // Only use the first integer value250 // Only use the first integer value
251 if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION))251 if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION))
252 $return = 0;252 $return = 0;
253 }253 }
254 else {254 else {
255 if (!$return = filter_var($return, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_FRACTION))255 if (!$return = filter_var($return, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_FRACTION))
256 trigger_error(sprintf(__('No integer match found for %s, and return value is not an integer'), $param), E_USER_ERROR);256 trigger_error(sprintf(__('No integer match found for %s, and return value is not an integer'), $param), E_USER_ERROR);
257 }257 }
258258
259 break;259 break;
260260
261 case _BOOL :261 case _BOOL :
262 $return = filter_var($return, FILTER_VALIDATE_BOOLEAN);262 $return = filter_var($return, FILTER_VALIDATE_BOOLEAN);
263 break;263 break;
264264
265 case _ARRAY :265 case _ARRAY :
266 if ($return == '')266 if ($return == '')
267 {267 {
268 $return = array();268 $return = array();
269 break; 269 break;
270 }270 }
271 271
272 if (!is_array($return)) 272 if (!is_array($return))
273 {273 {
274 $return = array($return);274 $return = array($return);
275 }275 }
276 break;276 break;
277277
278 case _ARRAY_INT:278 case _ARRAY_INT:
279279
280 if ($return == '') {280 if ($return == '') {
281 $return = array();281 $return = array();
282 }282 }
283 else {283 else {
284 if ($sanitize) {284 if ($sanitize) {
285 // Only use the first integer value285 // Only use the first integer value
286 if (!$return = filter_var_array($return, FILTER_SANITIZE_NUMBER_INT))286 if (!$return = filter_var_array($return, FILTER_SANITIZE_NUMBER_INT))
287 $return = array();287 $return = array();
288 }288 }
289 else {289 else {
290 if (!$return = filter_var_array($return, FILTER_VALIDATE_INT))290 if (!$return = filter_var_array($return, FILTER_VALIDATE_INT))
291 trigger_error(sprintf(__('No integer found for %s, and return value is not an integer'), $param), E_USER_ERROR);291 trigger_error(sprintf(__('No integer found for %s, and return value is not an integer'), $param), E_USER_ERROR);
292 }292 }
293 }293 }
294 break;294 break;
295295
296 case _STRING :296 case _STRING :
297 case _PASSWORD :297 case _PASSWORD :
298 $return = filter_var($return, FILTER_SANITIZE_STRING);298 $return = filter_var($return, FILTER_SANITIZE_STRING);
299 break;299 break;
300300
301 case _STRINGSPECIAL:301 case _STRINGSPECIAL:
302 $return = filter_var($return, FILTER_SANITIZE_SPECIAL_CHARS);302 $return = filter_var($return, FILTER_SANITIZE_SPECIAL_CHARS);
303 break; 303 break;
304 304
305 case _HTMLSTRING :305 case _HTMLSTRING :
306 306
307 // decimal notation307 // decimal notation
308 $return = preg_replace_callback('/&#(\d+);/m', function($m){308 $return = preg_replace_callback('/&#(\d+);/m', function($m){
309 return chr($m[1]);309 return chr($m[1]);
310 }, $return);310 }, $return);
311311
312 // convert hex312 // convert hex
313 $return = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){313 $return = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){
314 return chr("0x".$m[1]);314 return chr("0x".$m[1]);
315 }, $return);315 }, $return);
316 316
317 $return = (string) $return;317 $return = (string) $return;
318 break;318 break;
319319
320 case _WORD :320 case _WORD :
321 $return = filter_var($return, FILTER_SANITIZE_STRING);321 $return = filter_var($return, FILTER_SANITIZE_STRING);
322 $return = (string) preg_replace( '/[^A-Z_\-]/i', '', $return );322 $return = (string) preg_replace( '/[^A-Z_\-]/i', '', $return );
323 break;323 break;
324 324
325 case _USERNAME :325 case _USERNAME :
326 $return = filter_var($return, FILTER_SANITIZE_STRING);326 $return = filter_var($return, FILTER_SANITIZE_STRING);
327 $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return );327 $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return );
328 $return = strtolower($return);328 $return = strtolower($return);
329 break;329 break;
330 330
331 case _FILENAME :331 case _FILENAME :
332 if ($return == '')332 if ($return == '')
333 {333 {
334 $return = '';334 $return = '';
335 break; 335 break;
336 }336 }
337 // Remove non alphanumerics337 // Remove non alphanumerics
338 $return = strtolower($return); 338 $return = strtolower($return);
339 $code_entities_match = array('&quot;' ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'+' ,'{' ,'}' ,'|' ,':' ,'"' ,'<' ,'>' ,'?' ,'[' ,']' ,'' ,';' ,"'" ,',' ,'_' ,'/' ,'*' ,'+' ,'~' ,'`' ,'=' ,' ' ,'---' ,'--','--'); 339 $code_entities_match = array('&quot;' ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'+' ,'{' ,'}' ,'|' ,':' ,'"' ,'<' ,'>' ,'?' ,'[' ,']' ,'' ,';' ,"'" ,',' ,'_' ,'/' ,'*' ,'+' ,'~' ,'`' ,'=' ,' ' ,'---' ,'--','--');
340 $code_entities_replace = array('' ,'-' ,'-' ,'' ,'' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-','-'); 340 $code_entities_replace = array('' ,'-' ,'-' ,'' ,'' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-','-');
341 341
342 $return = str_replace($code_entities_match, $code_entities_replace, $return);342 $return = str_replace($code_entities_match, $code_entities_replace, $return);
343 break;343 break;
344 344
345 case _URI :345 case _URI :
346 if ($return == '')346 if ($return == '')
347 {347 {
348 $return = '';348 $return = '';
349 break; 349 break;
350 }350 }
351 $return = urlencode($return);351 $return = urlencode($return);
352 break;352 break;
353 353
354 case _CHECKBOX:354 case _CHECKBOX:
355 if ($return == 'on') {355 if ($return == 'on') {
356 $return = 1;356 $return = 1;
357 }357 }
358 if ($return == 'off' || $return == '') {358 if ($return == 'off' || $return == '') {
359 $return = 0;359 $return = 0;
360 }360 }
361361
362 break;362 break;
363363
364 default :364 default :
365 // No casting necessary365 // No casting necessary
366 if (!$sanitize)366 if (!$sanitize)
367 trigger_error(sprintf(__('Unknown Type %s'), $type), E_USER_ERROR);367 trigger_error(sprintf(__('Unknown Type %s'), $type), E_USER_ERROR);
368368
369 break;369 break;
370 }370 }
371 371
372 return $return;372 return $return;
373 }373 }
374 374
375 /**375 /**
376 * Gets a formatted Url376 * Gets a formatted Url
377 * @return 377 * @return
378 * @param $page Object[optional]378 * @param $page Object[optional]
379 */379 */
380 public static function GetURL($page = "")380 public static function GetURL($page = "")
381 {381 {
382 $page = Kit::ValidateParam($page, _WORD);382 $page = Kit::ValidateParam($page, _WORD);
383 $fullUrl = 'http';383 $fullUrl = 'http';
384 384
385 if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on')385 if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on')
386 {386 {
387 $fullUrl .= 's';387 $fullUrl .= 's';
388 }388 }
389 389
390 $fullUrl .= '://';390 $fullUrl .= '://';
391 391
392 if($_SERVER['SERVER_PORT']!='80')392 if($_SERVER['SERVER_PORT']!='80')
393 {393 {
394 $fullUrl .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];394 $fullUrl .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
395 }395 }
396 else396 else
397 {397 {
398 $fullUrl .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];398 $fullUrl .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
399 }399 }
400 400
401 // Append the page if its not empty401 // Append the page if its not empty
402 if ($page != '')402 if ($page != '')
403 {403 {
404 $fullUrl .= '?p=' . $page;404 $fullUrl .= '?p=' . $page;
405 }405 }
406 406
407 return $fullUrl;407 return $fullUrl;
408 }408 }
409409
410 /**410 /**
411 * Ensures a the relevant file for a class is inclued411 * Ensures a the relevant file for a class is included
412 * @param <string> $class412 * @param <string> $class
413 * @return <boolean> False on failure413 * @return <boolean> False on failure
414 */414 */
415 static function ClassLoader($class)415 static function ClassLoader($class)
416 {416 {
417 if (class_exists($class))417 if (class_exists($class))
418 return;418 return;
419419
420 $class = strtolower($class);420 $class = strtolower($class);
421421
422 // It doesnt already exist - so lets look in some places to try and find it422 if (strpos($class, 'manager')) {
423 // Load from app
424 if (file_exists('lib/app/' . $class . '.class.php')) {
425 include_once('lib/app/' . $class . '.class.php');
426 }
427 }
428
429 // It doesn't already exist - so lets look in some places to try and find it
423 if (file_exists('lib/pages/' . $class . '.class.php'))430 if (file_exists('lib/pages/' . $class . '.class.php'))
424 {431 {
425 include_once('lib/pages/' . $class . '.class.php');432 include_once('lib/pages/' . $class . '.class.php');
@@ -444,7 +451,7 @@
444 {451 {
445 include_once('lib/service/' . $class . '.class.php');452 include_once('lib/service/' . $class . '.class.php');
446 }453 }
447 }454 }
448455
449 /**456 /**
450 * GetXiboRoot457 * GetXiboRoot
@@ -570,85 +577,89 @@
570 }577 }
571578
572 public static function ReturnBytes($val) {579 public static function ReturnBytes($val) {
573 580
574 $val = trim($val);581 $val = trim($val);
575 $last = strtolower($val[strlen($val)-1]);582 $last = strtolower($val[strlen($val)-1]);
576 switch($last) {583 switch($last) {
577 // The 'G' modifier is available since PHP 5.1.0584 // The 'G' modifier is available since PHP 5.1.0
578 case 'g':585 case 'g':
579 $val *= 1024;586 $val *= 1024;
580 case 'm':587 case 'm':
581 $val *= 1024;588 $val *= 1024;
582 case 'k':589 case 'k':
583 $val *= 1024;590 $val *= 1024;
584 }591 }
585592
586 return $val;593 return $val;
587 }594 }
588595
589 /**596 /**
590 * Creates a form token597 * Creates a form token
591 * @return 598 * @return
592 */599 */
593 public static function Token($tokenName = "token")600 public static function Token($tokenName = "token", $withInput = true)
594 {601 {
595 //Store in the users session602 //Store in the users session
596 $token = md5(uniqid() . SECRET_KEY . time());603 $token = md5(uniqid() . SECRET_KEY . time());
597 604
598 $_SESSION[$tokenName] = $token;605 $_SESSION[$tokenName] = $token;
599 $_SESSION[$tokenName.'_timeout'] = time();606 $_SESSION[$tokenName.'_timeout'] = time();
600 607
601 return '<input type="hidden" name="' . $tokenName . '" value="' . $token . '">';608 if ($withInput)
602 }609 return '<input type="hidden" name="' . $tokenName . '" value="' . $token . '">';
603610 else
604 /**611 return $token;
605 * Checks a form token612 }
606 * @param string token613
607 * @return 614 /**
608 */615 * Checks a form token
609 public static function CheckToken($tokenName = "token")616 * @param string token
610 {617 * @return
611 if (!isset($_POST[$tokenName]) || !isset($_SESSION[$tokenName]))618 */
612 return false;619 public static function CheckToken($tokenName = "token")
613 620 {
614 if ($_POST[$tokenName] == $_SESSION[$tokenName])621 if (!isset($_POST[$tokenName]) || !isset($_SESSION[$tokenName]))
615 {622 return false;
616 // See if its still in Date623
617 if (($_SESSION[$tokenName.'_timeout'] + 1200) <= time())624 if ($_POST[$tokenName] == $_SESSION[$tokenName])
618 {625 {
619 return false;626 // See if its still in Date
620 }627 if (($_SESSION[$tokenName.'_timeout'] + 1200) <= time())
621 return true;628 {
622 }629 return false;
623 else630 }
624 {631 return true;
625 unset($_SESSION[$tokenName]);632 }
626633 else
627 Debug::LogEntry('error', "Form token incorrect from: ". $_SERVER['REMOTE_ADDR']. " with token [" . $_POST[$tokenName] . "] for session_id [" . session_id() . ']');634 {
628 return false;635 unset($_SESSION[$tokenName]);
629 }636
630 }637 Debug::LogEntry('error', "Form token incorrect from: ". $_SERVER['REMOTE_ADDR']. " with token [" . $_POST[$tokenName] . "] for session_id [" . session_id() . ']');
631638 return false;
632 /**639 }
633 * Format Bytes640 }
634 * http://stackoverflow.com/questions/2510434/format-bytes-to-kilobytes-megabytes-gigabytes641
635 * @param [int] $size The file size in bytes642 /**
636 * @param integer $precision The precision to go to643 * Format Bytes
637 * @return [string] The Formatted string with suffix644 * http://stackoverflow.com/questions/2510434/format-bytes-to-kilobytes-megabytes-gigabytes
638 */645 * @param [int] $size The file size in bytes
639 public static function formatBytes($size, $precision = 2) {646 * @param integer $precision The precision to go to
640 647 * @return [string] The Formatted string with suffix
641 if ($size == 0)648 */
642 return 0;649 public static function formatBytes($size, $precision = 2)
643650 {
644 $base = log($size) / log(1024);651 if ($size == 0)
645 $suffixes = array('', 'k', 'M', 'G', 'T'); 652 return 0;
646653
647 return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];654 $base = log($size) / log(1024);
648 }655 $suffixes = array('', 'k', 'M', 'G', 'T');
649656
650 public static function uniqueId() {657 return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
651 return uniqid(rand());658 }
652 }659
660 public static function uniqueId()
661 {
662 return uniqid(rand());
663 }
653}664}
654?>665?>
655666
=== modified file 'server/lib/app/modulemanager.class.php'
--- server/lib/app/modulemanager.class.php 2014-03-08 14:41:11 +0000
+++ server/lib/app/modulemanager.class.php 2014-10-21 16:06:16 +0000
@@ -22,7 +22,6 @@
2222
23class ModuleManager23class ModuleManager
24{24{
25 private $db;
26 private $user;25 private $user;
27 26
28 public $message;27 public $message;
@@ -34,13 +33,11 @@
34 /**33 /**
35 * Constructs the Module Manager.34 * Constructs the Module Manager.
36 * @return 35 * @return
37 * @param $db Object
38 * @param $user Object36 * @param $user Object
39 */37 */
40 public function __construct(database $db, User $user, $regionSpecific = -1, $module = '', $assignable = 1)38 public function __construct(User $user, $regionSpecific = -1, $module = '', $assignable = 1)
41 {39 {
42 $this->db =& $db;40 $this->user =& $user;
43 $this->user =& $user;
44 41
45 if (!$this->theMenu = $user->ModuleAuth($regionSpecific, $module, $assignable))42 if (!$this->theMenu = $user->ModuleAuth($regionSpecific, $module, $assignable))
46 {43 {
4744
=== modified file 'server/lib/app/permissionmanager.class.php'
--- server/lib/app/permissionmanager.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/app/permissionmanager.class.php 2014-10-21 16:06:16 +0000
@@ -22,7 +22,6 @@
2222
23class PermissionManager23class PermissionManager
24{24{
25 private $db;
26 private $user;25 private $user;
27 26
28 public $ownerId;27 public $ownerId;
@@ -38,9 +37,8 @@
38 * @param $db Object37 * @param $db Object
39 * @param $user Object38 * @param $user Object
40 */39 */
41 public function __construct(database $db, User $user)40 public function __construct(User $user)
42 {41 {
43 $this->db =& $db;
44 $this->user =& $user;42 $this->user =& $user;
4543
46 $this->view = false;44 $this->view = false;
4745
=== modified file 'server/lib/app/responsemanager.class.php'
--- server/lib/app/responsemanager.class.php 2014-08-11 18:44:46 +0000
+++ server/lib/app/responsemanager.class.php 2014-10-21 16:06:16 +0000
@@ -54,6 +54,7 @@
54 public $focusInFirstInput;54 public $focusInFirstInput;
55 public $appendHiddenSubmit;55 public $appendHiddenSubmit;
56 public $modal;56 public $modal;
57 public $nextToken;
57 58
58 public $login;59 public $login;
59 public $clockUpdate;60 public $clockUpdate;
@@ -199,7 +200,7 @@
199 $this->message = $message;200 $this->message = $message;
200 $this->refresh = $refresh;201 $this->refresh = $refresh;
201 $this->refreshLocation = $refreshLocation;202 $this->refreshLocation = $refreshLocation;
202 203 $this->nextToken = Kit::Token();
203 return;204 return;
204 }205 }
205 206
@@ -317,6 +318,7 @@
317 $response['refreshLocation']= $this->refreshLocation;318 $response['refreshLocation']= $this->refreshLocation;
318 $response['focusInFirstInput']= $this->focusInFirstInput;319 $response['focusInFirstInput']= $this->focusInFirstInput;
319 $response['modal'] = $this->modal;320 $response['modal'] = $this->modal;
321 $response['nextToken'] = $this->nextToken;
320 322
321 // Login323 // Login
322 $response['login'] = $this->login;324 $response['login'] = $this->login;
323325
=== modified file 'server/lib/app/session.class.php'
--- server/lib/app/session.class.php 2014-06-15 14:39:41 +0000
+++ server/lib/app/session.class.php 2014-10-21 16:06:16 +0000
@@ -160,8 +160,9 @@
160 // we do not want to update the expiry time of a session if it is the Clock Timer going off160 // we do not want to update the expiry time of a session if it is the Clock Timer going off
161 $page = Kit::GetParam('p', _REQUEST, _WORD);161 $page = Kit::GetParam('p', _REQUEST, _WORD);
162 $query = Kit::GetParam('q', _REQUEST, _WORD);162 $query = Kit::GetParam('q', _REQUEST, _WORD);
163 $autoRefresh = (isset($_REQUEST['autoRefresh']) && Kit::GetParam('autoRefresh', _REQUEST, _WORD, 'false') == 'true');
163164
164 if (($page == 'clock' && $query == 'GetClock') || ($page == 'index' && $query == 'PingPong') || ($page == 'layout' && $query == 'LayoutStatus')) {165 if ($autoRefresh || ($page == 'clock' && $query == 'GetClock') || ($page == 'index' && $query == 'PingPong') || ($page == 'layout' && $query == 'LayoutStatus')) {
165166
166 // Update the existing session without the expiry167 // Update the existing session without the expiry
167 $SQL = "UPDATE session SET session_data = :session_data WHERE session_id = :session_id ";168 $SQL = "UPDATE session SET session_data = :session_data WHERE session_id = :session_id ";
@@ -336,10 +337,16 @@
336 * @param type $secondKey337 * @param type $secondKey
337 * @return boolean338 * @return boolean
338 */339 */
339 public static function Get($key, $secondKey)340 public static function Get($key, $secondKey = NULL)
340 {341 {
341 if (isset($_SESSION[$key][$secondKey]))342 if ($secondKey != NULL) {
342 return $_SESSION[$key][$secondKey];343 if (isset($_SESSION[$key][$secondKey]))
344 return $_SESSION[$key][$secondKey];
345 }
346 else {
347 if (isset($_SESSION[$key]))
348 return $_SESSION[$key];
349 }
343 350
344 return false;351 return false;
345 } 352 }
346353
=== modified file 'server/lib/app/thememanager.class.php'
--- server/lib/app/thememanager.class.php 2014-08-17 12:38:20 +0000
+++ server/lib/app/thememanager.class.php 2014-10-21 16:06:16 +0000
@@ -152,6 +152,46 @@
152 }152 }
153153
154 /**154 /**
155 * Get Item Path
156 * @param string $item The Item required
157 */
158 public static function ItemPath($item) {
159
160 $theme = Theme::GetInstance();
161
162 // See if we have the requested file in the theme folder
163 if (file_exists('theme/' . $theme->name . '/' . $item)) {
164 return 'theme/' . $theme->name . '/' . $item;
165 }
166 // If not, then use the default folder
167 elseif (file_exists('theme/default/' . $item)) {
168 return 'theme/default/' . $item;
169 }
170 else
171 return '';
172 }
173
174 /**
175 * Get Item Path
176 * @param string $item The Item required
177 */
178 public static function Script($item) {
179
180 $theme = Theme::GetInstance();
181
182 // See if we have the requested file in the theme folder
183 if (file_exists('theme/' . $theme->name . '/' . $item)) {
184 return '<script src="theme/' . $theme->name . '/' . $item . '"></script>';
185 }
186 // If not, then use the default folder
187 elseif (file_exists('theme/default/' . $item)) {
188 return '<script src="theme/default/' . $item . '"></script>';
189 }
190 else
191 return '';
192 }
193
194 /**
155 * Translate a string into the user language195 * Translate a string into the user language
156 * @param string $string The String to Translate196 * @param string $string The String to Translate
157 * @param array $args Variables to insert (will replace %d %s in order)197 * @param array $args Variables to insert (will replace %d %s in order)
@@ -181,6 +221,22 @@
181 return $return;221 return $return;
182 }222 }
183223
224 public static function SetTranslation($key, $value) {
225 // Get existing translations
226 $translations = Theme::Get('translations');
227
228 if ($translations == '') {
229 $translations = array();
230 }
231 else {
232 $translations = json_decode($translations, true);
233 }
234
235 $translations[$key] = $value;
236
237 Theme::Set('translations', json_encode($translations));
238 }
239
184 public static function Prepare($string) {240 public static function Prepare($string) {
185 return htmlspecialchars($string);241 return htmlspecialchars($string);
186 }242 }
187243
=== modified file 'server/lib/app/translationengine.class.php'
--- server/lib/app/translationengine.class.php 2014-08-17 12:38:20 +0000
+++ server/lib/app/translationengine.class.php 2014-10-21 16:06:16 +0000
@@ -27,85 +27,86 @@
27 27
28class TranslationEngine28class TranslationEngine
29{ 29{
30 private static $locale;
31 private static $jsLocale;
32
30 /**33 /**
31 * Gets and Sets the Local 34 * Gets and Sets the Local
32 * @return 35 * @return
33 */36 */
34 public static function InitLocale($language = NULL)37 public static function InitLocale($language = NULL)
35 {38 {
36 $localeDir = 'locale';39 $localeDir = 'locale';
37 $default = ($language == NULL) ? Config::GetSetting('DEFAULT_LANGUAGE') : $language;40 $default = ($language == NULL) ? Config::GetSetting('DEFAULT_LANGUAGE') : $language;
38 41
39 global $transEngine;42 global $transEngine;
40 global $stream;43 global $stream;
4144
42 //Debug::LogEntry('audit', 'IN', 'TranslationEngine', 'InitLocal');45 //Debug::LogEntry('audit', 'IN', 'TranslationEngine', 'InitLocal');
4346 // Build an array of supported languages
44 // Try to get the local firstly from _REQUEST (post then get)47 $supportedLangs = scandir($localeDir);
45 $lang = Kit::GetParam('lang', _REQUEST, _WORD, '');48
4649 // Try to get the local firstly from _REQUEST (post then get)
47 // Build an array of supported languages50 $lang = Kit::GetParam('lang', _REQUEST, _WORD, '');
48 $supportedLangs = scandir($localeDir);51
4952 // If we don't have a language, try from HTTP accept
50 if ($lang != '')53 if ($lang == '' && Config::GetSetting('DETECT_LANGUAGE') == 1) {
51 {54 $langs = Kit::GetParam('HTTP_ACCEPT_LANGUAGE', $_SERVER, _STRING);
52 // Set the language55
53 //Debug::LogEntry('audit', 'Set the Language from REQUEST [' . $lang . ']', 'TranslationEngine', 'InitLocal');56 if ($langs != '') {
5457 //Debug::LogEntry('audit', ' HTTP_ACCEPT_LANGUAGE [' . $langs . ']', 'TranslationEngine', 'InitLocal');
55 // Is this language supported?58 $langs = explode(',', $langs);
56 // if not just use the default (eb_GB).59
57 if (!in_array($lang . '.mo', $supportedLangs))60 foreach ($langs as $lang) {
58 {61 // Remove any quality rating (as we aren't interested)
59 trigger_error(sprintf('Language not supported. %s', $lang));62 $rawLang = explode(';', $lang);
6063 $lang = str_replace('-', '_', $rawLang[0]);
61 // Use the default language instead.64
62 $lang = $default;65 if (in_array($lang . '.mo', $supportedLangs)) {
63 }66 //Debug::LogEntry('audit', 'Obtained the Language from HTTP_ACCEPT_LANGUAGE [' . $lang . ']', 'TranslationEngine', 'InitLocal');
64 }67 break;
65 else
66 {
67 $langs = Kit::GetParam('HTTP_ACCEPT_LANGUAGE', $_SERVER, _STRING);
68
69 if ($langs != '')
70 {
71 //Debug::LogEntry('audit', ' HTTP_ACCEPT_LANGUAGE [' . $langs . ']', 'TranslationEngine', 'InitLocal');
72 $langs = explode(',', $langs);
73
74 foreach ($langs as $lang)
75 {
76 // Remove any quality rating (as we aren't interested)
77 $rawLang = explode(';', $lang);
78 $lang = str_replace("-", "_", $rawLang[0]);
79
80 if (in_array($lang . '.mo', $supportedLangs))
81 {
82 //Debug::LogEntry('audit', 'Obtained the Language from HTTP_ACCEPT_LANGUAGE [' . $lang . ']', 'TranslationEngine', 'InitLocal');
83 break;
84 }
85
86 // Set lang as the default
87 $lang = $default;
88 }68 }
89 }69
90 else70 // Set lang as the default
91 {
92 $lang = $default;71 $lang = $default;
93 }72 }
94 }73 }
9574 }
96 // We have the language75
97 //Debug::LogEntry('audit', 'Creating new file streamer for '. $localeDir . '/' . $lang . '.mo', 'TranslationEngine', 'InitLocal');76 // Are we still empty?
9877 if ($lang == '')
99 if (!$stream = new CachedFileReader($localeDir . '/' . $lang . '.mo'))78 $lang = $default;
100 {79
101 trigger_error('Unable to translate this language');80 // Sanitize it
102 $transEngine = false;81 $lang = str_replace('-', '_', $lang);
103 82 $jsLang = str_replace('_', '-', $lang);
104 return;83
105 }84 // Check its valid
10685 if (!in_array($lang . '.mo', $supportedLangs)) {
107 $transEngine = new gettext_reader($stream);86 trigger_error(sprintf('Language not supported. %s', $lang));
87
88 // Fall back
89 $lang = 'en_GB';
90 }
91
92 //Debug::LogEntry('audit', 'Creating new file streamer for '. $localeDir . '/' . $lang . '.mo', 'TranslationEngine', 'InitLocal');
93 if (!$stream = new CachedFileReader($localeDir . '/' . $lang . '.mo')) {
94 $transEngine = false;
95 return;
96 }
97
98 $transEngine = new gettext_reader($stream);
99 self::$locale = $lang;
100 self::$jsLocale = str_replace('_', '-', $lang);
108 }101 }
102
103 public static function GetLocale() {
104 return self::$locale;
105 }
106
107 public static function GetJsLocale() {
108 return self::$jsLocale;
109 }
109}110}
110111
111/**112/**
112113
=== modified file 'server/lib/data/campaign.data.class.php'
--- server/lib/data/campaign.data.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/data/campaign.data.class.php 2014-10-21 16:06:16 +0000
@@ -97,12 +97,14 @@
97 throw new Exception(__('Unable to Unlink'));97 throw new Exception(__('Unable to Unlink'));
9898
99 // Remove all permissions99 // Remove all permissions
100 Kit::ClassLoader('campaignsecurity');
101 $security = new CampaignSecurity($this->db);100 $security = new CampaignSecurity($this->db);
102101
103 if (!$security->UnlinkAll($campaignId))102 if (!$security->UnlinkAll($campaignId))
104 throw new Exception(__('Unable to set permissions'));103 throw new Exception(__('Unable to set permissions'));
105104
105 // Remove from all Schedules
106 Schedule::DeleteScheduleForCampaign($campaignId);
107
106 // Delete from the Campaign108 // Delete from the Campaign
107 $sth = $dbh->prepare('DELETE FROM `campaign` WHERE CampaignID = :campaignid');109 $sth = $dbh->prepare('DELETE FROM `campaign` WHERE CampaignID = :campaignid');
108 $sth->execute(array(110 $sth->execute(array(
109111
=== modified file 'server/lib/data/campaignsecurity.data.class.php'
--- server/lib/data/campaignsecurity.data.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/data/campaignsecurity.data.class.php 2014-10-21 16:06:16 +0000
@@ -22,6 +22,15 @@
2222
23class CampaignSecurity extends Data23class CampaignSecurity extends Data
24{24{
25 public function GetPermissions($objectId)
26 {
27 $userGroup = new UserGroup();
28 if (!$result = $userGroup->GetPermissionsForObject('lkcampaigngroup', 'CampaignID', $objectId))
29 return $this->SetError($userGroup->GetErrorMessage());
30
31 return $result;
32 }
33
25 /**34 /**
26 * Links a Campaign to a Group35 * Links a Campaign to a Group
27 * @return36 * @return
2837
=== modified file 'server/lib/data/datasetdata.data.class.php'
--- server/lib/data/datasetdata.data.class.php 2014-08-06 11:57:27 +0000
+++ server/lib/data/datasetdata.data.class.php 2014-10-21 16:06:16 +0000
@@ -355,6 +355,10 @@
355 $rowNumber++;355 $rowNumber++;
356 }356 }
357357
358 // Close the file
359 fclose($handle);
360
361 // Change the auto detect setting back
358 ini_set('auto_detect_line_endings', false);362 ini_set('auto_detect_line_endings', false);
359363
360 // Delete the temporary file364 // Delete the temporary file
361365
=== modified file 'server/lib/data/datasetgroupsecurity.data.class.php'
--- server/lib/data/datasetgroupsecurity.data.class.php 2014-07-10 21:09:24 +0000
+++ server/lib/data/datasetgroupsecurity.data.class.php 2014-10-21 16:06:16 +0000
@@ -27,46 +27,24 @@
27 if ($dataSetId == 0 || $dataSetId == '')27 if ($dataSetId == 0 || $dataSetId == '')
28 return $this->SetError(25001, __('Missing dataSetId'));28 return $this->SetError(25001, __('Missing dataSetId'));
2929
30 try {30 $userGroup = new UserGroup();
31 $dbh = PDOConnect::init();31 if (!$result = $userGroup->GetPermissionsForObject('lkdatasetgroup', 'DataSetID', $dataSetId))
3232 return $this->SetError($userGroup->GetErrorMessage());
33 $sth = $dbh->prepare('SELECT `group`.groupid, `group`.`group`, view, edit, del, `group`.isuserspecific33
34 FROM `group`34 $security = array();
35 LEFT OUTER JOIN lkdatasetgroup35
36 ON lkdatasetgroup.GroupID = group.GroupID36 foreach($result as $row) {
37 AND lkdatasetgroup.DataSetID = :datasetid37 $security[] = array(
38 WHERE `group`.GroupID <> :groupid38 'groupid' => Kit::ValidateParam($row['groupid'], _INT),
39 ORDER BY `group`.IsEveryone DESC, `group`.IsUserSpecific, `group`.`Group`');39 'group' => Kit::ValidateParam($row['group'], _STRING),
4040 'view' => Kit::ValidateParam($row['view'], _INT),
41 $sth->execute(array(41 'edit' => Kit::ValidateParam($row['edit'], _INT),
42 'datasetid' => $dataSetId,42 'del' => Kit::ValidateParam($row['del'], _INT),
43 'groupid' => $groupId43 'isuserspecific' => Kit::ValidateParam($row['isuserspecific'], _INT),
44 ));44 );
4545 }
46 $security = array();46
4747 return $security;
48 foreach($sth->fetchAll() as $row) {
49 $security[] = array(
50 'groupid' => Kit::ValidateParam($row['groupid'], _INT),
51 'group' => Kit::ValidateParam($row['group'], _STRING),
52 'view' => Kit::ValidateParam($row['view'], _INT),
53 'edit' => Kit::ValidateParam($row['edit'], _INT),
54 'del' => Kit::ValidateParam($row['del'], _INT),
55 'isuserspecific' => Kit::ValidateParam($row['isuserspecific'], _INT),
56 );
57 }
58
59 return $security;
60 }
61 catch (Exception $e) {
62
63 Debug::LogEntry('error', $e->getMessage());
64
65 if (!$this->IsError())
66 $this->SetError(1, __('Unknown Error'));
67
68 return false;
69 }
70 }48 }
7149
72 /**50 /**
7351
=== modified file 'server/lib/data/display.data.class.php'
--- server/lib/data/display.data.class.php 2014-09-16 10:59:55 +0000
+++ server/lib/data/display.data.class.php 2014-10-21 16:06:16 +0000
@@ -63,6 +63,7 @@
63 public $screenShotRequested;63 public $screenShotRequested;
6464
65 public $displayGroupId;65 public $displayGroupId;
66 private $_config;
66 67
67 public function Load() {68 public function Load() {
68 try {69 try {
@@ -105,7 +106,7 @@
105 $this->wakeOnLanTime = Kit::ValidateParam($row['WakeOnLanTime'], _STRING);106 $this->wakeOnLanTime = Kit::ValidateParam($row['WakeOnLanTime'], _STRING);
106 $this->broadCastAddress = Kit::ValidateParam($row['BroadCastAddress'], _STRING);107 $this->broadCastAddress = Kit::ValidateParam($row['BroadCastAddress'], _STRING);
107 $this->secureOn = Kit::ValidateParam($row['SecureOn'], _STRING);108 $this->secureOn = Kit::ValidateParam($row['SecureOn'], _STRING);
108 $this->cidr = Kit::ValidateParam($row['Cidr'], _INT);109 $this->cidr = Kit::ValidateParam($row['Cidr'], _STRING);
109 $this->latitude = Kit::ValidateParam($row['Latitude'], _DOUBLE);110 $this->latitude = Kit::ValidateParam($row['Latitude'], _DOUBLE);
110 $this->longitude = Kit::ValidateParam($row['Longitude'], _DOUBLE);111 $this->longitude = Kit::ValidateParam($row['Longitude'], _DOUBLE);
111 $this->versionInstructions = Kit::ValidateParam($row['version_instructions'], _STRING);112 $this->versionInstructions = Kit::ValidateParam($row['version_instructions'], _STRING);
@@ -656,7 +657,137 @@
656 657
657 return false;658 return false;
658 }659 }
659660 }
661
662 public function GetSetting($key, $default) {
663
664 if (!$this->SetConfig())
665 return false;
666
667 // Find
668 $return = $default;
669 foreach($this->_config as $row) {
670 if ($row['name'] == $key || $row['name'] == ucfirst($key)) {
671 //Debug::Audit('Found ' . $key . '. value= ' . $row['value']);
672 $return = $row['value'];
673 break;
674 }
675 }
676
677 return $return;
678 }
679
680 private function SetConfig() {
681 if ($this->_config == null) {
682 try {
683 $dbh = PDOConnect::init();
684
685 $displayProfile = new DisplayProfile();
686 $displayProfile->displayProfileId = $this->displayProfileId;
687
688 if ($displayProfile->displayProfileId == 0) {
689 // Load the default profile
690 $displayProfile->type = $this->clientType;
691 $displayProfile->LoadDefault();
692 }
693 else {
694 // Load the specified profile
695 $displayProfile->Load();
696 }
697
698 $this->_config = $displayProfile->config;
699
700 return true;
701 }
702 catch (Exception $e) {
703
704 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
705
706 if (!$this->IsError())
707 $this->SetError(1, __('Unknown Error'));
708
709 return false;
710 }
711 }
712 }
713 /**
714 * Assess each Display to correctly set the logged in flag based on last accessed time
715 * @return
716 */
717 public static function ValidateDisplays() {
718 // Maintain an array of timed out displays
719 $timedOutDisplays = array();
720
721 try {
722 $dbh = PDOConnect::init();
723 $statObject = new Stat();
724
725 // Get a list of all displays and there last accessed / alert time out value
726 $sth = $dbh->prepare('SELECT displayid, display, lastaccessed, alert_timeout, client_type, displayprofileid, email_alert, loggedin FROM display');
727 $sthUpdate = $dbh->prepare('UPDATE display SET loggedin = 0 WHERE displayid = :displayid');
728
729 $sth->execute(array());
730
731 // Get the global time out (overrides the alert time out on the display if 0)
732 $globalTimeout = Config::GetSetting('MAINTENANCE_ALERT_TOUT') * 60;
733
734 $displays = $sth->fetchAll();
735
736 foreach ($displays as $row) {
737 $displayid = Kit::ValidateParam($row['displayid'], _INT);
738 $lastAccessed = Kit::ValidateParam($row['lastaccessed'], _INT);
739 $alertTimeout = Kit::ValidateParam($row['alert_timeout'], _INT);
740 $clientType = Kit::ValidateParam($row['client_type'], _WORD);
741 $loggedIn = Kit::ValidateParam($row['loggedin'], _INT);
742
743 // Get the config object
744 if ($alertTimeout == 0) {
745 $displayProfileId = (empty($row['displayprofileid']) ? 0 : Kit::ValidateParam($row['displayprofileid'], _INT));
746
747 $display = new Display();
748 $display->displayId = $displayid;
749 $display->displayProfileId = $displayProfileId;
750 $display->clientType = $clientType;
751 $timeoutToTestAgainst = $display->GetSetting('collectInterval', $globalTimeout);
752 }
753 else {
754 $timeoutToTestAgainst = $globalTimeout;
755 }
756
757 // Store the time out to test against
758 $row['timeout'] = $timeoutToTestAgainst;
759 $timeOut = $lastAccessed + $timeoutToTestAgainst;
760
761 // If the last time we accessed is less than now minus the time out
762 if ($timeOut < time()) {
763 Debug::Audit('Timed out display. Last Accessed: ' . date('Y-m-d h:i:s', $lastAccessed) . '. Time out: ' . date('Y-m-d h:i:s', $timeOut));
764
765 // If this is the first switch (i.e. the row was logged in before)
766 if ($loggedIn == 1) {
767
768 // Update the display and set it as logged out
769 $sthUpdate->execute(array('displayid' => $displayid));
770
771 // Log the down event
772 $statObject->displayDown($displayid, $lastAccessed);
773 }
774
775 // Store this row
776 $timedOutDisplays[] = $row;
777 }
778 }
779
780 return $timedOutDisplays;
781 }
782 catch (Exception $e) {
783
784 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
785
786 if (!$this->IsError())
787 $this->SetError(1, __('Unknown Error'));
788
789 return false;
790 }
660 }791 }
661792
662 /**793 /**
663794
=== modified file 'server/lib/data/displayprofile.data.class.php'
--- server/lib/data/displayprofile.data.class.php 2014-08-07 11:58:10 +0000
+++ server/lib/data/displayprofile.data.class.php 2014-10-21 16:06:16 +0000
@@ -39,6 +39,8 @@
3939
40 public function Load() {40 public function Load() {
4141
42 Debug::Audit('Load ' . $this->displayProfileId);
43
42 try {44 try {
43 $dbh = PDOConnect::init();45 $dbh = PDOConnect::init();
44 46
@@ -75,6 +77,59 @@
7577
76 }78 }
7779
80 public function LoadDefault() {
81
82 Debug::Audit('Load Default');
83
84 try {
85 $dbh = PDOConnect::init();
86
87 $sth = $dbh->prepare('SELECT * FROM `displayprofile` WHERE type = :type AND IsDefault = 1');
88 $sth->execute(array(
89 'type' => $this->displayProfileId
90 ));
91
92 if (!$row = $sth->fetch()) {
93 // Return the client default
94 include_once('config/client.config.php');
95 $this->name = $CLIENT_CONFIG[$this->type]['synonym'];
96 $this->type = $this->type;
97 $this->config = $CLIENT_CONFIG[$this->type]['settings'];
98 $this->isDefault = 1;
99 $this->userId = 1;
100
101 // Just populate the values with the defaults if the values aren't set already
102 for ($i = 0; $i < count($this->config); $i++) {
103 $this->config[$i]['value'] = isset($this->config[$i]['value']) ? $this->config[$i]['value'] : $this->config[$i]['default'];
104 }
105 }
106 else {
107 $this->name = Kit::ValidateParam($row['name'], _STRING);
108 $this->type = Kit::ValidateParam($row['type'], _STRING);
109 $this->config = Kit::ValidateParam($row['config'], _HTMLSTRING);
110 $this->isDefault = Kit::ValidateParam($row['isdefault'], _INT);
111 $this->userId = Kit::ValidateParam($row['userid'], _INT);
112
113 // Load the client settings into an array
114 $this->config = ($this->config == '') ? array() : json_decode($this->config, true);
115
116 $this->isNew = false;
117 }
118
119 return true;
120 }
121 catch (Exception $e) {
122
123 Debug::LogEntry('error', $e->getMessage());
124
125 if (!$this->IsError())
126 $this->SetError(1, __('Unknown Error'));
127
128 return false;
129 }
130
131 }
132
78 public function Save() {133 public function Save() {
79134
80 // Validation.135 // Validation.
81136
=== modified file 'server/lib/data/layout.data.class.php'
--- server/lib/data/layout.data.class.php 2014-09-16 16:41:43 +0000
+++ server/lib/data/layout.data.class.php 2014-10-21 16:06:16 +0000
@@ -19,19 +19,13 @@
19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
20 */ 20 */
21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
22Kit::ClassLoader('campaign');
2223
23class Layout extends Data24class Layout extends Data
24{25{
25 private $xml;26 private $xml;
26 private $DomXml;27 private $DomXml;
2728
28 public function __construct($db)
29 {
30 Kit::ClassLoader('campaign');
31
32 parent::__construct($db);
33 }
34
35 /**29 /**
36 * Add a layout30 * Add a layout
37 * @param <type> $layout31 * @param <type> $layout
@@ -543,10 +537,7 @@
543 $campaign = new Campaign($this->db);537 $campaign = new Campaign($this->db);
544 538
545 // Include to media data class?539 // Include to media data class?
546 if ($copyMedia)540 if ($copyMedia) {
547 {
548 Kit::ClassLoader('media');
549 Kit::ClassLoader('mediagroupsecurity');
550 $mediaObject = new Media($this->db);541 $mediaObject = new Media($this->db);
551 $mediaSecurity = new MediaGroupSecurity($this->db);542 $mediaSecurity = new MediaGroupSecurity($this->db);
552 }543 }
@@ -554,11 +545,6 @@
554 // We need the old campaignid545 // We need the old campaignid
555 $oldCampaignId = $campaign->GetCampaignId($oldLayoutId);546 $oldCampaignId = $campaign->GetCampaignId($oldLayoutId);
556 547
557 // Permissions model
558 Kit::ClassLoader('campaignsecurity');
559 Kit::ClassLoader('layoutregiongroupsecurity');
560 Kit::ClassLoader('layoutmediagroupsecurity');
561
562 // The Layout ID is the old layout548 // The Layout ID is the old layout
563 $SQL = "";549 $SQL = "";
564 $SQL .= " INSERT INTO layout (layout, xml, userID, description, tags, templateID, retired, duration, backgroundImageId, createdDT, modifiedDT, status) ";550 $SQL .= " INSERT INTO layout (layout, xml, userID, description, tags, templateID, retired, duration, backgroundImageId, createdDT, modifiedDT, status) ";
@@ -613,7 +599,7 @@
613 if ($this->IsRegionSpecific($type))599 if ($this->IsRegionSpecific($type))
614 {600 {
615 // Generate a new media id601 // Generate a new media id
616 $newMediaId = md5(uniqid());602 $newMediaId = md5(Kit::uniqueId());
617 603
618 $mediaNode->setAttribute('id', $newMediaId);604 $mediaNode->setAttribute('id', $newMediaId);
619 605
@@ -740,12 +726,14 @@
740 if ($layoutId == 0)726 if ($layoutId == 0)
741 $this->ThrowError(__('No Layout selected'));727 $this->ThrowError(__('No Layout selected'));
742 728
729 // Security
743 $sth = $dbh->prepare('DELETE FROM lklayoutmediagroup WHERE layoutid = :layoutid');730 $sth = $dbh->prepare('DELETE FROM lklayoutmediagroup WHERE layoutid = :layoutid');
744 $sth->execute(array('layoutid' => $layoutId));731 $sth->execute(array('layoutid' => $layoutId));
745732
746 $sth = $dbh->prepare('DELETE FROM lklayoutregiongroup WHERE layoutid = :layoutid');733 $sth = $dbh->prepare('DELETE FROM lklayoutregiongroup WHERE layoutid = :layoutid');
747 $sth->execute(array('layoutid' => $layoutId));734 $sth->execute(array('layoutid' => $layoutId));
748735
736 // Media Links
749 $sth = $dbh->prepare('DELETE FROM lklayoutmedia WHERE layoutid = :layoutid');737 $sth = $dbh->prepare('DELETE FROM lklayoutmedia WHERE layoutid = :layoutid');
750 $sth->execute(array('layoutid' => $layoutId));738 $sth->execute(array('layoutid' => $layoutId));
751 739
@@ -756,6 +744,10 @@
756 // Remove the Campaign (will remove links to this layout - orphaning the layout)744 // Remove the Campaign (will remove links to this layout - orphaning the layout)
757 if (!$campaign->Delete($campaignId))745 if (!$campaign->Delete($campaignId))
758 $this->ThrowError(25008, __('Unable to delete campaign'));746 $this->ThrowError(25008, __('Unable to delete campaign'));
747
748 // Remove the Layout from any display defaults
749 $sth = $dbh->prepare('UPDATE `display` SET defaultlayoutid = 4 WHERE defaultlayoutid = :layoutid');
750 $sth->execute(array('layoutid' => $layoutId));
759 751
760 // Remove the Layout (now it is orphaned it can be deleted safely)752 // Remove the Layout (now it is orphaned it can be deleted safely)
761 $sth = $dbh->prepare('DELETE FROM layout WHERE layoutid = :layoutid');753 $sth = $dbh->prepare('DELETE FROM layout WHERE layoutid = :layoutid');
@@ -1236,7 +1228,7 @@
1236 $fileName = $libraryPath . 'temp/export_' . Kit::ValidateParam($row['layout'], _FILENAME) . '.zip';1228 $fileName = $libraryPath . 'temp/export_' . Kit::ValidateParam($row['layout'], _FILENAME) . '.zip';
12371229
1238 $zip = new ZipArchive();1230 $zip = new ZipArchive();
1239 $zip->open($fileName, ZIPARCHIVE::OVERWRITE); 1231 $zip->open($fileName, ZIPARCHIVE::OVERWRITE);
1240 $zip->addFromString('layout.xml', $xml);1232 $zip->addFromString('layout.xml', $xml);
12411233
1242 $params = array('layoutid' => $layoutId); 1234 $params = array('layoutid' => $layoutId);
12431235
=== modified file 'server/lib/data/maintenance.data.class.php'
--- server/lib/data/maintenance.data.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/data/maintenance.data.class.php 2014-10-21 16:06:16 +0000
@@ -28,27 +28,78 @@
28 */28 */
29 public function BackupDatabase($saveAs = "string")29 public function BackupDatabase($saveAs = "string")
30 {30 {
31 // Always truncate the log first31 // Check we can run mysql
32 $this->db->query("TRUNCATE TABLE `log` ");32 if (!function_exists('exec'))
33 $this->db->query("TRUNCATE TABLE `oauth_log` ");33 return $this->SetError(__('Exec is not available.'));
3434
35 // Global database variables to seed into exec
35 global $dbhost;36 global $dbhost;
36 global $dbuser;37 global $dbuser;
37 global $dbpass;38 global $dbpass;
38 global $dbname;39 global $dbname;
3940
40 // Run mysqldump to a temporary file
41
42 // get temporary file41 // get temporary file
43 $tempFile = tempnam(Config::GetSetting('LIBRARY_LOCATION'), 'dmp');42 $fileNameStructure = Config::GetSetting('LIBRARY_LOCATION') . 'structure.dump';
4443 $fileNameData = Config::GetSetting('LIBRARY_LOCATION') . 'data.dump';
45 exec('mysqldump --opt --host=' . $dbhost . ' --user=' . $dbuser . ' --password=' . $dbpass . ' ' . $dbname . ' > ' . escapeshellarg($tempFile) . ' ');44 $zipFile = 'database.tar.gz';
4645
47 $sqlDump = file_get_contents($tempFile);46 // Run mysqldump structure to a temporary file
4847 $command = 'mysqldump --opt --host=' . $dbhost . ' --user=' . $dbuser . ' --password=' . addslashes($dbpass) . ' ' . $dbname . ' --no-data > ' . escapeshellarg($fileNameStructure) . ' ';
49 unlink($tempFile);48 exec($command);
5049
51 return $sqlDump;50 // Run mysqldump data to a temporary file
51 $command = 'mysqldump --opt --host=' . $dbhost . ' --user=' . $dbuser . ' --password=' . addslashes($dbpass) . ' ' . $dbname . ' --ignore-table=' . $dbname . '.log --ignore-table=' . $dbname . '.oauth_log > ' . escapeshellarg($fileNameData) . ' ';
52 exec($command);
53
54 // Check it worked
55 if (!file_exists($fileNameStructure) || !file_exists($fileNameData))
56 return $this->SetError(__('Database dump failed.'));
57
58 // Zippy
59 Debug::Audit($zipFile);
60 $zip = new ZipArchive();
61 $zip->open($zipFile, ZIPARCHIVE::OVERWRITE);
62 $zip->addFile($fileNameStructure, 'structure.dump');
63 $zip->addFile($fileNameData, 'data.dump');
64 $zip->close();
65
66 // Remove the dump file
67 unlink($fileNameStructure);
68 unlink($fileNameData);
69
70 // Uncomment only if you are having permission issues
71 // chmod($zipFile, 0777);
72
73 // Push file back to browser
74 if (ini_get('zlib.output_compression')) {
75 ini_set('zlib.output_compression', 'Off');
76 }
77
78 $size = filesize($zipFile);
79
80 header('Content-Type: application/octet-stream');
81 header("Content-Transfer-Encoding: Binary");
82 header("Content-disposition: attachment; filename=\"" . basename($zipFile) . "\"");
83
84 //Output a header
85 header('Pragma: public');
86 header('Cache-Control: max-age=86400');
87 header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 86400));
88 header('Content-Length: ' . $size);
89
90 // Send via Apache X-Sendfile header?
91 if (Config::GetSetting('SENDFILE_MODE') == 'Apache') {
92 header("X-Sendfile: $zipFile");
93 exit();
94 }
95
96 // Return the file with PHP
97 // Disable any buffering to prevent OOM errors.
98 @ob_end_clean();
99 @ob_end_flush();
100 readfile($zipFile);
101
102 exit;
52 }103 }
53104
54 /**105 /**
@@ -69,5 +120,95 @@
69120
70 return true;121 return true;
71 }122 }
123
124 public function TidyLibrary($tidyOldRevisions) {
125 // Also run a script to tidy up orphaned media in the library
126 $library = Config::GetSetting('LIBRARY_LOCATION');
127 $library = rtrim($library, '/') . '/';
128 $mediaObject = new Media();
129
130 Debug::Audit('Library Location: ' . $library);
131
132 // Dump the files in the temp folder
133 foreach (scandir($library . 'temp') as $item) {
134 if ($item == '.' || $item == '..')
135 continue;
136
137 Debug::Audit('Deleting temp file: ' . $item);
138
139 unlink($library . 'temp' . DIRECTORY_SEPARATOR . $item);
140 }
141
142 $media = array();
143 $unusedMedia = array();
144
145 // Run a query to get an array containing all of the media in the library
146 try {
147 $dbh = PDOConnect::init();
148
149 $sth = $dbh->prepare('
150 SELECT media.mediaid, media.storedAs, media.type, media.isedited, COUNT(lklayoutmedia.lklayoutmediaid) AS UsedInLayoutCount
151 FROM `media`
152 LEFT OUTER JOIN `lklayoutmedia`
153 ON lklayoutmedia.mediaid = media.mediaid
154 GROUP BY media.mediaid, media.storedAs ');
155
156 $sth->execute(array());
157
158 foreach ($sth->fetchAll() as $row) {
159 $media[$row['storedAs']] = $row;
160
161 // If its not used in a layout and its not a generic module, add to the unused array.
162 if ($tidyOldRevisions && $row['UsedInLayoutCount'] <= 0 && $row['isedited'] > 0 && $row['type'] != 'module' && $row['type'] != 'font')
163 $unusedMedia[$row['storedAs']] = $row;
164 }
165 }
166 catch (Exception $e) {
167
168 Debug::LogEntry('error', $e->getMessage());
169
170 if (!$this->IsError())
171 $this->SetError(1, __('Unknown Error'));
172
173 return false;
174 }
175
176 //Debug::Audit(var_export($media, true));
177 //Debug::Audit(var_export($unusedMedia, true));
178
179 // Get a list of all media files
180 foreach(scandir($library) as $file) {
181
182 if ($file == '.' || $file == '..')
183 continue;
184
185 if (is_dir($library . $file))
186 continue;
187
188 // Ignore thumbnails
189 if (strstr($file, 'tn_') || strstr($file, 'bg_'))
190 continue;
191
192 // Is this file in the system anywhere?
193 if (!array_key_exists($file, $media)) {
194 // Totally missing
195 Debug::Audit('Deleting file: ' . $file);
196
197 // If not, delete it
198 $mediaObject->DeleteMediaFile($file);
199 }
200 else if (array_key_exists($file, $unusedMedia)) {
201 // It exists but isn't being used any more
202 Debug::Audit('Deleting media: ' . $media[$file]['mediaid']);
203 $mediaObject->Delete($media[$file]['mediaid']);
204 }
205 else {
206 // Don't do anything, this file still exists
207 //Debug::Audit('Still exists: ' . $file);
208 }
209 }
210
211 return true;
212 }
72}213}
73?>214?>
74215
=== modified file 'server/lib/data/media.data.class.php'
--- server/lib/data/media.data.class.php 2014-07-24 16:23:27 +0000
+++ server/lib/data/media.data.class.php 2014-10-21 16:06:16 +0000
@@ -22,6 +22,8 @@
2222
23class Media extends Data23class Media extends Data
24{24{
25 private $_moduleFiles;
26
25 private $moduleInfoLoaded;27 private $moduleInfoLoaded;
26 private $regionSpecific;28 private $regionSpecific;
27 private $validExtensions;29 private $validExtensions;
@@ -80,7 +82,7 @@
80 $this->ThrowError(10, __('The name cannot be longer than 100 characters'));82 $this->ThrowError(10, __('The name cannot be longer than 100 characters'));
81 83
82 // Test the duration (except for video and localvideo which can have a 0)84 // Test the duration (except for video and localvideo which can have a 0)
83 if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile')85 if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile' && $type != 'font')
84 $this->ThrowError(11, __('You must enter a duration.'));86 $this->ThrowError(11, __('You must enter a duration.'));
85 87
86 // Check the naming of this item to ensure it doesnt conflict88 // Check the naming of this item to ensure it doesnt conflict
@@ -193,7 +195,7 @@
193 if (strlen($name) > 100)195 if (strlen($name) > 100)
194 $this->ThrowError(10, __('The name cannot be longer than 100 characters'));196 $this->ThrowError(10, __('The name cannot be longer than 100 characters'));
195 197
196 if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile')198 if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile' && $type != 'font')
197 $this->ThrowError(11, __('You must enter a duration.'));199 $this->ThrowError(11, __('You must enter a duration.'));
198 200
199 // Any media (not this one) already has this name?201 // Any media (not this one) already has this name?
@@ -330,8 +332,6 @@
330 {332 {
331 Debug::LogEntry('audit', 'IN', 'Media', 'Delete');333 Debug::LogEntry('audit', 'IN', 'Media', 'Delete');
332 334
333 Kit::ClassLoader('lkmediadisplaygroup');
334
335 try {335 try {
336 $dbh = PDOConnect::init();336 $dbh = PDOConnect::init();
337 337
@@ -357,7 +357,6 @@
357 $fileName = Kit::ValidateParam($row['StoredAs'], _STRING);357 $fileName = Kit::ValidateParam($row['StoredAs'], _STRING);
358 358
359 // Remove permission assignments359 // Remove permission assignments
360 Kit::ClassLoader('mediagroupsecurity');
361 $security = new MediaGroupSecurity($this->db);360 $security = new MediaGroupSecurity($this->db);
362 361
363 if (!$security->UnlinkAll($mediaId))362 if (!$security->UnlinkAll($mediaId))
@@ -648,5 +647,102 @@
648 return false;647 return false;
649 }648 }
650 }649 }
650
651 public function AddModuleFile($file, $force = false) {
652 try {
653 $name = basename($file);
654
655 $moduleExists = $this->ModuleFileExists($name);
656
657 if (!$force && $moduleExists) {
658 return;
659 }
660
661 $dbh = PDOConnect::init();
662 $libraryFolder = Config::GetSetting('LIBRARY_LOCATION');
663
664 // Get the name
665 $storedAs = $libraryFolder . $name;
666
667 // Now copy the file
668 if (!@copy($file, $storedAs))
669 $this->ThrowError(15, 'Error storing file.');
670
671 // Calculate the MD5 and the file size
672 $md5 = md5_file($storedAs);
673 $fileSize = filesize($storedAs);
674
675 if ($moduleExists) {
676 $SQL = "UPDATE `media` SET md5 = :md5, filesize = :filesize WHERE storedAs = :storedas ";
677
678 $sth = $dbh->prepare($SQL);
679 $sth->execute(array(
680 'storedas' => $name,
681 'filesize' => $fileSize,
682 'md5' => $md5
683 ));
684 }
685 else {
686 // All OK to insert this record
687 $SQL = "INSERT INTO media (name, type, duration, originalFilename, userID, retired, is_module, storedAs, FileSize, MD5) ";
688 $SQL .= "VALUES (:name, :type, :duration, :originalfilename, 1, :retired, 1, :storedas, :filesize, :md5) ";
689
690 $sth = $dbh->prepare($SQL);
691 $sth->execute(array(
692 'name' => $name,
693 'type' => 'module',
694 'duration' => 10,
695 'originalfilename' => $name,
696 'retired' => 0,
697 'storedas' => $name,
698 'filesize' => $fileSize,
699 'md5' => $md5
700 ));
701 }
702
703 $dbh->commit();
704
705 // Add to the cache
706 $this->_moduleFiles[] = $name;
707 }
708 catch (Exception $e) {
709
710 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
711
712 if (!$this->IsError())
713 $this->SetError(1, __('Unknown Error'));
714
715 return false;
716 }
717 }
718
719 public function ModuleFileExists($file) {
720 try {
721 if ($this->_moduleFiles == NULL || count($this->_moduleFiles) < 1) {
722 $dbh = PDOConnect::init();
723
724 $sth = $dbh->prepare('SELECT storedAs FROM `media` WHERE type = :type');
725 $sth->execute(array(
726 'type' => 'module'
727 ));
728
729 $this->_moduleFiles = array();
730
731 foreach ($sth->fetchAll() as $moduleFile)
732 $this->_moduleFiles[] = $moduleFile['storedAs'];
733 }
734
735 return (in_array($file, $this->_moduleFiles));
736 }
737 catch (Exception $e) {
738
739 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
740
741 if (!$this->IsError())
742 $this->SetError(1, __('Unknown Error'));
743
744 return false;
745 }
746 }
651}747}
652?>748?>
653749
=== modified file 'server/lib/data/region.data.class.php'
--- server/lib/data/region.data.class.php 2014-08-11 19:57:05 +0000
+++ server/lib/data/region.data.class.php 2014-10-21 16:06:16 +0000
@@ -20,6 +20,9 @@
20 */ 20 */
21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
2222
23require_once("lib/pages/module.class.php");
24Kit::ClassLoader('layout');
25
23class Region extends Data26class Region extends Data
24{27{
25 // Caching28 // Caching
@@ -27,14 +30,6 @@
27 private $layoutDocument;30 private $layoutDocument;
2831
29 public $delayFinalise = false;32 public $delayFinalise = false;
30
31 public function __construct(database $db)
32 {
33 $this->db =& $db;
34
35 require_once("lib/pages/module.class.php");
36 Kit::ClassLoader('layout');
37 }
38 33
39 /**34 /**
40 * Gets the Xml for the specified layout35 * Gets the Xml for the specified layout
@@ -44,7 +39,7 @@
44 public function GetLayoutXml($layoutid)39 public function GetLayoutXml($layoutid)
45 {40 {
46 if ($this->layoutXml == '') {41 if ($this->layoutXml == '') {
47 $layout = new Layout($this->db);42 $layout = new Layout();
48 $this->layoutXml = $layout->GetLayoutXml($layoutid);43 $this->layoutXml = $layout->GetLayoutXml($layoutid);
49 }44 }
5045
@@ -97,7 +92,7 @@
9792
98 //Do we have a region ID provided?93 //Do we have a region ID provided?
99 if ($regionid == '')94 if ($regionid == '')
100 $regionid = uniqid();95 $regionid = Kit::uniqid();
10196
102 // Validation97 // Validation
103 if (!is_numeric($width) || !is_numeric($height) || !is_numeric($top) || !is_numeric($left))98 if (!is_numeric($width) || !is_numeric($height) || !is_numeric($top) || !is_numeric($left))
10499
=== modified file 'server/lib/data/schedule.data.class.php'
--- server/lib/data/schedule.data.class.php 2014-09-05 16:07:36 +0000
+++ server/lib/data/schedule.data.class.php 2014-10-21 16:06:16 +0000
@@ -22,29 +22,29 @@
22 22
23class Schedule extends Data23class Schedule extends Data
24{24{
25 /**25 /**
26 * Add26 * Add
27 * @return 27 * @return
28 * @param $displayGroupIDs Object28 * @param $displayGroupIDs Object
29 * @param $fromDT Object29 * @param $fromDT Object
30 * @param $toDT Object30 * @param $toDT Object
31 * @param $layoutID Object31 * @param $layoutID Object
32 * @param $recType Object32 * @param $recType Object
33 * @param $recDetail Object33 * @param $recDetail Object
34 * @param $recToDT Object34 * @param $recToDT Object
35 * @param $isPriority Object35 * @param $isPriority Object
36 * @param $userID Object36 * @param $userID Object
37 * @param $displayOrder Object37 * @param $displayOrder Object
38 */38 */
39 public function Add($displayGroupIDs, $fromDT, $toDT, $campaignId, $recType, $recDetail, $recToDT, $isPriority, $userID, $displayOrder = 0)39 public function Add($displayGroupIDs, $fromDT, $toDT, $campaignId, $recType, $recDetail, $recToDT, $isPriority, $userID, $displayOrder = 0)
40 {40 {
41 Debug::LogEntry('audit', 'IN', 'Schedule', 'Add');41 Debug::LogEntry('audit', 'IN', 'Schedule', 'Add');
42 42
43 try {43 try {
44 $dbh = PDOConnect::init();44 $dbh = PDOConnect::init();
45 45
46 // Validation46 // Validation
47 if (count($displayGroupIDs) == 0)47 if (count($displayGroupIDs) == 0)
48 return $this->SetError(25001, __('No display groups selected'));48 return $this->SetError(25001, __('No display groups selected'));
49 49
50 if ($userID == 0)50 if ($userID == 0)
@@ -54,121 +54,124 @@
54 if ($recDetail == 0)54 if ($recDetail == 0)
55 $recDetail = 1;55 $recDetail = 1;
56 56
57 // make the displayid_list from the selected displays.57 // make the displayid_list from the selected displays.
58 $displayGroupIDList = implode(",", $displayGroupIDs);58 $displayGroupIDList = implode(",", $displayGroupIDs);
5959
60 // Parameters for the query60 // Parameters for the query
61 $params = array(61 $params = array(
62 'campaignid' => $campaignId,62 'campaignid' => $campaignId,
63 'displaygroupids' => $displayGroupIDList,63 'displaygroupids' => $displayGroupIDList,
64 'userid' => $userID,64 'userid' => $userID,
65 'is_priority' => $isPriority,65 'is_priority' => $isPriority,
66 'fromdt' => $fromDT,66 'fromdt' => $fromDT,
67 'todt' => $toDT,67 'todt' => $toDT,
68 'displayorder' => $displayOrder68 'displayorder' => $displayOrder
69 );69 );
70 70
71 $SQL = "";71 $SQL = "";
72 $SQL .= "INSERT INTO `schedule` (CampaignId, DisplayGroupIDs, userID, is_priority, FromDT, ToDT, DisplayOrder ";72 $SQL .= "INSERT INTO `schedule` (CampaignId, DisplayGroupIDs, userID, is_priority, FromDT, ToDT, DisplayOrder ";
73 73
74 // Columns for Recurrence74 // Columns for Recurrence
75 if ($recType != '' && $recType != 'null') {75 if ($recType != '' && $recType != 'null') {
76 $SQL .= ", recurrence_type, recurrence_detail, recurrence_range ";76 $SQL .= ", recurrence_type, recurrence_detail, recurrence_range ";
77 }77 }
78 78
79 $SQL .= ") ";79 $SQL .= ") ";
80 $SQL .= " VALUES ( :campaignid, :displaygroupids, :userid, :is_priority, :fromdt, :todt, :displayorder ";80 $SQL .= " VALUES ( :campaignid, :displaygroupids, :userid, :is_priority, :fromdt, :todt, :displayorder ";
81 81
82 // Values for Recurrence82 // Values for Recurrence
83 if ($recType != '' && $recType != 'null')83 if ($recType != '' && $recType != 'null')
84 {84 {
85 $SQL .= ", :recurrence_type, :recurrence_detail, :recurrence_range ";85 // Check that we have an end date
86 $params['recurrence_type'] = $recType;86 if ($recToDT == '' || $recToDT == 0)
87 $params['recurrence_detail'] = $recDetail;87 $this->ThrowError(__('Please provide an until date or set repeats to None'));
88 $params['recurrence_range'] = $recToDT;88
89 }89 $SQL .= ", :recurrence_type, :recurrence_detail, :recurrence_range ";
9090 $params['recurrence_type'] = $recType;
91 $SQL .= ")";91 $params['recurrence_detail'] = $recDetail;
9292 $params['recurrence_range'] = $recToDT;
93 $sth = $dbh->prepare($SQL);93 }
94
95 $SQL .= ")";
96
97 $sth = $dbh->prepare($SQL);
94 $sth->execute($params);98 $sth->execute($params);
95 99
96 // Get the event id100 // Get the event id
97 $eventID = $dbh->lastInsertId();101 $eventID = $dbh->lastInsertId();
98 102
99 // Make sure we dont just have one...103 // Make sure we dont just have one...
100 if (!is_array($displayGroupIDs)) 104 if (!is_array($displayGroupIDs))
101 $displayGroupIDs = array($displayGroupIDs);105 $displayGroupIDs = array($displayGroupIDs);
102 106
103 // Create a detail record for each display group107 // Create a detail record for each display group
104 foreach ($displayGroupIDs as $displayGroupID)108 foreach ($displayGroupIDs as $displayGroupID)
105 {109 {
106 // Add the parent detail record for this event110 // Add the parent detail record for this event
107 if (!$this->AddDetail($displayGroupID, $fromDT, $toDT, $userID, $eventID))111 if (!$this->AddDetail($displayGroupID, $fromDT, $toDT, $userID, $eventID))
108 throw new Exception("Error Processing Request", 1);112 throw new Exception("Error Processing Request", 1);
109 113
110 // Is there any recurrance to take care of?114 // Is there any recurrance to take care of?
111 if ($recType != '' && $recType != 'null') {115 if ($recType != '' && $recType != 'null') {
112 // Set the temp starts116 // Set the temp starts
113 $t_start_temp = $fromDT;117 $t_start_temp = $fromDT;
114 $t_end_temp = $toDT;118 $t_end_temp = $toDT;
115 119
116 Debug::LogEntry('audit', sprintf('Recurrence detected until %d. Recurrence period is %s and interval is %s.', $recToDT, $recDetail, $recType), 'Schedule', 'Add');120 Debug::LogEntry('audit', sprintf('Recurrence detected until %d. Recurrence period is %s and interval is %s.', $recToDT, $recDetail, $recType), 'Schedule', 'Add');
117 121
118 //loop until we have added the recurring events for the schedule122 //loop until we have added the recurring events for the schedule
119 while ($t_start_temp < $recToDT) 123 while ($t_start_temp < $recToDT)
120 {124 {
121 // add the appropriate time to the start and end125 // add the appropriate time to the start and end
122 switch ($recType) 126 switch ($recType)
123 {127 {
124 case 'Minute':128 case 'Minute':
125 $t_start_temp = mktime(date("H", $t_start_temp), date("i", $t_start_temp) + $recDetail, date("s", $t_start_temp) ,date("m", $t_start_temp) ,date("d", $t_start_temp), date("Y", $t_start_temp));129 $t_start_temp = mktime(date("H", $t_start_temp), date("i", $t_start_temp) + $recDetail, date("s", $t_start_temp) ,date("m", $t_start_temp) ,date("d", $t_start_temp), date("Y", $t_start_temp));
126 $t_end_temp = mktime(date("H", $t_end_temp), date("i", $t_end_temp) + $recDetail, date("s", $t_end_temp) ,date("m", $t_end_temp) ,date("d", $t_end_temp), date("Y", $t_end_temp));130 $t_end_temp = mktime(date("H", $t_end_temp), date("i", $t_end_temp) + $recDetail, date("s", $t_end_temp) ,date("m", $t_end_temp) ,date("d", $t_end_temp), date("Y", $t_end_temp));
127 break;131 break;
128 132
129 case 'Hour':133 case 'Hour':
130 $t_start_temp = mktime(date("H", $t_start_temp) + $recDetail, date("i", $t_start_temp), date("s", $t_start_temp) ,date("m", $t_start_temp) ,date("d", $t_start_temp), date("Y", $t_start_temp));134 $t_start_temp = mktime(date("H", $t_start_temp) + $recDetail, date("i", $t_start_temp), date("s", $t_start_temp) ,date("m", $t_start_temp) ,date("d", $t_start_temp), date("Y", $t_start_temp));
131 $t_end_temp = mktime(date("H", $t_end_temp) + $recDetail, date("i", $t_end_temp), date("s", $t_end_temp) ,date("m", $t_end_temp) ,date("d", $t_end_temp), date("Y", $t_end_temp));135 $t_end_temp = mktime(date("H", $t_end_temp) + $recDetail, date("i", $t_end_temp), date("s", $t_end_temp) ,date("m", $t_end_temp) ,date("d", $t_end_temp), date("Y", $t_end_temp));
132 break;136 break;
133 137
134 case 'Day':138 case 'Day':
135 $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, date("Y", $t_start_temp));139 $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, date("Y", $t_start_temp));
136 $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, date("Y", $t_end_temp));140 $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, date("Y", $t_end_temp));
137 break;141 break;
138 142
139 case 'Week':143 case 'Week':
140 $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));144 $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));
141 $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));145 $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));
142 break;146 break;
143 147
144 case 'Month':148 case 'Month':
145 $t_start_temp = mktime(date("H", $t_start_temp), date("i", $t_start_temp), date("s", $t_start_temp) ,date("m", $t_start_temp)+$recDetail ,date("d", $t_start_temp), date("Y", $t_start_temp));149 $t_start_temp = mktime(date("H", $t_start_temp), date("i", $t_start_temp), date("s", $t_start_temp) ,date("m", $t_start_temp)+$recDetail ,date("d", $t_start_temp), date("Y", $t_start_temp));
146 $t_end_temp = mktime(date("H", $t_end_temp), date("i", $t_end_temp), date("s", $t_end_temp) ,date("m", $t_end_temp)+$recDetail ,date("d", $t_end_temp), date("Y", $t_end_temp));150 $t_end_temp = mktime(date("H", $t_end_temp), date("i", $t_end_temp), date("s", $t_end_temp) ,date("m", $t_end_temp)+$recDetail ,date("d", $t_end_temp), date("Y", $t_end_temp));
147 break;151 break;
148 152
149 case 'Year':153 case 'Year':
150 $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), date("Y", $t_start_temp)+$recDetail);154 $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), date("Y", $t_start_temp)+$recDetail);
151 $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), date("Y", $t_end_temp)+$recDetail);155 $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), date("Y", $t_end_temp)+$recDetail);
152 break;156 break;
153 }157 }
154 158
155 // after we have added the appropriate amount, are we still valid159 // after we have added the appropriate amount, are we still valid
156 if ($t_start_temp > $recToDT) break;160 if ($t_start_temp > $recToDT) break;
157 161
158 if (!$this->AddDetail($displayGroupID, $t_start_temp, $t_end_temp, $userID, $eventID))162 if (!$this->AddDetail($displayGroupID, $t_start_temp, $t_end_temp, $userID, $eventID))
159 throw new Exception("Error Processing Request", 1); 163 throw new Exception("Error Processing Request", 1);
160 }164 }
161 }165 }
162 }166 }
163 167
164 // Notify (dont error)168 // Notify (dont error)
165 Kit::ClassLoader('Display');
166 $displayObject = new Display($this->db);169 $displayObject = new Display($this->db);
167 $displayObject->NotifyDisplays($campaignId);170 $displayObject->NotifyDisplays($campaignId);
168 171
169 Debug::LogEntry('audit', 'OUT', 'Schedule', 'Add');172 Debug::LogEntry('audit', 'OUT', 'Schedule', 'Add');
170 173
171 return true; 174 return true;
172 }175 }
173 catch (Exception $e) {176 catch (Exception $e) {
174 177
@@ -179,8 +182,8 @@
179 182
180 return false;183 return false;
181 }184 }
182 }185 }
183 186
184 /**187 /**
185 * Edits a Schedule188 * Edits a Schedule
186 * @param <type> $eventID189 * @param <type> $eventID
@@ -196,400 +199,459 @@
196 * @param <int> $displayOrder199 * @param <int> $displayOrder
197 * @return <type>200 * @return <type>
198 */201 */
199 public function Edit($eventID, $displayGroupIDs, $fromDT, $toDT, $campaignId, $rec_type, $rec_detail, $recToDT, $isPriority, $userid, $displayOrder)202 public function Edit($eventID, $displayGroupIDs, $fromDT, $toDT, $campaignId, $rec_type, $rec_detail, $recToDT, $isPriority, $userid, $displayOrder)
200 {203 {
201 Debug::LogEntry('audit', 'IN', 'Schedule', 'Edit');204 Debug::LogEntry('audit', 'IN', 'Schedule', 'Edit');
202205
203 // Cant have a 0 increment as it creates a loop206 // Cant have a 0 increment as it creates a loop
204 if ($rec_detail == 0)207 if ($rec_detail == 0)
205 $rec_detail = 1;208 $rec_detail = 1;
206 209
207 // What we are really going to do here is delete and re-add... just because it is easier to get the logic right210 // What we are really going to do here is delete and re-add... just because it is easier to get the logic right
208 // and it means the same logic will be applied across both functions.211 // and it means the same logic will be applied across both functions.
209 212
210 // Delete the old schedule213 // Delete the old schedule
211 if (!$this->Delete($eventID))214 if (!$this->Delete($eventID))
212 return false;215 return false;
213 216
214 // Add the new one217 // Add the new one
215 if (!$this->Add($displayGroupIDs, $fromDT, $toDT, $campaignId, $rec_type, $rec_detail, $recToDT, $isPriority, $userid, $displayOrder))218 if (!$this->Add($displayGroupIDs, $fromDT, $toDT, $campaignId, $rec_type, $rec_detail, $recToDT, $isPriority, $userid, $displayOrder))
216 return false;219 return false;
217 220
218 Debug::LogEntry('audit', 'OUT', 'Schedule', 'Edit');221 Debug::LogEntry('audit', 'OUT', 'Schedule', 'Edit');
219 222
220 return true;223 return true;
221 }224 }
222 225
223 /**226 /**
224 * Deletes a scheduled event227 * Deletes a scheduled event
225 * @return 228 * @return
226 * @param $eventID Object229 * @param $eventID Object
227 */230 */
228 public function Delete($eventID)231 public function Delete($eventID)
229 {232 {
230 Debug::LogEntry('audit', 'IN', 'Schedule', 'Delete');233 Debug::LogEntry('audit', 'IN', 'Schedule', 'Delete');
231 234
232 try {235 try {
233 $dbh = PDOConnect::init();236 $dbh = PDOConnect::init();
234 237
235 if (!$this->DeleteScheduleForEvent($eventID))238 if (!$this->DeleteScheduleForEvent($eventID))
236 throw new Exception("Error Processing Request", 1);239 throw new Exception("Error Processing Request", 1);
237 240
238 // Delete all Schedule records for this DisplayGroupID241 // Delete all Schedule records for this DisplayGroupID
239 $sth = $dbh->prepare('DELETE FROM schedule WHERE eventID = :eventid');242 $sth = $dbh->prepare('DELETE FROM schedule WHERE eventID = :eventid');
240 $sth->execute(array(243 $sth->execute(array(
241 'eventid' => $eventID244 'eventid' => $eventID
242 ));245 ));
243 246
244 Debug::LogEntry('audit', 'OUT', 'Schedule', 'Delete');247 Debug::LogEntry('audit', 'OUT', 'Schedule', 'Delete');
245 248
246 return true; 249 return true;
247 }250 }
248 catch (Exception $e) {251 catch (Exception $e) {
249 252
250 Debug::LogEntry('error', $e->getMessage());253 Debug::LogEntry('error', $e->getMessage());
251 254
252 if (!$this->IsError())255 if (!$this->IsError())
253 $this->SetError(25016,__('Unable to delete schedule record for this Event.'));256 $this->SetError(25016,__('Unable to delete schedule record for this Event.'));
254 257
255 return false;258 return false;
256 }259 }
257 }260 }
258 261
259 /**262 /**
260 * Adds a Schedule Detail record. This can optionally be linked to a Schedule Event record.263 * Adds a Schedule Detail record. This can optionally be linked to a Schedule Event record.
261 * @return 264 * @return
262 * @param $displayGroupID Object265 * @param $displayGroupID Object
263 * @param $layoutID Object266 * @param $layoutID Object
264 * @param $fromDT Object267 * @param $fromDT Object
265 * @param $toDT Object268 * @param $toDT Object
266 * @param $userID Object269 * @param $userID Object
267 * @param $isPriority Object270 * @param $isPriority Object
268 * @param $eventID Object[optional]271 * @param $eventID Object[optional]
269 */272 */
270 public function AddDetail($displayGroupID, $fromDT, $toDT, $userID, $eventID)273 public function AddDetail($displayGroupID, $fromDT, $toDT, $userID, $eventID)
271 {274 {
272 Debug::LogEntry('audit', 'IN', 'Schedule', 'AddDetail');275 Debug::LogEntry('audit', 'IN', 'Schedule', 'AddDetail');
273 276
274 try {277 try {
275 $dbh = PDOConnect::init();278 $dbh = PDOConnect::init();
276279
277 // The parameters for the INSERT280 // The parameters for the INSERT
278 $params = array(281 $params = array(
279 'displaygroupid' => $displayGroupID,282 'displaygroupid' => $displayGroupID,
280 'fromdt' => $fromDT,283 'fromdt' => $fromDT,
281 'todt' => $toDT,284 'todt' => $toDT,
282 'userid' => $userID285 'userid' => $userID
283 );286 );
284 287
285 // Insert statement288 // Insert statement
286 $SQL = "INSERT INTO schedule_detail (DisplayGroupID, FromDT, ToDT, userID";289 $SQL = "INSERT INTO schedule_detail (DisplayGroupID, FromDT, ToDT, userID";
287 290
288 // Extras for Event ID291 // Extras for Event ID
289 if ($eventID != '')292 if ($eventID != '')
290 {293 {
291 $SQL .= ", eventID";294 $SQL .= ", eventID";
292 $params['eventid'] = $eventID;295 $params['eventid'] = $eventID;
293 }296 }
294297
295 $SQL .= ") ";298 $SQL .= ") ";
296 299
297 // Values300 // Values
298 $SQL .= "VALUES (:displaygroupid, :fromdt, :todt, :userid";301 $SQL .= "VALUES (:displaygroupid, :fromdt, :todt, :userid";
299 302
300 if ($eventID != '')303 if ($eventID != '')
301 $SQL .= ", :eventid";304 $SQL .= ", :eventid";
302305
303 $SQL .= ")";306 $SQL .= ")";
304 307
305 // Execute the SQL308 // Execute the SQL
306 $sth = $dbh->prepare($SQL);309 $sth = $dbh->prepare($SQL);
307 $sth->execute($params);310 $sth->execute($params);
308 311
309 Debug::LogEntry('audit', 'OUT', 'Schedule', 'AddDetail');312 Debug::LogEntry('audit', 'OUT', 'Schedule', 'AddDetail');
310 313
311 return true; 314 return true;
312 }315 }
313 catch (Exception $e) {316 catch (Exception $e) {
314 317
315 Debug::LogEntry('error', $e->getMessage());318 Debug::LogEntry('error', $e->getMessage());
316 319
317 if (!$this->IsError())320 if (!$this->IsError())
318 $this->SetError(25002, __('Could not update Layout on Schedule'));321 $this->SetError(25002, __('Could not update Layout on Schedule'));
319 322
320 return false;323 return false;
321 } 324 }
322 }325 }
323 326
324 /**327 /**
325 * Deletes all the Schedule records for a display group328 * Deletes all the Schedule records for a display group
326 * @return 329 * @return
327 * @param $displayGroupID Object330 * @param $displayGroupID Object
328 */331 */
329 public function DeleteScheduleForDisplayGroup($displayGroupID)332 public function DeleteScheduleForDisplayGroup($displayGroupID)
330 {333 {
331 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForDisplayGroup');334 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForDisplayGroup');
332 335
333 try {336 try {
334 $dbh = PDOConnect::init();337 $dbh = PDOConnect::init();
335338
336 // Delete all Schedule records for this DisplayGroupID339 // Delete all Schedule records for this DisplayGroupID
337 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE DisplayGroupID = :displaygroupid');340 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE DisplayGroupID = :displaygroupid');
338 $sth->execute(array(341 $sth->execute(array(
339 'displaygroupid' => $displayGroupID342 'displaygroupid' => $displayGroupID
340 ));343 ));
341344
342 // Tidy up the schedule table. There might be orphaned records because of this delete345 // Tidy up the schedule table. There might be orphaned records because of this delete
343 $this->TidyScheduleTable();346 $this->TidyScheduleTable();
344347
345 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForDisplayGroup');348 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForDisplayGroup');
346 349
347 return true; 350 return true;
348 }351 }
349 catch (Exception $e) {352 catch (Exception $e) {
350 353
351 Debug::LogEntry('error', $e->getMessage());354 Debug::LogEntry('error', $e->getMessage());
352 355
353 if (!$this->IsError())356 if (!$this->IsError())
354 $this->SetError(25015,__('Unable to delete schedule records for this Display Group.'));357 $this->SetError(25015,__('Unable to delete schedule records for this Display Group.'));
355 358
356 return false;359 return false;
357 }360 }
358 }361 }
359362
360 /**363 /**
361 * Removes any orphaned records from the Schedule Table364 * Deletes all the Schedule records for a display group
362 * Usually called as a result of an open-ended delete (such as deleting an entire display group)365 * @return
363 */366 * @param $displayGroupID Object
364 private function TidyScheduleTable() {367 */
365 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'TidyScheduleTable');368 public static function DeleteScheduleForCampaign($campaignId)
366369 {
367 try {370 try {
368 $dbh = PDOConnect::init();371 $dbh = PDOConnect::init();
369 372
370 $sth = $dbh->prepare('DELETE FROM `schedule` WHERE EventID NOT IN (SELECT EventID FROM `schedule_detail`)');373 // Delete all Schedule Detail records for this campaignId
371 $sth->execute();374 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID IN (SELECT EventID FROM `schedule` WHERE CampaignID = :campaignId)');
372 375 $sth->execute(array(
373 return true;376 'campaignId' => $campaignId
374 }377 ));
375 catch (Exception $e) {378
376 379 // Delete all Schedule records for this campaignId
377 Debug::LogEntry('error', $e->getMessage());380 $sth = $dbh->prepare('DELETE FROM schedule WHERE CampaignId = :campaignId');
378 381 $sth->execute(array(
379 if (!$this->IsError())382 'campaignId' => $campaignId
380 $this->SetError(1, __('Unknown Error'));383 ));
381 384
382 return false;385 return true;
383 }386 }
384 }387 catch (Exception $e) {
385 388
386 /**389 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
387 * Deletes all the Schedule records for an EventID390
388 * @return 391 if (!$this->IsError())
389 * @param $displayGroupID Object392 $this->SetError(25015,__('Unable to delete schedule records for Campaign.'));
390 */393
391 public function DeleteScheduleForEvent($eventID) {394 return false;
392 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForEvent');395 }
393 396 }
394 try {397
395 $dbh = PDOConnect::init();398 /**
396 399 * Removes any orphaned records from the Schedule Table
397 // Delete all Schedule records for this DisplayGroupID400 * Usually called as a result of an open-ended delete (such as deleting an entire display group)
398 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID = :eventid');401 */
399 $sth->execute(array(402 private static function TidyScheduleTable()
400 'eventid' => $eventID403 {
401 ));404 try {
402 405 $dbh = PDOConnect::init();
403 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForEvent');406
404 407 $sth = $dbh->prepare('DELETE FROM `schedule` WHERE EventID NOT IN (SELECT EventID FROM `schedule_detail`)');
405 return true; 408 $sth->execute();
406 }409
407 catch (Exception $e) {410 return true;
408 411 }
409 Debug::LogEntry('error', $e->getMessage());412 catch (Exception $e) {
410 413
411 if (!$this->IsError())414 Debug::LogEntry('error', $e->getMessage());
412 $this->SetError(25016,__('Unable to delete schedule records for this Event.'));415
413 416 if (!$this->IsError())
414 return false;417 $this->SetError(1, __('Unknown Error'));
415 }418
416 }419 return false;
417 420 }
418 /**421 }
419 * Deletes all the Schedule records for an EventID and DisplayGroupID422
420 * @return 423 /**
421 * @param $displayGroupID Object424 * Removes any orphaned records from the Schedule Table
422 */425 * Usually called as a result of an open-ended delete (such as deleting an entire display group)
423 public function DeleteScheduleForEventAndGroup($eventID, $displayGroupID) {426 */
424 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForEventAndGroup');427 private static function TidyScheduleDetailTable()
425 428 {
426 try {429 try {
427 $dbh = PDOConnect::init();430 $dbh = PDOConnect::init();
428 431
429 // Delete all Schedule records for this DisplayGroupID432 $sth = $dbh->prepare('DELETE FROM `schedule_detail` WHERE EventID NOT IN (SELECT EventID FROM `schedule`)');
430 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID = :eventid AND DisplayGroupID = :displaygroupid');433 $sth->execute();
431 $sth->execute(array(434
432 'displaygroupid' => $displayGroupID,435 return true;
433 'eventid' => $eventID436 }
434 ));437 catch (Exception $e) {
435438
436 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForEventAndGroup');439 Debug::LogEntry('error', $e->getMessage());
437 440
438 return true; 441 if (!$this->IsError())
439 }442 $this->SetError(1, __('Unknown Error'));
440 catch (Exception $e) {443
441 444 return false;
442 Debug::LogEntry('error', $e->getMessage());445 }
443 446 }
444 if (!$this->IsError())447
445 $this->SetError(25016,__('Unable to delete schedule records for this Event and DisplayGroup.'));448 /**
446 449 * Deletes all the Schedule records for an EventID
447 return false;450 * @return
448 }451 * @param $displayGroupID Object
449 }452 */
450 453 public function DeleteScheduleForEvent($eventID) {
451 /**454 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForEvent');
452 * Deletes the event detail record provided455
453 * @return 456 try {
454 * @param $eventDetailID Object457 $dbh = PDOConnect::init();
455 */458
456 public function DeleteEventDetail($eventDetailID) {459 // Delete all Schedule records for this DisplayGroupID
457 Debug::LogEntry('audit', 'IN', 'Schedule', 'DeleteEventDetail');460 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID = :eventid');
458 461 $sth->execute(array(
459 try {462 'eventid' => $eventID
460 $dbh = PDOConnect::init();463 ));
461 464
462 // Delete all Schedule records for this EventDetail465 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForEvent');
463 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE schedule_detailID = :schedule_detailid');466
464 $sth->execute(array(467 return true;
465 'schedule_detailid' => $eventDetailID468 }
466 ));469 catch (Exception $e) {
467 470
468 Debug::LogEntry('audit', 'OUT', 'Schedule', 'DeleteEventDetail');471 Debug::LogEntry('error', $e->getMessage());
469 472
470 return true; 473 if (!$this->IsError())
471 }474 $this->SetError(25016,__('Unable to delete schedule records for this Event.'));
472 catch (Exception $e) {475
473 476 return false;
474 Debug::LogEntry('error', $e->getMessage());477 }
475 478 }
476 if (!$this->IsError())479
477 $this->SetError(25016,__('Unable to delete schedule records for this Event.'));480 /**
478 481 * Deletes all the Schedule records for an EventID and DisplayGroupID
479 return false;482 * @return
480 }483 * @param $displayGroupID Object
481 }484 */
482 485 public function DeleteScheduleForEventAndGroup($eventID, $displayGroupID) {
483 public function DeleteDisplayGroupFromEvent($eventID, $displayGroupID)486 Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForEventAndGroup');
484 {487
485 Debug::LogEntry('audit', 'IN', 'Schedule', 'EditDisplayGroupsForEvent');488 try {
486 489 $dbh = PDOConnect::init();
487 try {490
488 $dbh = PDOConnect::init();491 // Delete all Schedule records for this DisplayGroupID
489 492 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID = :eventid AND DisplayGroupID = :displaygroupid');
490 // Read the display groups from the event493 $sth->execute(array(
491 $SQL = sprintf('', $eventID);494 'displaygroupid' => $displayGroupID,
492 $sth = $dbh->prepare('SELECT DisplayGroupIDs FROM schedule WHERE EventID = :eventid');495 'eventid' => $eventID
493 $sth->execute(array(496 ));
494 'eventid' => $eventID497
495 ));498 Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForEventAndGroup');
496 499
497 if (!$row = $sth->fetch())500 return true;
498 $this->ThrowError(25034,__('Error retriving information necessary to delete this event'));501 }
499 502 catch (Exception $e) {
500 // Get the Display Group IDs503
501 $displayGroupIDs = Kit::ValidateParam($row['DisplayGroupIDs'], _STRING);504 Debug::LogEntry('error', $e->getMessage());
502 505
503 // Load into an array and remove the one in $displayGroupID506 if (!$this->IsError())
504 $displayGroupIDs = explode(',', $displayGroupIDs);507 $this->SetError(25016,__('Unable to delete schedule records for this Event and DisplayGroup.'));
505 $key = array_search($displayGroupID, $displayGroupIDs);508
506 509 return false;
507 if ($key !== true) {510 }
508 unset($displayGroupIDs[$key]);511 }
509 }512
510 else {513 /**
511 Debug::LogEntry('audit', 'Display Group ID is already removed from the Event - this is strange.', 'Schedule', 'EditDisplayGroupsForEvent');514 * Deletes the event detail record provided
512 return true;515 * @return
513 }516 * @param $eventDetailID Object
514 517 */
515 // Save the list back to the event518 public function DeleteEventDetail($eventDetailID) {
516 $displayGroupIDList = implode(',', $displayGroupIDs);519 Debug::LogEntry('audit', 'IN', 'Schedule', 'DeleteEventDetail');
517 520
518 // Delete all Schedule records for this EventDetail521 try {
519 $sth = $dbh->prepare('UPDATE schedule SET DisplayGroupIDs = :displaygroupids WHERE EventID = :eventid');522 $dbh = PDOConnect::init();
520 $sth->execute(array(523
521 'eventid' => $eventID,524 // Delete all Schedule records for this EventDetail
522 'displaygroupids' => $displayGroupIDList525 $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE schedule_detailID = :schedule_detailid');
523 ));526 $sth->execute(array(
524 527 'schedule_detailid' => $eventDetailID
525 Debug::LogEntry('audit', 'OUT', 'Schedule', 'EditDisplayGroupsForEvent');528 ));
526 529
527 return true; 530 Debug::LogEntry('audit', 'OUT', 'Schedule', 'DeleteEventDetail');
528 }531
529 catch (Exception $e) {532 return true;
530 533 }
531 Debug::LogEntry('error', $e->getMessage());534 catch (Exception $e) {
532 535
533 if (!$this->IsError())536 Debug::LogEntry('error', $e->getMessage());
534 $this->SetError(25036,__('Unable to edit the display groups for this Event.'));537
535 538 if (!$this->IsError())
536 return false;539 $this->SetError(25016,__('Unable to delete schedule records for this Event.'));
537 }540
538 }541 return false;
539542 }
540 /**543 }
541 * Gets an array of display group ids for the given event544
542 * @param [int] $eventId The Event ID545 public function DeleteDisplayGroupFromEvent($eventID, $displayGroupID)
543 */546 {
544 public function DisplayGroupsForEvent($eventId) {547 Debug::LogEntry('audit', 'IN', 'Schedule', 'EditDisplayGroupsForEvent');
545 $eventId = Kit::ValidateParam($eventId, _INT);548
546549 try {
547 try {550 $dbh = PDOConnect::init();
548 $dbh = PDOConnect::init();551
549 552 // Read the display groups from the event
550 $sth = $dbh->prepare('SELECT DISTINCT DisplayGroupID FROM `schedule_detail` WHERE EventID = :eventid');553 $SQL = sprintf('', $eventID);
551 $sth->execute(array(554 $sth = $dbh->prepare('SELECT DisplayGroupIDs FROM schedule WHERE EventID = :eventid');
552 'eventid' => $eventId555 $sth->execute(array(
553 ));556 'eventid' => $eventID
554557 ));
555 $ids = array();558
556 559 if (!$row = $sth->fetch())
557 while ($row = $sth->fetch()) {560 $this->ThrowError(25034,__('Error retriving information necessary to delete this event'));
558 $ids[] = Kit::ValidateParam($row['DisplayGroupID'], _INT);561
559 }562 // Get the Display Group IDs
560563 $displayGroupIDs = Kit::ValidateParam($row['DisplayGroupIDs'], _STRING);
561 return $ids;564
562 }565 // Load into an array and remove the one in $displayGroupID
563 catch (Exception $e) {566 $displayGroupIDs = explode(',', $displayGroupIDs);
564 567 $key = array_search($displayGroupID, $displayGroupIDs);
565 Debug::LogEntry('error', $e->getMessage());568
566 569 if ($key !== true) {
567 if (!$this->IsError())570 unset($displayGroupIDs[$key]);
568 $this->SetError(1, __('Unknown Error'));571 }
569 572 else {
570 return false;573 Debug::LogEntry('audit', 'Display Group ID is already removed from the Event - this is strange.', 'Schedule', 'EditDisplayGroupsForEvent');
571 }574 return true;
572 }575 }
576
577 // Save the list back to the event
578 $displayGroupIDList = implode(',', $displayGroupIDs);
579
580 // Delete all Schedule records for this EventDetail
581 $sth = $dbh->prepare('UPDATE schedule SET DisplayGroupIDs = :displaygroupids WHERE EventID = :eventid');
582 $sth->execute(array(
583 'eventid' => $eventID,
584 'displaygroupids' => $displayGroupIDList
585 ));
586
587 Debug::LogEntry('audit', 'OUT', 'Schedule', 'EditDisplayGroupsForEvent');
588
589 return true;
590 }
591 catch (Exception $e) {
592
593 Debug::LogEntry('error', $e->getMessage());
594
595 if (!$this->IsError())
596 $this->SetError(25036,__('Unable to edit the display groups for this Event.'));
597
598 return false;
599 }
600 }
601
602 /**
603 * Gets an array of display group ids for the given event
604 * @param [int] $eventId The Event ID
605 */
606 public function DisplayGroupsForEvent($eventId) {
607 $eventId = Kit::ValidateParam($eventId, _INT);
608
609 try {
610 $dbh = PDOConnect::init();
611
612 $sth = $dbh->prepare('SELECT DISTINCT DisplayGroupID FROM `schedule_detail` WHERE EventID = :eventid');
613 $sth->execute(array(
614 'eventid' => $eventId
615 ));
616
617 $ids = array();
618
619 while ($row = $sth->fetch()) {
620 $ids[] = Kit::ValidateParam($row['DisplayGroupID'], _INT);
621 }
622
623 return $ids;
624 }
625 catch (Exception $e) {
626
627 Debug::LogEntry('error', $e->getMessage());
628
629 if (!$this->IsError())
630 $this->SetError(1, __('Unknown Error'));
631
632 return false;
633 }
634 }
573}635}
574636
575class Event637class Event
576{638{
577 public $eventID;639 public $eventID;
578 public $eventDetailID;640 public $eventDetailID;
579 public $fromDT;641 public $fromDT;
580 public $toDT;642 public $toDT;
581 public $layout;643 public $layout;
582 public $layoutUri;644 public $layoutUri;
583 public $deleteUri;645 public $deleteUri;
584 public $spanningDays;646 public $spanningDays;
585 public $startDayNo;647 public $startDayNo;
586 public $displayGroup;648 public $displayGroup;
587 public $editPermission;649 public $editPermission;
588 public $isdisplayspecific;650 public $isdisplayspecific;
589 651
590 public function __construct()652 public function __construct()
591 {653 {
592 654
593 }655 }
594}656}
595?>657?>
596\ No newline at end of file658\ No newline at end of file
597659
=== modified file 'server/lib/data/stat.data.class.php'
--- server/lib/data/stat.data.class.php 2014-01-18 09:47:41 +0000
+++ server/lib/data/stat.data.class.php 2014-10-21 16:06:16 +0000
@@ -22,68 +22,126 @@
2222
23class Stat extends data23class Stat extends data
24{24{
25 public function Add($type, $fromDT, $toDT, $scheduleID, $displayID, $layoutID, $mediaID, $tag)25 public function Add($type, $fromDT, $toDT, $scheduleID, $displayID, $layoutID, $mediaID, $tag)
26 {26 {
27 try {27 try {
28 $dbh = PDOConnect::init();28 $dbh = PDOConnect::init();
2929
30 // Lower case the type for consistancy30 // Lower case the type for consistency
31 $type = strtolower($type);31 $type = strtolower($type);
3232
33 // Prepare a statement33 // Prepare a statement
34 $sth = $dbh->prepare('INSERT INTO stat (Type, statDate, start, end, scheduleID, displayID, layoutID, mediaID, Tag) VALUES (:type, :statdate, :start, :end, :scheduleid, :displayid, :layoutid, :mediaid, :tag)');34 $sth = $dbh->prepare('INSERT INTO stat (Type, statDate, start, end, scheduleID, displayID, layoutID, mediaID, Tag) VALUES (:type, :statdate, :start, :end, :scheduleid, :displayid, :layoutid, :mediaid, :tag)');
35 35
36 // Construct a parameters array to execute36 // Construct a parameters array to execute
37 $params = array();37 $params = array();
38 $params['statdate'] = date("Y-m-d H:i:s");38 $params['statdate'] = date("Y-m-d H:i:s");
39 $params['type'] = $type;39 $params['type'] = $type;
40 $params['start'] = $fromDT;40 $params['start'] = $fromDT;
41 $params['end'] = $toDT;41 $params['end'] = $toDT;
42 $params['scheduleid'] = $scheduleID;42 $params['scheduleid'] = $scheduleID;
43 $params['displayid'] = $displayID;43 $params['displayid'] = $displayID;
44 $params['layoutid'] = $layoutID;44 $params['layoutid'] = $layoutID;
4545
46 // Optional parameters46 // Optional parameters
47 $params['mediaid'] = null;47 $params['mediaid'] = null;
48 $params['tag'] = null;48 $params['tag'] = null;
49 49
50 // We should run different SQL depending on what Type we are50 // We should run different SQL depending on what Type we are
51 switch ($type)51 switch ($type)
52 {52 {
53 case 'media':53 case 'media':
54 $params['mediaid'] = $mediaID;54 $params['mediaid'] = $mediaID;
55 55
56 break;56 break;
5757
58 case 'layout':58 case 'layout':
59 // Nothing additional to do59 // Nothing additional to do
60 break;60 break;
61 61
62 case 'event':62 case 'event':
63 63
64 $params['layoutid'] = 0;64 $params['layoutid'] = 0;
65 $params['tag'] = $tag;65 $params['tag'] = $tag;
66 66
67 break;67 break;
68 68
69 default:69 default:
70 // Nothing to do, just exit70 // Nothing to do, just exit
71 return true;71 return true;
72 }72 }
7373
74 $sth->execute($params);74 $sth->execute($params);
75 75
76 return true; 76 return true;
77 }77 }
78 catch (Exception $e) {78 catch (Exception $e) {
79 79
80 Debug::LogEntry('error', $e->getMessage());80 Debug::LogEntry('error', $e->getMessage());
81 81
82 if (!$this->IsError())82 if (!$this->IsError())
83 $this->SetError(25000, 'Stat Insert Failed.');83 $this->SetError(25000, 'Stat Insert Failed.');
84 84
85 return false;85 return false;
86 }86 }
87 }87 }
88
89 public function displayDown($displayId, $lastAccessed)
90 {
91 try {
92 $dbh = PDOConnect::init();
93
94 // Prepare a statement
95 $sth = $dbh->prepare('
96 INSERT INTO stat (Type, statDate, start, scheduleID, displayID)
97 VALUES (:type, :statdate, :start, :scheduleid, :displayid)');
98
99 // Construct a parameters array to execute
100 $params = array();
101 $params['type'] = 'displaydown';
102 $params['displayid'] = $displayId;
103 $params['statdate'] = date('Y-m-d H:i:s');
104 $params['start'] = $lastAccessed;
105 $params['scheduleid'] = 0;
106
107 $sth->execute($params);
108
109 return true;
110 }
111 catch (Exception $e) {
112
113 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
114
115 if (!$this->IsError())
116 $this->SetError(1, __('Unknown Error'));
117
118 return false;
119 }
120 }
121
122 public function displayUp($displayId) {
123 try {
124 $dbh = PDOConnect::init();
125
126 Debug::Audit('Display Up: ' . $displayId);
127
128 $sth = $dbh->prepare('UPDATE stat SET end = :toDt WHERE displayId = :displayId AND end IS NULL');
129 $sth->execute(array(
130 'toDt' => date('Y-m-d H:i:s'),
131 'displayId' => $displayId
132 ));
133
134 return true;
135 }
136 catch (Exception $e) {
137
138 Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
139
140 if (!$this->IsError())
141 $this->SetError(1, __('Unknown Error'));
142
143 return false;
144 }
145 }
88}146}
89?>147?>
90\ No newline at end of file148\ No newline at end of file
91149
=== modified file 'server/lib/data/usergroup.data.class.php'
--- server/lib/data/usergroup.data.class.php 2014-08-07 15:47:19 +0000
+++ server/lib/data/usergroup.data.class.php 2014-10-21 16:06:16 +0000
@@ -22,6 +22,58 @@
2222
23class UserGroup extends Data23class UserGroup extends Data
24{24{
25 public function GetPermissionsForObject($object, $idCol, $objectId, $clause = '')
26 {
27 try {
28 $dbh = PDOConnect::init();
29
30 $params = array('id' => $objectId);
31 $SQL = 'SELECT joinedGroup.groupid, joinedGroup.group, view, edit, del, joinedGroup.isuserspecific ';
32 $SQL .= ' FROM (
33 SELECT `group`.*
34 FROM `group`
35 LEFT OUTER JOIN lkusergroup
36 ON lkusergroup.GroupID = group.GroupID
37 WHERE IsUserSpecific = 0
38 UNION ALL
39 SELECT `group`.*
40 FROM `group`
41 INNER JOIN lkusergroup
42 ON lkusergroup.GroupID = group.GroupID
43 AND IsUserSpecific = 1
44 INNER JOIN `user`
45 ON lkusergroup.UserID = user.UserID
46 AND retired = 0
47 ) joinedGroup ';
48 $SQL .= ' LEFT OUTER JOIN ' . $object;
49 $SQL .= ' ON ' . $object . '.GroupID = joinedGroup.GroupID ';
50
51 if ($clause != '') {
52 $SQL .= $clause;
53 }
54 else {
55 $SQL .= ' AND ' . $object . '.' . $idCol . ' = :id ';
56 $params = array('id' => $objectId);
57 }
58
59 $SQL .= 'ORDER BY joinedGroup.IsEveryone DESC, joinedGroup.IsUserSpecific, joinedGroup.`Group`; ';
60
61 $sth = $dbh->prepare($SQL);
62 $sth->execute($params);
63
64 return $sth->fetchAll();
65 }
66 catch (Exception $e) {
67
68 Debug::LogEntry('error', $e->getMessage());
69
70 if (!$this->IsError())
71 $this->SetError(1, __('Unknown Error'));
72
73 return false;
74 }
75 }
76
25 /**77 /**
26 * Adds a User Group to Xibo78 * Adds a User Group to Xibo
27 * @return79 * @return
2880
=== modified file 'server/lib/include.php'
--- server/lib/include.php 2014-08-17 12:38:20 +0000
+++ server/lib/include.php 2014-10-21 16:06:16 +0000
@@ -20,7 +20,7 @@
20 */20 */
21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
2222
23define('WEBSITE_VERSION', 80);23define('WEBSITE_VERSION', 81);
2424
25// No errors reported until we read the settings from the DB25// No errors reported until we read the settings from the DB
26error_reporting(0);26error_reporting(0);
@@ -41,10 +41,11 @@
41require_once("lib/app/responsemanager.class.php");41require_once("lib/app/responsemanager.class.php");
42require_once("lib/app/datemanager.class.php");42require_once("lib/app/datemanager.class.php");
43require_once("lib/app/app_functions.php");43require_once("lib/app/app_functions.php");
44require_once("lib/data/data.class.php");
44require_once("lib/modules/module.interface.php");45require_once("lib/modules/module.interface.php");
45require_once("lib/modules/module.class.php");46require_once("lib/modules/module.class.php");
46require_once("lib/data/data.class.php");
47require_once("lib/app/session.class.php");47require_once("lib/app/session.class.php");
48require_once("lib/app/cache.class.php");
48require_once("lib/app/thememanager.class.php");49require_once("lib/app/thememanager.class.php");
49require_once("lib/pages/base.class.php");50require_once("lib/pages/base.class.php");
5051
@@ -111,6 +112,11 @@
111// Error Handling (our error handler requires a DB connection112// Error Handling (our error handler requires a DB connection
112set_error_handler(array(new Debug(), "ErrorHandler"));113set_error_handler(array(new Debug(), "ErrorHandler"));
113114
115// Define an auto-load function
116spl_autoload_register(function ($class) {
117 Kit::ClassLoader($class);
118});
119
114// Define the VERSION120// Define the VERSION
115Config::Version();121Config::Version();
116122
117123
=== modified file 'server/lib/modules/module.class.php'
--- server/lib/modules/module.class.php 2014-09-05 16:07:36 +0000
+++ server/lib/modules/module.class.php 2014-10-21 16:06:16 +0000
@@ -19,6 +19,7 @@
19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.19 * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
20 */20 */
21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");21defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
22include_once('lib/data/media.data.class.php');
2223
23abstract class Module implements ModuleInterface24abstract class Module implements ModuleInterface
24{25{
@@ -37,6 +38,7 @@
37 protected $previewEnabled;38 protected $previewEnabled;
38 protected $validExtensions;39 protected $validExtensions;
39 protected $validExtensionsText;40 protected $validExtensionsText;
41 protected $imageUri;
40 protected $settings;42 protected $settings;
4143
42 // The Schema Version of this code44 // The Schema Version of this code
@@ -51,6 +53,7 @@
51 protected $deleteFromRegion;53 protected $deleteFromRegion;
52 protected $width;54 protected $width;
53 protected $height;55 protected $height;
56 protected $layoutSchemaVersion;
5457
55 // Media information58 // Media information
56 protected $mediaid;59 protected $mediaid;
@@ -145,6 +148,7 @@
145 $this->validExtensionsText = Kit::ValidateParam($row['ValidExtensions'], _STRING);148 $this->validExtensionsText = Kit::ValidateParam($row['ValidExtensions'], _STRING);
146 $this->previewEnabled = Kit::ValidateParam($row['PreviewEnabled'], _INT);149 $this->previewEnabled = Kit::ValidateParam($row['PreviewEnabled'], _INT);
147 $this->assignable = Kit::ValidateParam($row['assignable'], _INT);150 $this->assignable = Kit::ValidateParam($row['assignable'], _INT);
151 $this->imageUri = Kit::ValidateParam($row['ImageUri'], _STRING);
148 $this->render_as = Kit::ValidateParam($row['render_as'], _WORD);152 $this->render_as = Kit::ValidateParam($row['render_as'], _WORD);
149 $this->settings = Kit::ValidateParam($row['settings'], _HTMLSTRING);153 $this->settings = Kit::ValidateParam($row['settings'], _HTMLSTRING);
150154
@@ -155,7 +159,7 @@
155 if ($this->settings == '')159 if ($this->settings == '')
156 $this->settings = array();160 $this->settings = array();
157 else161 else
158 $this->settings = json_decode($this->settings);162 $this->settings = json_decode($this->settings, true);
159163
160 // Translated name of this module164 // Translated name of this module
161 $this->displayType = __(Kit::ValidateParam($row['Name'], _STRING));165 $this->displayType = __(Kit::ValidateParam($row['Name'], _STRING));
@@ -200,6 +204,8 @@
200204
201 $layoutDoc = new DOMDocument();205 $layoutDoc = new DOMDocument();
202 $layoutDoc->loadXML($layoutXml);206 $layoutDoc->loadXML($layoutXml);
207
208 $this->layoutSchemaVersion = (int)$layoutDoc->documentElement->getAttribute('schemaVersion');
203209
204 $layoutXpath = new DOMXPath($layoutDoc);210 $layoutXpath = new DOMXPath($layoutDoc);
205211
@@ -821,6 +827,7 @@
821 case 'video':827 case 'video':
822 case 'localvideo':828 case 'localvideo':
823 case 'genericfile':829 case 'genericfile':
830 case 'font':
824 $defaultDuration = 0;831 $defaultDuration = 0;
825 break;832 break;
826833
@@ -837,7 +844,7 @@
837 break;844 break;
838845
839 default:846 default:
840 $defaultDuration = '';847 $defaultDuration = 10;
841 }848 }
842 849
843850
@@ -979,6 +986,11 @@
979 'r');986 'r');
980 }987 }
981988
989 $formFields[] = FormManager::AddCheckbox('deleteOldVersion', __('Delete the old version.'),
990 ((Config::GetSetting('LIBRARY_MEDIA_UPDATEINALL_CHECKB') == 'Checked') ? 1 : 0),
991 __('Completely remove the old version of this media item if a new file is being uploaded.'),
992 '');
993
982 // Add in any extra form fields we might have provided by the super-class994 // Add in any extra form fields we might have provided by the super-class
983 if ($extraFormFields != NULL && is_array($extraFormFields)) {995 if ($extraFormFields != NULL && is_array($extraFormFields)) {
984 foreach($extraFormFields as $field) {996 foreach($extraFormFields as $field) {
@@ -1085,7 +1097,6 @@
1085 }1097 }
10861098
1087 // Hand off to the media module1099 // Hand off to the media module
1088 Kit::ClassLoader('media');
1089 $mediaObject = new Media($db);1100 $mediaObject = new Media($db);
10901101
1091 // Stored As from the XML1102 // Stored As from the XML
@@ -1116,10 +1127,7 @@
1116 } 1127 }
11171128
1118 // Are we on a region1129 // Are we on a region
1119 if ($regionid != '')1130 if ($regionid != '') {
1120 {
1121 Kit::ClassLoader('layoutmediagroupsecurity');
1122
1123 $security = new LayoutMediaGroupSecurity($db);1131 $security = new LayoutMediaGroupSecurity($db);
1124 $security->Copy($layoutid, $regionid, $mediaid, $new_mediaid);1132 $security->Copy($layoutid, $regionid, $mediaid, $new_mediaid);
1125 }1133 }
@@ -1176,6 +1184,12 @@
1176 if (Kit::GetParam('replaceInLayouts', _POST, _CHECKBOX) == 1)1184 if (Kit::GetParam('replaceInLayouts', _POST, _CHECKBOX) == 1)
1177 $this->ReplaceMediaInAllLayouts($mediaid, $this->mediaid, $this->duration);1185 $this->ReplaceMediaInAllLayouts($mediaid, $this->mediaid, $this->duration);
11781186
1187 // Do we need to delete the old media item?
1188 if ($tmpName != '' && Kit::GetParam('deleteOldVersion', _POST, _CHECKBOX) == 1) {
1189 if (!$mediaObject->Delete($mediaid))
1190 $this->response->message .= ' ' . __('Failed to remove old media');
1191 }
1192
1179 return $this->response;1193 return $this->response;
1180 }1194 }
11811195
@@ -1337,7 +1351,7 @@
13371351
1338 // Default Hover window contains a thumbnail, media type and duration1352 // Default Hover window contains a thumbnail, media type and duration
1339 $output = '<div class="well">';1353 $output = '<div class="well">';
1340 $output .= '<div class="preview-module-image"><img alt="' . $this->displayType . ' thumbnail" src="theme/default/img/forms/' . $this->type . '.gif"></div>';1354 $output .= '<div class="preview-module-image"><img alt="' . $this->displayType . ' thumbnail" src="theme/default/img/' . $this->imageUri . '"></div>';
1341 $output .= '<div class="info">';1355 $output .= '<div class="info">';
1342 $output .= ' <ul>';1356 $output .= ' <ul>';
1343 $output .= ' <li>' . $msgType . ': ' . $this->displayType . '</li>';1357 $output .= ' <li>' . $msgType . ': ' . $this->displayType . '</li>';
@@ -1371,52 +1385,37 @@
1371 if (!$this->auth->modifyPermissions)1385 if (!$this->auth->modifyPermissions)
1372 trigger_error(__('You do not have permissions to edit this media'), E_USER_ERROR);1386 trigger_error(__('You do not have permissions to edit this media'), E_USER_ERROR);
13731387
1374 // List of all Groups with a view/edit/delete checkbox1388 // List of all Groups with a view / edit / delete check box
1375 $SQL = '';1389 $permissions = new UserGroup();
1376 $SQL .= 'SELECT `group`.GroupID, `group`.`Group`, View, Edit, Del, `group`.IsUserSpecific ';1390
1377 $SQL .= ' FROM `group` ';1391 if ($this->assignedMedia) {
13781392 if (!$result = $permissions->GetPermissionsForObject('lklayoutmediagroup', NULL, NULL, sprintf(" AND lklayoutmediagroup.MediaID = '%s' AND lklayoutmediagroup.RegionID = '%s' AND lklayoutmediagroup.LayoutID = %d ", $this->mediaid, $this->regionid, $this->layoutid)))
1379 if ($this->assignedMedia)1393 trigger_error($permissions->GetErrorMessage(), E_USER_ERROR);
1380 {1394 }
1381 $SQL .= ' LEFT OUTER JOIN lklayoutmediagroup ';1395 else {
1382 $SQL .= ' ON lklayoutmediagroup.GroupID = group.GroupID ';1396 if (!$result = $permissions->GetPermissionsForObject('lkmediagroup', 'MediaID', $this->mediaid))
1383 $SQL .= sprintf(" AND lklayoutmediagroup.MediaID = '%s' AND lklayoutmediagroup.RegionID = '%s' AND lklayoutmediagroup.LayoutID = %d ", $this->mediaid, $this->regionid, $this->layoutid);1397 trigger_error($permissions->GetErrorMessage(), E_USER_ERROR);
1384 }1398 }
1385 else1399
1386 {1400 if (count($result) <= 0)
1387 $SQL .= ' LEFT OUTER JOIN lkmediagroup ';1401 trigger_error(__('Unable to get permissions'), E_USER_ERROR);
1388 $SQL .= ' ON lkmediagroup.GroupID = group.GroupID ';1402
1389 $SQL .= sprintf(' AND lkmediagroup.MediaID = %d ', $this->mediaid);1403 $checkboxes = array();
1390 }1404
13911405 foreach ($result as $row) {
1392 $SQL .= ' WHERE `group`.GroupID <> %d ';1406 $groupId = $row['groupid'];
1393 $SQL .= 'ORDER BY `group`.IsEveryone DESC, `group`.IsUserSpecific, `group`.`Group` ';1407 $rowClass = ($row['isuserspecific'] == 0) ? 'strong_text' : '';
1394
1395 $SQL = sprintf($SQL, $user->getGroupFromId($user->userid, true));
1396
1397 Debug::LogEntry('audit', $SQL, 'module', 'PermissionsForm');
1398
1399 if (!$results = $db->query($SQL))
1400 {
1401 trigger_error($db->error());
1402 trigger_error(__('Unable to get permissions for this layout'), E_USER_ERROR);
1403 }
1404
1405 while ($row = $db->get_assoc_row($results))
1406 {
1407 $groupId = $row['GroupID'];
1408 $rowClass = ($row['IsUserSpecific'] == 0) ? 'strong_text' : '';
14091408
1410 $checkbox = array(1409 $checkbox = array(
1411 'id' => $groupId,1410 'id' => $groupId,
1412 'name' => Kit::ValidateParam($row['Group'], _STRING),1411 'name' => Kit::ValidateParam($row['group'], _STRING),
1413 'class' => $rowClass,1412 'class' => $rowClass,
1414 'value_view' => $groupId . '_view',1413 'value_view' => $groupId . '_view',
1415 'value_view_checked' => (($row['View'] == 1) ? 'checked' : ''),1414 'value_view_checked' => (($row['view'] == 1) ? 'checked' : ''),
1416 'value_edit' => $groupId . '_edit',1415 'value_edit' => $groupId . '_edit',
1417 'value_edit_checked' => (($row['Edit'] == 1) ? 'checked' : ''),1416 'value_edit_checked' => (($row['edit'] == 1) ? 'checked' : ''),
1418 'value_del' => $groupId . '_del',1417 'value_del' => $groupId . '_del',
1419 'value_del_checked' => (($row['Del'] == 1) ? 'checked' : ''),1418 'value_del_checked' => (($row['del'] == 1) ? 'checked' : ''),
1420 );1419 );
14211420
1422 $checkboxes[] = $checkbox;1421 $checkboxes[] = $checkbox;
@@ -2118,6 +2117,13 @@
2118 return false;2117 return false;
2119 }2118 }
2120 }2119 }
2120
2121 public function GetSetting($setting, $default = NULL) {
2122 if (isset($this->settings[$setting]))
2123 return $this->settings[$setting];
2124 else
2125 return $default;
2126 }
2121 2127
2122 /**2128 /**
2123 * Return file based media items to the browser for Download/Preview2129 * Return file based media items to the browser for Download/Preview
21242130
=== modified file 'server/lib/pages/admin.class.php'
--- server/lib/pages/admin.class.php 2014-09-16 16:41:43 +0000
+++ server/lib/pages/admin.class.php 2014-10-21 16:06:16 +0000
@@ -137,13 +137,13 @@
137 'title' => __('Tidy Library'),137 'title' => __('Tidy Library'),
138 'class' => 'XiboFormButton',138 'class' => 'XiboFormButton',
139 'selected' => false,139 'selected' => false,
140 'link' => 'index.php?p=admin&q=TidyLibrary',140 'link' => 'index.php?p=admin&q=TidyLibraryForm',
141 'help' => __('Run through the library and remove and unnecessary files'),141 'help' => __('Run through the library and remove and unnecessary files'),
142 'onclick' => ''142 'onclick' => ''
143 );143 );
144 }144 }
145145
146 return $menu; 146 return $menu;
147 }147 }
148148
149 function Edit() {149 function Edit() {
@@ -153,8 +153,7 @@
153 if (!Kit::CheckToken())153 if (!Kit::CheckToken())
154 trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);154 trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
155155
156 Kit::ClassLoader('setting');156 $data = new Setting();
157 $data = new Setting($this->db);
158157
159 // Get all of the settings in an array158 // Get all of the settings in an array
160 $settings = Config::GetAll(NULL, array('userChange' => 1, 'userSee' => 1));159 $settings = Config::GetAll(NULL, array('userChange' => 1, 'userSee' => 1));
@@ -185,6 +184,7 @@
185 }184 }
186185
187 $response->SetFormSubmitResponse(__('Settings Updated'), false);186 $response->SetFormSubmitResponse(__('Settings Updated'), false);
187 $response->callBack = 'settingsUpdated';
188 $response->Respond();188 $response->Respond();
189 }189 }
190 190
@@ -417,20 +417,10 @@
417 public function BackupDatabase()417 public function BackupDatabase()
418 {418 {
419 // We want to output a load of stuff to the browser as a text file.419 // We want to output a load of stuff to the browser as a text file.
420 Kit::ClassLoader('maintenance');
421 $maintenance = new Maintenance($this->db);420 $maintenance = new Maintenance($this->db);
422421
423 $dump = $maintenance->BackupDatabase();422 if (!$dump = $maintenance->BackupDatabase())
424423 trigger_error($maintenance->GetErrorMessage(), E_USER_ERROR);
425 if ($dump == '')
426 trigger_error(__('Unable to export database'), E_USER_ERROR);
427
428 header('Content-Type: text/plaintext');
429 header('Content-Disposition: attachment; filename="' . date('Y-m-d H:i:s') . '.bak"');
430 header("Content-Transfer-Encoding: binary");
431 header('Accept-Ranges: bytes');
432 echo $dump;
433 exit;
434 }424 }
435425
436 /**426 /**
@@ -545,70 +535,46 @@
545 return round($bytes, $precision) . ' ' . $units[$pow];535 return round($bytes, $precision) . ' ' . $units[$pow];
546 }536 }
547537
538 public function TidyLibraryForm()
539 {
540 $response = new ResponseManager();
541
542 Theme::Set('form_id', 'TidyLibraryForm');
543 Theme::Set('form_action', 'index.php?p=admin&q=TidyLibrary');
544
545 $formFields = array();
546
547 // Check box to also delete un-used media that has been revised.
548 $formFields[] = FormManager::AddCheckbox('tidyOldRevisions', __('Remove old revisions'), 0,
549 __('Cleaning up old revisions of media will result in any unused media revisions being permanently deleted.'), '');
550
551 $formFields[] = FormManager::AddMessage(__('Tidying the Library will delete any temporary files. Are you sure you want to proceed?'));
552
553 Theme::Set('form_fields', $formFields);
554
555 $response->SetFormRequestResponse(NULL, __('Tidy Library'), '350px', '275px');
556 $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('Settings', 'TidyLibrary') . '")');
557 $response->AddButton(__('No'), 'XiboDialogClose()');
558 $response->AddButton(__('Yes'), '$("#TidyLibraryForm").submit()');
559 $response->Respond();
560 }
561
548 /**562 /**
549 * Tidies up the library563 * Tidies up the library
550 */564 */
551 public function TidyLibrary()565 public function TidyLibrary()
552 {566 {
553 $db =& $this->db;
554 $response = new ResponseManager();567 $response = new ResponseManager();
555568 $tidyOldRevisions = (Kit::GetParam('tidyOldRevisions', _POST, _CHECKBOX) == 1);
556 if (Config::GetSetting('SETTING_LIBRARY_TIDY_ENABLED') != 1)569 if (Config::GetSetting('SETTING_LIBRARY_TIDY_ENABLED') != 1)
557 trigger_error(__('Sorry this function is disabled.'), E_USER_ERROR);570 trigger_error(__('Sorry this function is disabled.'), E_USER_ERROR);
558571
559 // Also run a script to tidy up orphaned media in the library572 $maintenance = new Maintenance();
560 $library = Config::GetSetting('LIBRARY_LOCATION');573 if (!$maintenance->TidyLibrary($tidyOldRevisions))
561 $library = rtrim($library, '/') . '/';574 trigger_error($maintenance->GetErrorMessage(), E_USER_ERROR);
562575
563 Debug::LogEntry('audit', 'Library Location: ' . $library);576 $response->SetFormSubmitResponse(__('Library Tidy Complete'));
564577 $response->Respond();
565 // Dump the files in the temp folder
566 foreach (scandir($library . 'temp') as $item)
567 {
568 if ($item == '.' || $item == '..')
569 continue;
570
571 Debug::LogEntry('audit', 'Deleting temp file: ' . $item);
572
573 unlink($library . 'temp' . DIRECTORY_SEPARATOR . $item);
574 }
575
576 // Get a list of all media files
577 foreach(scandir($library) as $file)
578 {
579 Debug::LogEntry('audit', 'Checking file: ' . $file);
580
581 if ($file == '.' || $file == '..')
582 continue;
583
584 if (is_dir($library . $file))
585 continue;
586
587 $rowCount = $db->GetCountOfRows("SELECT * FROM media WHERE storedAs = '" . $file . "'");
588
589 Debug::LogEntry('audit', 'Media count for file: ' . $file . ' is ' . $rowCount);
590
591 // For each media file, check to see if the file still exists in the library
592 if ($rowCount == 0)
593 {
594 Debug::LogEntry('audit', 'Deleting file: ' . $file);
595
596 // If not, delete it
597 unlink($library . $file);
598
599 if (file_exists($library . 'tn_' . $file))
600 {
601 unlink($library . 'tn_' . $file);
602 }
603
604 if (file_exists($library . 'bg_' . $file))
605 {
606 unlink($library . 'bg_' . $file);
607 }
608 }
609 }
610
611 trigger_error(__('Library Tidy Complete'), E_USER_ERROR);
612 }578 }
613}579}
614?>580?>
615581
=== modified file 'server/lib/pages/campaign.class.php'
--- server/lib/pages/campaign.class.php 2014-08-15 14:40:03 +0000
+++ server/lib/pages/campaign.class.php 2014-10-21 16:06:16 +0000
@@ -355,41 +355,30 @@
355 Theme::Set('form_action', 'index.php?p=campaign&q=Permissions');355 Theme::Set('form_action', 'index.php?p=campaign&q=Permissions');
356 Theme::Set('form_meta', '<input type="hidden" name="campaignId" value="' . $campaignId . '" />');356 Theme::Set('form_meta', '<input type="hidden" name="campaignId" value="' . $campaignId . '" />');
357357
358 // List of all Groups with a view/edit/delete checkbox358 // List of all Groups with a view / edit / delete check box
359 $SQL = '';359 $permissions = new CampaignSecurity();
360 $SQL .= 'SELECT `group`.GroupID, `group`.`Group`, View, Edit, Del, `group`.IsUserSpecific ';360 if (!$result = $permissions->GetPermissions($campaignId))
361 $SQL .= ' FROM `group` ';361 trigger_error($permissions->GetErrorMessage(), E_USER_ERROR);
362 $SQL .= ' LEFT OUTER JOIN lkcampaigngroup ';362
363 $SQL .= ' ON lkcampaigngroup.GroupID = group.GroupID ';363 if (count($result) <= 0)
364 $SQL .= ' AND lkcampaigngroup.CampaignID = %d ';
365 $SQL .= ' WHERE `group`.GroupID <> %d ';
366 $SQL .= 'ORDER BY `group`.IsEveryone DESC, `group`.IsUserSpecific, `group`.`Group` ';
367
368 $SQL = sprintf($SQL, $campaignId, $this->user->getGroupFromID($this->user->userid, true));
369
370 if (!$results = $db->query($SQL))
371 {
372 trigger_error($db->error());
373 trigger_error(__('Unable to get permissions for this Campaign'), E_USER_ERROR);364 trigger_error(__('Unable to get permissions for this Campaign'), E_USER_ERROR);
374 }
375365
376 $checkboxes = array();366 $checkboxes = array();
377367
378 while ($row = $db->get_assoc_row($results))368 foreach ($result as $row) {
379 {369 $groupId = $row['groupid'];
380 $groupId = $row['GroupID'];370 $rowClass = ($row['isuserspecific'] == 0) ? 'strong_text' : '';
381 $rowClass = ($row['IsUserSpecific'] == 0) ? 'strong_text' : '';
382371
383 $checkbox = array(372 $checkbox = array(
384 'id' => $groupId,373 'id' => $groupId,
385 'name' => Kit::ValidateParam($row['Group'], _STRING),374 'name' => Kit::ValidateParam($row['group'], _STRING),
386 'class' => $rowClass,375 'class' => $rowClass,
387 'value_view' => $groupId . '_view',376 'value_view' => $groupId . '_view',
388 'value_view_checked' => (($row['View'] == 1) ? 'checked' : ''),377 'value_view_checked' => (($row['view'] == 1) ? 'checked' : ''),
389 'value_edit' => $groupId . '_edit',378 'value_edit' => $groupId . '_edit',
390 'value_edit_checked' => (($row['Edit'] == 1) ? 'checked' : ''),379 'value_edit_checked' => (($row['edit'] == 1) ? 'checked' : ''),
391 'value_del' => $groupId . '_del',380 'value_del' => $groupId . '_del',
392 'value_del_checked' => (($row['Del'] == 1) ? 'checked' : ''),381 'value_del_checked' => (($row['del'] == 1) ? 'checked' : ''),
393 );382 );
394383
395 $checkboxes[] = $checkbox;384 $checkboxes[] = $checkbox;
@@ -593,7 +582,7 @@
593 public function SetMembers()582 public function SetMembers()
594 {583 {
595 // Check the token584 // Check the token
596 if (!Kit::CheckToken())585 if (!Kit::CheckToken('assign_token'))
597 trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);586 trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
598 587
599 $db =& $this->db;588 $db =& $this->db;
@@ -646,10 +635,10 @@
646 $id = uniqid();635 $id = uniqid();
647 Theme::Set('id', $id);636 Theme::Set('id', $id);
648 Theme::Set('form_meta', '<input type="hidden" name="p" value="campaign"><input type="hidden" name="q" value="LayoutAssignView">');637 Theme::Set('form_meta', '<input type="hidden" name="p" value="campaign"><input type="hidden" name="q" value="LayoutAssignView">');
649 Theme::Set('pager', ResponseManager::Pager($id, 'form_grid_pager'));638 Theme::Set('pager', ResponseManager::Pager($id, 'grid_pager'));
650 639
651 // Get the currently assigned layouts and put them in the "well"640 // Get the currently assigned layouts and put them in the "well"
652 // // Layouts in group641 // Layouts in group
653 $SQL = "SELECT layout.Layoutid, ";642 $SQL = "SELECT layout.Layoutid, ";
654 $SQL .= " layout.layout, ";643 $SQL .= " layout.layout, ";
655 $SQL .= " CONCAT('LayoutID_', layout.LayoutID) AS list_id ";644 $SQL .= " CONCAT('LayoutID_', layout.LayoutID) AS list_id ";
@@ -669,11 +658,17 @@
669658
670 Debug::LogEntry('audit', count($layoutsAssigned) . ' layouts assigned already');659 Debug::LogEntry('audit', count($layoutsAssigned) . ' layouts assigned already');
671660
661 $formFields = array();
662 $formFields[] = FormManager::AddText('filter_name', __('Name'), NULL, NULL, 'l');
663 Theme::Set('form_fields', $formFields);
664
672 // Set the layouts assigned665 // Set the layouts assigned
673 Theme::Set('layouts_assigned', $layoutsAssigned);666 Theme::Set('layouts_assigned', $layoutsAssigned);
667 Theme::Set('append', Theme::RenderReturn('campaign_form_layout_assign'));
674668
675 // Call to render the template669 // Call to render the template
676 $output = Theme::RenderReturn('campaign_form_layout_assign');670 Theme::Set('header_text', __('Choose Layouts'));
671 $output = Theme::RenderReturn('grid_render');
677672
678 // Construct the Response673 // Construct the Response
679 $response->html = $output;674 $response->html = $output;
@@ -706,12 +701,24 @@
706 // Get a list of media701 // Get a list of media
707 $layoutList = $user->LayoutList(NULL, array('layout' => $name));702 $layoutList = $user->LayoutList(NULL, array('layout' => $name));
708703
704 $cols = array(
705 array('name' => 'layout', 'title' => __('Name'))
706 );
707 Theme::Set('table_cols', $cols);
708
709 $rows = array();709 $rows = array();
710710
711 // Add some extra information711 // Add some extra information
712 foreach ($layoutList as $row) {712 foreach ($layoutList as $row) {
713713
714 $row['list_id'] = 'LayoutID_' . $row['layoutid'];714 $row['list_id'] = 'LayoutID_' . $row['layoutid'];
715 $row['assign_icons'][] = array(
716 'assign_icons_class' => 'layout_assign_list_select'
717 );
718 $row['dataAttributes'] = array(
719 array('name' => 'rowid', 'value' => $row['list_id']),
720 array('name' => 'litext', 'value' => $row['layout'])
721 );
715722
716 $rows[] = $row;723 $rows[] = $row;
717 }724 }
@@ -719,7 +726,7 @@
719 Theme::Set('table_rows', $rows);726 Theme::Set('table_rows', $rows);
720727
721 // Render the Theme728 // Render the Theme
722 $response->SetGridResponse(Theme::RenderReturn('campaign_form_layout_assign_list'));729 $response->SetGridResponse(Theme::RenderReturn('table_render'));
723 $response->callBack = 'LayoutAssignCallback';730 $response->callBack = 'LayoutAssignCallback';
724 $response->pageSize = 5;731 $response->pageSize = 5;
725 $response->Respond();732 $response->Respond();
726733
=== modified file 'server/lib/pages/content.class.php'
--- server/lib/pages/content.class.php 2014-09-15 16:57:34 +0000
+++ server/lib/pages/content.class.php 2014-10-21 16:06:16 +0000
@@ -164,7 +164,7 @@
164 $cols[] = array('name' => 'thumbnail', 'title' => __('Thumbnail'));164 $cols[] = array('name' => 'thumbnail', 'title' => __('Thumbnail'));
165165
166 $cols[] = array('name' => 'duration_text', 'title' => __('Duration'));166 $cols[] = array('name' => 'duration_text', 'title' => __('Duration'));
167 $cols[] = array('name' => 'size_text', 'title' => __('Size'));167 $cols[] = array('name' => 'size_text', 'title' => __('Size'), 'sorter' => 'filesize');
168 $cols[] = array('name' => 'owner', 'title' => __('Owner'));168 $cols[] = array('name' => 'owner', 'title' => __('Owner'));
169 $cols[] = array('name' => 'permissions', 'title' => __('Permissions'));169 $cols[] = array('name' => 'permissions', 'title' => __('Permissions'));
170 $cols[] = array('name' => 'revised', 'title' => __('Revised?'), 'icons' => true);170 $cols[] = array('name' => 'revised', 'title' => __('Revised?'), 'icons' => true);
@@ -188,8 +188,9 @@
188 // Thumbnail URL188 // Thumbnail URL
189 $row['thumbnail'] = '';189 $row['thumbnail'] = '';
190190
191 if ($row['mediatype'] == 'image')191 if ($row['mediatype'] == 'image') {
192 $row['thumbnail'] = '<img src="index.php?p=module&mod=image&q=Exec&method=GetResource&mediaid=' . $row['mediaid'] . '&width=100&height=100&dynamic=true&thumb=true" alt="' . $row['media'] . '" />';192 $row['thumbnail'] = '<a class="img-replace" data-toggle="lightbox" data-type="image" data-img-src="index.php?p=module&mod=image&q=Exec&method=GetResource&mediaid=' . $row['mediaid'] . '&width=100&height=100&dynamic=true&thumb=true" href="index.php?p=module&mod=image&q=Exec&method=GetResource&mediaid=' . $row['mediaid'] . '"><i class="fa fa-file-image-o"></i></a>';
193 }
193194
194 $row['buttons'] = array();195 $row['buttons'] = array();
195196
@@ -257,7 +258,7 @@
257 $response = new ResponseManager();258 $response = new ResponseManager();
258 259
259 // Get a list of the enabled modules and then create buttons for them260 // Get a list of the enabled modules and then create buttons for them
260 if (!$enabledModules = new ModuleManager($db, $user, 0, '', -1)) 261 if (!$enabledModules = new ModuleManager($user, 0, '', -1))
261 trigger_error($enabledModules->message, E_USER_ERROR);262 trigger_error($enabledModules->message, E_USER_ERROR);
262 263
263 $buttons = array();264 $buttons = array();
@@ -300,7 +301,7 @@
300 $id = uniqid();301 $id = uniqid();
301 Theme::Set('id', $id);302 Theme::Set('id', $id);
302 Theme::Set('form_meta', '<input type="hidden" name="p" value="content"><input type="hidden" name="q" value="LibraryAssignView">');303 Theme::Set('form_meta', '<input type="hidden" name="p" value="content"><input type="hidden" name="q" value="LibraryAssignView">');
303 Theme::Set('pager', ResponseManager::Pager($id, 'form_grid_pager'));304 Theme::Set('pager', ResponseManager::Pager($id, 'grid_pager'));
304 305
305 // Module types filter306 // Module types filter
306 $modules = $this->user->ModuleAuth(0, '', 1);307 $modules = $this->user->ModuleAuth(0, '', 1);
307308
=== modified file 'server/lib/pages/display.class.php'
--- server/lib/pages/display.class.php 2014-09-16 10:59:55 +0000
+++ server/lib/pages/display.class.php 2014-10-21 16:06:16 +0000
@@ -27,14 +27,12 @@
27 $this->db =& $db;27 $this->db =& $db;
28 $this->user =& $user;28 $this->user =& $user;
2929
30 Kit::ClassLoader('Display');
31
32 $this->sub_page = Kit::GetParam('sp', _GET, _WORD, 'view');30 $this->sub_page = Kit::GetParam('sp', _GET, _WORD, 'view');
33 $this->ajax = Kit::GetParam('ajax', _REQUEST, _WORD, 'false');31 $this->ajax = Kit::GetParam('ajax', _REQUEST, _WORD, 'false');
34 $displayid = Kit::GetParam('displayid', _REQUEST, _INT, 0);32 $displayid = Kit::GetParam('displayid', _REQUEST, _INT, 0);
3533
36 // validate displays so we get a realistic view of the table34 // validate displays so we get a realistic view of the table
37 $this->validateDisplays();35 Display::ValidateDisplays();
38 }36 }
3937
40 /**38 /**
@@ -56,12 +54,14 @@
56 $filter_displaygroup = Session::Get('display', 'filter_displaygroup');54 $filter_displaygroup = Session::Get('display', 'filter_displaygroup');
57 $filter_display = Session::Get('display', 'filter_display');55 $filter_display = Session::Get('display', 'filter_display');
58 $filter_showThumbnail = Session::Get('display', 'filter_showThumbnail');56 $filter_showThumbnail = Session::Get('display', 'filter_showThumbnail');
57 $filter_autoRefresh = Session::Get('display', 'filter_autoRefresh');
59 }58 }
60 else {59 else {
61 $filter_pinned = 0;60 $filter_pinned = 0;
62 $filter_displaygroup = NULL;61 $filter_displaygroup = NULL;
63 $filter_display = NULL;62 $filter_display = NULL;
64 $filter_showThumbnail = 0;63 $filter_showThumbnail = 0;
64 $filter_autoRefresh = 0;
65 }65 }
6666
67 $formFields = array();67 $formFields = array();
@@ -76,13 +76,26 @@
76 $displayGroups,76 $displayGroups,
77 'displaygroupid',77 'displaygroupid',
78 'displaygroup',78 'displaygroup',
79 NULL,
80 'd');
81
82 $formFields[] = FormManager::AddCombo(
83 'filter_showThumbnail',
84 __('Thumbnails'),
85 $filter_showThumbnail,
86 array(
87 array('key' => 0, 'value' => __('None')),
88 array('key' => 1, 'value' => __('Always')),
89 array('key' => 2, 'value' => __('When Logged In')),
90 ),
91 'key',
92 'value',
79 NULL, 93 NULL,
80 'd');
81
82 $formFields[] = FormManager::AddCheckbox('filter_showThumbnail', __('Show Thumbnails'),
83 $filter_showThumbnail, NULL,
84 't');94 't');
8595
96 $formFields[] = FormManager::AddNumber('filter_autoRefresh', __('Auto Refresh'), $filter_autoRefresh,
97 NULL, 'r');
98
86 $formFields[] = FormManager::AddCheckbox('XiboFilterPinned', __('Keep Open'), 99 $formFields[] = FormManager::AddCheckbox('XiboFilterPinned', __('Keep Open'),
87 $filter_pinned, NULL, 100 $filter_pinned, NULL,
88 'k');101 'k');
@@ -141,7 +154,7 @@
141 $displayObject->wakeOnLanTime = Kit::GetParam('wakeOnLanTime', _POST, _STRING);154 $displayObject->wakeOnLanTime = Kit::GetParam('wakeOnLanTime', _POST, _STRING);
142 $displayObject->broadCastAddress = Kit::GetParam('broadCastAddress', _POST, _STRING);155 $displayObject->broadCastAddress = Kit::GetParam('broadCastAddress', _POST, _STRING);
143 $displayObject->secureOn = Kit::GetParam('secureOn', _POST, _STRING);156 $displayObject->secureOn = Kit::GetParam('secureOn', _POST, _STRING);
144 $displayObject->cidr = Kit::GetParam('cidr', _POST, _INT);157 $displayObject->cidr = Kit::GetParam('cidr', _POST, _STRING);
145 $displayObject->latitude = Kit::GetParam('latitude', _POST, _DOUBLE);158 $displayObject->latitude = Kit::GetParam('latitude', _POST, _DOUBLE);
146 $displayObject->longitude = Kit::GetParam('longitude', _POST, _DOUBLE);159 $displayObject->longitude = Kit::GetParam('longitude', _POST, _DOUBLE);
147 $displayObject->displayProfileId = Kit::GetParam('displayprofileid', _POST, _INT);160 $displayObject->displayProfileId = Kit::GetParam('displayprofileid', _POST, _INT);
@@ -225,8 +238,8 @@
225 __('Do you want to be notified by email if there is a problem with this display?'), 238 __('Do you want to be notified by email if there is a problem with this display?'),
226 'a');239 'a');
227240
228 $formFields[] = FormManager::AddNumber('alert_timeout', __('Alert Timeout'), $displayObject->alertTimeout, 241 $formFields[] = FormManager::AddCheckbox('alert_timeout', __('Use the Global Timeout?'), $displayObject->alertTimeout,
229 __('How long in minutes after the display last connected to the webservice should we send an alert. Set this value higher than the collection interval on the client. Set to 0 to use global default.'), 242 __('Should this display be tested against the global time out or the client collection interval?'),
230 'o');243 'o');
231244
232 Theme::Set('form_fields_maintenance', $formFields);245 Theme::Set('form_fields_maintenance', $formFields);
@@ -259,7 +272,7 @@
259 __('The time this display should receive the WOL command, using the 24hr clock - e.g. 19:00. Maintenance must be enabled.'), 't');272 __('The time this display should receive the WOL command, using the 24hr clock - e.g. 19:00. Maintenance must be enabled.'), 't');
260273
261 $formFields[] = FormManager::AddText('cidr', __('Wake on LAN CIDR'), $displayObject->cidr, 274 $formFields[] = FormManager::AddText('cidr', __('Wake on LAN CIDR'), $displayObject->cidr,
262 __('Enter a number within the range of 0 to 32 in the following field. Leave the following field empty, if no subnet mask should be used (CIDR = 0). If the remote host\'s broadcast address is unkown: Enter the host name or IP address of the remote host in Broad Cast Address and enter the CIDR subnet mask of the remote host in this field.'), 'c');275 __('Enter a number within the range of 0 to 32 in the following field. Leave the following field empty, if no subnet mask should be used (CIDR = 0). If the remote host\'s broadcast address is unknown: Enter the host name or IP address of the remote host in Broad Cast Address and enter the CIDR subnet mask of the remote host in this field.'), 'c');
263276
264 Theme::Set('form_fields_wol', $formFields);277 Theme::Set('form_fields_wol', $formFields);
265278
@@ -327,6 +340,7 @@
327 $db =& $this->db;340 $db =& $this->db;
328 $user =& $this->user;341 $user =& $this->user;
329 $response = new ResponseManager();342 $response = new ResponseManager();
343 $dateFormat = Config::GetSetting('DATE_FORMAT');
330344
331 // Filter by Name345 // Filter by Name
332 $filter_display = Kit::GetParam('filter_display', _POST, _STRING);346 $filter_display = Kit::GetParam('filter_display', _POST, _STRING);
@@ -337,9 +351,13 @@
337 setSession('display', 'filter_displaygroup', $filter_displaygroupid);351 setSession('display', 'filter_displaygroup', $filter_displaygroupid);
338352
339 // Thumbnail?353 // Thumbnail?
340 $filter_showThumbnail = Kit::GetParam('filter_showThumbnail', _REQUEST, _CHECKBOX);354 $filter_showThumbnail = Kit::GetParam('filter_showThumbnail', _REQUEST, _INT);
341 setSession('display', 'filter_showThumbnail', $filter_showThumbnail);355 setSession('display', 'filter_showThumbnail', $filter_showThumbnail);
342356
357 // filter_autoRefresh?
358 $filter_autoRefresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0);
359 setSession('display', 'filter_autoRefresh', $filter_autoRefresh);
360
343 // Pinned option? 361 // Pinned option?
344 setSession('display', 'DisplayFilter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));362 setSession('display', 'DisplayFilter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));
345363
@@ -358,22 +376,19 @@
358 $cols = array(376 $cols = array(
359 array('name' => 'displayid', 'title' => __('ID')),377 array('name' => 'displayid', 'title' => __('ID')),
360 array('name' => 'licensed', 'title' => __('License'), 'icons' => true),378 array('name' => 'licensed', 'title' => __('License'), 'icons' => true),
361 array('name' => 'display', 'title' => __('Display')),379 array('name' => 'displayWithLink', 'title' => __('Display')),
362 array('name' => 'description', 'title' => __('Description')),380 array('name' => 'description', 'title' => __('Description'), 'hidden' => ($filter_showThumbnail == 1 || $filter_showThumbnail == 2)),
363 array('name' => 'layout', 'title' => __('Default Layout')),381 array('name' => 'layout', 'title' => __('Default Layout'), 'hidden' => ($filter_showThumbnail == 1 || $filter_showThumbnail == 2)),
364 array('name' => 'inc_schedule', 'title' => __('Interleave Default'), 'icons' => true),382 array('name' => 'inc_schedule', 'title' => __('Interleave Default'), 'icons' => true, 'hidden' => ($filter_showThumbnail == 1 || $filter_showThumbnail == 2)),
365 array('name' => 'email_alert', 'title' => __('Email Alert'), 'icons' => true),383 array('name' => 'email_alert', 'title' => __('Email Alert'), 'icons' => true, 'hidden' => ($filter_showThumbnail == 1 || $filter_showThumbnail == 2)),
366 array('name' => 'loggedin', 'title' => __('Logged In'), 'icons' => true),384 array('name' => 'loggedin', 'title' => __('Logged In'), 'icons' => true),
367 array('name' => 'lastaccessed', 'title' => __('Last Accessed')),385 array('name' => 'lastaccessed', 'title' => __('Last Accessed')),
368 array('name' => 'clientaddress', 'title' => __('IP Address')),386 array('name' => 'clientaddress', 'title' => __('IP Address'), 'hidden' => ($filter_showThumbnail == 1)),
369 array('name' => 'macaddress', 'title' => __('Mac Address'))387 array('name' => 'macaddress', 'title' => __('Mac Address'), 'hidden' => ($filter_showThumbnail == 1)),
388 array('name' => 'screenShotRequested', 'title' => __('Screen shot?'), 'icons' => true, 'hidden' => ($filter_showThumbnail == 0)),
389 array('name' => 'thumbnail', 'title' => __('Thumbnail'), 'hidden' => ($filter_showThumbnail == 0))
370 );390 );
371 391
372 if ($filter_showThumbnail == 1) {
373 $cols[] = array('name' => 'screenShotRequested', 'title' => __('Screen shot?'), 'icons' => true);
374 $cols[] = array('name' => 'thumbnail', 'title' => __('Thumbnail'));
375 }
376
377 Theme::Set('table_cols', $cols);392 Theme::Set('table_cols', $cols);
378 Theme::Set('rowClass', 'mediainventorystatus');393 Theme::Set('rowClass', 'mediainventorystatus');
379394
@@ -387,11 +402,11 @@
387 if ($linkTarget == '')402 if ($linkTarget == '')
388 $linkTarget = '_top';403 $linkTarget = '_top';
389404
390 $row['display'] = sprintf('<a href="' . $vncTemplate . '" title="VNC to ' . $row['display'] . '" target="' . $linkTarget . '">' . Theme::Prepare($row['display']) . '</a>', $row['clientaddress']);405 $row['displayWithLink'] = sprintf('<a href="' . $vncTemplate . '" title="VNC to ' . $row['display'] . '" target="' . $linkTarget . '">' . Theme::Prepare($row['display']) . '</a>', $row['clientaddress']);
391 }406 }
392407
393 // Format last accessed408 // Format last accessed
394 $row['lastaccessed'] = date("Y-m-d H:i:s", $row['lastaccessed']);409 $row['lastaccessed'] = date($dateFormat, $row['lastaccessed']);
395410
396 // Create some login lights411 // Create some login lights
397 $row['mediainventorystatus'] = ($row['mediainventorystatus'] == 1) ? 'success' : (($row['mediainventorystatus'] == 2) ? 'danger' : 'warning');412 $row['mediainventorystatus'] = ($row['mediainventorystatus'] == 1) ? 'success' : (($row['mediainventorystatus'] == 2) ? 'danger' : 'warning');
@@ -399,7 +414,10 @@
399 // Thumbnail414 // Thumbnail
400 $row['thumbnail'] = '';415 $row['thumbnail'] = '';
401 if ($filter_showThumbnail == 1 && file_exists(Config::GetSetting('LIBRARY_LOCATION') . 'screenshots/' . $row['displayid'] . '_screenshot.jpg')) {416 if ($filter_showThumbnail == 1 && file_exists(Config::GetSetting('LIBRARY_LOCATION') . 'screenshots/' . $row['displayid'] . '_screenshot.jpg')) {
402 $row['thumbnail'] = '<img class="display-screenshot" src="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '" />';417 $row['thumbnail'] = '<a data-toggle="lightbox" data-type="image" href="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '"><img class="display-screenshot" src="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '" /></a>';
418 }
419 else if ($filter_showThumbnail == 2) {
420 $row['thumbnail'] = '<i class="fa fa-times-circle"></i>';
403 }421 }
404422
405 // Edit and Delete buttons first423 // Edit and Delete buttons first
@@ -454,7 +472,13 @@
454 $row['buttons'][] = array(472 $row['buttons'][] = array(
455 'id' => 'display_button_requestScreenShot',473 'id' => 'display_button_requestScreenShot',
456 'url' => 'index.php?p=display&q=RequestScreenShotForm&displayId=' . $row['displayid'],474 'url' => 'index.php?p=display&q=RequestScreenShotForm&displayId=' . $row['displayid'],
457 'text' => __('Request Screen Shot')475 'text' => __('Request Screen Shot'),
476 'multi-select' => true,
477 'dataAttributes' => array(
478 array('name' => 'multiselectlink', 'value' => 'index.php?p=display&q=RequestScreenShot'),
479 array('name' => 'rowtitle', 'value' => $row['display']),
480 array('name' => 'displayId', 'value' => $row['displayid'])
481 )
458 );482 );
459483
460 $row['buttons'][] = array('linkType' => 'divider');484 $row['buttons'][] = array('linkType' => 'divider');
@@ -523,55 +547,11 @@
523 $output = Theme::RenderReturn('table_render');547 $output = Theme::RenderReturn('table_render');
524548
525 $response->SetGridResponse($output);549 $response->SetGridResponse($output);
550 $response->refresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0);
526 $response->Respond();551 $response->Respond();
527 }552 }
528553
529 /**554 /**
530 * Assess each Display to correctly set the logged in flag based on last accessed time
531 * @return
532 */
533 function validateDisplays()
534 {
535 $db =& $this->db;
536
537 // Get the global timeout (overrides the alert timeout on the display if 0
538 $globalTimeout = Config::GetSetting('MAINTENANCE_ALERT_TOUT');
539
540 // Get a list of all displays and there last accessed / alert timeout value
541 $SQL = "";
542 $SQL .= "SELECT displayid, lastaccessed, alert_timeout FROM display ";
543
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches