Merge lp:~dangarner/xibo/server-170-alpha2 into lp:xibo/1.7
- server-170-alpha2
- Merge into tuttle
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 |
Related bugs: |
|
Related blueprints: |
Adding Checkbox to library and timeline
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Xibo Maintainters | Pending | ||
Review via email: mp+239095@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'example_oauth/index.php' | |||
2 | --- example_oauth/index.php 2014-07-12 13:54:51 +0000 | |||
3 | +++ example_oauth/index.php 2014-10-21 16:06:16 +0000 | |||
4 | @@ -1,4 +1,7 @@ | |||
5 | 1 | <?php | 1 | <?php |
6 | 2 | error_reporting(E_ALL); | ||
7 | 3 | ini_set('display_errors', 1); | ||
8 | 4 | |||
9 | 2 | require_once('oauth-php/library/OAuthStore.php'); | 5 | require_once('oauth-php/library/OAuthStore.php'); |
10 | 3 | require_once('oauth-php/library/OAuthRequester.php'); | 6 | require_once('oauth-php/library/OAuthRequester.php'); |
11 | 4 | require_once('oauth-php/library/OAuthRequestLogger.php'); | 7 | require_once('oauth-php/library/OAuthRequestLogger.php'); |
12 | @@ -6,16 +9,16 @@ | |||
13 | 6 | 9 | ||
14 | 7 | DEFINE('OAUTH_LOG_REQUEST', true); | 10 | DEFINE('OAUTH_LOG_REQUEST', true); |
15 | 8 | 11 | ||
26 | 9 | $connection = array('server' => 'localhost', | 12 | $connection = new PDO('mysql:host=localhost;dbname=oauth_consumer', 'root', 'root'); |
27 | 10 | 'username' => 'root', | 13 | $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
28 | 11 | 'password' => '', | 14 | $connection->query("SET NAMES 'utf8'"); |
29 | 12 | 'database' => 'oauth_consumer'); | 15 | |
30 | 13 | 16 | OAuthStore::instance('PDO', array('conn' => $connection)); | |
31 | 14 | OAuthStore::instance('MySQL', $connection); | 17 | |
32 | 15 | 18 | DEFINE('LOCAL_BASE', 'http://172.28.128.3/example_oauth/index.php'); | |
33 | 16 | DEFINE('SERVER_BASE', 'http://localhost/xibo/1.6/server-162/server/'); | 19 | DEFINE('SERVER_BASE', 'http://unittest.xibo.co.uk/'); |
34 | 17 | DEFINE('CONSUMER_KEY', 'e982575d2ab70546923b92e50c5b96ca053b407a8'); | 20 | DEFINE('CONSUMER_KEY', '9beeb94ea11bfa15da1ab7b2b0fb543205436b27b'); |
35 | 18 | DEFINE('CONSUMER_SECRET', 'a891f97e69985230a2e0e869b9f875e3'); | 21 | DEFINE('CONSUMER_SECRET', 'fba59ef57d3331032a099cf04b1ebb2d'); |
36 | 19 | //DEFINE('SERVER_BASE', 'http://unittest2.xibo.org.uk/api/'); | 22 | //DEFINE('SERVER_BASE', 'http://unittest2.xibo.org.uk/api/'); |
37 | 20 | //DEFINE('CONSUMER_KEY', '201798cda77e4e82e0488d0c8c2e43ae0519d180f'); | 23 | //DEFINE('CONSUMER_KEY', '201798cda77e4e82e0488d0c8c2e43ae0519d180f'); |
38 | 21 | //DEFINE('CONSUMER_SECRET', '9eb4aa8a51e4a393b3fb5ad6f1a75bae'); | 24 | //DEFINE('CONSUMER_SECRET', '9eb4aa8a51e4a393b3fb5ad6f1a75bae'); |
39 | @@ -92,7 +95,7 @@ | |||
40 | 92 | } | 95 | } |
41 | 93 | 96 | ||
42 | 94 | // Callback to our (consumer) site, will be called when the user finished the authorization at the server | 97 | // Callback to our (consumer) site, will be called when the user finished the authorization at the server |
44 | 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); |
45 | 96 | 99 | ||
46 | 97 | // Now redirect to the autorization uri and get us authorized | 100 | // Now redirect to the autorization uri and get us authorized |
47 | 98 | if (!empty($token['authorize_uri'])) | 101 | if (!empty($token['authorize_uri'])) |
48 | 99 | 102 | ||
49 | === modified file 'server/config/client.config.php' | |||
50 | --- server/config/client.config.php 2014-09-16 16:41:43 +0000 | |||
51 | +++ server/config/client.config.php 2014-10-21 16:06:16 +0000 | |||
52 | @@ -272,7 +272,7 @@ | |||
53 | 272 | 'title' => __('Use CEF as the Web Browser'), | 272 | 'title' => __('Use CEF as the Web Browser'), |
54 | 273 | 'type' => _CHECKBOX, | 273 | 'type' => _CHECKBOX, |
55 | 274 | 'fieldType' => 'checkbox', | 274 | 'fieldType' => 'checkbox', |
57 | 275 | 'default' => 1, | 275 | 'default' => 0, |
58 | 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.'), |
59 | 277 | 'enabled' => true, | 277 | 'enabled' => true, |
60 | 278 | 'groupClass' => NULL | 278 | 'groupClass' => NULL |
61 | 279 | 279 | ||
62 | === modified file 'server/config/config.class.php' | |||
63 | --- server/config/config.class.php 2014-08-16 12:51:07 +0000 | |||
64 | +++ server/config/config.class.php 2014-10-21 16:06:16 +0000 | |||
65 | @@ -56,7 +56,7 @@ | |||
66 | 56 | * @return | 56 | * @return |
67 | 57 | * @param $setting Object[optional] | 57 | * @param $setting Object[optional] |
68 | 58 | */ | 58 | */ |
70 | 59 | static function GetSetting($setting) | 59 | static function GetSetting($setting, $default = NULL) |
71 | 60 | { | 60 | { |
72 | 61 | try { | 61 | try { |
73 | 62 | $dbh = PDOConnect::init(); | 62 | $dbh = PDOConnect::init(); |
74 | @@ -65,12 +65,14 @@ | |||
75 | 65 | $sth->execute(array('setting' => $setting)); | 65 | $sth->execute(array('setting' => $setting)); |
76 | 66 | 66 | ||
77 | 67 | if (!$result = $sth->fetch()) | 67 | if (!$result = $sth->fetch()) |
79 | 68 | return false; | 68 | return $default; |
80 | 69 | 69 | ||
81 | 70 | //Debug::LogEntry('audit', 'Retrieved setting ' . $result['value'] . ' for ' . $setting, 'Config', 'GetSetting'); | 70 | //Debug::LogEntry('audit', 'Retrieved setting ' . $result['value'] . ' for ' . $setting, 'Config', 'GetSetting'); |
83 | 71 | 71 | ||
84 | 72 | // Validate as a string and return | 72 | // Validate as a string and return |
86 | 73 | return Kit::ValidateParam($result['value'], _STRING); | 73 | $result = Kit::ValidateParam($result['value'], _STRING); |
87 | 74 | |||
88 | 75 | return ($result == '') ? $default : $result; | ||
89 | 74 | } | 76 | } |
90 | 75 | catch (Exception $e) { | 77 | catch (Exception $e) { |
91 | 76 | trigger_error($e->getMessage()); | 78 | trigger_error($e->getMessage()); |
92 | 77 | 79 | ||
93 | === modified file 'server/install/database/80.sql' | |||
94 | --- server/install/database/80.sql 2014-09-19 14:08:28 +0000 | |||
95 | +++ server/install/database/80.sql 2014-10-21 16:06:16 +0000 | |||
96 | @@ -41,11 +41,6 @@ | |||
97 | 41 | PRIMARY KEY (`displayprofileid`) | 41 | PRIMARY KEY (`displayprofileid`) |
98 | 42 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; | 42 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; |
99 | 43 | 43 | ||
100 | 44 | INSERT INTO `displayprofile` (`displayprofileid`, `name`, `type`, `config`, `isdefault`, `userid`) VALUES | ||
101 | 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), | ||
102 | 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); | ||
103 | 47 | |||
104 | 48 | |||
105 | 49 | UPDATE layout SET background = SUBSTRING_INDEX(background, '.', 1) WHERE IFNULL(background, '') <> ''; | 44 | UPDATE layout SET background = SUBSTRING_INDEX(background, '.', 1) WHERE IFNULL(background, '') <> ''; |
106 | 50 | ALTER TABLE `layout` CHANGE `background` `backgroundImageId` INT( 11 ) NULL DEFAULT NULL; | 45 | ALTER TABLE `layout` CHANGE `background` `backgroundImageId` INT( 11 ) NULL DEFAULT NULL; |
107 | 51 | 46 | ||
108 | @@ -178,6 +173,6 @@ | |||
109 | 178 | ('DisplayProfile', 'Delete', 'manual/single.php?p=admin/displayprofiles#delete'); | 173 | ('DisplayProfile', 'Delete', 'manual/single.php?p=admin/displayprofiles#delete'); |
110 | 179 | 174 | ||
111 | 180 | 175 | ||
113 | 181 | UPDATE `version` SET `app_ver` = '1.7.0-alpha', `XmdsVersion` = 4; | 176 | UPDATE `version` SET `app_ver` = '1.7.0-alpha', `XmdsVersion` = 4, `XlfVersion` = 2 ; |
114 | 182 | UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE'; | 177 | UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE'; |
115 | 183 | UPDATE `version` SET `DBVersion` = '80'; | 178 | UPDATE `version` SET `DBVersion` = '80'; |
116 | 184 | 179 | ||
117 | === added file 'server/install/database/81.sql' | |||
118 | --- server/install/database/81.sql 1970-01-01 00:00:00 +0000 | |||
119 | +++ server/install/database/81.sql 2014-10-21 16:06:16 +0000 | |||
120 | @@ -0,0 +1,23 @@ | |||
121 | 1 | INSERT INTO `setting` (`setting` ,`value` ,`fieldType` ,`helptext` ,`options` ,`cat` ,`userChange` ,`title` ,`validation` ,`ordering` ,`default` ,`userSee` ,`type`) | ||
122 | 2 | VALUES ( | ||
123 | 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' | ||
124 | 4 | ); | ||
125 | 5 | |||
126 | 6 | INSERT INTO `setting` (`setting` ,`value` ,`fieldType` ,`helptext` ,`options` ,`cat` ,`userChange` ,`title` ,`validation` ,`ordering` ,`default` ,`userSee` ,`type`) | ||
127 | 7 | VALUES ( | ||
128 | 8 | 'DETECT_LANGUAGE', '1', 'checkbox', 'Detect the browser language?', NULL , 'regional', '1', 'Detect Language', '', '40', '1', '1', 'checkbox' | ||
129 | 9 | ); | ||
130 | 10 | |||
131 | 11 | ALTER TABLE `media` ADD `is_module` TINYINT NOT NULL DEFAULT '0'; | ||
132 | 12 | |||
133 | 13 | INSERT INTO `module` (`ModuleID`, `Module`, `Name`, `Enabled`, `RegionSpecific`, `Description`, `ImageUri`, `SchemaVersion`, `ValidExtensions`, `PreviewEnabled`, `assignable`) VALUES | ||
134 | 14 | (NULL, 'font', 'Font', '1', '0', 'A font to use in other Modules', 'forms/library.gif', '1', 'ttf,otf,eot,svg,woff', '0', '0'); | ||
135 | 15 | |||
136 | 16 | ALTER TABLE `stat` ADD INDEX ( `statDate` ); | ||
137 | 17 | |||
138 | 18 | ALTER TABLE `stat` CHANGE `layoutID` `layoutID` INT( 8 ) NULL; | ||
139 | 19 | ALTER TABLE `stat` CHANGE `end` `end` DATETIME NULL; | ||
140 | 20 | |||
141 | 21 | UPDATE `version` SET `app_ver` = '1.7.0-alpha2', `XmdsVersion` = 4, `XlfVersion` = 2; | ||
142 | 22 | UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE'; | ||
143 | 23 | UPDATE `version` SET `DBVersion` = '81'; | ||
144 | 0 | \ No newline at end of file | 24 | \ No newline at end of file |
145 | 1 | 25 | ||
146 | === modified file 'server/install/master/data.sql' | |||
147 | --- server/install/master/data.sql 2014-09-19 12:55:15 +0000 | |||
148 | +++ server/install/master/data.sql 2014-10-21 16:06:16 +0000 | |||
149 | @@ -1,5 +1,5 @@ | |||
150 | 1 | INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES | 1 | INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES |
152 | 2 | ('1.7.0-alpha', 4, 1, 80); | 2 | ('1.7.0-alpha2', 4, 2, 81); |
153 | 3 | 3 | ||
154 | 4 | INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`) VALUES | 4 | INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`) VALUES |
155 | 5 | (1, 'Users', 0, 0), | 5 | (1, 'Users', 0, 0), |
156 | @@ -113,7 +113,8 @@ | |||
157 | 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), |
158 | 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), |
159 | 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), |
161 | 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', '[]'), |
162 | 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); | ||
163 | 117 | 118 | ||
164 | 118 | INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES | 119 | INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES |
165 | 119 | (1, 'Schedule'), | 120 | (1, 'Schedule'), |
166 | @@ -263,7 +264,9 @@ | |||
167 | 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'), |
168 | 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'), |
169 | 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'), |
171 | 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'), |
172 | 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'), | ||
173 | 269 | (75, 'DETECT_LANGUAGE', '1', 'checkbox', 'Detect the browser language?', NULL , 'regional', '1', 'Detect Language', '', 40, '1', 1, 'checkbox'); | ||
174 | 267 | 270 | ||
175 | 268 | INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES | 271 | INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES |
176 | 269 | (1, 'Super Admin'), | 272 | (1, 'Super Admin'), |
177 | @@ -339,10 +342,6 @@ | |||
178 | 339 | (1, 'Value'), | 342 | (1, 'Value'), |
179 | 340 | (2, 'Formula'); | 343 | (2, 'Formula'); |
180 | 341 | 344 | ||
181 | 342 | INSERT INTO `displayprofile` (`displayprofileid`, `name`, `type`, `config`, `isdefault`, `userid`) VALUES | ||
182 | 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), | ||
183 | 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); | ||
184 | 345 | |||
185 | 346 | INSERT INTO `bandwidthtype` (`bandwidthtypeid`, `name`) VALUES | 345 | INSERT INTO `bandwidthtype` (`bandwidthtypeid`, `name`) VALUES |
186 | 347 | (1, 'Register'), | 346 | (1, 'Register'), |
187 | 348 | (2, 'Required Files'), | 347 | (2, 'Required Files'), |
188 | 349 | 348 | ||
189 | === modified file 'server/install/master/structure.sql' | |||
190 | --- server/install/master/structure.sql 2014-09-16 10:59:55 +0000 | |||
191 | +++ server/install/master/structure.sql 2014-10-21 16:06:16 +0000 | |||
192 | @@ -321,6 +321,7 @@ | |||
193 | 321 | `retired` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Is retired?', | 321 | `retired` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Is retired?', |
194 | 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', |
195 | 323 | `editedMediaID` int(11) DEFAULT NULL COMMENT 'The Parent ID', | 323 | `editedMediaID` int(11) DEFAULT NULL COMMENT 'The Parent ID', |
196 | 324 | `is_module` tinyint(4) NOT NULL DEFAULT '0', | ||
197 | 324 | PRIMARY KEY (`mediaID`) | 325 | PRIMARY KEY (`mediaID`) |
198 | 325 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ; | 326 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ; |
199 | 326 | 327 | ||
200 | @@ -530,12 +531,13 @@ | |||
201 | 530 | `statDate` datetime NOT NULL COMMENT 'State entry date', | 531 | `statDate` datetime NOT NULL COMMENT 'State entry date', |
202 | 531 | `scheduleID` int(8) NOT NULL, | 532 | `scheduleID` int(8) NOT NULL, |
203 | 532 | `displayID` int(4) NOT NULL, | 533 | `displayID` int(4) NOT NULL, |
205 | 533 | `layoutID` int(8) NOT NULL, | 534 | `layoutID` int(8) NULL, |
206 | 534 | `mediaID` varchar(50) DEFAULT NULL, | 535 | `mediaID` varchar(50) DEFAULT NULL, |
207 | 535 | `start` datetime NOT NULL, | 536 | `start` datetime NOT NULL, |
209 | 536 | `end` datetime NOT NULL, | 537 | `end` datetime NULL, |
210 | 537 | `Tag` varchar(254) DEFAULT NULL, | 538 | `Tag` varchar(254) DEFAULT NULL, |
212 | 538 | PRIMARY KEY (`statID`) | 539 | PRIMARY KEY (`statID`), |
213 | 540 | KEY `statDate` (`statDate`) | ||
214 | 539 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; | 541 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; |
215 | 540 | 542 | ||
216 | 541 | CREATE TABLE IF NOT EXISTS `template` ( | 543 | CREATE TABLE IF NOT EXISTS `template` ( |
217 | 542 | 544 | ||
218 | === added file 'server/lib/app/cache.class.php' | |||
219 | --- server/lib/app/cache.class.php 1970-01-01 00:00:00 +0000 | |||
220 | +++ server/lib/app/cache.class.php 2014-10-21 16:06:16 +0000 | |||
221 | @@ -0,0 +1,82 @@ | |||
222 | 1 | <?php | ||
223 | 2 | /* | ||
224 | 3 | * Xibo - Digital Signage - http://www.xibo.org.uk | ||
225 | 4 | * Copyright (C) 2009-2013 Daniel Garner | ||
226 | 5 | * | ||
227 | 6 | * This file is part of Xibo. | ||
228 | 7 | * | ||
229 | 8 | * Xibo is free software: you can redistribute it and/or modify | ||
230 | 9 | * it under the terms of the GNU Affero General Public License as published by | ||
231 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
232 | 11 | * any later version. | ||
233 | 12 | * | ||
234 | 13 | * Xibo is distributed in the hope that it will be useful, | ||
235 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
236 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
237 | 16 | * GNU Affero General Public License for more details. | ||
238 | 17 | * | ||
239 | 18 | * You should have received a copy of the GNU Affero General Public License | ||
240 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | ||
241 | 20 | * | ||
242 | 21 | * A very simple file cache | ||
243 | 22 | */ | ||
244 | 23 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | ||
245 | 24 | |||
246 | 25 | class Cache { | ||
247 | 26 | |||
248 | 27 | private static $_data; | ||
249 | 28 | private static $_location; | ||
250 | 29 | |||
251 | 30 | private function __construct() {} | ||
252 | 31 | |||
253 | 32 | public static function put($key, $value, $expires) { | ||
254 | 33 | if (!self::$_data) | ||
255 | 34 | self::load(); | ||
256 | 35 | |||
257 | 36 | $expires = time() + $expires; | ||
258 | 37 | |||
259 | 38 | self::$_data[$key] = array('value' => $value, 'expires' => $expires); | ||
260 | 39 | |||
261 | 40 | self::save(); | ||
262 | 41 | } | ||
263 | 42 | |||
264 | 43 | public static function get($key, $default = NULL) { | ||
265 | 44 | if (!self::$_data) | ||
266 | 45 | self::load(); | ||
267 | 46 | |||
268 | 47 | if (!Cache::has($key)) | ||
269 | 48 | return $default; | ||
270 | 49 | |||
271 | 50 | $data = self::$_data[$key]; | ||
272 | 51 | |||
273 | 52 | if ($data['expires'] < time()) { | ||
274 | 53 | unset(self::$_data['key']); | ||
275 | 54 | return $default; | ||
276 | 55 | } | ||
277 | 56 | else | ||
278 | 57 | return $data['value']; | ||
279 | 58 | } | ||
280 | 59 | |||
281 | 60 | public static function has($key) { | ||
282 | 61 | if (!self::$_data) | ||
283 | 62 | self::load(); | ||
284 | 63 | |||
285 | 64 | return (isset(self::$_data[$key]) && self::$_data[$key] != null && self::$_data[$key]['expires'] >= time()); | ||
286 | 65 | } | ||
287 | 66 | |||
288 | 67 | private static function load() { | ||
289 | 68 | self::$_location = Config::GetSetting('LIBRARY_LOCATION') . 'cache/cache'; | ||
290 | 69 | |||
291 | 70 | if (!file_exists(self::$_location)) | ||
292 | 71 | self::$_data = array(); | ||
293 | 72 | else | ||
294 | 73 | self::$_data = unserialize(file_get_contents(self::$_location)); | ||
295 | 74 | } | ||
296 | 75 | |||
297 | 76 | private static function save() { | ||
298 | 77 | self::$_location = Config::GetSetting('LIBRARY_LOCATION') . 'cache/cache'; | ||
299 | 78 | |||
300 | 79 | file_put_contents(self::$_location, serialize(self::$_data)); | ||
301 | 80 | } | ||
302 | 81 | } | ||
303 | 82 | ?> | ||
304 | 0 | 83 | ||
305 | === modified file 'server/lib/app/debug.class.php' | |||
306 | --- server/lib/app/debug.class.php 2014-01-18 09:47:41 +0000 | |||
307 | +++ server/lib/app/debug.class.php 2014-10-21 16:06:16 +0000 | |||
308 | @@ -22,174 +22,185 @@ | |||
309 | 22 | 22 | ||
310 | 23 | class Debug | 23 | class Debug |
311 | 24 | { | 24 | { |
435 | 25 | public function __construct() | 25 | public function __construct() |
436 | 26 | { | 26 | { |
437 | 27 | if (!defined('AUDIT')) | 27 | if (!defined('AUDIT')) |
438 | 28 | { | 28 | { |
439 | 29 | // Get the setting from the DB and define it | 29 | // Get the setting from the DB and define it |
440 | 30 | if (Config::GetSetting('audit') != 'On') | 30 | if (Config::GetSetting('audit') != 'On') |
441 | 31 | { | 31 | { |
442 | 32 | define('AUDIT', false); | 32 | define('AUDIT', false); |
443 | 33 | } | 33 | } |
444 | 34 | else | 34 | else |
445 | 35 | { | 35 | { |
446 | 36 | define('AUDIT', true); | 36 | define('AUDIT', true); |
447 | 37 | } | 37 | } |
448 | 38 | } | 38 | } |
449 | 39 | } | 39 | } |
450 | 40 | 40 | ||
451 | 41 | public function ErrorHandler($errno, $errmsg, $filename, $linenum, $vars) { | 41 | public function ErrorHandler($errno, $errmsg, $filename, $linenum, $vars) { |
452 | 42 | 42 | ||
453 | 43 | // timestamp for the error entry | 43 | // timestamp for the error entry |
454 | 44 | $dt = date("Y-m-d H:i:s (T)"); | 44 | $dt = date("Y-m-d H:i:s (T)"); |
455 | 45 | 45 | ||
456 | 46 | // define an assoc array of error string | 46 | // define an assoc array of error string |
457 | 47 | // in reality the only entries we should | 47 | // in reality the only entries we should |
458 | 48 | // consider are E_WARNING, E_NOTICE, E_USER_ERROR, | 48 | // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
459 | 49 | // E_USER_WARNING and E_USER_NOTICE | 49 | // E_USER_WARNING and E_USER_NOTICE |
460 | 50 | $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => | 50 | $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => |
461 | 51 | 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', | 51 | 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', |
462 | 52 | E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', | 52 | E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', |
463 | 53 | E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', | 53 | E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', |
464 | 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 => |
465 | 55 | 'Runtime Notice', E_RECOVERABLE_ERROR => 'Recoverable Error', 8192 => 'Deprecated Call'); | 55 | 'Runtime Notice', E_RECOVERABLE_ERROR => 'Recoverable Error', 8192 => 'Deprecated Call'); |
466 | 56 | 56 | ||
467 | 57 | // set of errors for which a var trace will be saved | 57 | // set of errors for which a var trace will be saved |
468 | 58 | $user_errors_halt = array(E_USER_ERROR); | 58 | $user_errors_halt = array(E_USER_ERROR); |
469 | 59 | $user_errors_inline = array(E_USER_WARNING); | 59 | $user_errors_inline = array(E_USER_WARNING); |
470 | 60 | 60 | ||
471 | 61 | $err = "<errormsg>" . $errmsg . "</errormsg>\n"; | 61 | $err = "<errormsg>" . $errmsg . "</errormsg>\n"; |
472 | 62 | $err .= "<errornum>" . $errno . "</errornum>\n"; | 62 | $err .= "<errornum>" . $errno . "</errornum>\n"; |
473 | 63 | $err .= "<errortype>" . $errortype[$errno] . "</errortype>\n"; | 63 | $err .= "<errortype>" . $errortype[$errno] . "</errortype>\n"; |
474 | 64 | $err .= "<scriptname>" . $filename . "</scriptname>\n"; | 64 | $err .= "<scriptname>" . $filename . "</scriptname>\n"; |
475 | 65 | $err .= "<scriptlinenum>" . $linenum . "</scriptlinenum>\n"; | 65 | $err .= "<scriptlinenum>" . $linenum . "</scriptlinenum>\n"; |
476 | 66 | 66 | ||
477 | 67 | // Log everything | 67 | // Log everything |
478 | 68 | Debug::LogEntry("error", $err); | 68 | Debug::LogEntry("error", $err); |
479 | 69 | 69 | ||
480 | 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!) |
481 | 71 | if (in_array($errno, $user_errors_halt)) | 71 | if (in_array($errno, $user_errors_halt)) |
482 | 72 | { | 72 | { |
483 | 73 | // We have a halt error | 73 | // We have a halt error |
484 | 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.'); |
485 | 75 | 75 | ||
486 | 76 | $response = new ResponseManager(); | 76 | $response = new ResponseManager(); |
487 | 77 | 77 | ||
488 | 78 | $response->SetError($errmsg); | 78 | $response->SetError($errmsg); |
489 | 79 | $response->Respond(); | 79 | $response->Respond(); |
490 | 80 | } | 80 | } |
491 | 81 | 81 | ||
492 | 82 | // Is Debug Enabled? (i.e. Development or Support) | 82 | // Is Debug Enabled? (i.e. Development or Support) |
493 | 83 | if (error_reporting() != 0) | 83 | if (error_reporting() != 0) |
494 | 84 | { | 84 | { |
495 | 85 | if (in_array($errno, $user_errors_inline)) | 85 | if (in_array($errno, $user_errors_inline)) |
496 | 86 | { | 86 | { |
497 | 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? |
498 | 88 | // For now we treat this like a halt error? Or do we just try and output some javascript to pop up an error | 88 | // For now we treat this like a halt error? Or do we just try and output some javascript to pop up an error |
499 | 89 | // surely the javascript idea wont work in ajax? | 89 | // surely the javascript idea wont work in ajax? |
500 | 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? |
501 | 91 | echo $errmsg; | 91 | echo $errmsg; |
502 | 92 | die(); | 92 | die(); |
503 | 93 | } | 93 | } |
504 | 94 | } | 94 | } |
505 | 95 | 95 | ||
506 | 96 | // Must return false | 96 | // Must return false |
507 | 97 | return false; | 97 | return false; |
508 | 98 | } | 98 | } |
509 | 99 | 99 | ||
510 | 100 | /** | 100 | /** |
511 | 101 | * Mail an error - currently disabled | 101 | * Mail an error - currently disabled |
512 | 102 | * @return | 102 | * @return |
513 | 103 | * @param $errmsg Object | 103 | * @param $errmsg Object |
514 | 104 | * @param $err Object | 104 | * @param $err Object |
515 | 105 | */ | 105 | */ |
516 | 106 | function MailError($errmsg, $err) | 106 | function MailError($errmsg, $err) |
517 | 107 | { | 107 | { |
518 | 108 | return true; | 108 | return true; |
519 | 109 | 109 | ||
520 | 110 | $to = 'info@xibo.org.uk'; | 110 | $to = 'info@xibo.org.uk'; |
521 | 111 | 111 | ||
522 | 112 | $from = Config::GetSetting("mail_from"); | 112 | $from = Config::GetSetting("mail_from"); |
523 | 113 | if ($from == "") return true; | 113 | if ($from == "") return true; |
524 | 114 | 114 | ||
525 | 115 | $subject = "Error message from Digital Signage System"; | 115 | $subject = "Error message from Digital Signage System"; |
526 | 116 | $message = wordwrap("$errmsg\n$err"); | 116 | $message = wordwrap("$errmsg\n$err"); |
527 | 117 | 117 | ||
528 | 118 | $headers = "From: $from" . "\r\n" . "Reply-To: $from" . "\r\n" . | 118 | $headers = "From: $from" . "\r\n" . "Reply-To: $from" . "\r\n" . |
529 | 119 | "X-Mailer: PHP/" . phpversion(); | 119 | "X-Mailer: PHP/" . phpversion(); |
530 | 120 | 120 | ||
531 | 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); |
532 | 122 | return true; | 122 | return true; |
533 | 123 | } | 123 | } |
534 | 124 | 124 | ||
535 | 125 | /** | 125 | /** |
536 | 126 | * Write an Entry to the Log table | 126 | * Write an Entry to the Log table |
537 | 127 | * @return | 127 | * @return |
538 | 128 | * @param $db Object | 128 | * @param $db Object |
539 | 129 | * @param $type Object | 129 | * @param $type Object |
540 | 130 | * @param $message Object | 130 | * @param $message Object |
541 | 131 | * @param $page Object[optional] | 131 | * @param $page Object[optional] |
542 | 132 | * @param $function Object[optional] | 132 | * @param $function Object[optional] |
543 | 133 | * @param $logdate Object[optional] | 133 | * @param $logdate Object[optional] |
544 | 134 | * @param $displayid Object[optional] | 134 | * @param $displayid Object[optional] |
545 | 135 | * @param $scheduleID Object[optional] | 135 | * @param $scheduleID Object[optional] |
546 | 136 | * @param $layoutid Object[optional] | 136 | * @param $layoutid Object[optional] |
547 | 137 | * @param $mediaid Object[optional] | 137 | * @param $mediaid Object[optional] |
548 | 138 | */ | 138 | */ |
549 | 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) |
550 | 140 | { | 140 | { |
551 | 141 | if ($type == 'audit' && !AUDIT) | 141 | if ($type == 'audit' && !AUDIT) |
552 | 142 | return; | 142 | return; |
553 | 143 | 143 | ||
554 | 144 | $currentdate = date("Y-m-d H:i:s"); | 144 | $currentdate = date("Y-m-d H:i:s"); |
555 | 145 | $requestUri = Kit::GetParam('REQUEST_URI', $_SERVER, _STRING, 'Not Supplied'); | 145 | $requestUri = Kit::GetParam('REQUEST_URI', $_SERVER, _STRING, 'Not Supplied'); |
556 | 146 | $requestIp = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING, 'Not Supplied'); | 146 | $requestIp = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING, 'Not Supplied'); |
557 | 147 | $requestUserAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'Not Supplied'); | 147 | $requestUserAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'Not Supplied'); |
558 | 148 | $requestUserAgent = substr($requestUserAgent, 0, 253); | 148 | $requestUserAgent = substr($requestUserAgent, 0, 253); |
604 | 149 | $userid = Kit::GetParam('userid', _SESSION, _INT, 0); | 149 | $userid = Kit::GetParam('userid', _SESSION, _INT, 0); |
605 | 150 | $message = Kit::ValidateParam($message, _HTMLSTRING); | 150 | $message = Kit::ValidateParam($message, _HTMLSTRING); |
606 | 151 | 151 | ||
607 | 152 | if ($logdate == "") | 152 | if ($logdate == "") |
608 | 153 | $logdate = $currentdate; | 153 | $logdate = $currentdate; |
609 | 154 | 154 | ||
610 | 155 | //Prepare the variables | 155 | //Prepare the variables |
611 | 156 | if ($page == "") | 156 | if ($page == "") |
612 | 157 | $page = Kit::GetParam('p', _GET, _WORD); | 157 | $page = Kit::GetParam('p', _GET, _WORD); |
613 | 158 | 158 | ||
614 | 159 | // Insert into the DB | 159 | // Insert into the DB |
615 | 160 | try { | 160 | try { |
616 | 161 | $dbh = PDOConnect::init(); | 161 | $dbh = PDOConnect::init(); |
617 | 162 | 162 | ||
618 | 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) '; |
619 | 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) '; |
620 | 165 | 165 | ||
621 | 166 | $sth = $dbh->prepare($SQL); | 166 | $sth = $dbh->prepare($SQL); |
622 | 167 | 167 | ||
623 | 168 | $params = array( | 168 | $params = array( |
624 | 169 | 'logdate' => $currentdate, | 169 | 'logdate' => $currentdate, |
625 | 170 | 'type' => $type, | 170 | 'type' => $type, |
626 | 171 | 'page' => $page, | 171 | 'page' => $page, |
627 | 172 | 'function' => $function, | 172 | 'function' => $function, |
628 | 173 | 'message' => $message, | 173 | 'message' => $message, |
629 | 174 | 'requesturi' => $requestUri, | 174 | 'requesturi' => $requestUri, |
630 | 175 | 'remoteaddr' => $requestIp, | 175 | 'remoteaddr' => $requestIp, |
631 | 176 | 'useragent' => $requestUserAgent, | 176 | 'useragent' => $requestUserAgent, |
632 | 177 | 'userid' => $userid, | 177 | 'userid' => $userid, |
633 | 178 | 'displayid' => $displayid, | 178 | 'displayid' => $displayid, |
634 | 179 | 'scheduleid' => $scheduleID, | 179 | 'scheduleid' => $scheduleID, |
635 | 180 | 'layoutid' => $layoutid, | 180 | 'layoutid' => $layoutid, |
636 | 181 | 'mediaid' => $mediaid | 181 | 'mediaid' => $mediaid |
637 | 182 | ); | 182 | ); |
638 | 183 | 183 | ||
639 | 184 | $sth->execute($params); | 184 | $sth->execute($params); |
640 | 185 | } | 185 | } |
641 | 186 | catch (PDOException $e) { | 186 | catch (PDOException $e) { |
642 | 187 | // In this case just silently log the error | 187 | // In this case just silently log the error |
643 | 188 | error_log($message . '\n\n', 3, './err_log.xml'); | 188 | error_log($message . '\n\n', 3, './err_log.xml'); |
644 | 189 | error_log($e->getMessage() . '\n\n', 3, './err_log.xml'); | 189 | error_log($e->getMessage() . '\n\n', 3, './err_log.xml'); |
645 | 190 | } | 190 | } |
646 | 191 | 191 | ||
647 | 192 | return true; | 192 | return true; |
648 | 193 | } | 193 | } |
649 | 194 | |||
650 | 195 | public static function Audit($message) { | ||
651 | 196 | if (!AUDIT) | ||
652 | 197 | return; | ||
653 | 198 | |||
654 | 199 | // Get the calling class / function | ||
655 | 200 | $trace = debug_backtrace(); | ||
656 | 201 | $caller = $trace[1]; | ||
657 | 202 | |||
658 | 203 | Debug::LogEntry('audit', $message, (isset($caller['class'])) ? $caller['class'] : 'Global', $caller['function']); | ||
659 | 204 | } | ||
660 | 194 | } | 205 | } |
661 | 195 | ?> | ||
662 | 196 | \ No newline at end of file | 206 | \ No newline at end of file |
663 | 207 | ?> | ||
664 | 197 | 208 | ||
665 | === modified file 'server/lib/app/kit.class.php' | |||
666 | --- server/lib/app/kit.class.php 2014-09-19 12:55:15 +0000 | |||
667 | +++ server/lib/app/kit.class.php 2014-10-21 16:06:16 +0000 | |||
668 | @@ -45,381 +45,388 @@ | |||
669 | 45 | 45 | ||
670 | 46 | class Kit | 46 | class Kit |
671 | 47 | { | 47 | { |
1033 | 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) |
1034 | 49 | static function Redirect($page, $message = '') | 49 | static function Redirect($page, $message = '') |
1035 | 50 | { | 50 | { |
1036 | 51 | $url = $page; | 51 | $url = $page; |
1037 | 52 | $ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false); | 52 | $ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false); |
1038 | 53 | 53 | ||
1039 | 54 | if ($ajax) | 54 | if ($ajax) |
1040 | 55 | { | 55 | { |
1041 | 56 | echo json_encode($page); | 56 | echo json_encode($page); |
1042 | 57 | die(); | 57 | die(); |
1043 | 58 | } | 58 | } |
1044 | 59 | 59 | ||
1045 | 60 | // Header or JS redirect | 60 | // Header or JS redirect |
1046 | 61 | if (headers_sent()) | 61 | if (headers_sent()) |
1047 | 62 | { | 62 | { |
1048 | 63 | echo "<script>document.location.href='$url';</script>\n"; | 63 | echo "<script>document.location.href='$url';</script>\n"; |
1049 | 64 | } | 64 | } |
1050 | 65 | else | 65 | else |
1051 | 66 | { | 66 | { |
1052 | 67 | header( 'HTTP/1.1 302 Moved Temporarily' ); | 67 | header( 'HTTP/1.1 302 Moved Temporarily' ); |
1053 | 68 | header( 'Location: ' . $url ); | 68 | header( 'Location: ' . $url ); |
1054 | 69 | } | 69 | } |
1055 | 70 | 70 | ||
1056 | 71 | die(); | 71 | die(); |
1057 | 72 | } | 72 | } |
1058 | 73 | 73 | ||
1059 | 74 | /** | 74 | /** |
1060 | 75 | * Gets the appropriate Param, making sure its valid | 75 | * Gets the appropriate Param, making sure its valid |
1061 | 76 | * Based on code from Joomla! 1.5 | 76 | * Based on code from Joomla! 1.5 |
1062 | 77 | * @return | 77 | * @return |
1063 | 78 | * @param $param Object | 78 | * @param $param Object |
1064 | 79 | * @param $source Object[optional] | 79 | * @param $source Object[optional] |
1065 | 80 | * @param $type Object[optional] | 80 | * @param $type Object[optional] |
1066 | 81 | * @param $default Object[optional] | 81 | * @param $default Object[optional] |
1067 | 82 | */ | 82 | */ |
1068 | 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) |
1069 | 84 | { | 84 | { |
1070 | 85 | // lower case param (we dont care) | 85 | // lower case param (we dont care) |
1071 | 86 | $param = strtolower($param); | 86 | $param = strtolower($param); |
1072 | 87 | 87 | ||
1073 | 88 | if (is_array($source)) | 88 | if (is_array($source)) |
1074 | 89 | { | 89 | { |
1075 | 90 | $source = array_change_key_case($source); | 90 | $source = array_change_key_case($source); |
1076 | 91 | 91 | ||
1077 | 92 | if(!isset($source[$param])) | 92 | if(!isset($source[$param])) |
1078 | 93 | { | 93 | { |
1079 | 94 | $return = $default; | 94 | $return = $default; |
1080 | 95 | } | 95 | } |
1081 | 96 | else | 96 | else |
1082 | 97 | { | 97 | { |
1083 | 98 | $return = $source[$param]; | 98 | $return = $source[$param]; |
1084 | 99 | } | 99 | } |
1085 | 100 | } | 100 | } |
1086 | 101 | else | 101 | else |
1087 | 102 | { | 102 | { |
1088 | 103 | switch ($source) | 103 | switch ($source) |
1089 | 104 | { | 104 | { |
1090 | 105 | case 'session': | 105 | case 'session': |
1091 | 106 | 106 | ||
1092 | 107 | if (isset($_SESSION)) | 107 | if (isset($_SESSION)) |
1093 | 108 | $_tempSESSION = array_change_key_case($_SESSION); | 108 | $_tempSESSION = array_change_key_case($_SESSION); |
1094 | 109 | 109 | ||
1095 | 110 | if(!isset($_tempSESSION[$param])) | 110 | if(!isset($_tempSESSION[$param])) |
1096 | 111 | { | 111 | { |
1097 | 112 | $return = $default; | 112 | $return = $default; |
1098 | 113 | } | 113 | } |
1099 | 114 | else if ($type == _CHECKBOX) | 114 | else if ($type == _CHECKBOX) |
1100 | 115 | { | 115 | { |
1101 | 116 | // this means that it was defined correctly and it was set | 116 | // this means that it was defined correctly and it was set |
1102 | 117 | $return = 1; | 117 | $return = 1; |
1103 | 118 | } | 118 | } |
1104 | 119 | else | 119 | else |
1105 | 120 | { | 120 | { |
1106 | 121 | if ($_tempSESSION[$param] == '') | 121 | if ($_tempSESSION[$param] == '') |
1107 | 122 | { | 122 | { |
1108 | 123 | $return = $default; | 123 | $return = $default; |
1109 | 124 | } | 124 | } |
1110 | 125 | else | 125 | else |
1111 | 126 | { | 126 | { |
1112 | 127 | $return = $_tempSESSION[$param]; | 127 | $return = $_tempSESSION[$param]; |
1113 | 128 | } | 128 | } |
1114 | 129 | } | 129 | } |
1115 | 130 | 130 | ||
1116 | 131 | break; | 131 | break; |
1117 | 132 | 132 | ||
1118 | 133 | case 'request': | 133 | case 'request': |
1119 | 134 | 134 | ||
1120 | 135 | $_tempREQUEST = array_change_key_case($_REQUEST); | 135 | $_tempREQUEST = array_change_key_case($_REQUEST); |
1121 | 136 | 136 | ||
1122 | 137 | if(!isset($_tempREQUEST[$param])) | 137 | if(!isset($_tempREQUEST[$param])) |
1123 | 138 | { | 138 | { |
1124 | 139 | $return = $default; | 139 | $return = $default; |
1125 | 140 | } | 140 | } |
1126 | 141 | else | 141 | else |
1127 | 142 | { | 142 | { |
1128 | 143 | if ($_tempREQUEST[$param] == '') | 143 | if ($_tempREQUEST[$param] == '') |
1129 | 144 | { | 144 | { |
1130 | 145 | $return = $default; | 145 | $return = $default; |
1131 | 146 | } | 146 | } |
1132 | 147 | else | 147 | else |
1133 | 148 | { | 148 | { |
1134 | 149 | $return = $_tempREQUEST[$param]; | 149 | $return = $_tempREQUEST[$param]; |
1135 | 150 | } | 150 | } |
1136 | 151 | } | 151 | } |
1137 | 152 | 152 | ||
1138 | 153 | break; | 153 | break; |
1139 | 154 | 154 | ||
1140 | 155 | case 'get': | 155 | case 'get': |
1141 | 156 | 156 | ||
1142 | 157 | $_tempGET = array_change_key_case($_GET); | 157 | $_tempGET = array_change_key_case($_GET); |
1143 | 158 | 158 | ||
1144 | 159 | if(!isset($_tempGET[$param])) | 159 | if(!isset($_tempGET[$param])) |
1145 | 160 | { | 160 | { |
1146 | 161 | $return = $default; | 161 | $return = $default; |
1147 | 162 | } | 162 | } |
1148 | 163 | else | 163 | else |
1149 | 164 | { | 164 | { |
1150 | 165 | if ($_tempGET[$param] == '') | 165 | if ($_tempGET[$param] == '') |
1151 | 166 | { | 166 | { |
1152 | 167 | $return = $default; | 167 | $return = $default; |
1153 | 168 | } | 168 | } |
1154 | 169 | else | 169 | else |
1155 | 170 | { | 170 | { |
1156 | 171 | $return = $_tempGET[$param]; | 171 | $return = $_tempGET[$param]; |
1157 | 172 | } | 172 | } |
1158 | 173 | } | 173 | } |
1159 | 174 | 174 | ||
1160 | 175 | break; | 175 | break; |
1161 | 176 | 176 | ||
1162 | 177 | case 'post': | 177 | case 'post': |
1163 | 178 | 178 | ||
1164 | 179 | $_tempPOST = array_change_key_case($_POST); | 179 | $_tempPOST = array_change_key_case($_POST); |
1165 | 180 | 180 | ||
1166 | 181 | if(!isset($_tempPOST[$param])) | 181 | if(!isset($_tempPOST[$param])) |
1167 | 182 | { | 182 | { |
1168 | 183 | $return = $default; | 183 | $return = $default; |
1169 | 184 | } | 184 | } |
1170 | 185 | else if ($type == _CHECKBOX) | 185 | else if ($type == _CHECKBOX) |
1171 | 186 | { | 186 | { |
1172 | 187 | // this means that it was defined correctly and it was set | 187 | // this means that it was defined correctly and it was set |
1173 | 188 | $return = 1; | 188 | $return = 1; |
1174 | 189 | } | 189 | } |
1175 | 190 | else | 190 | else |
1176 | 191 | { | 191 | { |
1177 | 192 | if ($_tempPOST[$param] == '') | 192 | if ($_tempPOST[$param] == '') |
1178 | 193 | { | 193 | { |
1179 | 194 | $return = $default; | 194 | $return = $default; |
1180 | 195 | } | 195 | } |
1181 | 196 | else | 196 | else |
1182 | 197 | { | 197 | { |
1183 | 198 | $return = $_tempPOST[$param]; | 198 | $return = $_tempPOST[$param]; |
1184 | 199 | } | 199 | } |
1185 | 200 | } | 200 | } |
1186 | 201 | 201 | ||
1187 | 202 | break; | 202 | break; |
1188 | 203 | 203 | ||
1189 | 204 | default: | 204 | default: |
1190 | 205 | return $default; | 205 | return $default; |
1191 | 206 | } | 206 | } |
1192 | 207 | } | 207 | } |
1193 | 208 | 208 | ||
1194 | 209 | // Validate this param | 209 | // Validate this param |
1195 | 210 | return Kit::ValidateParam($return, $type, $sanitize); | 210 | return Kit::ValidateParam($return, $type, $sanitize); |
1196 | 211 | } | 211 | } |
1197 | 212 | 212 | ||
1198 | 213 | /** | 213 | /** |
1199 | 214 | * Validates a Parameter | 214 | * Validates a Parameter |
1200 | 215 | * Based on code from Joomla! 1.5 | 215 | * Based on code from Joomla! 1.5 |
1201 | 216 | * @return | 216 | * @return |
1202 | 217 | * @param $param Object | 217 | * @param $param Object |
1203 | 218 | * @param $type Object | 218 | * @param $type Object |
1204 | 219 | */ | 219 | */ |
1205 | 220 | static function ValidateParam($param, $type, $sanitize = true) | 220 | static function ValidateParam($param, $type, $sanitize = true) |
1206 | 221 | { | 221 | { |
1207 | 222 | // If we are a NULL always return a null?? | 222 | // If we are a NULL always return a null?? |
1208 | 223 | //if ($param == NULL || $param == '') | 223 | //if ($param == NULL || $param == '') |
1209 | 224 | // return NULL; | 224 | // return NULL; |
1210 | 225 | 225 | ||
1211 | 226 | // Store in return var | 226 | // Store in return var |
1212 | 227 | $return = $param; | 227 | $return = $param; |
1213 | 228 | 228 | ||
1214 | 229 | // Validate | 229 | // Validate |
1215 | 230 | // Handle the type constraint | 230 | // Handle the type constraint |
1216 | 231 | switch ($type) | 231 | switch ($type) |
1217 | 232 | { | 232 | { |
1218 | 233 | case _INT : | 233 | case _INT : |
1219 | 234 | 234 | ||
1220 | 235 | if ($sanitize) { | 235 | if ($sanitize) { |
1221 | 236 | // Only use the first integer value | 236 | // Only use the first integer value |
1222 | 237 | if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_INT)) | 237 | if (!$return = filter_var($return, FILTER_SANITIZE_NUMBER_INT)) |
1223 | 238 | $return = 0; | 238 | $return = 0; |
1224 | 239 | } | 239 | } |
1225 | 240 | else { | 240 | else { |
1226 | 241 | if (!$return = filter_var($return, FILTER_VALIDATE_INT)) | 241 | if (!$return = filter_var($return, FILTER_VALIDATE_INT)) |
1227 | 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); |
1228 | 243 | } | 243 | } |
1229 | 244 | 244 | ||
1230 | 245 | break; | 245 | break; |
1231 | 246 | 246 | ||
1232 | 247 | case _DOUBLE : | 247 | case _DOUBLE : |
1233 | 248 | 248 | ||
1234 | 249 | if ($sanitize) { | 249 | if ($sanitize) { |
1235 | 250 | // Only use the first integer value | 250 | // Only use the first integer value |
1236 | 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)) |
1237 | 252 | $return = 0; | 252 | $return = 0; |
1238 | 253 | } | 253 | } |
1239 | 254 | else { | 254 | else { |
1240 | 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)) |
1241 | 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); |
1242 | 257 | } | 257 | } |
1243 | 258 | 258 | ||
1244 | 259 | break; | 259 | break; |
1245 | 260 | 260 | ||
1246 | 261 | case _BOOL : | 261 | case _BOOL : |
1247 | 262 | $return = filter_var($return, FILTER_VALIDATE_BOOLEAN); | 262 | $return = filter_var($return, FILTER_VALIDATE_BOOLEAN); |
1248 | 263 | break; | 263 | break; |
1249 | 264 | 264 | ||
1250 | 265 | case _ARRAY : | 265 | case _ARRAY : |
1251 | 266 | if ($return == '') | 266 | if ($return == '') |
1252 | 267 | { | 267 | { |
1253 | 268 | $return = array(); | 268 | $return = array(); |
1254 | 269 | break; | 269 | break; |
1255 | 270 | } | 270 | } |
1256 | 271 | 271 | ||
1257 | 272 | if (!is_array($return)) | 272 | if (!is_array($return)) |
1258 | 273 | { | 273 | { |
1259 | 274 | $return = array($return); | 274 | $return = array($return); |
1260 | 275 | } | 275 | } |
1261 | 276 | break; | 276 | break; |
1262 | 277 | 277 | ||
1263 | 278 | case _ARRAY_INT: | 278 | case _ARRAY_INT: |
1264 | 279 | 279 | ||
1265 | 280 | if ($return == '') { | 280 | if ($return == '') { |
1266 | 281 | $return = array(); | 281 | $return = array(); |
1267 | 282 | } | 282 | } |
1268 | 283 | else { | 283 | else { |
1269 | 284 | if ($sanitize) { | 284 | if ($sanitize) { |
1270 | 285 | // Only use the first integer value | 285 | // Only use the first integer value |
1271 | 286 | if (!$return = filter_var_array($return, FILTER_SANITIZE_NUMBER_INT)) | 286 | if (!$return = filter_var_array($return, FILTER_SANITIZE_NUMBER_INT)) |
1272 | 287 | $return = array(); | 287 | $return = array(); |
1273 | 288 | } | 288 | } |
1274 | 289 | else { | 289 | else { |
1275 | 290 | if (!$return = filter_var_array($return, FILTER_VALIDATE_INT)) | 290 | if (!$return = filter_var_array($return, FILTER_VALIDATE_INT)) |
1276 | 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); |
1277 | 292 | } | 292 | } |
1278 | 293 | } | 293 | } |
1279 | 294 | break; | 294 | break; |
1280 | 295 | 295 | ||
1281 | 296 | case _STRING : | 296 | case _STRING : |
1282 | 297 | case _PASSWORD : | 297 | case _PASSWORD : |
1283 | 298 | $return = filter_var($return, FILTER_SANITIZE_STRING); | 298 | $return = filter_var($return, FILTER_SANITIZE_STRING); |
1284 | 299 | break; | 299 | break; |
1285 | 300 | 300 | ||
1286 | 301 | case _STRINGSPECIAL: | 301 | case _STRINGSPECIAL: |
1287 | 302 | $return = filter_var($return, FILTER_SANITIZE_SPECIAL_CHARS); | 302 | $return = filter_var($return, FILTER_SANITIZE_SPECIAL_CHARS); |
1288 | 303 | break; | 303 | break; |
1289 | 304 | 304 | ||
1290 | 305 | case _HTMLSTRING : | 305 | case _HTMLSTRING : |
1291 | 306 | 306 | ||
1292 | 307 | // decimal notation | 307 | // decimal notation |
1293 | 308 | $return = preg_replace_callback('/&#(\d+);/m', function($m){ | 308 | $return = preg_replace_callback('/&#(\d+);/m', function($m){ |
1294 | 309 | return chr($m[1]); | 309 | return chr($m[1]); |
1295 | 310 | }, $return); | 310 | }, $return); |
1296 | 311 | 311 | ||
1297 | 312 | // convert hex | 312 | // convert hex |
1298 | 313 | $return = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){ | 313 | $return = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){ |
1299 | 314 | return chr("0x".$m[1]); | 314 | return chr("0x".$m[1]); |
1300 | 315 | }, $return); | 315 | }, $return); |
1301 | 316 | 316 | ||
1302 | 317 | $return = (string) $return; | 317 | $return = (string) $return; |
1303 | 318 | break; | 318 | break; |
1304 | 319 | 319 | ||
1305 | 320 | case _WORD : | 320 | case _WORD : |
1306 | 321 | $return = filter_var($return, FILTER_SANITIZE_STRING); | 321 | $return = filter_var($return, FILTER_SANITIZE_STRING); |
1307 | 322 | $return = (string) preg_replace( '/[^A-Z_\-]/i', '', $return ); | 322 | $return = (string) preg_replace( '/[^A-Z_\-]/i', '', $return ); |
1308 | 323 | break; | 323 | break; |
1309 | 324 | 324 | ||
1310 | 325 | case _USERNAME : | 325 | case _USERNAME : |
1311 | 326 | $return = filter_var($return, FILTER_SANITIZE_STRING); | 326 | $return = filter_var($return, FILTER_SANITIZE_STRING); |
1312 | 327 | $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return ); | 327 | $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return ); |
1313 | 328 | $return = strtolower($return); | 328 | $return = strtolower($return); |
1314 | 329 | break; | 329 | break; |
1315 | 330 | 330 | ||
1316 | 331 | case _FILENAME : | 331 | case _FILENAME : |
1317 | 332 | if ($return == '') | 332 | if ($return == '') |
1318 | 333 | { | 333 | { |
1319 | 334 | $return = ''; | 334 | $return = ''; |
1320 | 335 | break; | 335 | break; |
1321 | 336 | } | 336 | } |
1322 | 337 | // Remove non alphanumerics | 337 | // Remove non alphanumerics |
1323 | 338 | $return = strtolower($return); | 338 | $return = strtolower($return); |
1324 | 339 | $code_entities_match = array('"' ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'+' ,'{' ,'}' ,'|' ,':' ,'"' ,'<' ,'>' ,'?' ,'[' ,']' ,'' ,';' ,"'" ,',' ,'_' ,'/' ,'*' ,'+' ,'~' ,'`' ,'=' ,' ' ,'---' ,'--','--'); | 339 | $code_entities_match = array('"' ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'+' ,'{' ,'}' ,'|' ,':' ,'"' ,'<' ,'>' ,'?' ,'[' ,']' ,'' ,';' ,"'" ,',' ,'_' ,'/' ,'*' ,'+' ,'~' ,'`' ,'=' ,' ' ,'---' ,'--','--'); |
1325 | 340 | $code_entities_replace = array('' ,'-' ,'-' ,'' ,'' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-','-'); | 340 | $code_entities_replace = array('' ,'-' ,'-' ,'' ,'' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-','-'); |
1326 | 341 | 341 | ||
1327 | 342 | $return = str_replace($code_entities_match, $code_entities_replace, $return); | 342 | $return = str_replace($code_entities_match, $code_entities_replace, $return); |
1328 | 343 | break; | 343 | break; |
1329 | 344 | 344 | ||
1330 | 345 | case _URI : | 345 | case _URI : |
1331 | 346 | if ($return == '') | 346 | if ($return == '') |
1332 | 347 | { | 347 | { |
1333 | 348 | $return = ''; | 348 | $return = ''; |
1334 | 349 | break; | 349 | break; |
1335 | 350 | } | 350 | } |
1336 | 351 | $return = urlencode($return); | 351 | $return = urlencode($return); |
1337 | 352 | break; | 352 | break; |
1338 | 353 | 353 | ||
1339 | 354 | case _CHECKBOX: | 354 | case _CHECKBOX: |
1340 | 355 | if ($return == 'on') { | 355 | if ($return == 'on') { |
1341 | 356 | $return = 1; | 356 | $return = 1; |
1342 | 357 | } | 357 | } |
1343 | 358 | if ($return == 'off' || $return == '') { | 358 | if ($return == 'off' || $return == '') { |
1344 | 359 | $return = 0; | 359 | $return = 0; |
1345 | 360 | } | 360 | } |
1346 | 361 | 361 | ||
1347 | 362 | break; | 362 | break; |
1348 | 363 | 363 | ||
1349 | 364 | default : | 364 | default : |
1350 | 365 | // No casting necessary | 365 | // No casting necessary |
1351 | 366 | if (!$sanitize) | 366 | if (!$sanitize) |
1352 | 367 | trigger_error(sprintf(__('Unknown Type %s'), $type), E_USER_ERROR); | 367 | trigger_error(sprintf(__('Unknown Type %s'), $type), E_USER_ERROR); |
1353 | 368 | 368 | ||
1354 | 369 | break; | 369 | break; |
1355 | 370 | } | 370 | } |
1356 | 371 | 371 | ||
1357 | 372 | return $return; | 372 | return $return; |
1358 | 373 | } | 373 | } |
1359 | 374 | 374 | ||
1360 | 375 | /** | 375 | /** |
1361 | 376 | * Gets a formatted Url | 376 | * Gets a formatted Url |
1362 | 377 | * @return | 377 | * @return |
1363 | 378 | * @param $page Object[optional] | 378 | * @param $page Object[optional] |
1364 | 379 | */ | 379 | */ |
1365 | 380 | public static function GetURL($page = "") | 380 | public static function GetURL($page = "") |
1366 | 381 | { | 381 | { |
1367 | 382 | $page = Kit::ValidateParam($page, _WORD); | 382 | $page = Kit::ValidateParam($page, _WORD); |
1368 | 383 | $fullUrl = 'http'; | 383 | $fullUrl = 'http'; |
1369 | 384 | 384 | ||
1370 | 385 | if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') | 385 | if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') |
1371 | 386 | { | 386 | { |
1372 | 387 | $fullUrl .= 's'; | 387 | $fullUrl .= 's'; |
1373 | 388 | } | 388 | } |
1374 | 389 | 389 | ||
1375 | 390 | $fullUrl .= '://'; | 390 | $fullUrl .= '://'; |
1376 | 391 | 391 | ||
1377 | 392 | if($_SERVER['SERVER_PORT']!='80') | 392 | if($_SERVER['SERVER_PORT']!='80') |
1378 | 393 | { | 393 | { |
1379 | 394 | $fullUrl .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME']; | 394 | $fullUrl .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME']; |
1380 | 395 | } | 395 | } |
1381 | 396 | else | 396 | else |
1382 | 397 | { | 397 | { |
1383 | 398 | $fullUrl .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; | 398 | $fullUrl .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; |
1384 | 399 | } | 399 | } |
1385 | 400 | 400 | ||
1386 | 401 | // Append the page if its not empty | 401 | // Append the page if its not empty |
1387 | 402 | if ($page != '') | 402 | if ($page != '') |
1388 | 403 | { | 403 | { |
1389 | 404 | $fullUrl .= '?p=' . $page; | 404 | $fullUrl .= '?p=' . $page; |
1390 | 405 | } | 405 | } |
1391 | 406 | 406 | ||
1392 | 407 | return $fullUrl; | 407 | return $fullUrl; |
1393 | 408 | } | 408 | } |
1394 | 409 | 409 | ||
1395 | 410 | /** | 410 | /** |
1397 | 411 | * Ensures a the relevant file for a class is inclued | 411 | * Ensures a the relevant file for a class is included |
1398 | 412 | * @param <string> $class | 412 | * @param <string> $class |
1399 | 413 | * @return <boolean> False on failure | 413 | * @return <boolean> False on failure |
1400 | 414 | */ | 414 | */ |
1401 | 415 | static function ClassLoader($class) | 415 | static function ClassLoader($class) |
1403 | 416 | { | 416 | { |
1404 | 417 | if (class_exists($class)) | 417 | if (class_exists($class)) |
1405 | 418 | return; | 418 | return; |
1406 | 419 | 419 | ||
1407 | 420 | $class = strtolower($class); | 420 | $class = strtolower($class); |
1408 | 421 | 421 | ||
1410 | 422 | // It doesnt already exist - so lets look in some places to try and find it | 422 | if (strpos($class, 'manager')) { |
1411 | 423 | // Load from app | ||
1412 | 424 | if (file_exists('lib/app/' . $class . '.class.php')) { | ||
1413 | 425 | include_once('lib/app/' . $class . '.class.php'); | ||
1414 | 426 | } | ||
1415 | 427 | } | ||
1416 | 428 | |||
1417 | 429 | // It doesn't already exist - so lets look in some places to try and find it | ||
1418 | 423 | if (file_exists('lib/pages/' . $class . '.class.php')) | 430 | if (file_exists('lib/pages/' . $class . '.class.php')) |
1419 | 424 | { | 431 | { |
1420 | 425 | include_once('lib/pages/' . $class . '.class.php'); | 432 | include_once('lib/pages/' . $class . '.class.php'); |
1421 | @@ -444,7 +451,7 @@ | |||
1422 | 444 | { | 451 | { |
1423 | 445 | include_once('lib/service/' . $class . '.class.php'); | 452 | include_once('lib/service/' . $class . '.class.php'); |
1424 | 446 | } | 453 | } |
1426 | 447 | } | 454 | } |
1427 | 448 | 455 | ||
1428 | 449 | /** | 456 | /** |
1429 | 450 | * GetXiboRoot | 457 | * GetXiboRoot |
1430 | @@ -570,85 +577,89 @@ | |||
1431 | 570 | } | 577 | } |
1432 | 571 | 578 | ||
1433 | 572 | public static function ReturnBytes($val) { | 579 | public static function ReturnBytes($val) { |
1514 | 573 | 580 | ||
1515 | 574 | $val = trim($val); | 581 | $val = trim($val); |
1516 | 575 | $last = strtolower($val[strlen($val)-1]); | 582 | $last = strtolower($val[strlen($val)-1]); |
1517 | 576 | switch($last) { | 583 | switch($last) { |
1518 | 577 | // The 'G' modifier is available since PHP 5.1.0 | 584 | // The 'G' modifier is available since PHP 5.1.0 |
1519 | 578 | case 'g': | 585 | case 'g': |
1520 | 579 | $val *= 1024; | 586 | $val *= 1024; |
1521 | 580 | case 'm': | 587 | case 'm': |
1522 | 581 | $val *= 1024; | 588 | $val *= 1024; |
1523 | 582 | case 'k': | 589 | case 'k': |
1524 | 583 | $val *= 1024; | 590 | $val *= 1024; |
1525 | 584 | } | 591 | } |
1526 | 585 | 592 | ||
1527 | 586 | return $val; | 593 | return $val; |
1528 | 587 | } | 594 | } |
1529 | 588 | 595 | ||
1530 | 589 | /** | 596 | /** |
1531 | 590 | * Creates a form token | 597 | * Creates a form token |
1532 | 591 | * @return | 598 | * @return |
1533 | 592 | */ | 599 | */ |
1534 | 593 | public static function Token($tokenName = "token") | 600 | public static function Token($tokenName = "token", $withInput = true) |
1535 | 594 | { | 601 | { |
1536 | 595 | //Store in the users session | 602 | //Store in the users session |
1537 | 596 | $token = md5(uniqid() . SECRET_KEY . time()); | 603 | $token = md5(uniqid() . SECRET_KEY . time()); |
1538 | 597 | 604 | ||
1539 | 598 | $_SESSION[$tokenName] = $token; | 605 | $_SESSION[$tokenName] = $token; |
1540 | 599 | $_SESSION[$tokenName.'_timeout'] = time(); | 606 | $_SESSION[$tokenName.'_timeout'] = time(); |
1541 | 600 | 607 | ||
1542 | 601 | return '<input type="hidden" name="' . $tokenName . '" value="' . $token . '">'; | 608 | if ($withInput) |
1543 | 602 | } | 609 | return '<input type="hidden" name="' . $tokenName . '" value="' . $token . '">'; |
1544 | 603 | 610 | else | |
1545 | 604 | /** | 611 | return $token; |
1546 | 605 | * Checks a form token | 612 | } |
1547 | 606 | * @param string token | 613 | |
1548 | 607 | * @return | 614 | /** |
1549 | 608 | */ | 615 | * Checks a form token |
1550 | 609 | public static function CheckToken($tokenName = "token") | 616 | * @param string token |
1551 | 610 | { | 617 | * @return |
1552 | 611 | if (!isset($_POST[$tokenName]) || !isset($_SESSION[$tokenName])) | 618 | */ |
1553 | 612 | return false; | 619 | public static function CheckToken($tokenName = "token") |
1554 | 613 | 620 | { | |
1555 | 614 | if ($_POST[$tokenName] == $_SESSION[$tokenName]) | 621 | if (!isset($_POST[$tokenName]) || !isset($_SESSION[$tokenName])) |
1556 | 615 | { | 622 | return false; |
1557 | 616 | // See if its still in Date | 623 | |
1558 | 617 | if (($_SESSION[$tokenName.'_timeout'] + 1200) <= time()) | 624 | if ($_POST[$tokenName] == $_SESSION[$tokenName]) |
1559 | 618 | { | 625 | { |
1560 | 619 | return false; | 626 | // See if its still in Date |
1561 | 620 | } | 627 | if (($_SESSION[$tokenName.'_timeout'] + 1200) <= time()) |
1562 | 621 | return true; | 628 | { |
1563 | 622 | } | 629 | return false; |
1564 | 623 | else | 630 | } |
1565 | 624 | { | 631 | return true; |
1566 | 625 | unset($_SESSION[$tokenName]); | 632 | } |
1567 | 626 | 633 | else | |
1568 | 627 | Debug::LogEntry('error', "Form token incorrect from: ". $_SERVER['REMOTE_ADDR']. " with token [" . $_POST[$tokenName] . "] for session_id [" . session_id() . ']'); | 634 | { |
1569 | 628 | return false; | 635 | unset($_SESSION[$tokenName]); |
1570 | 629 | } | 636 | |
1571 | 630 | } | 637 | Debug::LogEntry('error', "Form token incorrect from: ". $_SERVER['REMOTE_ADDR']. " with token [" . $_POST[$tokenName] . "] for session_id [" . session_id() . ']'); |
1572 | 631 | 638 | return false; | |
1573 | 632 | /** | 639 | } |
1574 | 633 | * Format Bytes | 640 | } |
1575 | 634 | * http://stackoverflow.com/questions/2510434/format-bytes-to-kilobytes-megabytes-gigabytes | 641 | |
1576 | 635 | * @param [int] $size The file size in bytes | 642 | /** |
1577 | 636 | * @param integer $precision The precision to go to | 643 | * Format Bytes |
1578 | 637 | * @return [string] The Formatted string with suffix | 644 | * http://stackoverflow.com/questions/2510434/format-bytes-to-kilobytes-megabytes-gigabytes |
1579 | 638 | */ | 645 | * @param [int] $size The file size in bytes |
1580 | 639 | public static function formatBytes($size, $precision = 2) { | 646 | * @param integer $precision The precision to go to |
1581 | 640 | 647 | * @return [string] The Formatted string with suffix | |
1582 | 641 | if ($size == 0) | 648 | */ |
1583 | 642 | return 0; | 649 | public static function formatBytes($size, $precision = 2) |
1584 | 643 | 650 | { | |
1585 | 644 | $base = log($size) / log(1024); | 651 | if ($size == 0) |
1586 | 645 | $suffixes = array('', 'k', 'M', 'G', 'T'); | 652 | return 0; |
1587 | 646 | 653 | ||
1588 | 647 | return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; | 654 | $base = log($size) / log(1024); |
1589 | 648 | } | 655 | $suffixes = array('', 'k', 'M', 'G', 'T'); |
1590 | 649 | 656 | ||
1591 | 650 | public static function uniqueId() { | 657 | return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; |
1592 | 651 | return uniqid(rand()); | 658 | } |
1593 | 652 | } | 659 | |
1594 | 660 | public static function uniqueId() | ||
1595 | 661 | { | ||
1596 | 662 | return uniqid(rand()); | ||
1597 | 663 | } | ||
1598 | 653 | } | 664 | } |
1599 | 654 | ?> | 665 | ?> |
1600 | 655 | 666 | ||
1601 | === modified file 'server/lib/app/modulemanager.class.php' | |||
1602 | --- server/lib/app/modulemanager.class.php 2014-03-08 14:41:11 +0000 | |||
1603 | +++ server/lib/app/modulemanager.class.php 2014-10-21 16:06:16 +0000 | |||
1604 | @@ -22,7 +22,6 @@ | |||
1605 | 22 | 22 | ||
1606 | 23 | class ModuleManager | 23 | class ModuleManager |
1607 | 24 | { | 24 | { |
1608 | 25 | private $db; | ||
1609 | 26 | private $user; | 25 | private $user; |
1610 | 27 | 26 | ||
1611 | 28 | public $message; | 27 | public $message; |
1612 | @@ -34,13 +33,11 @@ | |||
1613 | 34 | /** | 33 | /** |
1614 | 35 | * Constructs the Module Manager. | 34 | * Constructs the Module Manager. |
1615 | 36 | * @return | 35 | * @return |
1616 | 37 | * @param $db Object | ||
1617 | 38 | * @param $user Object | 36 | * @param $user Object |
1618 | 39 | */ | 37 | */ |
1620 | 40 | public function __construct(database $db, User $user, $regionSpecific = -1, $module = '', $assignable = 1) | 38 | public function __construct(User $user, $regionSpecific = -1, $module = '', $assignable = 1) |
1621 | 41 | { | 39 | { |
1624 | 42 | $this->db =& $db; | 40 | $this->user =& $user; |
1623 | 43 | $this->user =& $user; | ||
1625 | 44 | 41 | ||
1626 | 45 | if (!$this->theMenu = $user->ModuleAuth($regionSpecific, $module, $assignable)) | 42 | if (!$this->theMenu = $user->ModuleAuth($regionSpecific, $module, $assignable)) |
1627 | 46 | { | 43 | { |
1628 | 47 | 44 | ||
1629 | === modified file 'server/lib/app/permissionmanager.class.php' | |||
1630 | --- server/lib/app/permissionmanager.class.php 2014-01-18 09:47:41 +0000 | |||
1631 | +++ server/lib/app/permissionmanager.class.php 2014-10-21 16:06:16 +0000 | |||
1632 | @@ -22,7 +22,6 @@ | |||
1633 | 22 | 22 | ||
1634 | 23 | class PermissionManager | 23 | class PermissionManager |
1635 | 24 | { | 24 | { |
1636 | 25 | private $db; | ||
1637 | 26 | private $user; | 25 | private $user; |
1638 | 27 | 26 | ||
1639 | 28 | public $ownerId; | 27 | public $ownerId; |
1640 | @@ -38,9 +37,8 @@ | |||
1641 | 38 | * @param $db Object | 37 | * @param $db Object |
1642 | 39 | * @param $user Object | 38 | * @param $user Object |
1643 | 40 | */ | 39 | */ |
1645 | 41 | public function __construct(database $db, User $user) | 40 | public function __construct(User $user) |
1646 | 42 | { | 41 | { |
1647 | 43 | $this->db =& $db; | ||
1648 | 44 | $this->user =& $user; | 42 | $this->user =& $user; |
1649 | 45 | 43 | ||
1650 | 46 | $this->view = false; | 44 | $this->view = false; |
1651 | 47 | 45 | ||
1652 | === modified file 'server/lib/app/responsemanager.class.php' | |||
1653 | --- server/lib/app/responsemanager.class.php 2014-08-11 18:44:46 +0000 | |||
1654 | +++ server/lib/app/responsemanager.class.php 2014-10-21 16:06:16 +0000 | |||
1655 | @@ -54,6 +54,7 @@ | |||
1656 | 54 | public $focusInFirstInput; | 54 | public $focusInFirstInput; |
1657 | 55 | public $appendHiddenSubmit; | 55 | public $appendHiddenSubmit; |
1658 | 56 | public $modal; | 56 | public $modal; |
1659 | 57 | public $nextToken; | ||
1660 | 57 | 58 | ||
1661 | 58 | public $login; | 59 | public $login; |
1662 | 59 | public $clockUpdate; | 60 | public $clockUpdate; |
1663 | @@ -199,7 +200,7 @@ | |||
1664 | 199 | $this->message = $message; | 200 | $this->message = $message; |
1665 | 200 | $this->refresh = $refresh; | 201 | $this->refresh = $refresh; |
1666 | 201 | $this->refreshLocation = $refreshLocation; | 202 | $this->refreshLocation = $refreshLocation; |
1668 | 202 | 203 | $this->nextToken = Kit::Token(); | |
1669 | 203 | return; | 204 | return; |
1670 | 204 | } | 205 | } |
1671 | 205 | 206 | ||
1672 | @@ -317,6 +318,7 @@ | |||
1673 | 317 | $response['refreshLocation']= $this->refreshLocation; | 318 | $response['refreshLocation']= $this->refreshLocation; |
1674 | 318 | $response['focusInFirstInput']= $this->focusInFirstInput; | 319 | $response['focusInFirstInput']= $this->focusInFirstInput; |
1675 | 319 | $response['modal'] = $this->modal; | 320 | $response['modal'] = $this->modal; |
1676 | 321 | $response['nextToken'] = $this->nextToken; | ||
1677 | 320 | 322 | ||
1678 | 321 | // Login | 323 | // Login |
1679 | 322 | $response['login'] = $this->login; | 324 | $response['login'] = $this->login; |
1680 | 323 | 325 | ||
1681 | === modified file 'server/lib/app/session.class.php' | |||
1682 | --- server/lib/app/session.class.php 2014-06-15 14:39:41 +0000 | |||
1683 | +++ server/lib/app/session.class.php 2014-10-21 16:06:16 +0000 | |||
1684 | @@ -160,8 +160,9 @@ | |||
1685 | 160 | // we do not want to update the expiry time of a session if it is the Clock Timer going off | 160 | // we do not want to update the expiry time of a session if it is the Clock Timer going off |
1686 | 161 | $page = Kit::GetParam('p', _REQUEST, _WORD); | 161 | $page = Kit::GetParam('p', _REQUEST, _WORD); |
1687 | 162 | $query = Kit::GetParam('q', _REQUEST, _WORD); | 162 | $query = Kit::GetParam('q', _REQUEST, _WORD); |
1688 | 163 | $autoRefresh = (isset($_REQUEST['autoRefresh']) && Kit::GetParam('autoRefresh', _REQUEST, _WORD, 'false') == 'true'); | ||
1689 | 163 | 164 | ||
1691 | 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')) { |
1692 | 165 | 166 | ||
1693 | 166 | // Update the existing session without the expiry | 167 | // Update the existing session without the expiry |
1694 | 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 "; |
1695 | @@ -336,10 +337,16 @@ | |||
1696 | 336 | * @param type $secondKey | 337 | * @param type $secondKey |
1697 | 337 | * @return boolean | 338 | * @return boolean |
1698 | 338 | */ | 339 | */ |
1700 | 339 | public static function Get($key, $secondKey) | 340 | public static function Get($key, $secondKey = NULL) |
1701 | 340 | { | 341 | { |
1704 | 341 | if (isset($_SESSION[$key][$secondKey])) | 342 | if ($secondKey != NULL) { |
1705 | 342 | return $_SESSION[$key][$secondKey]; | 343 | if (isset($_SESSION[$key][$secondKey])) |
1706 | 344 | return $_SESSION[$key][$secondKey]; | ||
1707 | 345 | } | ||
1708 | 346 | else { | ||
1709 | 347 | if (isset($_SESSION[$key])) | ||
1710 | 348 | return $_SESSION[$key]; | ||
1711 | 349 | } | ||
1712 | 343 | 350 | ||
1713 | 344 | return false; | 351 | return false; |
1714 | 345 | } | 352 | } |
1715 | 346 | 353 | ||
1716 | === modified file 'server/lib/app/thememanager.class.php' | |||
1717 | --- server/lib/app/thememanager.class.php 2014-08-17 12:38:20 +0000 | |||
1718 | +++ server/lib/app/thememanager.class.php 2014-10-21 16:06:16 +0000 | |||
1719 | @@ -152,6 +152,46 @@ | |||
1720 | 152 | } | 152 | } |
1721 | 153 | 153 | ||
1722 | 154 | /** | 154 | /** |
1723 | 155 | * Get Item Path | ||
1724 | 156 | * @param string $item The Item required | ||
1725 | 157 | */ | ||
1726 | 158 | public static function ItemPath($item) { | ||
1727 | 159 | |||
1728 | 160 | $theme = Theme::GetInstance(); | ||
1729 | 161 | |||
1730 | 162 | // See if we have the requested file in the theme folder | ||
1731 | 163 | if (file_exists('theme/' . $theme->name . '/' . $item)) { | ||
1732 | 164 | return 'theme/' . $theme->name . '/' . $item; | ||
1733 | 165 | } | ||
1734 | 166 | // If not, then use the default folder | ||
1735 | 167 | elseif (file_exists('theme/default/' . $item)) { | ||
1736 | 168 | return 'theme/default/' . $item; | ||
1737 | 169 | } | ||
1738 | 170 | else | ||
1739 | 171 | return ''; | ||
1740 | 172 | } | ||
1741 | 173 | |||
1742 | 174 | /** | ||
1743 | 175 | * Get Item Path | ||
1744 | 176 | * @param string $item The Item required | ||
1745 | 177 | */ | ||
1746 | 178 | public static function Script($item) { | ||
1747 | 179 | |||
1748 | 180 | $theme = Theme::GetInstance(); | ||
1749 | 181 | |||
1750 | 182 | // See if we have the requested file in the theme folder | ||
1751 | 183 | if (file_exists('theme/' . $theme->name . '/' . $item)) { | ||
1752 | 184 | return '<script src="theme/' . $theme->name . '/' . $item . '"></script>'; | ||
1753 | 185 | } | ||
1754 | 186 | // If not, then use the default folder | ||
1755 | 187 | elseif (file_exists('theme/default/' . $item)) { | ||
1756 | 188 | return '<script src="theme/default/' . $item . '"></script>'; | ||
1757 | 189 | } | ||
1758 | 190 | else | ||
1759 | 191 | return ''; | ||
1760 | 192 | } | ||
1761 | 193 | |||
1762 | 194 | /** | ||
1763 | 155 | * Translate a string into the user language | 195 | * Translate a string into the user language |
1764 | 156 | * @param string $string The String to Translate | 196 | * @param string $string The String to Translate |
1765 | 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) |
1766 | @@ -181,6 +221,22 @@ | |||
1767 | 181 | return $return; | 221 | return $return; |
1768 | 182 | } | 222 | } |
1769 | 183 | 223 | ||
1770 | 224 | public static function SetTranslation($key, $value) { | ||
1771 | 225 | // Get existing translations | ||
1772 | 226 | $translations = Theme::Get('translations'); | ||
1773 | 227 | |||
1774 | 228 | if ($translations == '') { | ||
1775 | 229 | $translations = array(); | ||
1776 | 230 | } | ||
1777 | 231 | else { | ||
1778 | 232 | $translations = json_decode($translations, true); | ||
1779 | 233 | } | ||
1780 | 234 | |||
1781 | 235 | $translations[$key] = $value; | ||
1782 | 236 | |||
1783 | 237 | Theme::Set('translations', json_encode($translations)); | ||
1784 | 238 | } | ||
1785 | 239 | |||
1786 | 184 | public static function Prepare($string) { | 240 | public static function Prepare($string) { |
1787 | 185 | return htmlspecialchars($string); | 241 | return htmlspecialchars($string); |
1788 | 186 | } | 242 | } |
1789 | 187 | 243 | ||
1790 | === modified file 'server/lib/app/translationengine.class.php' | |||
1791 | --- server/lib/app/translationengine.class.php 2014-08-17 12:38:20 +0000 | |||
1792 | +++ server/lib/app/translationengine.class.php 2014-10-21 16:06:16 +0000 | |||
1793 | @@ -27,85 +27,86 @@ | |||
1794 | 27 | 27 | ||
1795 | 28 | class TranslationEngine | 28 | class TranslationEngine |
1796 | 29 | { | 29 | { |
1797 | 30 | private static $locale; | ||
1798 | 31 | private static $jsLocale; | ||
1799 | 32 | |||
1800 | 30 | /** | 33 | /** |
1801 | 31 | * Gets and Sets the Local | 34 | * Gets and Sets the Local |
1802 | 32 | * @return | 35 | * @return |
1803 | 33 | */ | 36 | */ |
1804 | 34 | public static function InitLocale($language = NULL) | 37 | public static function InitLocale($language = NULL) |
1805 | 35 | { | 38 | { |
1858 | 36 | $localeDir = 'locale'; | 39 | $localeDir = 'locale'; |
1859 | 37 | $default = ($language == NULL) ? Config::GetSetting('DEFAULT_LANGUAGE') : $language; | 40 | $default = ($language == NULL) ? Config::GetSetting('DEFAULT_LANGUAGE') : $language; |
1860 | 38 | 41 | ||
1861 | 39 | global $transEngine; | 42 | global $transEngine; |
1862 | 40 | global $stream; | 43 | global $stream; |
1863 | 41 | 44 | ||
1864 | 42 | //Debug::LogEntry('audit', 'IN', 'TranslationEngine', 'InitLocal'); | 45 | //Debug::LogEntry('audit', 'IN', 'TranslationEngine', 'InitLocal'); |
1865 | 43 | 46 | // Build an array of supported languages | |
1866 | 44 | // Try to get the local firstly from _REQUEST (post then get) | 47 | $supportedLangs = scandir($localeDir); |
1867 | 45 | $lang = Kit::GetParam('lang', _REQUEST, _WORD, ''); | 48 | |
1868 | 46 | 49 | // Try to get the local firstly from _REQUEST (post then get) | |
1869 | 47 | // Build an array of supported languages | 50 | $lang = Kit::GetParam('lang', _REQUEST, _WORD, ''); |
1870 | 48 | $supportedLangs = scandir($localeDir); | 51 | |
1871 | 49 | 52 | // If we don't have a language, try from HTTP accept | |
1872 | 50 | if ($lang != '') | 53 | if ($lang == '' && Config::GetSetting('DETECT_LANGUAGE') == 1) { |
1873 | 51 | { | 54 | $langs = Kit::GetParam('HTTP_ACCEPT_LANGUAGE', $_SERVER, _STRING); |
1874 | 52 | // Set the language | 55 | |
1875 | 53 | //Debug::LogEntry('audit', 'Set the Language from REQUEST [' . $lang . ']', 'TranslationEngine', 'InitLocal'); | 56 | if ($langs != '') { |
1876 | 54 | 57 | //Debug::LogEntry('audit', ' HTTP_ACCEPT_LANGUAGE [' . $langs . ']', 'TranslationEngine', 'InitLocal'); | |
1877 | 55 | // Is this language supported? | 58 | $langs = explode(',', $langs); |
1878 | 56 | // if not just use the default (eb_GB). | 59 | |
1879 | 57 | if (!in_array($lang . '.mo', $supportedLangs)) | 60 | foreach ($langs as $lang) { |
1880 | 58 | { | 61 | // Remove any quality rating (as we aren't interested) |
1881 | 59 | trigger_error(sprintf('Language not supported. %s', $lang)); | 62 | $rawLang = explode(';', $lang); |
1882 | 60 | 63 | $lang = str_replace('-', '_', $rawLang[0]); | |
1883 | 61 | // Use the default language instead. | 64 | |
1884 | 62 | $lang = $default; | 65 | if (in_array($lang . '.mo', $supportedLangs)) { |
1885 | 63 | } | 66 | //Debug::LogEntry('audit', 'Obtained the Language from HTTP_ACCEPT_LANGUAGE [' . $lang . ']', 'TranslationEngine', 'InitLocal'); |
1886 | 64 | } | 67 | break; |
1835 | 65 | else | ||
1836 | 66 | { | ||
1837 | 67 | $langs = Kit::GetParam('HTTP_ACCEPT_LANGUAGE', $_SERVER, _STRING); | ||
1838 | 68 | |||
1839 | 69 | if ($langs != '') | ||
1840 | 70 | { | ||
1841 | 71 | //Debug::LogEntry('audit', ' HTTP_ACCEPT_LANGUAGE [' . $langs . ']', 'TranslationEngine', 'InitLocal'); | ||
1842 | 72 | $langs = explode(',', $langs); | ||
1843 | 73 | |||
1844 | 74 | foreach ($langs as $lang) | ||
1845 | 75 | { | ||
1846 | 76 | // Remove any quality rating (as we aren't interested) | ||
1847 | 77 | $rawLang = explode(';', $lang); | ||
1848 | 78 | $lang = str_replace("-", "_", $rawLang[0]); | ||
1849 | 79 | |||
1850 | 80 | if (in_array($lang . '.mo', $supportedLangs)) | ||
1851 | 81 | { | ||
1852 | 82 | //Debug::LogEntry('audit', 'Obtained the Language from HTTP_ACCEPT_LANGUAGE [' . $lang . ']', 'TranslationEngine', 'InitLocal'); | ||
1853 | 83 | break; | ||
1854 | 84 | } | ||
1855 | 85 | |||
1856 | 86 | // Set lang as the default | ||
1857 | 87 | $lang = $default; | ||
1887 | 88 | } | 68 | } |
1891 | 89 | } | 69 | |
1892 | 90 | else | 70 | // Set lang as the default |
1890 | 91 | { | ||
1893 | 92 | $lang = $default; | 71 | $lang = $default; |
1894 | 93 | } | 72 | } |
1895 | 94 | } | 73 | } |
1909 | 95 | 74 | } | |
1910 | 96 | // We have the language | 75 | |
1911 | 97 | //Debug::LogEntry('audit', 'Creating new file streamer for '. $localeDir . '/' . $lang . '.mo', 'TranslationEngine', 'InitLocal'); | 76 | // Are we still empty? |
1912 | 98 | 77 | if ($lang == '') | |
1913 | 99 | if (!$stream = new CachedFileReader($localeDir . '/' . $lang . '.mo')) | 78 | $lang = $default; |
1914 | 100 | { | 79 | |
1915 | 101 | trigger_error('Unable to translate this language'); | 80 | // Sanitize it |
1916 | 102 | $transEngine = false; | 81 | $lang = str_replace('-', '_', $lang); |
1917 | 103 | 82 | $jsLang = str_replace('_', '-', $lang); | |
1918 | 104 | return; | 83 | |
1919 | 105 | } | 84 | // Check its valid |
1920 | 106 | 85 | if (!in_array($lang . '.mo', $supportedLangs)) { | |
1921 | 107 | $transEngine = new gettext_reader($stream); | 86 | trigger_error(sprintf('Language not supported. %s', $lang)); |
1922 | 87 | |||
1923 | 88 | // Fall back | ||
1924 | 89 | $lang = 'en_GB'; | ||
1925 | 90 | } | ||
1926 | 91 | |||
1927 | 92 | //Debug::LogEntry('audit', 'Creating new file streamer for '. $localeDir . '/' . $lang . '.mo', 'TranslationEngine', 'InitLocal'); | ||
1928 | 93 | if (!$stream = new CachedFileReader($localeDir . '/' . $lang . '.mo')) { | ||
1929 | 94 | $transEngine = false; | ||
1930 | 95 | return; | ||
1931 | 96 | } | ||
1932 | 97 | |||
1933 | 98 | $transEngine = new gettext_reader($stream); | ||
1934 | 99 | self::$locale = $lang; | ||
1935 | 100 | self::$jsLocale = str_replace('_', '-', $lang); | ||
1936 | 108 | } | 101 | } |
1937 | 102 | |||
1938 | 103 | public static function GetLocale() { | ||
1939 | 104 | return self::$locale; | ||
1940 | 105 | } | ||
1941 | 106 | |||
1942 | 107 | public static function GetJsLocale() { | ||
1943 | 108 | return self::$jsLocale; | ||
1944 | 109 | } | ||
1945 | 109 | } | 110 | } |
1946 | 110 | 111 | ||
1947 | 111 | /** | 112 | /** |
1948 | 112 | 113 | ||
1949 | === modified file 'server/lib/data/campaign.data.class.php' | |||
1950 | --- server/lib/data/campaign.data.class.php 2014-01-18 09:47:41 +0000 | |||
1951 | +++ server/lib/data/campaign.data.class.php 2014-10-21 16:06:16 +0000 | |||
1952 | @@ -97,12 +97,14 @@ | |||
1953 | 97 | throw new Exception(__('Unable to Unlink')); | 97 | throw new Exception(__('Unable to Unlink')); |
1954 | 98 | 98 | ||
1955 | 99 | // Remove all permissions | 99 | // Remove all permissions |
1956 | 100 | Kit::ClassLoader('campaignsecurity'); | ||
1957 | 101 | $security = new CampaignSecurity($this->db); | 100 | $security = new CampaignSecurity($this->db); |
1958 | 102 | 101 | ||
1959 | 103 | if (!$security->UnlinkAll($campaignId)) | 102 | if (!$security->UnlinkAll($campaignId)) |
1960 | 104 | throw new Exception(__('Unable to set permissions')); | 103 | throw new Exception(__('Unable to set permissions')); |
1961 | 105 | 104 | ||
1962 | 105 | // Remove from all Schedules | ||
1963 | 106 | Schedule::DeleteScheduleForCampaign($campaignId); | ||
1964 | 107 | |||
1965 | 106 | // Delete from the Campaign | 108 | // Delete from the Campaign |
1966 | 107 | $sth = $dbh->prepare('DELETE FROM `campaign` WHERE CampaignID = :campaignid'); | 109 | $sth = $dbh->prepare('DELETE FROM `campaign` WHERE CampaignID = :campaignid'); |
1967 | 108 | $sth->execute(array( | 110 | $sth->execute(array( |
1968 | 109 | 111 | ||
1969 | === modified file 'server/lib/data/campaignsecurity.data.class.php' | |||
1970 | --- server/lib/data/campaignsecurity.data.class.php 2014-01-18 09:47:41 +0000 | |||
1971 | +++ server/lib/data/campaignsecurity.data.class.php 2014-10-21 16:06:16 +0000 | |||
1972 | @@ -22,6 +22,15 @@ | |||
1973 | 22 | 22 | ||
1974 | 23 | class CampaignSecurity extends Data | 23 | class CampaignSecurity extends Data |
1975 | 24 | { | 24 | { |
1976 | 25 | public function GetPermissions($objectId) | ||
1977 | 26 | { | ||
1978 | 27 | $userGroup = new UserGroup(); | ||
1979 | 28 | if (!$result = $userGroup->GetPermissionsForObject('lkcampaigngroup', 'CampaignID', $objectId)) | ||
1980 | 29 | return $this->SetError($userGroup->GetErrorMessage()); | ||
1981 | 30 | |||
1982 | 31 | return $result; | ||
1983 | 32 | } | ||
1984 | 33 | |||
1985 | 25 | /** | 34 | /** |
1986 | 26 | * Links a Campaign to a Group | 35 | * Links a Campaign to a Group |
1987 | 27 | * @return | 36 | * @return |
1988 | 28 | 37 | ||
1989 | === modified file 'server/lib/data/datasetdata.data.class.php' | |||
1990 | --- server/lib/data/datasetdata.data.class.php 2014-08-06 11:57:27 +0000 | |||
1991 | +++ server/lib/data/datasetdata.data.class.php 2014-10-21 16:06:16 +0000 | |||
1992 | @@ -355,6 +355,10 @@ | |||
1993 | 355 | $rowNumber++; | 355 | $rowNumber++; |
1994 | 356 | } | 356 | } |
1995 | 357 | 357 | ||
1996 | 358 | // Close the file | ||
1997 | 359 | fclose($handle); | ||
1998 | 360 | |||
1999 | 361 | // Change the auto detect setting back | ||
2000 | 358 | ini_set('auto_detect_line_endings', false); | 362 | ini_set('auto_detect_line_endings', false); |
2001 | 359 | 363 | ||
2002 | 360 | // Delete the temporary file | 364 | // Delete the temporary file |
2003 | 361 | 365 | ||
2004 | === modified file 'server/lib/data/datasetgroupsecurity.data.class.php' | |||
2005 | --- server/lib/data/datasetgroupsecurity.data.class.php 2014-07-10 21:09:24 +0000 | |||
2006 | +++ server/lib/data/datasetgroupsecurity.data.class.php 2014-10-21 16:06:16 +0000 | |||
2007 | @@ -27,46 +27,24 @@ | |||
2008 | 27 | if ($dataSetId == 0 || $dataSetId == '') | 27 | if ($dataSetId == 0 || $dataSetId == '') |
2009 | 28 | return $this->SetError(25001, __('Missing dataSetId')); | 28 | return $this->SetError(25001, __('Missing dataSetId')); |
2010 | 29 | 29 | ||
2051 | 30 | try { | 30 | $userGroup = new UserGroup(); |
2052 | 31 | $dbh = PDOConnect::init(); | 31 | if (!$result = $userGroup->GetPermissionsForObject('lkdatasetgroup', 'DataSetID', $dataSetId)) |
2053 | 32 | 32 | return $this->SetError($userGroup->GetErrorMessage()); | |
2054 | 33 | $sth = $dbh->prepare('SELECT `group`.groupid, `group`.`group`, view, edit, del, `group`.isuserspecific | 33 | |
2055 | 34 | FROM `group` | 34 | $security = array(); |
2056 | 35 | LEFT OUTER JOIN lkdatasetgroup | 35 | |
2057 | 36 | ON lkdatasetgroup.GroupID = group.GroupID | 36 | foreach($result as $row) { |
2058 | 37 | AND lkdatasetgroup.DataSetID = :datasetid | 37 | $security[] = array( |
2059 | 38 | WHERE `group`.GroupID <> :groupid | 38 | 'groupid' => Kit::ValidateParam($row['groupid'], _INT), |
2060 | 39 | ORDER BY `group`.IsEveryone DESC, `group`.IsUserSpecific, `group`.`Group`'); | 39 | 'group' => Kit::ValidateParam($row['group'], _STRING), |
2061 | 40 | 40 | 'view' => Kit::ValidateParam($row['view'], _INT), | |
2062 | 41 | $sth->execute(array( | 41 | 'edit' => Kit::ValidateParam($row['edit'], _INT), |
2063 | 42 | 'datasetid' => $dataSetId, | 42 | 'del' => Kit::ValidateParam($row['del'], _INT), |
2064 | 43 | 'groupid' => $groupId | 43 | 'isuserspecific' => Kit::ValidateParam($row['isuserspecific'], _INT), |
2065 | 44 | )); | 44 | ); |
2066 | 45 | 45 | } | |
2067 | 46 | $security = array(); | 46 | |
2068 | 47 | 47 | return $security; | |
2029 | 48 | foreach($sth->fetchAll() as $row) { | ||
2030 | 49 | $security[] = array( | ||
2031 | 50 | 'groupid' => Kit::ValidateParam($row['groupid'], _INT), | ||
2032 | 51 | 'group' => Kit::ValidateParam($row['group'], _STRING), | ||
2033 | 52 | 'view' => Kit::ValidateParam($row['view'], _INT), | ||
2034 | 53 | 'edit' => Kit::ValidateParam($row['edit'], _INT), | ||
2035 | 54 | 'del' => Kit::ValidateParam($row['del'], _INT), | ||
2036 | 55 | 'isuserspecific' => Kit::ValidateParam($row['isuserspecific'], _INT), | ||
2037 | 56 | ); | ||
2038 | 57 | } | ||
2039 | 58 | |||
2040 | 59 | return $security; | ||
2041 | 60 | } | ||
2042 | 61 | catch (Exception $e) { | ||
2043 | 62 | |||
2044 | 63 | Debug::LogEntry('error', $e->getMessage()); | ||
2045 | 64 | |||
2046 | 65 | if (!$this->IsError()) | ||
2047 | 66 | $this->SetError(1, __('Unknown Error')); | ||
2048 | 67 | |||
2049 | 68 | return false; | ||
2050 | 69 | } | ||
2069 | 70 | } | 48 | } |
2070 | 71 | 49 | ||
2071 | 72 | /** | 50 | /** |
2072 | 73 | 51 | ||
2073 | === modified file 'server/lib/data/display.data.class.php' | |||
2074 | --- server/lib/data/display.data.class.php 2014-09-16 10:59:55 +0000 | |||
2075 | +++ server/lib/data/display.data.class.php 2014-10-21 16:06:16 +0000 | |||
2076 | @@ -63,6 +63,7 @@ | |||
2077 | 63 | public $screenShotRequested; | 63 | public $screenShotRequested; |
2078 | 64 | 64 | ||
2079 | 65 | public $displayGroupId; | 65 | public $displayGroupId; |
2080 | 66 | private $_config; | ||
2081 | 66 | 67 | ||
2082 | 67 | public function Load() { | 68 | public function Load() { |
2083 | 68 | try { | 69 | try { |
2084 | @@ -105,7 +106,7 @@ | |||
2085 | 105 | $this->wakeOnLanTime = Kit::ValidateParam($row['WakeOnLanTime'], _STRING); | 106 | $this->wakeOnLanTime = Kit::ValidateParam($row['WakeOnLanTime'], _STRING); |
2086 | 106 | $this->broadCastAddress = Kit::ValidateParam($row['BroadCastAddress'], _STRING); | 107 | $this->broadCastAddress = Kit::ValidateParam($row['BroadCastAddress'], _STRING); |
2087 | 107 | $this->secureOn = Kit::ValidateParam($row['SecureOn'], _STRING); | 108 | $this->secureOn = Kit::ValidateParam($row['SecureOn'], _STRING); |
2089 | 108 | $this->cidr = Kit::ValidateParam($row['Cidr'], _INT); | 109 | $this->cidr = Kit::ValidateParam($row['Cidr'], _STRING); |
2090 | 109 | $this->latitude = Kit::ValidateParam($row['Latitude'], _DOUBLE); | 110 | $this->latitude = Kit::ValidateParam($row['Latitude'], _DOUBLE); |
2091 | 110 | $this->longitude = Kit::ValidateParam($row['Longitude'], _DOUBLE); | 111 | $this->longitude = Kit::ValidateParam($row['Longitude'], _DOUBLE); |
2092 | 111 | $this->versionInstructions = Kit::ValidateParam($row['version_instructions'], _STRING); | 112 | $this->versionInstructions = Kit::ValidateParam($row['version_instructions'], _STRING); |
2093 | @@ -656,7 +657,137 @@ | |||
2094 | 656 | 657 | ||
2095 | 657 | return false; | 658 | return false; |
2096 | 658 | } | 659 | } |
2098 | 659 | 660 | } | |
2099 | 661 | |||
2100 | 662 | public function GetSetting($key, $default) { | ||
2101 | 663 | |||
2102 | 664 | if (!$this->SetConfig()) | ||
2103 | 665 | return false; | ||
2104 | 666 | |||
2105 | 667 | // Find | ||
2106 | 668 | $return = $default; | ||
2107 | 669 | foreach($this->_config as $row) { | ||
2108 | 670 | if ($row['name'] == $key || $row['name'] == ucfirst($key)) { | ||
2109 | 671 | //Debug::Audit('Found ' . $key . '. value= ' . $row['value']); | ||
2110 | 672 | $return = $row['value']; | ||
2111 | 673 | break; | ||
2112 | 674 | } | ||
2113 | 675 | } | ||
2114 | 676 | |||
2115 | 677 | return $return; | ||
2116 | 678 | } | ||
2117 | 679 | |||
2118 | 680 | private function SetConfig() { | ||
2119 | 681 | if ($this->_config == null) { | ||
2120 | 682 | try { | ||
2121 | 683 | $dbh = PDOConnect::init(); | ||
2122 | 684 | |||
2123 | 685 | $displayProfile = new DisplayProfile(); | ||
2124 | 686 | $displayProfile->displayProfileId = $this->displayProfileId; | ||
2125 | 687 | |||
2126 | 688 | if ($displayProfile->displayProfileId == 0) { | ||
2127 | 689 | // Load the default profile | ||
2128 | 690 | $displayProfile->type = $this->clientType; | ||
2129 | 691 | $displayProfile->LoadDefault(); | ||
2130 | 692 | } | ||
2131 | 693 | else { | ||
2132 | 694 | // Load the specified profile | ||
2133 | 695 | $displayProfile->Load(); | ||
2134 | 696 | } | ||
2135 | 697 | |||
2136 | 698 | $this->_config = $displayProfile->config; | ||
2137 | 699 | |||
2138 | 700 | return true; | ||
2139 | 701 | } | ||
2140 | 702 | catch (Exception $e) { | ||
2141 | 703 | |||
2142 | 704 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
2143 | 705 | |||
2144 | 706 | if (!$this->IsError()) | ||
2145 | 707 | $this->SetError(1, __('Unknown Error')); | ||
2146 | 708 | |||
2147 | 709 | return false; | ||
2148 | 710 | } | ||
2149 | 711 | } | ||
2150 | 712 | } | ||
2151 | 713 | /** | ||
2152 | 714 | * Assess each Display to correctly set the logged in flag based on last accessed time | ||
2153 | 715 | * @return | ||
2154 | 716 | */ | ||
2155 | 717 | public static function ValidateDisplays() { | ||
2156 | 718 | // Maintain an array of timed out displays | ||
2157 | 719 | $timedOutDisplays = array(); | ||
2158 | 720 | |||
2159 | 721 | try { | ||
2160 | 722 | $dbh = PDOConnect::init(); | ||
2161 | 723 | $statObject = new Stat(); | ||
2162 | 724 | |||
2163 | 725 | // Get a list of all displays and there last accessed / alert time out value | ||
2164 | 726 | $sth = $dbh->prepare('SELECT displayid, display, lastaccessed, alert_timeout, client_type, displayprofileid, email_alert, loggedin FROM display'); | ||
2165 | 727 | $sthUpdate = $dbh->prepare('UPDATE display SET loggedin = 0 WHERE displayid = :displayid'); | ||
2166 | 728 | |||
2167 | 729 | $sth->execute(array()); | ||
2168 | 730 | |||
2169 | 731 | // Get the global time out (overrides the alert time out on the display if 0) | ||
2170 | 732 | $globalTimeout = Config::GetSetting('MAINTENANCE_ALERT_TOUT') * 60; | ||
2171 | 733 | |||
2172 | 734 | $displays = $sth->fetchAll(); | ||
2173 | 735 | |||
2174 | 736 | foreach ($displays as $row) { | ||
2175 | 737 | $displayid = Kit::ValidateParam($row['displayid'], _INT); | ||
2176 | 738 | $lastAccessed = Kit::ValidateParam($row['lastaccessed'], _INT); | ||
2177 | 739 | $alertTimeout = Kit::ValidateParam($row['alert_timeout'], _INT); | ||
2178 | 740 | $clientType = Kit::ValidateParam($row['client_type'], _WORD); | ||
2179 | 741 | $loggedIn = Kit::ValidateParam($row['loggedin'], _INT); | ||
2180 | 742 | |||
2181 | 743 | // Get the config object | ||
2182 | 744 | if ($alertTimeout == 0) { | ||
2183 | 745 | $displayProfileId = (empty($row['displayprofileid']) ? 0 : Kit::ValidateParam($row['displayprofileid'], _INT)); | ||
2184 | 746 | |||
2185 | 747 | $display = new Display(); | ||
2186 | 748 | $display->displayId = $displayid; | ||
2187 | 749 | $display->displayProfileId = $displayProfileId; | ||
2188 | 750 | $display->clientType = $clientType; | ||
2189 | 751 | $timeoutToTestAgainst = $display->GetSetting('collectInterval', $globalTimeout); | ||
2190 | 752 | } | ||
2191 | 753 | else { | ||
2192 | 754 | $timeoutToTestAgainst = $globalTimeout; | ||
2193 | 755 | } | ||
2194 | 756 | |||
2195 | 757 | // Store the time out to test against | ||
2196 | 758 | $row['timeout'] = $timeoutToTestAgainst; | ||
2197 | 759 | $timeOut = $lastAccessed + $timeoutToTestAgainst; | ||
2198 | 760 | |||
2199 | 761 | // If the last time we accessed is less than now minus the time out | ||
2200 | 762 | if ($timeOut < time()) { | ||
2201 | 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)); | ||
2202 | 764 | |||
2203 | 765 | // If this is the first switch (i.e. the row was logged in before) | ||
2204 | 766 | if ($loggedIn == 1) { | ||
2205 | 767 | |||
2206 | 768 | // Update the display and set it as logged out | ||
2207 | 769 | $sthUpdate->execute(array('displayid' => $displayid)); | ||
2208 | 770 | |||
2209 | 771 | // Log the down event | ||
2210 | 772 | $statObject->displayDown($displayid, $lastAccessed); | ||
2211 | 773 | } | ||
2212 | 774 | |||
2213 | 775 | // Store this row | ||
2214 | 776 | $timedOutDisplays[] = $row; | ||
2215 | 777 | } | ||
2216 | 778 | } | ||
2217 | 779 | |||
2218 | 780 | return $timedOutDisplays; | ||
2219 | 781 | } | ||
2220 | 782 | catch (Exception $e) { | ||
2221 | 783 | |||
2222 | 784 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
2223 | 785 | |||
2224 | 786 | if (!$this->IsError()) | ||
2225 | 787 | $this->SetError(1, __('Unknown Error')); | ||
2226 | 788 | |||
2227 | 789 | return false; | ||
2228 | 790 | } | ||
2229 | 660 | } | 791 | } |
2230 | 661 | 792 | ||
2231 | 662 | /** | 793 | /** |
2232 | 663 | 794 | ||
2233 | === modified file 'server/lib/data/displayprofile.data.class.php' | |||
2234 | --- server/lib/data/displayprofile.data.class.php 2014-08-07 11:58:10 +0000 | |||
2235 | +++ server/lib/data/displayprofile.data.class.php 2014-10-21 16:06:16 +0000 | |||
2236 | @@ -39,6 +39,8 @@ | |||
2237 | 39 | 39 | ||
2238 | 40 | public function Load() { | 40 | public function Load() { |
2239 | 41 | 41 | ||
2240 | 42 | Debug::Audit('Load ' . $this->displayProfileId); | ||
2241 | 43 | |||
2242 | 42 | try { | 44 | try { |
2243 | 43 | $dbh = PDOConnect::init(); | 45 | $dbh = PDOConnect::init(); |
2244 | 44 | 46 | ||
2245 | @@ -75,6 +77,59 @@ | |||
2246 | 75 | 77 | ||
2247 | 76 | } | 78 | } |
2248 | 77 | 79 | ||
2249 | 80 | public function LoadDefault() { | ||
2250 | 81 | |||
2251 | 82 | Debug::Audit('Load Default'); | ||
2252 | 83 | |||
2253 | 84 | try { | ||
2254 | 85 | $dbh = PDOConnect::init(); | ||
2255 | 86 | |||
2256 | 87 | $sth = $dbh->prepare('SELECT * FROM `displayprofile` WHERE type = :type AND IsDefault = 1'); | ||
2257 | 88 | $sth->execute(array( | ||
2258 | 89 | 'type' => $this->displayProfileId | ||
2259 | 90 | )); | ||
2260 | 91 | |||
2261 | 92 | if (!$row = $sth->fetch()) { | ||
2262 | 93 | // Return the client default | ||
2263 | 94 | include_once('config/client.config.php'); | ||
2264 | 95 | $this->name = $CLIENT_CONFIG[$this->type]['synonym']; | ||
2265 | 96 | $this->type = $this->type; | ||
2266 | 97 | $this->config = $CLIENT_CONFIG[$this->type]['settings']; | ||
2267 | 98 | $this->isDefault = 1; | ||
2268 | 99 | $this->userId = 1; | ||
2269 | 100 | |||
2270 | 101 | // Just populate the values with the defaults if the values aren't set already | ||
2271 | 102 | for ($i = 0; $i < count($this->config); $i++) { | ||
2272 | 103 | $this->config[$i]['value'] = isset($this->config[$i]['value']) ? $this->config[$i]['value'] : $this->config[$i]['default']; | ||
2273 | 104 | } | ||
2274 | 105 | } | ||
2275 | 106 | else { | ||
2276 | 107 | $this->name = Kit::ValidateParam($row['name'], _STRING); | ||
2277 | 108 | $this->type = Kit::ValidateParam($row['type'], _STRING); | ||
2278 | 109 | $this->config = Kit::ValidateParam($row['config'], _HTMLSTRING); | ||
2279 | 110 | $this->isDefault = Kit::ValidateParam($row['isdefault'], _INT); | ||
2280 | 111 | $this->userId = Kit::ValidateParam($row['userid'], _INT); | ||
2281 | 112 | |||
2282 | 113 | // Load the client settings into an array | ||
2283 | 114 | $this->config = ($this->config == '') ? array() : json_decode($this->config, true); | ||
2284 | 115 | |||
2285 | 116 | $this->isNew = false; | ||
2286 | 117 | } | ||
2287 | 118 | |||
2288 | 119 | return true; | ||
2289 | 120 | } | ||
2290 | 121 | catch (Exception $e) { | ||
2291 | 122 | |||
2292 | 123 | Debug::LogEntry('error', $e->getMessage()); | ||
2293 | 124 | |||
2294 | 125 | if (!$this->IsError()) | ||
2295 | 126 | $this->SetError(1, __('Unknown Error')); | ||
2296 | 127 | |||
2297 | 128 | return false; | ||
2298 | 129 | } | ||
2299 | 130 | |||
2300 | 131 | } | ||
2301 | 132 | |||
2302 | 78 | public function Save() { | 133 | public function Save() { |
2303 | 79 | 134 | ||
2304 | 80 | // Validation. | 135 | // Validation. |
2305 | 81 | 136 | ||
2306 | === modified file 'server/lib/data/layout.data.class.php' | |||
2307 | --- server/lib/data/layout.data.class.php 2014-09-16 16:41:43 +0000 | |||
2308 | +++ server/lib/data/layout.data.class.php 2014-10-21 16:06:16 +0000 | |||
2309 | @@ -19,19 +19,13 @@ | |||
2310 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
2311 | 20 | */ | 20 | */ |
2312 | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); |
2313 | 22 | Kit::ClassLoader('campaign'); | ||
2314 | 22 | 23 | ||
2315 | 23 | class Layout extends Data | 24 | class Layout extends Data |
2316 | 24 | { | 25 | { |
2317 | 25 | private $xml; | 26 | private $xml; |
2318 | 26 | private $DomXml; | 27 | private $DomXml; |
2319 | 27 | 28 | ||
2320 | 28 | public function __construct($db) | ||
2321 | 29 | { | ||
2322 | 30 | Kit::ClassLoader('campaign'); | ||
2323 | 31 | |||
2324 | 32 | parent::__construct($db); | ||
2325 | 33 | } | ||
2326 | 34 | |||
2327 | 35 | /** | 29 | /** |
2328 | 36 | * Add a layout | 30 | * Add a layout |
2329 | 37 | * @param <type> $layout | 31 | * @param <type> $layout |
2330 | @@ -543,10 +537,7 @@ | |||
2331 | 543 | $campaign = new Campaign($this->db); | 537 | $campaign = new Campaign($this->db); |
2332 | 544 | 538 | ||
2333 | 545 | // Include to media data class? | 539 | // Include to media data class? |
2338 | 546 | if ($copyMedia) | 540 | if ($copyMedia) { |
2335 | 547 | { | ||
2336 | 548 | Kit::ClassLoader('media'); | ||
2337 | 549 | Kit::ClassLoader('mediagroupsecurity'); | ||
2339 | 550 | $mediaObject = new Media($this->db); | 541 | $mediaObject = new Media($this->db); |
2340 | 551 | $mediaSecurity = new MediaGroupSecurity($this->db); | 542 | $mediaSecurity = new MediaGroupSecurity($this->db); |
2341 | 552 | } | 543 | } |
2342 | @@ -554,11 +545,6 @@ | |||
2343 | 554 | // We need the old campaignid | 545 | // We need the old campaignid |
2344 | 555 | $oldCampaignId = $campaign->GetCampaignId($oldLayoutId); | 546 | $oldCampaignId = $campaign->GetCampaignId($oldLayoutId); |
2345 | 556 | 547 | ||
2346 | 557 | // Permissions model | ||
2347 | 558 | Kit::ClassLoader('campaignsecurity'); | ||
2348 | 559 | Kit::ClassLoader('layoutregiongroupsecurity'); | ||
2349 | 560 | Kit::ClassLoader('layoutmediagroupsecurity'); | ||
2350 | 561 | |||
2351 | 562 | // The Layout ID is the old layout | 548 | // The Layout ID is the old layout |
2352 | 563 | $SQL = ""; | 549 | $SQL = ""; |
2353 | 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) "; |
2354 | @@ -613,7 +599,7 @@ | |||
2355 | 613 | if ($this->IsRegionSpecific($type)) | 599 | if ($this->IsRegionSpecific($type)) |
2356 | 614 | { | 600 | { |
2357 | 615 | // Generate a new media id | 601 | // Generate a new media id |
2359 | 616 | $newMediaId = md5(uniqid()); | 602 | $newMediaId = md5(Kit::uniqueId()); |
2360 | 617 | 603 | ||
2361 | 618 | $mediaNode->setAttribute('id', $newMediaId); | 604 | $mediaNode->setAttribute('id', $newMediaId); |
2362 | 619 | 605 | ||
2363 | @@ -740,12 +726,14 @@ | |||
2364 | 740 | if ($layoutId == 0) | 726 | if ($layoutId == 0) |
2365 | 741 | $this->ThrowError(__('No Layout selected')); | 727 | $this->ThrowError(__('No Layout selected')); |
2366 | 742 | 728 | ||
2367 | 729 | // Security | ||
2368 | 743 | $sth = $dbh->prepare('DELETE FROM lklayoutmediagroup WHERE layoutid = :layoutid'); | 730 | $sth = $dbh->prepare('DELETE FROM lklayoutmediagroup WHERE layoutid = :layoutid'); |
2369 | 744 | $sth->execute(array('layoutid' => $layoutId)); | 731 | $sth->execute(array('layoutid' => $layoutId)); |
2370 | 745 | 732 | ||
2371 | 746 | $sth = $dbh->prepare('DELETE FROM lklayoutregiongroup WHERE layoutid = :layoutid'); | 733 | $sth = $dbh->prepare('DELETE FROM lklayoutregiongroup WHERE layoutid = :layoutid'); |
2372 | 747 | $sth->execute(array('layoutid' => $layoutId)); | 734 | $sth->execute(array('layoutid' => $layoutId)); |
2373 | 748 | 735 | ||
2374 | 736 | // Media Links | ||
2375 | 749 | $sth = $dbh->prepare('DELETE FROM lklayoutmedia WHERE layoutid = :layoutid'); | 737 | $sth = $dbh->prepare('DELETE FROM lklayoutmedia WHERE layoutid = :layoutid'); |
2376 | 750 | $sth->execute(array('layoutid' => $layoutId)); | 738 | $sth->execute(array('layoutid' => $layoutId)); |
2377 | 751 | 739 | ||
2378 | @@ -756,6 +744,10 @@ | |||
2379 | 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) |
2380 | 757 | if (!$campaign->Delete($campaignId)) | 745 | if (!$campaign->Delete($campaignId)) |
2381 | 758 | $this->ThrowError(25008, __('Unable to delete campaign')); | 746 | $this->ThrowError(25008, __('Unable to delete campaign')); |
2382 | 747 | |||
2383 | 748 | // Remove the Layout from any display defaults | ||
2384 | 749 | $sth = $dbh->prepare('UPDATE `display` SET defaultlayoutid = 4 WHERE defaultlayoutid = :layoutid'); | ||
2385 | 750 | $sth->execute(array('layoutid' => $layoutId)); | ||
2386 | 759 | 751 | ||
2387 | 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) |
2388 | 761 | $sth = $dbh->prepare('DELETE FROM layout WHERE layoutid = :layoutid'); | 753 | $sth = $dbh->prepare('DELETE FROM layout WHERE layoutid = :layoutid'); |
2389 | @@ -1236,7 +1228,7 @@ | |||
2390 | 1236 | $fileName = $libraryPath . 'temp/export_' . Kit::ValidateParam($row['layout'], _FILENAME) . '.zip'; | 1228 | $fileName = $libraryPath . 'temp/export_' . Kit::ValidateParam($row['layout'], _FILENAME) . '.zip'; |
2391 | 1237 | 1229 | ||
2392 | 1238 | $zip = new ZipArchive(); | 1230 | $zip = new ZipArchive(); |
2394 | 1239 | $zip->open($fileName, ZIPARCHIVE::OVERWRITE); | 1231 | $zip->open($fileName, ZIPARCHIVE::OVERWRITE); |
2395 | 1240 | $zip->addFromString('layout.xml', $xml); | 1232 | $zip->addFromString('layout.xml', $xml); |
2396 | 1241 | 1233 | ||
2397 | 1242 | $params = array('layoutid' => $layoutId); | 1234 | $params = array('layoutid' => $layoutId); |
2398 | 1243 | 1235 | ||
2399 | === modified file 'server/lib/data/maintenance.data.class.php' | |||
2400 | --- server/lib/data/maintenance.data.class.php 2014-01-18 09:47:41 +0000 | |||
2401 | +++ server/lib/data/maintenance.data.class.php 2014-10-21 16:06:16 +0000 | |||
2402 | @@ -28,27 +28,78 @@ | |||
2403 | 28 | */ | 28 | */ |
2404 | 29 | public function BackupDatabase($saveAs = "string") | 29 | public function BackupDatabase($saveAs = "string") |
2405 | 30 | { | 30 | { |
2410 | 31 | // Always truncate the log first | 31 | // Check we can run mysql |
2411 | 32 | $this->db->query("TRUNCATE TABLE `log` "); | 32 | if (!function_exists('exec')) |
2412 | 33 | $this->db->query("TRUNCATE TABLE `oauth_log` "); | 33 | return $this->SetError(__('Exec is not available.')); |
2413 | 34 | 34 | ||
2414 | 35 | // Global database variables to seed into exec | ||
2415 | 35 | global $dbhost; | 36 | global $dbhost; |
2416 | 36 | global $dbuser; | 37 | global $dbuser; |
2417 | 37 | global $dbpass; | 38 | global $dbpass; |
2418 | 38 | global $dbname; | 39 | global $dbname; |
2419 | 39 | 40 | ||
2420 | 40 | // Run mysqldump to a temporary file | ||
2421 | 41 | |||
2422 | 42 | // get temporary file | 41 | // get temporary file |
2432 | 43 | $tempFile = tempnam(Config::GetSetting('LIBRARY_LOCATION'), 'dmp'); | 42 | $fileNameStructure = Config::GetSetting('LIBRARY_LOCATION') . 'structure.dump'; |
2433 | 44 | 43 | $fileNameData = Config::GetSetting('LIBRARY_LOCATION') . 'data.dump'; | |
2434 | 45 | exec('mysqldump --opt --host=' . $dbhost . ' --user=' . $dbuser . ' --password=' . $dbpass . ' ' . $dbname . ' > ' . escapeshellarg($tempFile) . ' '); | 44 | $zipFile = 'database.tar.gz'; |
2435 | 46 | 45 | ||
2436 | 47 | $sqlDump = file_get_contents($tempFile); | 46 | // Run mysqldump structure to a temporary file |
2437 | 48 | 47 | $command = 'mysqldump --opt --host=' . $dbhost . ' --user=' . $dbuser . ' --password=' . addslashes($dbpass) . ' ' . $dbname . ' --no-data > ' . escapeshellarg($fileNameStructure) . ' '; | |
2438 | 49 | unlink($tempFile); | 48 | exec($command); |
2439 | 50 | 49 | ||
2440 | 51 | return $sqlDump; | 50 | // Run mysqldump data to a temporary file |
2441 | 51 | $command = 'mysqldump --opt --host=' . $dbhost . ' --user=' . $dbuser . ' --password=' . addslashes($dbpass) . ' ' . $dbname . ' --ignore-table=' . $dbname . '.log --ignore-table=' . $dbname . '.oauth_log > ' . escapeshellarg($fileNameData) . ' '; | ||
2442 | 52 | exec($command); | ||
2443 | 53 | |||
2444 | 54 | // Check it worked | ||
2445 | 55 | if (!file_exists($fileNameStructure) || !file_exists($fileNameData)) | ||
2446 | 56 | return $this->SetError(__('Database dump failed.')); | ||
2447 | 57 | |||
2448 | 58 | // Zippy | ||
2449 | 59 | Debug::Audit($zipFile); | ||
2450 | 60 | $zip = new ZipArchive(); | ||
2451 | 61 | $zip->open($zipFile, ZIPARCHIVE::OVERWRITE); | ||
2452 | 62 | $zip->addFile($fileNameStructure, 'structure.dump'); | ||
2453 | 63 | $zip->addFile($fileNameData, 'data.dump'); | ||
2454 | 64 | $zip->close(); | ||
2455 | 65 | |||
2456 | 66 | // Remove the dump file | ||
2457 | 67 | unlink($fileNameStructure); | ||
2458 | 68 | unlink($fileNameData); | ||
2459 | 69 | |||
2460 | 70 | // Uncomment only if you are having permission issues | ||
2461 | 71 | // chmod($zipFile, 0777); | ||
2462 | 72 | |||
2463 | 73 | // Push file back to browser | ||
2464 | 74 | if (ini_get('zlib.output_compression')) { | ||
2465 | 75 | ini_set('zlib.output_compression', 'Off'); | ||
2466 | 76 | } | ||
2467 | 77 | |||
2468 | 78 | $size = filesize($zipFile); | ||
2469 | 79 | |||
2470 | 80 | header('Content-Type: application/octet-stream'); | ||
2471 | 81 | header("Content-Transfer-Encoding: Binary"); | ||
2472 | 82 | header("Content-disposition: attachment; filename=\"" . basename($zipFile) . "\""); | ||
2473 | 83 | |||
2474 | 84 | //Output a header | ||
2475 | 85 | header('Pragma: public'); | ||
2476 | 86 | header('Cache-Control: max-age=86400'); | ||
2477 | 87 | header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 86400)); | ||
2478 | 88 | header('Content-Length: ' . $size); | ||
2479 | 89 | |||
2480 | 90 | // Send via Apache X-Sendfile header? | ||
2481 | 91 | if (Config::GetSetting('SENDFILE_MODE') == 'Apache') { | ||
2482 | 92 | header("X-Sendfile: $zipFile"); | ||
2483 | 93 | exit(); | ||
2484 | 94 | } | ||
2485 | 95 | |||
2486 | 96 | // Return the file with PHP | ||
2487 | 97 | // Disable any buffering to prevent OOM errors. | ||
2488 | 98 | @ob_end_clean(); | ||
2489 | 99 | @ob_end_flush(); | ||
2490 | 100 | readfile($zipFile); | ||
2491 | 101 | |||
2492 | 102 | exit; | ||
2493 | 52 | } | 103 | } |
2494 | 53 | 104 | ||
2495 | 54 | /** | 105 | /** |
2496 | @@ -69,5 +120,95 @@ | |||
2497 | 69 | 120 | ||
2498 | 70 | return true; | 121 | return true; |
2499 | 71 | } | 122 | } |
2500 | 123 | |||
2501 | 124 | public function TidyLibrary($tidyOldRevisions) { | ||
2502 | 125 | // Also run a script to tidy up orphaned media in the library | ||
2503 | 126 | $library = Config::GetSetting('LIBRARY_LOCATION'); | ||
2504 | 127 | $library = rtrim($library, '/') . '/'; | ||
2505 | 128 | $mediaObject = new Media(); | ||
2506 | 129 | |||
2507 | 130 | Debug::Audit('Library Location: ' . $library); | ||
2508 | 131 | |||
2509 | 132 | // Dump the files in the temp folder | ||
2510 | 133 | foreach (scandir($library . 'temp') as $item) { | ||
2511 | 134 | if ($item == '.' || $item == '..') | ||
2512 | 135 | continue; | ||
2513 | 136 | |||
2514 | 137 | Debug::Audit('Deleting temp file: ' . $item); | ||
2515 | 138 | |||
2516 | 139 | unlink($library . 'temp' . DIRECTORY_SEPARATOR . $item); | ||
2517 | 140 | } | ||
2518 | 141 | |||
2519 | 142 | $media = array(); | ||
2520 | 143 | $unusedMedia = array(); | ||
2521 | 144 | |||
2522 | 145 | // Run a query to get an array containing all of the media in the library | ||
2523 | 146 | try { | ||
2524 | 147 | $dbh = PDOConnect::init(); | ||
2525 | 148 | |||
2526 | 149 | $sth = $dbh->prepare(' | ||
2527 | 150 | SELECT media.mediaid, media.storedAs, media.type, media.isedited, COUNT(lklayoutmedia.lklayoutmediaid) AS UsedInLayoutCount | ||
2528 | 151 | FROM `media` | ||
2529 | 152 | LEFT OUTER JOIN `lklayoutmedia` | ||
2530 | 153 | ON lklayoutmedia.mediaid = media.mediaid | ||
2531 | 154 | GROUP BY media.mediaid, media.storedAs '); | ||
2532 | 155 | |||
2533 | 156 | $sth->execute(array()); | ||
2534 | 157 | |||
2535 | 158 | foreach ($sth->fetchAll() as $row) { | ||
2536 | 159 | $media[$row['storedAs']] = $row; | ||
2537 | 160 | |||
2538 | 161 | // If its not used in a layout and its not a generic module, add to the unused array. | ||
2539 | 162 | if ($tidyOldRevisions && $row['UsedInLayoutCount'] <= 0 && $row['isedited'] > 0 && $row['type'] != 'module' && $row['type'] != 'font') | ||
2540 | 163 | $unusedMedia[$row['storedAs']] = $row; | ||
2541 | 164 | } | ||
2542 | 165 | } | ||
2543 | 166 | catch (Exception $e) { | ||
2544 | 167 | |||
2545 | 168 | Debug::LogEntry('error', $e->getMessage()); | ||
2546 | 169 | |||
2547 | 170 | if (!$this->IsError()) | ||
2548 | 171 | $this->SetError(1, __('Unknown Error')); | ||
2549 | 172 | |||
2550 | 173 | return false; | ||
2551 | 174 | } | ||
2552 | 175 | |||
2553 | 176 | //Debug::Audit(var_export($media, true)); | ||
2554 | 177 | //Debug::Audit(var_export($unusedMedia, true)); | ||
2555 | 178 | |||
2556 | 179 | // Get a list of all media files | ||
2557 | 180 | foreach(scandir($library) as $file) { | ||
2558 | 181 | |||
2559 | 182 | if ($file == '.' || $file == '..') | ||
2560 | 183 | continue; | ||
2561 | 184 | |||
2562 | 185 | if (is_dir($library . $file)) | ||
2563 | 186 | continue; | ||
2564 | 187 | |||
2565 | 188 | // Ignore thumbnails | ||
2566 | 189 | if (strstr($file, 'tn_') || strstr($file, 'bg_')) | ||
2567 | 190 | continue; | ||
2568 | 191 | |||
2569 | 192 | // Is this file in the system anywhere? | ||
2570 | 193 | if (!array_key_exists($file, $media)) { | ||
2571 | 194 | // Totally missing | ||
2572 | 195 | Debug::Audit('Deleting file: ' . $file); | ||
2573 | 196 | |||
2574 | 197 | // If not, delete it | ||
2575 | 198 | $mediaObject->DeleteMediaFile($file); | ||
2576 | 199 | } | ||
2577 | 200 | else if (array_key_exists($file, $unusedMedia)) { | ||
2578 | 201 | // It exists but isn't being used any more | ||
2579 | 202 | Debug::Audit('Deleting media: ' . $media[$file]['mediaid']); | ||
2580 | 203 | $mediaObject->Delete($media[$file]['mediaid']); | ||
2581 | 204 | } | ||
2582 | 205 | else { | ||
2583 | 206 | // Don't do anything, this file still exists | ||
2584 | 207 | //Debug::Audit('Still exists: ' . $file); | ||
2585 | 208 | } | ||
2586 | 209 | } | ||
2587 | 210 | |||
2588 | 211 | return true; | ||
2589 | 212 | } | ||
2590 | 72 | } | 213 | } |
2591 | 73 | ?> | 214 | ?> |
2592 | 74 | 215 | ||
2593 | === modified file 'server/lib/data/media.data.class.php' | |||
2594 | --- server/lib/data/media.data.class.php 2014-07-24 16:23:27 +0000 | |||
2595 | +++ server/lib/data/media.data.class.php 2014-10-21 16:06:16 +0000 | |||
2596 | @@ -22,6 +22,8 @@ | |||
2597 | 22 | 22 | ||
2598 | 23 | class Media extends Data | 23 | class Media extends Data |
2599 | 24 | { | 24 | { |
2600 | 25 | private $_moduleFiles; | ||
2601 | 26 | |||
2602 | 25 | private $moduleInfoLoaded; | 27 | private $moduleInfoLoaded; |
2603 | 26 | private $regionSpecific; | 28 | private $regionSpecific; |
2604 | 27 | private $validExtensions; | 29 | private $validExtensions; |
2605 | @@ -80,7 +82,7 @@ | |||
2606 | 80 | $this->ThrowError(10, __('The name cannot be longer than 100 characters')); | 82 | $this->ThrowError(10, __('The name cannot be longer than 100 characters')); |
2607 | 81 | 83 | ||
2608 | 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) |
2610 | 83 | if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile') | 85 | if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile' && $type != 'font') |
2611 | 84 | $this->ThrowError(11, __('You must enter a duration.')); | 86 | $this->ThrowError(11, __('You must enter a duration.')); |
2612 | 85 | 87 | ||
2613 | 86 | // Check the naming of this item to ensure it doesnt conflict | 88 | // Check the naming of this item to ensure it doesnt conflict |
2614 | @@ -193,7 +195,7 @@ | |||
2615 | 193 | if (strlen($name) > 100) | 195 | if (strlen($name) > 100) |
2616 | 194 | $this->ThrowError(10, __('The name cannot be longer than 100 characters')); | 196 | $this->ThrowError(10, __('The name cannot be longer than 100 characters')); |
2617 | 195 | 197 | ||
2619 | 196 | if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile') | 198 | if ($duration == 0 && $type != 'video' && $type != 'localvideo' && $type != 'genericfile' && $type != 'font') |
2620 | 197 | $this->ThrowError(11, __('You must enter a duration.')); | 199 | $this->ThrowError(11, __('You must enter a duration.')); |
2621 | 198 | 200 | ||
2622 | 199 | // Any media (not this one) already has this name? | 201 | // Any media (not this one) already has this name? |
2623 | @@ -330,8 +332,6 @@ | |||
2624 | 330 | { | 332 | { |
2625 | 331 | Debug::LogEntry('audit', 'IN', 'Media', 'Delete'); | 333 | Debug::LogEntry('audit', 'IN', 'Media', 'Delete'); |
2626 | 332 | 334 | ||
2627 | 333 | Kit::ClassLoader('lkmediadisplaygroup'); | ||
2628 | 334 | |||
2629 | 335 | try { | 335 | try { |
2630 | 336 | $dbh = PDOConnect::init(); | 336 | $dbh = PDOConnect::init(); |
2631 | 337 | 337 | ||
2632 | @@ -357,7 +357,6 @@ | |||
2633 | 357 | $fileName = Kit::ValidateParam($row['StoredAs'], _STRING); | 357 | $fileName = Kit::ValidateParam($row['StoredAs'], _STRING); |
2634 | 358 | 358 | ||
2635 | 359 | // Remove permission assignments | 359 | // Remove permission assignments |
2636 | 360 | Kit::ClassLoader('mediagroupsecurity'); | ||
2637 | 361 | $security = new MediaGroupSecurity($this->db); | 360 | $security = new MediaGroupSecurity($this->db); |
2638 | 362 | 361 | ||
2639 | 363 | if (!$security->UnlinkAll($mediaId)) | 362 | if (!$security->UnlinkAll($mediaId)) |
2640 | @@ -648,5 +647,102 @@ | |||
2641 | 648 | return false; | 647 | return false; |
2642 | 649 | } | 648 | } |
2643 | 650 | } | 649 | } |
2644 | 650 | |||
2645 | 651 | public function AddModuleFile($file, $force = false) { | ||
2646 | 652 | try { | ||
2647 | 653 | $name = basename($file); | ||
2648 | 654 | |||
2649 | 655 | $moduleExists = $this->ModuleFileExists($name); | ||
2650 | 656 | |||
2651 | 657 | if (!$force && $moduleExists) { | ||
2652 | 658 | return; | ||
2653 | 659 | } | ||
2654 | 660 | |||
2655 | 661 | $dbh = PDOConnect::init(); | ||
2656 | 662 | $libraryFolder = Config::GetSetting('LIBRARY_LOCATION'); | ||
2657 | 663 | |||
2658 | 664 | // Get the name | ||
2659 | 665 | $storedAs = $libraryFolder . $name; | ||
2660 | 666 | |||
2661 | 667 | // Now copy the file | ||
2662 | 668 | if (!@copy($file, $storedAs)) | ||
2663 | 669 | $this->ThrowError(15, 'Error storing file.'); | ||
2664 | 670 | |||
2665 | 671 | // Calculate the MD5 and the file size | ||
2666 | 672 | $md5 = md5_file($storedAs); | ||
2667 | 673 | $fileSize = filesize($storedAs); | ||
2668 | 674 | |||
2669 | 675 | if ($moduleExists) { | ||
2670 | 676 | $SQL = "UPDATE `media` SET md5 = :md5, filesize = :filesize WHERE storedAs = :storedas "; | ||
2671 | 677 | |||
2672 | 678 | $sth = $dbh->prepare($SQL); | ||
2673 | 679 | $sth->execute(array( | ||
2674 | 680 | 'storedas' => $name, | ||
2675 | 681 | 'filesize' => $fileSize, | ||
2676 | 682 | 'md5' => $md5 | ||
2677 | 683 | )); | ||
2678 | 684 | } | ||
2679 | 685 | else { | ||
2680 | 686 | // All OK to insert this record | ||
2681 | 687 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, userID, retired, is_module, storedAs, FileSize, MD5) "; | ||
2682 | 688 | $SQL .= "VALUES (:name, :type, :duration, :originalfilename, 1, :retired, 1, :storedas, :filesize, :md5) "; | ||
2683 | 689 | |||
2684 | 690 | $sth = $dbh->prepare($SQL); | ||
2685 | 691 | $sth->execute(array( | ||
2686 | 692 | 'name' => $name, | ||
2687 | 693 | 'type' => 'module', | ||
2688 | 694 | 'duration' => 10, | ||
2689 | 695 | 'originalfilename' => $name, | ||
2690 | 696 | 'retired' => 0, | ||
2691 | 697 | 'storedas' => $name, | ||
2692 | 698 | 'filesize' => $fileSize, | ||
2693 | 699 | 'md5' => $md5 | ||
2694 | 700 | )); | ||
2695 | 701 | } | ||
2696 | 702 | |||
2697 | 703 | $dbh->commit(); | ||
2698 | 704 | |||
2699 | 705 | // Add to the cache | ||
2700 | 706 | $this->_moduleFiles[] = $name; | ||
2701 | 707 | } | ||
2702 | 708 | catch (Exception $e) { | ||
2703 | 709 | |||
2704 | 710 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
2705 | 711 | |||
2706 | 712 | if (!$this->IsError()) | ||
2707 | 713 | $this->SetError(1, __('Unknown Error')); | ||
2708 | 714 | |||
2709 | 715 | return false; | ||
2710 | 716 | } | ||
2711 | 717 | } | ||
2712 | 718 | |||
2713 | 719 | public function ModuleFileExists($file) { | ||
2714 | 720 | try { | ||
2715 | 721 | if ($this->_moduleFiles == NULL || count($this->_moduleFiles) < 1) { | ||
2716 | 722 | $dbh = PDOConnect::init(); | ||
2717 | 723 | |||
2718 | 724 | $sth = $dbh->prepare('SELECT storedAs FROM `media` WHERE type = :type'); | ||
2719 | 725 | $sth->execute(array( | ||
2720 | 726 | 'type' => 'module' | ||
2721 | 727 | )); | ||
2722 | 728 | |||
2723 | 729 | $this->_moduleFiles = array(); | ||
2724 | 730 | |||
2725 | 731 | foreach ($sth->fetchAll() as $moduleFile) | ||
2726 | 732 | $this->_moduleFiles[] = $moduleFile['storedAs']; | ||
2727 | 733 | } | ||
2728 | 734 | |||
2729 | 735 | return (in_array($file, $this->_moduleFiles)); | ||
2730 | 736 | } | ||
2731 | 737 | catch (Exception $e) { | ||
2732 | 738 | |||
2733 | 739 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
2734 | 740 | |||
2735 | 741 | if (!$this->IsError()) | ||
2736 | 742 | $this->SetError(1, __('Unknown Error')); | ||
2737 | 743 | |||
2738 | 744 | return false; | ||
2739 | 745 | } | ||
2740 | 746 | } | ||
2741 | 651 | } | 747 | } |
2742 | 652 | ?> | 748 | ?> |
2743 | 653 | 749 | ||
2744 | === modified file 'server/lib/data/region.data.class.php' | |||
2745 | --- server/lib/data/region.data.class.php 2014-08-11 19:57:05 +0000 | |||
2746 | +++ server/lib/data/region.data.class.php 2014-10-21 16:06:16 +0000 | |||
2747 | @@ -20,6 +20,9 @@ | |||
2748 | 20 | */ | 20 | */ |
2749 | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); |
2750 | 22 | 22 | ||
2751 | 23 | require_once("lib/pages/module.class.php"); | ||
2752 | 24 | Kit::ClassLoader('layout'); | ||
2753 | 25 | |||
2754 | 23 | class Region extends Data | 26 | class Region extends Data |
2755 | 24 | { | 27 | { |
2756 | 25 | // Caching | 28 | // Caching |
2757 | @@ -27,14 +30,6 @@ | |||
2758 | 27 | private $layoutDocument; | 30 | private $layoutDocument; |
2759 | 28 | 31 | ||
2760 | 29 | public $delayFinalise = false; | 32 | public $delayFinalise = false; |
2761 | 30 | |||
2762 | 31 | public function __construct(database $db) | ||
2763 | 32 | { | ||
2764 | 33 | $this->db =& $db; | ||
2765 | 34 | |||
2766 | 35 | require_once("lib/pages/module.class.php"); | ||
2767 | 36 | Kit::ClassLoader('layout'); | ||
2768 | 37 | } | ||
2769 | 38 | 33 | ||
2770 | 39 | /** | 34 | /** |
2771 | 40 | * Gets the Xml for the specified layout | 35 | * Gets the Xml for the specified layout |
2772 | @@ -44,7 +39,7 @@ | |||
2773 | 44 | public function GetLayoutXml($layoutid) | 39 | public function GetLayoutXml($layoutid) |
2774 | 45 | { | 40 | { |
2775 | 46 | if ($this->layoutXml == '') { | 41 | if ($this->layoutXml == '') { |
2777 | 47 | $layout = new Layout($this->db); | 42 | $layout = new Layout(); |
2778 | 48 | $this->layoutXml = $layout->GetLayoutXml($layoutid); | 43 | $this->layoutXml = $layout->GetLayoutXml($layoutid); |
2779 | 49 | } | 44 | } |
2780 | 50 | 45 | ||
2781 | @@ -97,7 +92,7 @@ | |||
2782 | 97 | 92 | ||
2783 | 98 | //Do we have a region ID provided? | 93 | //Do we have a region ID provided? |
2784 | 99 | if ($regionid == '') | 94 | if ($regionid == '') |
2786 | 100 | $regionid = uniqid(); | 95 | $regionid = Kit::uniqid(); |
2787 | 101 | 96 | ||
2788 | 102 | // Validation | 97 | // Validation |
2789 | 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)) |
2790 | 104 | 99 | ||
2791 | === modified file 'server/lib/data/schedule.data.class.php' | |||
2792 | --- server/lib/data/schedule.data.class.php 2014-09-05 16:07:36 +0000 | |||
2793 | +++ server/lib/data/schedule.data.class.php 2014-10-21 16:06:16 +0000 | |||
2794 | @@ -22,29 +22,29 @@ | |||
2795 | 22 | 22 | ||
2796 | 23 | class Schedule extends Data | 23 | class Schedule extends Data |
2797 | 24 | { | 24 | { |
2816 | 25 | /** | 25 | /** |
2817 | 26 | * Add | 26 | * Add |
2818 | 27 | * @return | 27 | * @return |
2819 | 28 | * @param $displayGroupIDs Object | 28 | * @param $displayGroupIDs Object |
2820 | 29 | * @param $fromDT Object | 29 | * @param $fromDT Object |
2821 | 30 | * @param $toDT Object | 30 | * @param $toDT Object |
2822 | 31 | * @param $layoutID Object | 31 | * @param $layoutID Object |
2823 | 32 | * @param $recType Object | 32 | * @param $recType Object |
2824 | 33 | * @param $recDetail Object | 33 | * @param $recDetail Object |
2825 | 34 | * @param $recToDT Object | 34 | * @param $recToDT Object |
2826 | 35 | * @param $isPriority Object | 35 | * @param $isPriority Object |
2827 | 36 | * @param $userID Object | 36 | * @param $userID Object |
2828 | 37 | * @param $displayOrder Object | 37 | * @param $displayOrder Object |
2829 | 38 | */ | 38 | */ |
2830 | 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) |
2831 | 40 | { | 40 | { |
2832 | 41 | Debug::LogEntry('audit', 'IN', 'Schedule', 'Add'); | 41 | Debug::LogEntry('audit', 'IN', 'Schedule', 'Add'); |
2833 | 42 | 42 | ||
2834 | 43 | try { | 43 | try { |
2835 | 44 | $dbh = PDOConnect::init(); | 44 | $dbh = PDOConnect::init(); |
2836 | 45 | 45 | ||
2837 | 46 | // Validation | 46 | // Validation |
2839 | 47 | if (count($displayGroupIDs) == 0) | 47 | if (count($displayGroupIDs) == 0) |
2840 | 48 | return $this->SetError(25001, __('No display groups selected')); | 48 | return $this->SetError(25001, __('No display groups selected')); |
2841 | 49 | 49 | ||
2842 | 50 | if ($userID == 0) | 50 | if ($userID == 0) |
2843 | @@ -54,121 +54,124 @@ | |||
2844 | 54 | if ($recDetail == 0) | 54 | if ($recDetail == 0) |
2845 | 55 | $recDetail = 1; | 55 | $recDetail = 1; |
2846 | 56 | 56 | ||
2884 | 57 | // make the displayid_list from the selected displays. | 57 | // make the displayid_list from the selected displays. |
2885 | 58 | $displayGroupIDList = implode(",", $displayGroupIDs); | 58 | $displayGroupIDList = implode(",", $displayGroupIDs); |
2886 | 59 | 59 | ||
2887 | 60 | // Parameters for the query | 60 | // Parameters for the query |
2888 | 61 | $params = array( | 61 | $params = array( |
2889 | 62 | 'campaignid' => $campaignId, | 62 | 'campaignid' => $campaignId, |
2890 | 63 | 'displaygroupids' => $displayGroupIDList, | 63 | 'displaygroupids' => $displayGroupIDList, |
2891 | 64 | 'userid' => $userID, | 64 | 'userid' => $userID, |
2892 | 65 | 'is_priority' => $isPriority, | 65 | 'is_priority' => $isPriority, |
2893 | 66 | 'fromdt' => $fromDT, | 66 | 'fromdt' => $fromDT, |
2894 | 67 | 'todt' => $toDT, | 67 | 'todt' => $toDT, |
2895 | 68 | 'displayorder' => $displayOrder | 68 | 'displayorder' => $displayOrder |
2896 | 69 | ); | 69 | ); |
2897 | 70 | 70 | ||
2898 | 71 | $SQL = ""; | 71 | $SQL = ""; |
2899 | 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 "; |
2900 | 73 | 73 | ||
2901 | 74 | // Columns for Recurrence | 74 | // Columns for Recurrence |
2902 | 75 | if ($recType != '' && $recType != 'null') { | 75 | if ($recType != '' && $recType != 'null') { |
2903 | 76 | $SQL .= ", recurrence_type, recurrence_detail, recurrence_range "; | 76 | $SQL .= ", recurrence_type, recurrence_detail, recurrence_range "; |
2904 | 77 | } | 77 | } |
2905 | 78 | 78 | ||
2906 | 79 | $SQL .= ") "; | 79 | $SQL .= ") "; |
2907 | 80 | $SQL .= " VALUES ( :campaignid, :displaygroupids, :userid, :is_priority, :fromdt, :todt, :displayorder "; | 80 | $SQL .= " VALUES ( :campaignid, :displaygroupids, :userid, :is_priority, :fromdt, :todt, :displayorder "; |
2908 | 81 | 81 | ||
2909 | 82 | // Values for Recurrence | 82 | // Values for Recurrence |
2910 | 83 | if ($recType != '' && $recType != 'null') | 83 | if ($recType != '' && $recType != 'null') |
2911 | 84 | { | 84 | { |
2912 | 85 | $SQL .= ", :recurrence_type, :recurrence_detail, :recurrence_range "; | 85 | // Check that we have an end date |
2913 | 86 | $params['recurrence_type'] = $recType; | 86 | if ($recToDT == '' || $recToDT == 0) |
2914 | 87 | $params['recurrence_detail'] = $recDetail; | 87 | $this->ThrowError(__('Please provide an until date or set repeats to None')); |
2915 | 88 | $params['recurrence_range'] = $recToDT; | 88 | |
2916 | 89 | } | 89 | $SQL .= ", :recurrence_type, :recurrence_detail, :recurrence_range "; |
2917 | 90 | 90 | $params['recurrence_type'] = $recType; | |
2918 | 91 | $SQL .= ")"; | 91 | $params['recurrence_detail'] = $recDetail; |
2919 | 92 | 92 | $params['recurrence_range'] = $recToDT; | |
2920 | 93 | $sth = $dbh->prepare($SQL); | 93 | } |
2921 | 94 | |||
2922 | 95 | $SQL .= ")"; | ||
2923 | 96 | |||
2924 | 97 | $sth = $dbh->prepare($SQL); | ||
2925 | 94 | $sth->execute($params); | 98 | $sth->execute($params); |
2994 | 95 | 99 | ||
2995 | 96 | // Get the event id | 100 | // Get the event id |
2996 | 97 | $eventID = $dbh->lastInsertId(); | 101 | $eventID = $dbh->lastInsertId(); |
2997 | 98 | 102 | ||
2998 | 99 | // Make sure we dont just have one... | 103 | // Make sure we dont just have one... |
2999 | 100 | if (!is_array($displayGroupIDs)) | 104 | if (!is_array($displayGroupIDs)) |
3000 | 101 | $displayGroupIDs = array($displayGroupIDs); | 105 | $displayGroupIDs = array($displayGroupIDs); |
3001 | 102 | 106 | ||
3002 | 103 | // Create a detail record for each display group | 107 | // Create a detail record for each display group |
3003 | 104 | foreach ($displayGroupIDs as $displayGroupID) | 108 | foreach ($displayGroupIDs as $displayGroupID) |
3004 | 105 | { | 109 | { |
3005 | 106 | // Add the parent detail record for this event | 110 | // Add the parent detail record for this event |
3006 | 107 | if (!$this->AddDetail($displayGroupID, $fromDT, $toDT, $userID, $eventID)) | 111 | if (!$this->AddDetail($displayGroupID, $fromDT, $toDT, $userID, $eventID)) |
3007 | 108 | throw new Exception("Error Processing Request", 1); | 112 | throw new Exception("Error Processing Request", 1); |
3008 | 109 | 113 | ||
3009 | 110 | // Is there any recurrance to take care of? | 114 | // Is there any recurrance to take care of? |
3010 | 111 | if ($recType != '' && $recType != 'null') { | 115 | if ($recType != '' && $recType != 'null') { |
3011 | 112 | // Set the temp starts | 116 | // Set the temp starts |
3012 | 113 | $t_start_temp = $fromDT; | 117 | $t_start_temp = $fromDT; |
3013 | 114 | $t_end_temp = $toDT; | 118 | $t_end_temp = $toDT; |
3014 | 115 | 119 | ||
3015 | 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'); |
3016 | 117 | 121 | ||
3017 | 118 | //loop until we have added the recurring events for the schedule | 122 | //loop until we have added the recurring events for the schedule |
3018 | 119 | while ($t_start_temp < $recToDT) | 123 | while ($t_start_temp < $recToDT) |
3019 | 120 | { | 124 | { |
3020 | 121 | // add the appropriate time to the start and end | 125 | // add the appropriate time to the start and end |
3021 | 122 | switch ($recType) | 126 | switch ($recType) |
3022 | 123 | { | 127 | { |
3023 | 124 | case 'Minute': | 128 | case 'Minute': |
3024 | 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)); |
3025 | 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)); |
3026 | 127 | break; | 131 | break; |
3027 | 128 | 132 | ||
3028 | 129 | case 'Hour': | 133 | case 'Hour': |
3029 | 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)); |
3030 | 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)); |
3031 | 132 | break; | 136 | break; |
3032 | 133 | 137 | ||
3033 | 134 | case 'Day': | 138 | case 'Day': |
3034 | 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)); |
3035 | 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)); |
3036 | 137 | break; | 141 | break; |
3037 | 138 | 142 | ||
3038 | 139 | case 'Week': | 143 | case 'Week': |
3039 | 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)); |
3040 | 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)); |
3041 | 142 | break; | 146 | break; |
3042 | 143 | 147 | ||
3043 | 144 | case 'Month': | 148 | case 'Month': |
3044 | 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)); |
3045 | 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)); |
3046 | 147 | break; | 151 | break; |
3047 | 148 | 152 | ||
3048 | 149 | case 'Year': | 153 | case 'Year': |
3049 | 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); |
3050 | 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); |
3051 | 152 | break; | 156 | break; |
3052 | 153 | } | 157 | } |
3053 | 154 | 158 | ||
3054 | 155 | // after we have added the appropriate amount, are we still valid | 159 | // after we have added the appropriate amount, are we still valid |
3055 | 156 | if ($t_start_temp > $recToDT) break; | 160 | if ($t_start_temp > $recToDT) break; |
3056 | 157 | 161 | ||
3057 | 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)) |
3058 | 159 | throw new Exception("Error Processing Request", 1); | 163 | throw new Exception("Error Processing Request", 1); |
3059 | 160 | } | 164 | } |
3060 | 161 | } | 165 | } |
3061 | 162 | } | 166 | } |
3062 | 163 | 167 | ||
3063 | 164 | // Notify (dont error) | 168 | // Notify (dont error) |
3064 | 165 | Kit::ClassLoader('Display'); | ||
3065 | 166 | $displayObject = new Display($this->db); | 169 | $displayObject = new Display($this->db); |
3066 | 167 | $displayObject->NotifyDisplays($campaignId); | 170 | $displayObject->NotifyDisplays($campaignId); |
3071 | 168 | 171 | ||
3072 | 169 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'Add'); | 172 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'Add'); |
3073 | 170 | 173 | ||
3074 | 171 | return true; | 174 | return true; |
3075 | 172 | } | 175 | } |
3076 | 173 | catch (Exception $e) { | 176 | catch (Exception $e) { |
3077 | 174 | 177 | ||
3078 | @@ -179,8 +182,8 @@ | |||
3079 | 179 | 182 | ||
3080 | 180 | return false; | 183 | return false; |
3081 | 181 | } | 184 | } |
3084 | 182 | } | 185 | } |
3085 | 183 | 186 | ||
3086 | 184 | /** | 187 | /** |
3087 | 185 | * Edits a Schedule | 188 | * Edits a Schedule |
3088 | 186 | * @param <type> $eventID | 189 | * @param <type> $eventID |
3089 | @@ -196,400 +199,459 @@ | |||
3090 | 196 | * @param <int> $displayOrder | 199 | * @param <int> $displayOrder |
3091 | 197 | * @return <type> | 200 | * @return <type> |
3092 | 198 | */ | 201 | */ |
3096 | 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) |
3097 | 200 | { | 203 | { |
3098 | 201 | Debug::LogEntry('audit', 'IN', 'Schedule', 'Edit'); | 204 | Debug::LogEntry('audit', 'IN', 'Schedule', 'Edit'); |
3099 | 202 | 205 | ||
3100 | 203 | // Cant have a 0 increment as it creates a loop | 206 | // Cant have a 0 increment as it creates a loop |
3101 | 204 | if ($rec_detail == 0) | 207 | if ($rec_detail == 0) |
3102 | 205 | $rec_detail = 1; | 208 | $rec_detail = 1; |
3470 | 206 | 209 | ||
3471 | 207 | // What we are really going to do here is delete and re-add... just because it is easier to get the logic right | 210 | // What we are really going to do here is delete and re-add... just because it is easier to get the logic right |
3472 | 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. |
3473 | 209 | 212 | ||
3474 | 210 | // Delete the old schedule | 213 | // Delete the old schedule |
3475 | 211 | if (!$this->Delete($eventID)) | 214 | if (!$this->Delete($eventID)) |
3476 | 212 | return false; | 215 | return false; |
3477 | 213 | 216 | ||
3478 | 214 | // Add the new one | 217 | // Add the new one |
3479 | 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)) |
3480 | 216 | return false; | 219 | return false; |
3481 | 217 | 220 | ||
3482 | 218 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'Edit'); | 221 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'Edit'); |
3483 | 219 | 222 | ||
3484 | 220 | return true; | 223 | return true; |
3485 | 221 | } | 224 | } |
3486 | 222 | 225 | ||
3487 | 223 | /** | 226 | /** |
3488 | 224 | * Deletes a scheduled event | 227 | * Deletes a scheduled event |
3489 | 225 | * @return | 228 | * @return |
3490 | 226 | * @param $eventID Object | 229 | * @param $eventID Object |
3491 | 227 | */ | 230 | */ |
3492 | 228 | public function Delete($eventID) | 231 | public function Delete($eventID) |
3493 | 229 | { | 232 | { |
3494 | 230 | Debug::LogEntry('audit', 'IN', 'Schedule', 'Delete'); | 233 | Debug::LogEntry('audit', 'IN', 'Schedule', 'Delete'); |
3495 | 231 | 234 | ||
3496 | 232 | try { | 235 | try { |
3497 | 233 | $dbh = PDOConnect::init(); | 236 | $dbh = PDOConnect::init(); |
3498 | 234 | 237 | ||
3499 | 235 | if (!$this->DeleteScheduleForEvent($eventID)) | 238 | if (!$this->DeleteScheduleForEvent($eventID)) |
3500 | 236 | throw new Exception("Error Processing Request", 1); | 239 | throw new Exception("Error Processing Request", 1); |
3501 | 237 | 240 | ||
3502 | 238 | // Delete all Schedule records for this DisplayGroupID | 241 | // Delete all Schedule records for this DisplayGroupID |
3503 | 239 | $sth = $dbh->prepare('DELETE FROM schedule WHERE eventID = :eventid'); | 242 | $sth = $dbh->prepare('DELETE FROM schedule WHERE eventID = :eventid'); |
3504 | 240 | $sth->execute(array( | 243 | $sth->execute(array( |
3505 | 241 | 'eventid' => $eventID | 244 | 'eventid' => $eventID |
3506 | 242 | )); | 245 | )); |
3507 | 243 | 246 | ||
3508 | 244 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'Delete'); | 247 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'Delete'); |
3509 | 245 | 248 | ||
3510 | 246 | return true; | 249 | return true; |
3511 | 247 | } | 250 | } |
3512 | 248 | catch (Exception $e) { | 251 | catch (Exception $e) { |
3513 | 249 | 252 | ||
3514 | 250 | Debug::LogEntry('error', $e->getMessage()); | 253 | Debug::LogEntry('error', $e->getMessage()); |
3515 | 251 | 254 | ||
3516 | 252 | if (!$this->IsError()) | 255 | if (!$this->IsError()) |
3517 | 253 | $this->SetError(25016,__('Unable to delete schedule record for this Event.')); | 256 | $this->SetError(25016,__('Unable to delete schedule record for this Event.')); |
3518 | 254 | 257 | ||
3519 | 255 | return false; | 258 | return false; |
3520 | 256 | } | 259 | } |
3521 | 257 | } | 260 | } |
3522 | 258 | 261 | ||
3523 | 259 | /** | 262 | /** |
3524 | 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. |
3525 | 261 | * @return | 264 | * @return |
3526 | 262 | * @param $displayGroupID Object | 265 | * @param $displayGroupID Object |
3527 | 263 | * @param $layoutID Object | 266 | * @param $layoutID Object |
3528 | 264 | * @param $fromDT Object | 267 | * @param $fromDT Object |
3529 | 265 | * @param $toDT Object | 268 | * @param $toDT Object |
3530 | 266 | * @param $userID Object | 269 | * @param $userID Object |
3531 | 267 | * @param $isPriority Object | 270 | * @param $isPriority Object |
3532 | 268 | * @param $eventID Object[optional] | 271 | * @param $eventID Object[optional] |
3533 | 269 | */ | 272 | */ |
3534 | 270 | public function AddDetail($displayGroupID, $fromDT, $toDT, $userID, $eventID) | 273 | public function AddDetail($displayGroupID, $fromDT, $toDT, $userID, $eventID) |
3535 | 271 | { | 274 | { |
3536 | 272 | Debug::LogEntry('audit', 'IN', 'Schedule', 'AddDetail'); | 275 | Debug::LogEntry('audit', 'IN', 'Schedule', 'AddDetail'); |
3537 | 273 | 276 | ||
3538 | 274 | try { | 277 | try { |
3539 | 275 | $dbh = PDOConnect::init(); | 278 | $dbh = PDOConnect::init(); |
3540 | 276 | 279 | ||
3541 | 277 | // The parameters for the INSERT | 280 | // The parameters for the INSERT |
3542 | 278 | $params = array( | 281 | $params = array( |
3543 | 279 | 'displaygroupid' => $displayGroupID, | 282 | 'displaygroupid' => $displayGroupID, |
3544 | 280 | 'fromdt' => $fromDT, | 283 | 'fromdt' => $fromDT, |
3545 | 281 | 'todt' => $toDT, | 284 | 'todt' => $toDT, |
3546 | 282 | 'userid' => $userID | 285 | 'userid' => $userID |
3547 | 283 | ); | 286 | ); |
3548 | 284 | 287 | ||
3549 | 285 | // Insert statement | 288 | // Insert statement |
3550 | 286 | $SQL = "INSERT INTO schedule_detail (DisplayGroupID, FromDT, ToDT, userID"; | 289 | $SQL = "INSERT INTO schedule_detail (DisplayGroupID, FromDT, ToDT, userID"; |
3551 | 287 | 290 | ||
3552 | 288 | // Extras for Event ID | 291 | // Extras for Event ID |
3553 | 289 | if ($eventID != '') | 292 | if ($eventID != '') |
3554 | 290 | { | 293 | { |
3555 | 291 | $SQL .= ", eventID"; | 294 | $SQL .= ", eventID"; |
3556 | 292 | $params['eventid'] = $eventID; | 295 | $params['eventid'] = $eventID; |
3557 | 293 | } | 296 | } |
3558 | 294 | 297 | ||
3559 | 295 | $SQL .= ") "; | 298 | $SQL .= ") "; |
3560 | 296 | 299 | ||
3561 | 297 | // Values | 300 | // Values |
3562 | 298 | $SQL .= "VALUES (:displaygroupid, :fromdt, :todt, :userid"; | 301 | $SQL .= "VALUES (:displaygroupid, :fromdt, :todt, :userid"; |
3563 | 299 | 302 | ||
3564 | 300 | if ($eventID != '') | 303 | if ($eventID != '') |
3565 | 301 | $SQL .= ", :eventid"; | 304 | $SQL .= ", :eventid"; |
3566 | 302 | 305 | ||
3567 | 303 | $SQL .= ")"; | 306 | $SQL .= ")"; |
3568 | 304 | 307 | ||
3569 | 305 | // Execute the SQL | 308 | // Execute the SQL |
3570 | 306 | $sth = $dbh->prepare($SQL); | 309 | $sth = $dbh->prepare($SQL); |
3571 | 307 | $sth->execute($params); | 310 | $sth->execute($params); |
3572 | 308 | 311 | ||
3573 | 309 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'AddDetail'); | 312 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'AddDetail'); |
3574 | 310 | 313 | ||
3575 | 311 | return true; | 314 | return true; |
3576 | 312 | } | 315 | } |
3577 | 313 | catch (Exception $e) { | 316 | catch (Exception $e) { |
3578 | 314 | 317 | ||
3579 | 315 | Debug::LogEntry('error', $e->getMessage()); | 318 | Debug::LogEntry('error', $e->getMessage()); |
3580 | 316 | 319 | ||
3581 | 317 | if (!$this->IsError()) | 320 | if (!$this->IsError()) |
3582 | 318 | $this->SetError(25002, __('Could not update Layout on Schedule')); | 321 | $this->SetError(25002, __('Could not update Layout on Schedule')); |
3583 | 319 | 322 | ||
3584 | 320 | return false; | 323 | return false; |
3585 | 321 | } | 324 | } |
3586 | 322 | } | 325 | } |
3587 | 323 | 326 | ||
3588 | 324 | /** | 327 | /** |
3589 | 325 | * Deletes all the Schedule records for a display group | 328 | * Deletes all the Schedule records for a display group |
3590 | 326 | * @return | 329 | * @return |
3591 | 327 | * @param $displayGroupID Object | 330 | * @param $displayGroupID Object |
3592 | 328 | */ | 331 | */ |
3593 | 329 | public function DeleteScheduleForDisplayGroup($displayGroupID) | 332 | public function DeleteScheduleForDisplayGroup($displayGroupID) |
3594 | 330 | { | 333 | { |
3595 | 331 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForDisplayGroup'); | 334 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForDisplayGroup'); |
3596 | 332 | 335 | ||
3597 | 333 | try { | 336 | try { |
3598 | 334 | $dbh = PDOConnect::init(); | 337 | $dbh = PDOConnect::init(); |
3599 | 335 | 338 | ||
3600 | 336 | // Delete all Schedule records for this DisplayGroupID | 339 | // Delete all Schedule records for this DisplayGroupID |
3601 | 337 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE DisplayGroupID = :displaygroupid'); | 340 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE DisplayGroupID = :displaygroupid'); |
3602 | 338 | $sth->execute(array( | 341 | $sth->execute(array( |
3603 | 339 | 'displaygroupid' => $displayGroupID | 342 | 'displaygroupid' => $displayGroupID |
3604 | 340 | )); | 343 | )); |
3605 | 341 | 344 | ||
3606 | 342 | // Tidy up the schedule table. There might be orphaned records because of this delete | 345 | // Tidy up the schedule table. There might be orphaned records because of this delete |
3607 | 343 | $this->TidyScheduleTable(); | 346 | $this->TidyScheduleTable(); |
3608 | 344 | 347 | ||
3609 | 345 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForDisplayGroup'); | 348 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForDisplayGroup'); |
3610 | 346 | 349 | ||
3611 | 347 | return true; | 350 | return true; |
3612 | 348 | } | 351 | } |
3613 | 349 | catch (Exception $e) { | 352 | catch (Exception $e) { |
3614 | 350 | 353 | ||
3615 | 351 | Debug::LogEntry('error', $e->getMessage()); | 354 | Debug::LogEntry('error', $e->getMessage()); |
3616 | 352 | 355 | ||
3617 | 353 | if (!$this->IsError()) | 356 | if (!$this->IsError()) |
3618 | 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.')); |
3619 | 355 | 358 | ||
3620 | 356 | return false; | 359 | return false; |
3621 | 357 | } | 360 | } |
3622 | 358 | } | 361 | } |
3623 | 359 | 362 | ||
3624 | 360 | /** | 363 | /** |
3625 | 361 | * Removes any orphaned records from the Schedule Table | 364 | * Deletes all the Schedule records for a display group |
3626 | 362 | * Usually called as a result of an open-ended delete (such as deleting an entire display group) | 365 | * @return |
3627 | 363 | */ | 366 | * @param $displayGroupID Object |
3628 | 364 | private function TidyScheduleTable() { | 367 | */ |
3629 | 365 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'TidyScheduleTable'); | 368 | public static function DeleteScheduleForCampaign($campaignId) |
3630 | 366 | 369 | { | |
3631 | 367 | try { | 370 | try { |
3632 | 368 | $dbh = PDOConnect::init(); | 371 | $dbh = PDOConnect::init(); |
3633 | 369 | 372 | ||
3634 | 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 |
3635 | 371 | $sth->execute(); | 374 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID IN (SELECT EventID FROM `schedule` WHERE CampaignID = :campaignId)'); |
3636 | 372 | 375 | $sth->execute(array( | |
3637 | 373 | return true; | 376 | 'campaignId' => $campaignId |
3638 | 374 | } | 377 | )); |
3639 | 375 | catch (Exception $e) { | 378 | |
3640 | 376 | 379 | // Delete all Schedule records for this campaignId | |
3641 | 377 | Debug::LogEntry('error', $e->getMessage()); | 380 | $sth = $dbh->prepare('DELETE FROM schedule WHERE CampaignId = :campaignId'); |
3642 | 378 | 381 | $sth->execute(array( | |
3643 | 379 | if (!$this->IsError()) | 382 | 'campaignId' => $campaignId |
3644 | 380 | $this->SetError(1, __('Unknown Error')); | 383 | )); |
3645 | 381 | 384 | ||
3646 | 382 | return false; | 385 | return true; |
3647 | 383 | } | 386 | } |
3648 | 384 | } | 387 | catch (Exception $e) { |
3649 | 385 | 388 | ||
3650 | 386 | /** | 389 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); |
3651 | 387 | * Deletes all the Schedule records for an EventID | 390 | |
3652 | 388 | * @return | 391 | if (!$this->IsError()) |
3653 | 389 | * @param $displayGroupID Object | 392 | $this->SetError(25015,__('Unable to delete schedule records for Campaign.')); |
3654 | 390 | */ | 393 | |
3655 | 391 | public function DeleteScheduleForEvent($eventID) { | 394 | return false; |
3656 | 392 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForEvent'); | 395 | } |
3657 | 393 | 396 | } | |
3658 | 394 | try { | 397 | |
3659 | 395 | $dbh = PDOConnect::init(); | 398 | /** |
3660 | 396 | 399 | * Removes any orphaned records from the Schedule Table | |
3661 | 397 | // Delete all Schedule records for this DisplayGroupID | 400 | * Usually called as a result of an open-ended delete (such as deleting an entire display group) |
3662 | 398 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID = :eventid'); | 401 | */ |
3663 | 399 | $sth->execute(array( | 402 | private static function TidyScheduleTable() |
3664 | 400 | 'eventid' => $eventID | 403 | { |
3665 | 401 | )); | 404 | try { |
3666 | 402 | 405 | $dbh = PDOConnect::init(); | |
3667 | 403 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForEvent'); | 406 | |
3668 | 404 | 407 | $sth = $dbh->prepare('DELETE FROM `schedule` WHERE EventID NOT IN (SELECT EventID FROM `schedule_detail`)'); | |
3669 | 405 | return true; | 408 | $sth->execute(); |
3670 | 406 | } | 409 | |
3671 | 407 | catch (Exception $e) { | 410 | return true; |
3672 | 408 | 411 | } | |
3673 | 409 | Debug::LogEntry('error', $e->getMessage()); | 412 | catch (Exception $e) { |
3674 | 410 | 413 | ||
3675 | 411 | if (!$this->IsError()) | 414 | Debug::LogEntry('error', $e->getMessage()); |
3676 | 412 | $this->SetError(25016,__('Unable to delete schedule records for this Event.')); | 415 | |
3677 | 413 | 416 | if (!$this->IsError()) | |
3678 | 414 | return false; | 417 | $this->SetError(1, __('Unknown Error')); |
3679 | 415 | } | 418 | |
3680 | 416 | } | 419 | return false; |
3681 | 417 | 420 | } | |
3682 | 418 | /** | 421 | } |
3683 | 419 | * Deletes all the Schedule records for an EventID and DisplayGroupID | 422 | |
3684 | 420 | * @return | 423 | /** |
3685 | 421 | * @param $displayGroupID Object | 424 | * Removes any orphaned records from the Schedule Table |
3686 | 422 | */ | 425 | * Usually called as a result of an open-ended delete (such as deleting an entire display group) |
3687 | 423 | public function DeleteScheduleForEventAndGroup($eventID, $displayGroupID) { | 426 | */ |
3688 | 424 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForEventAndGroup'); | 427 | private static function TidyScheduleDetailTable() |
3689 | 425 | 428 | { | |
3690 | 426 | try { | 429 | try { |
3691 | 427 | $dbh = PDOConnect::init(); | 430 | $dbh = PDOConnect::init(); |
3692 | 428 | 431 | ||
3693 | 429 | // Delete all Schedule records for this DisplayGroupID | 432 | $sth = $dbh->prepare('DELETE FROM `schedule_detail` WHERE EventID NOT IN (SELECT EventID FROM `schedule`)'); |
3694 | 430 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID = :eventid AND DisplayGroupID = :displaygroupid'); | 433 | $sth->execute(); |
3695 | 431 | $sth->execute(array( | 434 | |
3696 | 432 | 'displaygroupid' => $displayGroupID, | 435 | return true; |
3697 | 433 | 'eventid' => $eventID | 436 | } |
3698 | 434 | )); | 437 | catch (Exception $e) { |
3699 | 435 | 438 | ||
3700 | 436 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForEventAndGroup'); | 439 | Debug::LogEntry('error', $e->getMessage()); |
3701 | 437 | 440 | ||
3702 | 438 | return true; | 441 | if (!$this->IsError()) |
3703 | 439 | } | 442 | $this->SetError(1, __('Unknown Error')); |
3704 | 440 | catch (Exception $e) { | 443 | |
3705 | 441 | 444 | return false; | |
3706 | 442 | Debug::LogEntry('error', $e->getMessage()); | 445 | } |
3707 | 443 | 446 | } | |
3708 | 444 | if (!$this->IsError()) | 447 | |
3709 | 445 | $this->SetError(25016,__('Unable to delete schedule records for this Event and DisplayGroup.')); | 448 | /** |
3710 | 446 | 449 | * Deletes all the Schedule records for an EventID | |
3711 | 447 | return false; | 450 | * @return |
3712 | 448 | } | 451 | * @param $displayGroupID Object |
3713 | 449 | } | 452 | */ |
3714 | 450 | 453 | public function DeleteScheduleForEvent($eventID) { | |
3715 | 451 | /** | 454 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForEvent'); |
3716 | 452 | * Deletes the event detail record provided | 455 | |
3717 | 453 | * @return | 456 | try { |
3718 | 454 | * @param $eventDetailID Object | 457 | $dbh = PDOConnect::init(); |
3719 | 455 | */ | 458 | |
3720 | 456 | public function DeleteEventDetail($eventDetailID) { | 459 | // Delete all Schedule records for this DisplayGroupID |
3721 | 457 | Debug::LogEntry('audit', 'IN', 'Schedule', 'DeleteEventDetail'); | 460 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID = :eventid'); |
3722 | 458 | 461 | $sth->execute(array( | |
3723 | 459 | try { | 462 | 'eventid' => $eventID |
3724 | 460 | $dbh = PDOConnect::init(); | 463 | )); |
3725 | 461 | 464 | ||
3726 | 462 | // Delete all Schedule records for this EventDetail | 465 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForEvent'); |
3727 | 463 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE schedule_detailID = :schedule_detailid'); | 466 | |
3728 | 464 | $sth->execute(array( | 467 | return true; |
3729 | 465 | 'schedule_detailid' => $eventDetailID | 468 | } |
3730 | 466 | )); | 469 | catch (Exception $e) { |
3731 | 467 | 470 | ||
3732 | 468 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'DeleteEventDetail'); | 471 | Debug::LogEntry('error', $e->getMessage()); |
3733 | 469 | 472 | ||
3734 | 470 | return true; | 473 | if (!$this->IsError()) |
3735 | 471 | } | 474 | $this->SetError(25016,__('Unable to delete schedule records for this Event.')); |
3736 | 472 | catch (Exception $e) { | 475 | |
3737 | 473 | 476 | return false; | |
3738 | 474 | Debug::LogEntry('error', $e->getMessage()); | 477 | } |
3739 | 475 | 478 | } | |
3740 | 476 | if (!$this->IsError()) | 479 | |
3741 | 477 | $this->SetError(25016,__('Unable to delete schedule records for this Event.')); | 480 | /** |
3742 | 478 | 481 | * Deletes all the Schedule records for an EventID and DisplayGroupID | |
3743 | 479 | return false; | 482 | * @return |
3744 | 480 | } | 483 | * @param $displayGroupID Object |
3745 | 481 | } | 484 | */ |
3746 | 482 | 485 | public function DeleteScheduleForEventAndGroup($eventID, $displayGroupID) { | |
3747 | 483 | public function DeleteDisplayGroupFromEvent($eventID, $displayGroupID) | 486 | Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'DeleteScheduleForEventAndGroup'); |
3748 | 484 | { | 487 | |
3749 | 485 | Debug::LogEntry('audit', 'IN', 'Schedule', 'EditDisplayGroupsForEvent'); | 488 | try { |
3750 | 486 | 489 | $dbh = PDOConnect::init(); | |
3751 | 487 | try { | 490 | |
3752 | 488 | $dbh = PDOConnect::init(); | 491 | // Delete all Schedule records for this DisplayGroupID |
3753 | 489 | 492 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE EventID = :eventid AND DisplayGroupID = :displaygroupid'); | |
3754 | 490 | // Read the display groups from the event | 493 | $sth->execute(array( |
3755 | 491 | $SQL = sprintf('', $eventID); | 494 | 'displaygroupid' => $displayGroupID, |
3756 | 492 | $sth = $dbh->prepare('SELECT DisplayGroupIDs FROM schedule WHERE EventID = :eventid'); | 495 | 'eventid' => $eventID |
3757 | 493 | $sth->execute(array( | 496 | )); |
3758 | 494 | 'eventid' => $eventID | 497 | |
3759 | 495 | )); | 498 | Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'DeleteScheduleForEventAndGroup'); |
3760 | 496 | 499 | ||
3761 | 497 | if (!$row = $sth->fetch()) | 500 | return true; |
3762 | 498 | $this->ThrowError(25034,__('Error retriving information necessary to delete this event')); | 501 | } |
3763 | 499 | 502 | catch (Exception $e) { | |
3764 | 500 | // Get the Display Group IDs | 503 | |
3765 | 501 | $displayGroupIDs = Kit::ValidateParam($row['DisplayGroupIDs'], _STRING); | 504 | Debug::LogEntry('error', $e->getMessage()); |
3766 | 502 | 505 | ||
3767 | 503 | // Load into an array and remove the one in $displayGroupID | 506 | if (!$this->IsError()) |
3768 | 504 | $displayGroupIDs = explode(',', $displayGroupIDs); | 507 | $this->SetError(25016,__('Unable to delete schedule records for this Event and DisplayGroup.')); |
3769 | 505 | $key = array_search($displayGroupID, $displayGroupIDs); | 508 | |
3770 | 506 | 509 | return false; | |
3771 | 507 | if ($key !== true) { | 510 | } |
3772 | 508 | unset($displayGroupIDs[$key]); | 511 | } |
3773 | 509 | } | 512 | |
3774 | 510 | else { | 513 | /** |
3775 | 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 |
3776 | 512 | return true; | 515 | * @return |
3777 | 513 | } | 516 | * @param $eventDetailID Object |
3778 | 514 | 517 | */ | |
3779 | 515 | // Save the list back to the event | 518 | public function DeleteEventDetail($eventDetailID) { |
3780 | 516 | $displayGroupIDList = implode(',', $displayGroupIDs); | 519 | Debug::LogEntry('audit', 'IN', 'Schedule', 'DeleteEventDetail'); |
3781 | 517 | 520 | ||
3782 | 518 | // Delete all Schedule records for this EventDetail | 521 | try { |
3783 | 519 | $sth = $dbh->prepare('UPDATE schedule SET DisplayGroupIDs = :displaygroupids WHERE EventID = :eventid'); | 522 | $dbh = PDOConnect::init(); |
3784 | 520 | $sth->execute(array( | 523 | |
3785 | 521 | 'eventid' => $eventID, | 524 | // Delete all Schedule records for this EventDetail |
3786 | 522 | 'displaygroupids' => $displayGroupIDList | 525 | $sth = $dbh->prepare('DELETE FROM schedule_detail WHERE schedule_detailID = :schedule_detailid'); |
3787 | 523 | )); | 526 | $sth->execute(array( |
3788 | 524 | 527 | 'schedule_detailid' => $eventDetailID | |
3789 | 525 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'EditDisplayGroupsForEvent'); | 528 | )); |
3790 | 526 | 529 | ||
3791 | 527 | return true; | 530 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'DeleteEventDetail'); |
3792 | 528 | } | 531 | |
3793 | 529 | catch (Exception $e) { | 532 | return true; |
3794 | 530 | 533 | } | |
3795 | 531 | Debug::LogEntry('error', $e->getMessage()); | 534 | catch (Exception $e) { |
3796 | 532 | 535 | ||
3797 | 533 | if (!$this->IsError()) | 536 | Debug::LogEntry('error', $e->getMessage()); |
3798 | 534 | $this->SetError(25036,__('Unable to edit the display groups for this Event.')); | 537 | |
3799 | 535 | 538 | if (!$this->IsError()) | |
3800 | 536 | return false; | 539 | $this->SetError(25016,__('Unable to delete schedule records for this Event.')); |
3801 | 537 | } | 540 | |
3802 | 538 | } | 541 | return false; |
3803 | 539 | 542 | } | |
3804 | 540 | /** | 543 | } |
3805 | 541 | * Gets an array of display group ids for the given event | 544 | |
3806 | 542 | * @param [int] $eventId The Event ID | 545 | public function DeleteDisplayGroupFromEvent($eventID, $displayGroupID) |
3807 | 543 | */ | 546 | { |
3808 | 544 | public function DisplayGroupsForEvent($eventId) { | 547 | Debug::LogEntry('audit', 'IN', 'Schedule', 'EditDisplayGroupsForEvent'); |
3809 | 545 | $eventId = Kit::ValidateParam($eventId, _INT); | 548 | |
3810 | 546 | 549 | try { | |
3811 | 547 | try { | 550 | $dbh = PDOConnect::init(); |
3812 | 548 | $dbh = PDOConnect::init(); | 551 | |
3813 | 549 | 552 | // Read the display groups from the event | |
3814 | 550 | $sth = $dbh->prepare('SELECT DISTINCT DisplayGroupID FROM `schedule_detail` WHERE EventID = :eventid'); | 553 | $SQL = sprintf('', $eventID); |
3815 | 551 | $sth->execute(array( | 554 | $sth = $dbh->prepare('SELECT DisplayGroupIDs FROM schedule WHERE EventID = :eventid'); |
3816 | 552 | 'eventid' => $eventId | 555 | $sth->execute(array( |
3817 | 553 | )); | 556 | 'eventid' => $eventID |
3818 | 554 | 557 | )); | |
3819 | 555 | $ids = array(); | 558 | |
3820 | 556 | 559 | if (!$row = $sth->fetch()) | |
3821 | 557 | while ($row = $sth->fetch()) { | 560 | $this->ThrowError(25034,__('Error retriving information necessary to delete this event')); |
3822 | 558 | $ids[] = Kit::ValidateParam($row['DisplayGroupID'], _INT); | 561 | |
3823 | 559 | } | 562 | // Get the Display Group IDs |
3824 | 560 | 563 | $displayGroupIDs = Kit::ValidateParam($row['DisplayGroupIDs'], _STRING); | |
3825 | 561 | return $ids; | 564 | |
3826 | 562 | } | 565 | // Load into an array and remove the one in $displayGroupID |
3827 | 563 | catch (Exception $e) { | 566 | $displayGroupIDs = explode(',', $displayGroupIDs); |
3828 | 564 | 567 | $key = array_search($displayGroupID, $displayGroupIDs); | |
3829 | 565 | Debug::LogEntry('error', $e->getMessage()); | 568 | |
3830 | 566 | 569 | if ($key !== true) { | |
3831 | 567 | if (!$this->IsError()) | 570 | unset($displayGroupIDs[$key]); |
3832 | 568 | $this->SetError(1, __('Unknown Error')); | 571 | } |
3833 | 569 | 572 | else { | |
3834 | 570 | return false; | 573 | Debug::LogEntry('audit', 'Display Group ID is already removed from the Event - this is strange.', 'Schedule', 'EditDisplayGroupsForEvent'); |
3835 | 571 | } | 574 | return true; |
3836 | 572 | } | 575 | } |
3837 | 576 | |||
3838 | 577 | // Save the list back to the event | ||
3839 | 578 | $displayGroupIDList = implode(',', $displayGroupIDs); | ||
3840 | 579 | |||
3841 | 580 | // Delete all Schedule records for this EventDetail | ||
3842 | 581 | $sth = $dbh->prepare('UPDATE schedule SET DisplayGroupIDs = :displaygroupids WHERE EventID = :eventid'); | ||
3843 | 582 | $sth->execute(array( | ||
3844 | 583 | 'eventid' => $eventID, | ||
3845 | 584 | 'displaygroupids' => $displayGroupIDList | ||
3846 | 585 | )); | ||
3847 | 586 | |||
3848 | 587 | Debug::LogEntry('audit', 'OUT', 'Schedule', 'EditDisplayGroupsForEvent'); | ||
3849 | 588 | |||
3850 | 589 | return true; | ||
3851 | 590 | } | ||
3852 | 591 | catch (Exception $e) { | ||
3853 | 592 | |||
3854 | 593 | Debug::LogEntry('error', $e->getMessage()); | ||
3855 | 594 | |||
3856 | 595 | if (!$this->IsError()) | ||
3857 | 596 | $this->SetError(25036,__('Unable to edit the display groups for this Event.')); | ||
3858 | 597 | |||
3859 | 598 | return false; | ||
3860 | 599 | } | ||
3861 | 600 | } | ||
3862 | 601 | |||
3863 | 602 | /** | ||
3864 | 603 | * Gets an array of display group ids for the given event | ||
3865 | 604 | * @param [int] $eventId The Event ID | ||
3866 | 605 | */ | ||
3867 | 606 | public function DisplayGroupsForEvent($eventId) { | ||
3868 | 607 | $eventId = Kit::ValidateParam($eventId, _INT); | ||
3869 | 608 | |||
3870 | 609 | try { | ||
3871 | 610 | $dbh = PDOConnect::init(); | ||
3872 | 611 | |||
3873 | 612 | $sth = $dbh->prepare('SELECT DISTINCT DisplayGroupID FROM `schedule_detail` WHERE EventID = :eventid'); | ||
3874 | 613 | $sth->execute(array( | ||
3875 | 614 | 'eventid' => $eventId | ||
3876 | 615 | )); | ||
3877 | 616 | |||
3878 | 617 | $ids = array(); | ||
3879 | 618 | |||
3880 | 619 | while ($row = $sth->fetch()) { | ||
3881 | 620 | $ids[] = Kit::ValidateParam($row['DisplayGroupID'], _INT); | ||
3882 | 621 | } | ||
3883 | 622 | |||
3884 | 623 | return $ids; | ||
3885 | 624 | } | ||
3886 | 625 | catch (Exception $e) { | ||
3887 | 626 | |||
3888 | 627 | Debug::LogEntry('error', $e->getMessage()); | ||
3889 | 628 | |||
3890 | 629 | if (!$this->IsError()) | ||
3891 | 630 | $this->SetError(1, __('Unknown Error')); | ||
3892 | 631 | |||
3893 | 632 | return false; | ||
3894 | 633 | } | ||
3895 | 634 | } | ||
3896 | 573 | } | 635 | } |
3897 | 574 | 636 | ||
3898 | 575 | class Event | 637 | class Event |
3899 | 576 | { | 638 | { |
3906 | 577 | public $eventID; | 639 | public $eventID; |
3907 | 578 | public $eventDetailID; | 640 | public $eventDetailID; |
3908 | 579 | public $fromDT; | 641 | public $fromDT; |
3909 | 580 | public $toDT; | 642 | public $toDT; |
3910 | 581 | public $layout; | 643 | public $layout; |
3911 | 582 | public $layoutUri; | 644 | public $layoutUri; |
3912 | 583 | public $deleteUri; | 645 | public $deleteUri; |
3917 | 584 | public $spanningDays; | 646 | public $spanningDays; |
3918 | 585 | public $startDayNo; | 647 | public $startDayNo; |
3919 | 586 | public $displayGroup; | 648 | public $displayGroup; |
3920 | 587 | public $editPermission; | 649 | public $editPermission; |
3921 | 588 | public $isdisplayspecific; | 650 | public $isdisplayspecific; |
3927 | 589 | 651 | ||
3928 | 590 | public function __construct() | 652 | public function __construct() |
3929 | 591 | { | 653 | { |
3930 | 592 | 654 | ||
3931 | 593 | } | 655 | } |
3932 | 594 | } | 656 | } |
3933 | 595 | ?> | 657 | ?> |
3934 | 596 | \ No newline at end of file | 658 | \ No newline at end of file |
3935 | 597 | 659 | ||
3936 | === modified file 'server/lib/data/stat.data.class.php' | |||
3937 | --- server/lib/data/stat.data.class.php 2014-01-18 09:47:41 +0000 | |||
3938 | +++ server/lib/data/stat.data.class.php 2014-10-21 16:06:16 +0000 | |||
3939 | @@ -22,68 +22,126 @@ | |||
3940 | 22 | 22 | ||
3941 | 23 | class Stat extends data | 23 | class Stat extends data |
3942 | 24 | { | 24 | { |
4006 | 25 | public function Add($type, $fromDT, $toDT, $scheduleID, $displayID, $layoutID, $mediaID, $tag) | 25 | public function Add($type, $fromDT, $toDT, $scheduleID, $displayID, $layoutID, $mediaID, $tag) |
4007 | 26 | { | 26 | { |
4008 | 27 | try { | 27 | try { |
4009 | 28 | $dbh = PDOConnect::init(); | 28 | $dbh = PDOConnect::init(); |
4010 | 29 | 29 | ||
4011 | 30 | // Lower case the type for consistancy | 30 | // Lower case the type for consistency |
4012 | 31 | $type = strtolower($type); | 31 | $type = strtolower($type); |
4013 | 32 | 32 | ||
4014 | 33 | // Prepare a statement | 33 | // Prepare a statement |
4015 | 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)'); |
4016 | 35 | 35 | ||
4017 | 36 | // Construct a parameters array to execute | 36 | // Construct a parameters array to execute |
4018 | 37 | $params = array(); | 37 | $params = array(); |
4019 | 38 | $params['statdate'] = date("Y-m-d H:i:s"); | 38 | $params['statdate'] = date("Y-m-d H:i:s"); |
4020 | 39 | $params['type'] = $type; | 39 | $params['type'] = $type; |
4021 | 40 | $params['start'] = $fromDT; | 40 | $params['start'] = $fromDT; |
4022 | 41 | $params['end'] = $toDT; | 41 | $params['end'] = $toDT; |
4023 | 42 | $params['scheduleid'] = $scheduleID; | 42 | $params['scheduleid'] = $scheduleID; |
4024 | 43 | $params['displayid'] = $displayID; | 43 | $params['displayid'] = $displayID; |
4025 | 44 | $params['layoutid'] = $layoutID; | 44 | $params['layoutid'] = $layoutID; |
4026 | 45 | 45 | ||
4027 | 46 | // Optional parameters | 46 | // Optional parameters |
4028 | 47 | $params['mediaid'] = null; | 47 | $params['mediaid'] = null; |
4029 | 48 | $params['tag'] = null; | 48 | $params['tag'] = null; |
4030 | 49 | 49 | ||
4031 | 50 | // We should run different SQL depending on what Type we are | 50 | // We should run different SQL depending on what Type we are |
4032 | 51 | switch ($type) | 51 | switch ($type) |
4033 | 52 | { | 52 | { |
4034 | 53 | case 'media': | 53 | case 'media': |
4035 | 54 | $params['mediaid'] = $mediaID; | 54 | $params['mediaid'] = $mediaID; |
4036 | 55 | 55 | ||
4037 | 56 | break; | 56 | break; |
4038 | 57 | 57 | ||
4039 | 58 | case 'layout': | 58 | case 'layout': |
4040 | 59 | // Nothing additional to do | 59 | // Nothing additional to do |
4041 | 60 | break; | 60 | break; |
4042 | 61 | 61 | ||
4043 | 62 | case 'event': | 62 | case 'event': |
4044 | 63 | 63 | ||
4045 | 64 | $params['layoutid'] = 0; | 64 | $params['layoutid'] = 0; |
4046 | 65 | $params['tag'] = $tag; | 65 | $params['tag'] = $tag; |
4047 | 66 | 66 | ||
4048 | 67 | break; | 67 | break; |
4049 | 68 | 68 | ||
4050 | 69 | default: | 69 | default: |
4051 | 70 | // Nothing to do, just exit | 70 | // Nothing to do, just exit |
4052 | 71 | return true; | 71 | return true; |
4053 | 72 | } | 72 | } |
4054 | 73 | 73 | ||
4055 | 74 | $sth->execute($params); | 74 | $sth->execute($params); |
4056 | 75 | 75 | ||
4057 | 76 | return true; | 76 | return true; |
4058 | 77 | } | 77 | } |
4059 | 78 | catch (Exception $e) { | 78 | catch (Exception $e) { |
4060 | 79 | 79 | ||
4061 | 80 | Debug::LogEntry('error', $e->getMessage()); | 80 | Debug::LogEntry('error', $e->getMessage()); |
4062 | 81 | 81 | ||
4063 | 82 | if (!$this->IsError()) | 82 | if (!$this->IsError()) |
4064 | 83 | $this->SetError(25000, 'Stat Insert Failed.'); | 83 | $this->SetError(25000, 'Stat Insert Failed.'); |
4065 | 84 | 84 | ||
4066 | 85 | return false; | 85 | return false; |
4067 | 86 | } | 86 | } |
4068 | 87 | } | 87 | } |
4069 | 88 | |||
4070 | 89 | public function displayDown($displayId, $lastAccessed) | ||
4071 | 90 | { | ||
4072 | 91 | try { | ||
4073 | 92 | $dbh = PDOConnect::init(); | ||
4074 | 93 | |||
4075 | 94 | // Prepare a statement | ||
4076 | 95 | $sth = $dbh->prepare(' | ||
4077 | 96 | INSERT INTO stat (Type, statDate, start, scheduleID, displayID) | ||
4078 | 97 | VALUES (:type, :statdate, :start, :scheduleid, :displayid)'); | ||
4079 | 98 | |||
4080 | 99 | // Construct a parameters array to execute | ||
4081 | 100 | $params = array(); | ||
4082 | 101 | $params['type'] = 'displaydown'; | ||
4083 | 102 | $params['displayid'] = $displayId; | ||
4084 | 103 | $params['statdate'] = date('Y-m-d H:i:s'); | ||
4085 | 104 | $params['start'] = $lastAccessed; | ||
4086 | 105 | $params['scheduleid'] = 0; | ||
4087 | 106 | |||
4088 | 107 | $sth->execute($params); | ||
4089 | 108 | |||
4090 | 109 | return true; | ||
4091 | 110 | } | ||
4092 | 111 | catch (Exception $e) { | ||
4093 | 112 | |||
4094 | 113 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
4095 | 114 | |||
4096 | 115 | if (!$this->IsError()) | ||
4097 | 116 | $this->SetError(1, __('Unknown Error')); | ||
4098 | 117 | |||
4099 | 118 | return false; | ||
4100 | 119 | } | ||
4101 | 120 | } | ||
4102 | 121 | |||
4103 | 122 | public function displayUp($displayId) { | ||
4104 | 123 | try { | ||
4105 | 124 | $dbh = PDOConnect::init(); | ||
4106 | 125 | |||
4107 | 126 | Debug::Audit('Display Up: ' . $displayId); | ||
4108 | 127 | |||
4109 | 128 | $sth = $dbh->prepare('UPDATE stat SET end = :toDt WHERE displayId = :displayId AND end IS NULL'); | ||
4110 | 129 | $sth->execute(array( | ||
4111 | 130 | 'toDt' => date('Y-m-d H:i:s'), | ||
4112 | 131 | 'displayId' => $displayId | ||
4113 | 132 | )); | ||
4114 | 133 | |||
4115 | 134 | return true; | ||
4116 | 135 | } | ||
4117 | 136 | catch (Exception $e) { | ||
4118 | 137 | |||
4119 | 138 | Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); | ||
4120 | 139 | |||
4121 | 140 | if (!$this->IsError()) | ||
4122 | 141 | $this->SetError(1, __('Unknown Error')); | ||
4123 | 142 | |||
4124 | 143 | return false; | ||
4125 | 144 | } | ||
4126 | 145 | } | ||
4127 | 88 | } | 146 | } |
4128 | 89 | ?> | 147 | ?> |
4129 | 90 | \ No newline at end of file | 148 | \ No newline at end of file |
4130 | 91 | 149 | ||
4131 | === modified file 'server/lib/data/usergroup.data.class.php' | |||
4132 | --- server/lib/data/usergroup.data.class.php 2014-08-07 15:47:19 +0000 | |||
4133 | +++ server/lib/data/usergroup.data.class.php 2014-10-21 16:06:16 +0000 | |||
4134 | @@ -22,6 +22,58 @@ | |||
4135 | 22 | 22 | ||
4136 | 23 | class UserGroup extends Data | 23 | class UserGroup extends Data |
4137 | 24 | { | 24 | { |
4138 | 25 | public function GetPermissionsForObject($object, $idCol, $objectId, $clause = '') | ||
4139 | 26 | { | ||
4140 | 27 | try { | ||
4141 | 28 | $dbh = PDOConnect::init(); | ||
4142 | 29 | |||
4143 | 30 | $params = array('id' => $objectId); | ||
4144 | 31 | $SQL = 'SELECT joinedGroup.groupid, joinedGroup.group, view, edit, del, joinedGroup.isuserspecific '; | ||
4145 | 32 | $SQL .= ' FROM ( | ||
4146 | 33 | SELECT `group`.* | ||
4147 | 34 | FROM `group` | ||
4148 | 35 | LEFT OUTER JOIN lkusergroup | ||
4149 | 36 | ON lkusergroup.GroupID = group.GroupID | ||
4150 | 37 | WHERE IsUserSpecific = 0 | ||
4151 | 38 | UNION ALL | ||
4152 | 39 | SELECT `group`.* | ||
4153 | 40 | FROM `group` | ||
4154 | 41 | INNER JOIN lkusergroup | ||
4155 | 42 | ON lkusergroup.GroupID = group.GroupID | ||
4156 | 43 | AND IsUserSpecific = 1 | ||
4157 | 44 | INNER JOIN `user` | ||
4158 | 45 | ON lkusergroup.UserID = user.UserID | ||
4159 | 46 | AND retired = 0 | ||
4160 | 47 | ) joinedGroup '; | ||
4161 | 48 | $SQL .= ' LEFT OUTER JOIN ' . $object; | ||
4162 | 49 | $SQL .= ' ON ' . $object . '.GroupID = joinedGroup.GroupID '; | ||
4163 | 50 | |||
4164 | 51 | if ($clause != '') { | ||
4165 | 52 | $SQL .= $clause; | ||
4166 | 53 | } | ||
4167 | 54 | else { | ||
4168 | 55 | $SQL .= ' AND ' . $object . '.' . $idCol . ' = :id '; | ||
4169 | 56 | $params = array('id' => $objectId); | ||
4170 | 57 | } | ||
4171 | 58 | |||
4172 | 59 | $SQL .= 'ORDER BY joinedGroup.IsEveryone DESC, joinedGroup.IsUserSpecific, joinedGroup.`Group`; '; | ||
4173 | 60 | |||
4174 | 61 | $sth = $dbh->prepare($SQL); | ||
4175 | 62 | $sth->execute($params); | ||
4176 | 63 | |||
4177 | 64 | return $sth->fetchAll(); | ||
4178 | 65 | } | ||
4179 | 66 | catch (Exception $e) { | ||
4180 | 67 | |||
4181 | 68 | Debug::LogEntry('error', $e->getMessage()); | ||
4182 | 69 | |||
4183 | 70 | if (!$this->IsError()) | ||
4184 | 71 | $this->SetError(1, __('Unknown Error')); | ||
4185 | 72 | |||
4186 | 73 | return false; | ||
4187 | 74 | } | ||
4188 | 75 | } | ||
4189 | 76 | |||
4190 | 25 | /** | 77 | /** |
4191 | 26 | * Adds a User Group to Xibo | 78 | * Adds a User Group to Xibo |
4192 | 27 | * @return | 79 | * @return |
4193 | 28 | 80 | ||
4194 | === modified file 'server/lib/include.php' | |||
4195 | --- server/lib/include.php 2014-08-17 12:38:20 +0000 | |||
4196 | +++ server/lib/include.php 2014-10-21 16:06:16 +0000 | |||
4197 | @@ -20,7 +20,7 @@ | |||
4198 | 20 | */ | 20 | */ |
4199 | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); |
4200 | 22 | 22 | ||
4202 | 23 | define('WEBSITE_VERSION', 80); | 23 | define('WEBSITE_VERSION', 81); |
4203 | 24 | 24 | ||
4204 | 25 | // No errors reported until we read the settings from the DB | 25 | // No errors reported until we read the settings from the DB |
4205 | 26 | error_reporting(0); | 26 | error_reporting(0); |
4206 | @@ -41,10 +41,11 @@ | |||
4207 | 41 | require_once("lib/app/responsemanager.class.php"); | 41 | require_once("lib/app/responsemanager.class.php"); |
4208 | 42 | require_once("lib/app/datemanager.class.php"); | 42 | require_once("lib/app/datemanager.class.php"); |
4209 | 43 | require_once("lib/app/app_functions.php"); | 43 | require_once("lib/app/app_functions.php"); |
4210 | 44 | require_once("lib/data/data.class.php"); | ||
4211 | 44 | require_once("lib/modules/module.interface.php"); | 45 | require_once("lib/modules/module.interface.php"); |
4212 | 45 | require_once("lib/modules/module.class.php"); | 46 | require_once("lib/modules/module.class.php"); |
4213 | 46 | require_once("lib/data/data.class.php"); | ||
4214 | 47 | require_once("lib/app/session.class.php"); | 47 | require_once("lib/app/session.class.php"); |
4215 | 48 | require_once("lib/app/cache.class.php"); | ||
4216 | 48 | require_once("lib/app/thememanager.class.php"); | 49 | require_once("lib/app/thememanager.class.php"); |
4217 | 49 | require_once("lib/pages/base.class.php"); | 50 | require_once("lib/pages/base.class.php"); |
4218 | 50 | 51 | ||
4219 | @@ -111,6 +112,11 @@ | |||
4220 | 111 | // Error Handling (our error handler requires a DB connection | 112 | // Error Handling (our error handler requires a DB connection |
4221 | 112 | set_error_handler(array(new Debug(), "ErrorHandler")); | 113 | set_error_handler(array(new Debug(), "ErrorHandler")); |
4222 | 113 | 114 | ||
4223 | 115 | // Define an auto-load function | ||
4224 | 116 | spl_autoload_register(function ($class) { | ||
4225 | 117 | Kit::ClassLoader($class); | ||
4226 | 118 | }); | ||
4227 | 119 | |||
4228 | 114 | // Define the VERSION | 120 | // Define the VERSION |
4229 | 115 | Config::Version(); | 121 | Config::Version(); |
4230 | 116 | 122 | ||
4231 | 117 | 123 | ||
4232 | === modified file 'server/lib/modules/module.class.php' | |||
4233 | --- server/lib/modules/module.class.php 2014-09-05 16:07:36 +0000 | |||
4234 | +++ server/lib/modules/module.class.php 2014-10-21 16:06:16 +0000 | |||
4235 | @@ -19,6 +19,7 @@ | |||
4236 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
4237 | 20 | */ | 20 | */ |
4238 | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); | 21 | defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser."); |
4239 | 22 | include_once('lib/data/media.data.class.php'); | ||
4240 | 22 | 23 | ||
4241 | 23 | abstract class Module implements ModuleInterface | 24 | abstract class Module implements ModuleInterface |
4242 | 24 | { | 25 | { |
4243 | @@ -37,6 +38,7 @@ | |||
4244 | 37 | protected $previewEnabled; | 38 | protected $previewEnabled; |
4245 | 38 | protected $validExtensions; | 39 | protected $validExtensions; |
4246 | 39 | protected $validExtensionsText; | 40 | protected $validExtensionsText; |
4247 | 41 | protected $imageUri; | ||
4248 | 40 | protected $settings; | 42 | protected $settings; |
4249 | 41 | 43 | ||
4250 | 42 | // The Schema Version of this code | 44 | // The Schema Version of this code |
4251 | @@ -51,6 +53,7 @@ | |||
4252 | 51 | protected $deleteFromRegion; | 53 | protected $deleteFromRegion; |
4253 | 52 | protected $width; | 54 | protected $width; |
4254 | 53 | protected $height; | 55 | protected $height; |
4255 | 56 | protected $layoutSchemaVersion; | ||
4256 | 54 | 57 | ||
4257 | 55 | // Media information | 58 | // Media information |
4258 | 56 | protected $mediaid; | 59 | protected $mediaid; |
4259 | @@ -145,6 +148,7 @@ | |||
4260 | 145 | $this->validExtensionsText = Kit::ValidateParam($row['ValidExtensions'], _STRING); | 148 | $this->validExtensionsText = Kit::ValidateParam($row['ValidExtensions'], _STRING); |
4261 | 146 | $this->previewEnabled = Kit::ValidateParam($row['PreviewEnabled'], _INT); | 149 | $this->previewEnabled = Kit::ValidateParam($row['PreviewEnabled'], _INT); |
4262 | 147 | $this->assignable = Kit::ValidateParam($row['assignable'], _INT); | 150 | $this->assignable = Kit::ValidateParam($row['assignable'], _INT); |
4263 | 151 | $this->imageUri = Kit::ValidateParam($row['ImageUri'], _STRING); | ||
4264 | 148 | $this->render_as = Kit::ValidateParam($row['render_as'], _WORD); | 152 | $this->render_as = Kit::ValidateParam($row['render_as'], _WORD); |
4265 | 149 | $this->settings = Kit::ValidateParam($row['settings'], _HTMLSTRING); | 153 | $this->settings = Kit::ValidateParam($row['settings'], _HTMLSTRING); |
4266 | 150 | 154 | ||
4267 | @@ -155,7 +159,7 @@ | |||
4268 | 155 | if ($this->settings == '') | 159 | if ($this->settings == '') |
4269 | 156 | $this->settings = array(); | 160 | $this->settings = array(); |
4270 | 157 | else | 161 | else |
4272 | 158 | $this->settings = json_decode($this->settings); | 162 | $this->settings = json_decode($this->settings, true); |
4273 | 159 | 163 | ||
4274 | 160 | // Translated name of this module | 164 | // Translated name of this module |
4275 | 161 | $this->displayType = __(Kit::ValidateParam($row['Name'], _STRING)); | 165 | $this->displayType = __(Kit::ValidateParam($row['Name'], _STRING)); |
4276 | @@ -200,6 +204,8 @@ | |||
4277 | 200 | 204 | ||
4278 | 201 | $layoutDoc = new DOMDocument(); | 205 | $layoutDoc = new DOMDocument(); |
4279 | 202 | $layoutDoc->loadXML($layoutXml); | 206 | $layoutDoc->loadXML($layoutXml); |
4280 | 207 | |||
4281 | 208 | $this->layoutSchemaVersion = (int)$layoutDoc->documentElement->getAttribute('schemaVersion'); | ||
4282 | 203 | 209 | ||
4283 | 204 | $layoutXpath = new DOMXPath($layoutDoc); | 210 | $layoutXpath = new DOMXPath($layoutDoc); |
4284 | 205 | 211 | ||
4285 | @@ -821,6 +827,7 @@ | |||
4286 | 821 | case 'video': | 827 | case 'video': |
4287 | 822 | case 'localvideo': | 828 | case 'localvideo': |
4288 | 823 | case 'genericfile': | 829 | case 'genericfile': |
4289 | 830 | case 'font': | ||
4290 | 824 | $defaultDuration = 0; | 831 | $defaultDuration = 0; |
4291 | 825 | break; | 832 | break; |
4292 | 826 | 833 | ||
4293 | @@ -837,7 +844,7 @@ | |||
4294 | 837 | break; | 844 | break; |
4295 | 838 | 845 | ||
4296 | 839 | default: | 846 | default: |
4298 | 840 | $defaultDuration = ''; | 847 | $defaultDuration = 10; |
4299 | 841 | } | 848 | } |
4300 | 842 | 849 | ||
4301 | 843 | 850 | ||
4302 | @@ -979,6 +986,11 @@ | |||
4303 | 979 | 'r'); | 986 | 'r'); |
4304 | 980 | } | 987 | } |
4305 | 981 | 988 | ||
4306 | 989 | $formFields[] = FormManager::AddCheckbox('deleteOldVersion', __('Delete the old version.'), | ||
4307 | 990 | ((Config::GetSetting('LIBRARY_MEDIA_UPDATEINALL_CHECKB') == 'Checked') ? 1 : 0), | ||
4308 | 991 | __('Completely remove the old version of this media item if a new file is being uploaded.'), | ||
4309 | 992 | ''); | ||
4310 | 993 | |||
4311 | 982 | // Add in any extra form fields we might have provided by the super-class | 994 | // Add in any extra form fields we might have provided by the super-class |
4312 | 983 | if ($extraFormFields != NULL && is_array($extraFormFields)) { | 995 | if ($extraFormFields != NULL && is_array($extraFormFields)) { |
4313 | 984 | foreach($extraFormFields as $field) { | 996 | foreach($extraFormFields as $field) { |
4314 | @@ -1085,7 +1097,6 @@ | |||
4315 | 1085 | } | 1097 | } |
4316 | 1086 | 1098 | ||
4317 | 1087 | // Hand off to the media module | 1099 | // Hand off to the media module |
4318 | 1088 | Kit::ClassLoader('media'); | ||
4319 | 1089 | $mediaObject = new Media($db); | 1100 | $mediaObject = new Media($db); |
4320 | 1090 | 1101 | ||
4321 | 1091 | // Stored As from the XML | 1102 | // Stored As from the XML |
4322 | @@ -1116,10 +1127,7 @@ | |||
4323 | 1116 | } | 1127 | } |
4324 | 1117 | 1128 | ||
4325 | 1118 | // Are we on a region | 1129 | // Are we on a region |
4330 | 1119 | if ($regionid != '') | 1130 | if ($regionid != '') { |
4327 | 1120 | { | ||
4328 | 1121 | Kit::ClassLoader('layoutmediagroupsecurity'); | ||
4329 | 1122 | |||
4331 | 1123 | $security = new LayoutMediaGroupSecurity($db); | 1131 | $security = new LayoutMediaGroupSecurity($db); |
4332 | 1124 | $security->Copy($layoutid, $regionid, $mediaid, $new_mediaid); | 1132 | $security->Copy($layoutid, $regionid, $mediaid, $new_mediaid); |
4333 | 1125 | } | 1133 | } |
4334 | @@ -1176,6 +1184,12 @@ | |||
4335 | 1176 | if (Kit::GetParam('replaceInLayouts', _POST, _CHECKBOX) == 1) | 1184 | if (Kit::GetParam('replaceInLayouts', _POST, _CHECKBOX) == 1) |
4336 | 1177 | $this->ReplaceMediaInAllLayouts($mediaid, $this->mediaid, $this->duration); | 1185 | $this->ReplaceMediaInAllLayouts($mediaid, $this->mediaid, $this->duration); |
4337 | 1178 | 1186 | ||
4338 | 1187 | // Do we need to delete the old media item? | ||
4339 | 1188 | if ($tmpName != '' && Kit::GetParam('deleteOldVersion', _POST, _CHECKBOX) == 1) { | ||
4340 | 1189 | if (!$mediaObject->Delete($mediaid)) | ||
4341 | 1190 | $this->response->message .= ' ' . __('Failed to remove old media'); | ||
4342 | 1191 | } | ||
4343 | 1192 | |||
4344 | 1179 | return $this->response; | 1193 | return $this->response; |
4345 | 1180 | } | 1194 | } |
4346 | 1181 | 1195 | ||
4347 | @@ -1337,7 +1351,7 @@ | |||
4348 | 1337 | 1351 | ||
4349 | 1338 | // Default Hover window contains a thumbnail, media type and duration | 1352 | // Default Hover window contains a thumbnail, media type and duration |
4350 | 1339 | $output = '<div class="well">'; | 1353 | $output = '<div class="well">'; |
4352 | 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>'; |
4353 | 1341 | $output .= '<div class="info">'; | 1355 | $output .= '<div class="info">'; |
4354 | 1342 | $output .= ' <ul>'; | 1356 | $output .= ' <ul>'; |
4355 | 1343 | $output .= ' <li>' . $msgType . ': ' . $this->displayType . '</li>'; | 1357 | $output .= ' <li>' . $msgType . ': ' . $this->displayType . '</li>'; |
4356 | @@ -1371,52 +1385,37 @@ | |||
4357 | 1371 | if (!$this->auth->modifyPermissions) | 1385 | if (!$this->auth->modifyPermissions) |
4358 | 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); |
4359 | 1373 | 1387 | ||
4395 | 1374 | // List of all Groups with a view/edit/delete checkbox | 1388 | // List of all Groups with a view / edit / delete check box |
4396 | 1375 | $SQL = ''; | 1389 | $permissions = new UserGroup(); |
4397 | 1376 | $SQL .= 'SELECT `group`.GroupID, `group`.`Group`, View, Edit, Del, `group`.IsUserSpecific '; | 1390 | |
4398 | 1377 | $SQL .= ' FROM `group` '; | 1391 | if ($this->assignedMedia) { |
4399 | 1378 | 1392 | 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))) | |
4400 | 1379 | if ($this->assignedMedia) | 1393 | trigger_error($permissions->GetErrorMessage(), E_USER_ERROR); |
4401 | 1380 | { | 1394 | } |
4402 | 1381 | $SQL .= ' LEFT OUTER JOIN lklayoutmediagroup '; | 1395 | else { |
4403 | 1382 | $SQL .= ' ON lklayoutmediagroup.GroupID = group.GroupID '; | 1396 | if (!$result = $permissions->GetPermissionsForObject('lkmediagroup', 'MediaID', $this->mediaid)) |
4404 | 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); |
4405 | 1384 | } | 1398 | } |
4406 | 1385 | else | 1399 | |
4407 | 1386 | { | 1400 | if (count($result) <= 0) |
4408 | 1387 | $SQL .= ' LEFT OUTER JOIN lkmediagroup '; | 1401 | trigger_error(__('Unable to get permissions'), E_USER_ERROR); |
4409 | 1388 | $SQL .= ' ON lkmediagroup.GroupID = group.GroupID '; | 1402 | |
4410 | 1389 | $SQL .= sprintf(' AND lkmediagroup.MediaID = %d ', $this->mediaid); | 1403 | $checkboxes = array(); |
4411 | 1390 | } | 1404 | |
4412 | 1391 | 1405 | foreach ($result as $row) { | |
4413 | 1392 | $SQL .= ' WHERE `group`.GroupID <> %d '; | 1406 | $groupId = $row['groupid']; |
4414 | 1393 | $SQL .= 'ORDER BY `group`.IsEveryone DESC, `group`.IsUserSpecific, `group`.`Group` '; | 1407 | $rowClass = ($row['isuserspecific'] == 0) ? 'strong_text' : ''; |
4380 | 1394 | |||
4381 | 1395 | $SQL = sprintf($SQL, $user->getGroupFromId($user->userid, true)); | ||
4382 | 1396 | |||
4383 | 1397 | Debug::LogEntry('audit', $SQL, 'module', 'PermissionsForm'); | ||
4384 | 1398 | |||
4385 | 1399 | if (!$results = $db->query($SQL)) | ||
4386 | 1400 | { | ||
4387 | 1401 | trigger_error($db->error()); | ||
4388 | 1402 | trigger_error(__('Unable to get permissions for this layout'), E_USER_ERROR); | ||
4389 | 1403 | } | ||
4390 | 1404 | |||
4391 | 1405 | while ($row = $db->get_assoc_row($results)) | ||
4392 | 1406 | { | ||
4393 | 1407 | $groupId = $row['GroupID']; | ||
4394 | 1408 | $rowClass = ($row['IsUserSpecific'] == 0) ? 'strong_text' : ''; | ||
4415 | 1409 | 1408 | ||
4416 | 1410 | $checkbox = array( | 1409 | $checkbox = array( |
4417 | 1411 | 'id' => $groupId, | 1410 | 'id' => $groupId, |
4419 | 1412 | 'name' => Kit::ValidateParam($row['Group'], _STRING), | 1411 | 'name' => Kit::ValidateParam($row['group'], _STRING), |
4420 | 1413 | 'class' => $rowClass, | 1412 | 'class' => $rowClass, |
4421 | 1414 | 'value_view' => $groupId . '_view', | 1413 | 'value_view' => $groupId . '_view', |
4423 | 1415 | 'value_view_checked' => (($row['View'] == 1) ? 'checked' : ''), | 1414 | 'value_view_checked' => (($row['view'] == 1) ? 'checked' : ''), |
4424 | 1416 | 'value_edit' => $groupId . '_edit', | 1415 | 'value_edit' => $groupId . '_edit', |
4426 | 1417 | 'value_edit_checked' => (($row['Edit'] == 1) ? 'checked' : ''), | 1416 | 'value_edit_checked' => (($row['edit'] == 1) ? 'checked' : ''), |
4427 | 1418 | 'value_del' => $groupId . '_del', | 1417 | 'value_del' => $groupId . '_del', |
4429 | 1419 | 'value_del_checked' => (($row['Del'] == 1) ? 'checked' : ''), | 1418 | 'value_del_checked' => (($row['del'] == 1) ? 'checked' : ''), |
4430 | 1420 | ); | 1419 | ); |
4431 | 1421 | 1420 | ||
4432 | 1422 | $checkboxes[] = $checkbox; | 1421 | $checkboxes[] = $checkbox; |
4433 | @@ -2118,6 +2117,13 @@ | |||
4434 | 2118 | return false; | 2117 | return false; |
4435 | 2119 | } | 2118 | } |
4436 | 2120 | } | 2119 | } |
4437 | 2120 | |||
4438 | 2121 | public function GetSetting($setting, $default = NULL) { | ||
4439 | 2122 | if (isset($this->settings[$setting])) | ||
4440 | 2123 | return $this->settings[$setting]; | ||
4441 | 2124 | else | ||
4442 | 2125 | return $default; | ||
4443 | 2126 | } | ||
4444 | 2121 | 2127 | ||
4445 | 2122 | /** | 2128 | /** |
4446 | 2123 | * Return file based media items to the browser for Download/Preview | 2129 | * Return file based media items to the browser for Download/Preview |
4447 | 2124 | 2130 | ||
4448 | === modified file 'server/lib/pages/admin.class.php' | |||
4449 | --- server/lib/pages/admin.class.php 2014-09-16 16:41:43 +0000 | |||
4450 | +++ server/lib/pages/admin.class.php 2014-10-21 16:06:16 +0000 | |||
4451 | @@ -137,13 +137,13 @@ | |||
4452 | 137 | 'title' => __('Tidy Library'), | 137 | 'title' => __('Tidy Library'), |
4453 | 138 | 'class' => 'XiboFormButton', | 138 | 'class' => 'XiboFormButton', |
4454 | 139 | 'selected' => false, | 139 | 'selected' => false, |
4456 | 140 | 'link' => 'index.php?p=admin&q=TidyLibrary', | 140 | 'link' => 'index.php?p=admin&q=TidyLibraryForm', |
4457 | 141 | 'help' => __('Run through the library and remove and unnecessary files'), | 141 | 'help' => __('Run through the library and remove and unnecessary files'), |
4458 | 142 | 'onclick' => '' | 142 | 'onclick' => '' |
4459 | 143 | ); | 143 | ); |
4460 | 144 | } | 144 | } |
4461 | 145 | 145 | ||
4463 | 146 | return $menu; | 146 | return $menu; |
4464 | 147 | } | 147 | } |
4465 | 148 | 148 | ||
4466 | 149 | function Edit() { | 149 | function Edit() { |
4467 | @@ -153,8 +153,7 @@ | |||
4468 | 153 | if (!Kit::CheckToken()) | 153 | if (!Kit::CheckToken()) |
4469 | 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); |
4470 | 155 | 155 | ||
4473 | 156 | Kit::ClassLoader('setting'); | 156 | $data = new Setting(); |
4472 | 157 | $data = new Setting($this->db); | ||
4474 | 158 | 157 | ||
4475 | 159 | // Get all of the settings in an array | 158 | // Get all of the settings in an array |
4476 | 160 | $settings = Config::GetAll(NULL, array('userChange' => 1, 'userSee' => 1)); | 159 | $settings = Config::GetAll(NULL, array('userChange' => 1, 'userSee' => 1)); |
4477 | @@ -185,6 +184,7 @@ | |||
4478 | 185 | } | 184 | } |
4479 | 186 | 185 | ||
4480 | 187 | $response->SetFormSubmitResponse(__('Settings Updated'), false); | 186 | $response->SetFormSubmitResponse(__('Settings Updated'), false); |
4481 | 187 | $response->callBack = 'settingsUpdated'; | ||
4482 | 188 | $response->Respond(); | 188 | $response->Respond(); |
4483 | 189 | } | 189 | } |
4484 | 190 | 190 | ||
4485 | @@ -417,20 +417,10 @@ | |||
4486 | 417 | public function BackupDatabase() | 417 | public function BackupDatabase() |
4487 | 418 | { | 418 | { |
4488 | 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. |
4489 | 420 | Kit::ClassLoader('maintenance'); | ||
4490 | 421 | $maintenance = new Maintenance($this->db); | 420 | $maintenance = new Maintenance($this->db); |
4491 | 422 | 421 | ||
4503 | 423 | $dump = $maintenance->BackupDatabase(); | 422 | if (!$dump = $maintenance->BackupDatabase()) |
4504 | 424 | 423 | trigger_error($maintenance->GetErrorMessage(), E_USER_ERROR); | |
4494 | 425 | if ($dump == '') | ||
4495 | 426 | trigger_error(__('Unable to export database'), E_USER_ERROR); | ||
4496 | 427 | |||
4497 | 428 | header('Content-Type: text/plaintext'); | ||
4498 | 429 | header('Content-Disposition: attachment; filename="' . date('Y-m-d H:i:s') . '.bak"'); | ||
4499 | 430 | header("Content-Transfer-Encoding: binary"); | ||
4500 | 431 | header('Accept-Ranges: bytes'); | ||
4501 | 432 | echo $dump; | ||
4502 | 433 | exit; | ||
4505 | 434 | } | 424 | } |
4506 | 435 | 425 | ||
4507 | 436 | /** | 426 | /** |
4508 | @@ -545,70 +535,46 @@ | |||
4509 | 545 | return round($bytes, $precision) . ' ' . $units[$pow]; | 535 | return round($bytes, $precision) . ' ' . $units[$pow]; |
4510 | 546 | } | 536 | } |
4511 | 547 | 537 | ||
4512 | 538 | public function TidyLibraryForm() | ||
4513 | 539 | { | ||
4514 | 540 | $response = new ResponseManager(); | ||
4515 | 541 | |||
4516 | 542 | Theme::Set('form_id', 'TidyLibraryForm'); | ||
4517 | 543 | Theme::Set('form_action', 'index.php?p=admin&q=TidyLibrary'); | ||
4518 | 544 | |||
4519 | 545 | $formFields = array(); | ||
4520 | 546 | |||
4521 | 547 | // Check box to also delete un-used media that has been revised. | ||
4522 | 548 | $formFields[] = FormManager::AddCheckbox('tidyOldRevisions', __('Remove old revisions'), 0, | ||
4523 | 549 | __('Cleaning up old revisions of media will result in any unused media revisions being permanently deleted.'), ''); | ||
4524 | 550 | |||
4525 | 551 | $formFields[] = FormManager::AddMessage(__('Tidying the Library will delete any temporary files. Are you sure you want to proceed?')); | ||
4526 | 552 | |||
4527 | 553 | Theme::Set('form_fields', $formFields); | ||
4528 | 554 | |||
4529 | 555 | $response->SetFormRequestResponse(NULL, __('Tidy Library'), '350px', '275px'); | ||
4530 | 556 | $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('Settings', 'TidyLibrary') . '")'); | ||
4531 | 557 | $response->AddButton(__('No'), 'XiboDialogClose()'); | ||
4532 | 558 | $response->AddButton(__('Yes'), '$("#TidyLibraryForm").submit()'); | ||
4533 | 559 | $response->Respond(); | ||
4534 | 560 | } | ||
4535 | 561 | |||
4536 | 548 | /** | 562 | /** |
4537 | 549 | * Tidies up the library | 563 | * Tidies up the library |
4538 | 550 | */ | 564 | */ |
4539 | 551 | public function TidyLibrary() | 565 | public function TidyLibrary() |
4540 | 552 | { | 566 | { |
4541 | 553 | $db =& $this->db; | ||
4542 | 554 | $response = new ResponseManager(); | 567 | $response = new ResponseManager(); |
4544 | 555 | 568 | $tidyOldRevisions = (Kit::GetParam('tidyOldRevisions', _POST, _CHECKBOX) == 1); | |
4545 | 556 | if (Config::GetSetting('SETTING_LIBRARY_TIDY_ENABLED') != 1) | 569 | if (Config::GetSetting('SETTING_LIBRARY_TIDY_ENABLED') != 1) |
4546 | 557 | trigger_error(__('Sorry this function is disabled.'), E_USER_ERROR); | 570 | trigger_error(__('Sorry this function is disabled.'), E_USER_ERROR); |
4547 | 558 | 571 | ||
4601 | 559 | // Also run a script to tidy up orphaned media in the library | 572 | $maintenance = new Maintenance(); |
4602 | 560 | $library = Config::GetSetting('LIBRARY_LOCATION'); | 573 | if (!$maintenance->TidyLibrary($tidyOldRevisions)) |
4603 | 561 | $library = rtrim($library, '/') . '/'; | 574 | trigger_error($maintenance->GetErrorMessage(), E_USER_ERROR); |
4604 | 562 | 575 | ||
4605 | 563 | Debug::LogEntry('audit', 'Library Location: ' . $library); | 576 | $response->SetFormSubmitResponse(__('Library Tidy Complete')); |
4606 | 564 | 577 | $response->Respond(); | |
4554 | 565 | // Dump the files in the temp folder | ||
4555 | 566 | foreach (scandir($library . 'temp') as $item) | ||
4556 | 567 | { | ||
4557 | 568 | if ($item == '.' || $item == '..') | ||
4558 | 569 | continue; | ||
4559 | 570 | |||
4560 | 571 | Debug::LogEntry('audit', 'Deleting temp file: ' . $item); | ||
4561 | 572 | |||
4562 | 573 | unlink($library . 'temp' . DIRECTORY_SEPARATOR . $item); | ||
4563 | 574 | } | ||
4564 | 575 | |||
4565 | 576 | // Get a list of all media files | ||
4566 | 577 | foreach(scandir($library) as $file) | ||
4567 | 578 | { | ||
4568 | 579 | Debug::LogEntry('audit', 'Checking file: ' . $file); | ||
4569 | 580 | |||
4570 | 581 | if ($file == '.' || $file == '..') | ||
4571 | 582 | continue; | ||
4572 | 583 | |||
4573 | 584 | if (is_dir($library . $file)) | ||
4574 | 585 | continue; | ||
4575 | 586 | |||
4576 | 587 | $rowCount = $db->GetCountOfRows("SELECT * FROM media WHERE storedAs = '" . $file . "'"); | ||
4577 | 588 | |||
4578 | 589 | Debug::LogEntry('audit', 'Media count for file: ' . $file . ' is ' . $rowCount); | ||
4579 | 590 | |||
4580 | 591 | // For each media file, check to see if the file still exists in the library | ||
4581 | 592 | if ($rowCount == 0) | ||
4582 | 593 | { | ||
4583 | 594 | Debug::LogEntry('audit', 'Deleting file: ' . $file); | ||
4584 | 595 | |||
4585 | 596 | // If not, delete it | ||
4586 | 597 | unlink($library . $file); | ||
4587 | 598 | |||
4588 | 599 | if (file_exists($library . 'tn_' . $file)) | ||
4589 | 600 | { | ||
4590 | 601 | unlink($library . 'tn_' . $file); | ||
4591 | 602 | } | ||
4592 | 603 | |||
4593 | 604 | if (file_exists($library . 'bg_' . $file)) | ||
4594 | 605 | { | ||
4595 | 606 | unlink($library . 'bg_' . $file); | ||
4596 | 607 | } | ||
4597 | 608 | } | ||
4598 | 609 | } | ||
4599 | 610 | |||
4600 | 611 | trigger_error(__('Library Tidy Complete'), E_USER_ERROR); | ||
4607 | 612 | } | 578 | } |
4608 | 613 | } | 579 | } |
4609 | 614 | ?> | 580 | ?> |
4610 | 615 | 581 | ||
4611 | === modified file 'server/lib/pages/campaign.class.php' | |||
4612 | --- server/lib/pages/campaign.class.php 2014-08-15 14:40:03 +0000 | |||
4613 | +++ server/lib/pages/campaign.class.php 2014-10-21 16:06:16 +0000 | |||
4614 | @@ -355,41 +355,30 @@ | |||
4615 | 355 | Theme::Set('form_action', 'index.php?p=campaign&q=Permissions'); | 355 | Theme::Set('form_action', 'index.php?p=campaign&q=Permissions'); |
4616 | 356 | Theme::Set('form_meta', '<input type="hidden" name="campaignId" value="' . $campaignId . '" />'); | 356 | Theme::Set('form_meta', '<input type="hidden" name="campaignId" value="' . $campaignId . '" />'); |
4617 | 357 | 357 | ||
4633 | 358 | // List of all Groups with a view/edit/delete checkbox | 358 | // List of all Groups with a view / edit / delete check box |
4634 | 359 | $SQL = ''; | 359 | $permissions = new CampaignSecurity(); |
4635 | 360 | $SQL .= 'SELECT `group`.GroupID, `group`.`Group`, View, Edit, Del, `group`.IsUserSpecific '; | 360 | if (!$result = $permissions->GetPermissions($campaignId)) |
4636 | 361 | $SQL .= ' FROM `group` '; | 361 | trigger_error($permissions->GetErrorMessage(), E_USER_ERROR); |
4637 | 362 | $SQL .= ' LEFT OUTER JOIN lkcampaigngroup '; | 362 | |
4638 | 363 | $SQL .= ' ON lkcampaigngroup.GroupID = group.GroupID '; | 363 | if (count($result) <= 0) |
4624 | 364 | $SQL .= ' AND lkcampaigngroup.CampaignID = %d '; | ||
4625 | 365 | $SQL .= ' WHERE `group`.GroupID <> %d '; | ||
4626 | 366 | $SQL .= 'ORDER BY `group`.IsEveryone DESC, `group`.IsUserSpecific, `group`.`Group` '; | ||
4627 | 367 | |||
4628 | 368 | $SQL = sprintf($SQL, $campaignId, $this->user->getGroupFromID($this->user->userid, true)); | ||
4629 | 369 | |||
4630 | 370 | if (!$results = $db->query($SQL)) | ||
4631 | 371 | { | ||
4632 | 372 | trigger_error($db->error()); | ||
4639 | 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); |
4640 | 374 | } | ||
4641 | 375 | 365 | ||
4642 | 376 | $checkboxes = array(); | 366 | $checkboxes = array(); |
4643 | 377 | 367 | ||
4648 | 378 | while ($row = $db->get_assoc_row($results)) | 368 | foreach ($result as $row) { |
4649 | 379 | { | 369 | $groupId = $row['groupid']; |
4650 | 380 | $groupId = $row['GroupID']; | 370 | $rowClass = ($row['isuserspecific'] == 0) ? 'strong_text' : ''; |
4647 | 381 | $rowClass = ($row['IsUserSpecific'] == 0) ? 'strong_text' : ''; | ||
4651 | 382 | 371 | ||
4652 | 383 | $checkbox = array( | 372 | $checkbox = array( |
4653 | 384 | 'id' => $groupId, | 373 | 'id' => $groupId, |
4655 | 385 | 'name' => Kit::ValidateParam($row['Group'], _STRING), | 374 | 'name' => Kit::ValidateParam($row['group'], _STRING), |
4656 | 386 | 'class' => $rowClass, | 375 | 'class' => $rowClass, |
4657 | 387 | 'value_view' => $groupId . '_view', | 376 | 'value_view' => $groupId . '_view', |
4659 | 388 | 'value_view_checked' => (($row['View'] == 1) ? 'checked' : ''), | 377 | 'value_view_checked' => (($row['view'] == 1) ? 'checked' : ''), |
4660 | 389 | 'value_edit' => $groupId . '_edit', | 378 | 'value_edit' => $groupId . '_edit', |
4662 | 390 | 'value_edit_checked' => (($row['Edit'] == 1) ? 'checked' : ''), | 379 | 'value_edit_checked' => (($row['edit'] == 1) ? 'checked' : ''), |
4663 | 391 | 'value_del' => $groupId . '_del', | 380 | 'value_del' => $groupId . '_del', |
4665 | 392 | 'value_del_checked' => (($row['Del'] == 1) ? 'checked' : ''), | 381 | 'value_del_checked' => (($row['del'] == 1) ? 'checked' : ''), |
4666 | 393 | ); | 382 | ); |
4667 | 394 | 383 | ||
4668 | 395 | $checkboxes[] = $checkbox; | 384 | $checkboxes[] = $checkbox; |
4669 | @@ -593,7 +582,7 @@ | |||
4670 | 593 | public function SetMembers() | 582 | public function SetMembers() |
4671 | 594 | { | 583 | { |
4672 | 595 | // Check the token | 584 | // Check the token |
4674 | 596 | if (!Kit::CheckToken()) | 585 | if (!Kit::CheckToken('assign_token')) |
4675 | 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); |
4676 | 598 | 587 | ||
4677 | 599 | $db =& $this->db; | 588 | $db =& $this->db; |
4678 | @@ -646,10 +635,10 @@ | |||
4679 | 646 | $id = uniqid(); | 635 | $id = uniqid(); |
4680 | 647 | Theme::Set('id', $id); | 636 | Theme::Set('id', $id); |
4681 | 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">'); |
4683 | 649 | Theme::Set('pager', ResponseManager::Pager($id, 'form_grid_pager')); | 638 | Theme::Set('pager', ResponseManager::Pager($id, 'grid_pager')); |
4684 | 650 | 639 | ||
4685 | 651 | // Get the currently assigned layouts and put them in the "well" | 640 | // Get the currently assigned layouts and put them in the "well" |
4687 | 652 | // // Layouts in group | 641 | // Layouts in group |
4688 | 653 | $SQL = "SELECT layout.Layoutid, "; | 642 | $SQL = "SELECT layout.Layoutid, "; |
4689 | 654 | $SQL .= " layout.layout, "; | 643 | $SQL .= " layout.layout, "; |
4690 | 655 | $SQL .= " CONCAT('LayoutID_', layout.LayoutID) AS list_id "; | 644 | $SQL .= " CONCAT('LayoutID_', layout.LayoutID) AS list_id "; |
4691 | @@ -669,11 +658,17 @@ | |||
4692 | 669 | 658 | ||
4693 | 670 | Debug::LogEntry('audit', count($layoutsAssigned) . ' layouts assigned already'); | 659 | Debug::LogEntry('audit', count($layoutsAssigned) . ' layouts assigned already'); |
4694 | 671 | 660 | ||
4695 | 661 | $formFields = array(); | ||
4696 | 662 | $formFields[] = FormManager::AddText('filter_name', __('Name'), NULL, NULL, 'l'); | ||
4697 | 663 | Theme::Set('form_fields', $formFields); | ||
4698 | 664 | |||
4699 | 672 | // Set the layouts assigned | 665 | // Set the layouts assigned |
4700 | 673 | Theme::Set('layouts_assigned', $layoutsAssigned); | 666 | Theme::Set('layouts_assigned', $layoutsAssigned); |
4701 | 667 | Theme::Set('append', Theme::RenderReturn('campaign_form_layout_assign')); | ||
4702 | 674 | 668 | ||
4703 | 675 | // Call to render the template | 669 | // Call to render the template |
4705 | 676 | $output = Theme::RenderReturn('campaign_form_layout_assign'); | 670 | Theme::Set('header_text', __('Choose Layouts')); |
4706 | 671 | $output = Theme::RenderReturn('grid_render'); | ||
4707 | 677 | 672 | ||
4708 | 678 | // Construct the Response | 673 | // Construct the Response |
4709 | 679 | $response->html = $output; | 674 | $response->html = $output; |
4710 | @@ -706,12 +701,24 @@ | |||
4711 | 706 | // Get a list of media | 701 | // Get a list of media |
4712 | 707 | $layoutList = $user->LayoutList(NULL, array('layout' => $name)); | 702 | $layoutList = $user->LayoutList(NULL, array('layout' => $name)); |
4713 | 708 | 703 | ||
4714 | 704 | $cols = array( | ||
4715 | 705 | array('name' => 'layout', 'title' => __('Name')) | ||
4716 | 706 | ); | ||
4717 | 707 | Theme::Set('table_cols', $cols); | ||
4718 | 708 | |||
4719 | 709 | $rows = array(); | 709 | $rows = array(); |
4720 | 710 | 710 | ||
4721 | 711 | // Add some extra information | 711 | // Add some extra information |
4722 | 712 | foreach ($layoutList as $row) { | 712 | foreach ($layoutList as $row) { |
4723 | 713 | 713 | ||
4724 | 714 | $row['list_id'] = 'LayoutID_' . $row['layoutid']; | 714 | $row['list_id'] = 'LayoutID_' . $row['layoutid']; |
4725 | 715 | $row['assign_icons'][] = array( | ||
4726 | 716 | 'assign_icons_class' => 'layout_assign_list_select' | ||
4727 | 717 | ); | ||
4728 | 718 | $row['dataAttributes'] = array( | ||
4729 | 719 | array('name' => 'rowid', 'value' => $row['list_id']), | ||
4730 | 720 | array('name' => 'litext', 'value' => $row['layout']) | ||
4731 | 721 | ); | ||
4732 | 715 | 722 | ||
4733 | 716 | $rows[] = $row; | 723 | $rows[] = $row; |
4734 | 717 | } | 724 | } |
4735 | @@ -719,7 +726,7 @@ | |||
4736 | 719 | Theme::Set('table_rows', $rows); | 726 | Theme::Set('table_rows', $rows); |
4737 | 720 | 727 | ||
4738 | 721 | // Render the Theme | 728 | // Render the Theme |
4740 | 722 | $response->SetGridResponse(Theme::RenderReturn('campaign_form_layout_assign_list')); | 729 | $response->SetGridResponse(Theme::RenderReturn('table_render')); |
4741 | 723 | $response->callBack = 'LayoutAssignCallback'; | 730 | $response->callBack = 'LayoutAssignCallback'; |
4742 | 724 | $response->pageSize = 5; | 731 | $response->pageSize = 5; |
4743 | 725 | $response->Respond(); | 732 | $response->Respond(); |
4744 | 726 | 733 | ||
4745 | === modified file 'server/lib/pages/content.class.php' | |||
4746 | --- server/lib/pages/content.class.php 2014-09-15 16:57:34 +0000 | |||
4747 | +++ server/lib/pages/content.class.php 2014-10-21 16:06:16 +0000 | |||
4748 | @@ -164,7 +164,7 @@ | |||
4749 | 164 | $cols[] = array('name' => 'thumbnail', 'title' => __('Thumbnail')); | 164 | $cols[] = array('name' => 'thumbnail', 'title' => __('Thumbnail')); |
4750 | 165 | 165 | ||
4751 | 166 | $cols[] = array('name' => 'duration_text', 'title' => __('Duration')); | 166 | $cols[] = array('name' => 'duration_text', 'title' => __('Duration')); |
4753 | 167 | $cols[] = array('name' => 'size_text', 'title' => __('Size')); | 167 | $cols[] = array('name' => 'size_text', 'title' => __('Size'), 'sorter' => 'filesize'); |
4754 | 168 | $cols[] = array('name' => 'owner', 'title' => __('Owner')); | 168 | $cols[] = array('name' => 'owner', 'title' => __('Owner')); |
4755 | 169 | $cols[] = array('name' => 'permissions', 'title' => __('Permissions')); | 169 | $cols[] = array('name' => 'permissions', 'title' => __('Permissions')); |
4756 | 170 | $cols[] = array('name' => 'revised', 'title' => __('Revised?'), 'icons' => true); | 170 | $cols[] = array('name' => 'revised', 'title' => __('Revised?'), 'icons' => true); |
4757 | @@ -188,8 +188,9 @@ | |||
4758 | 188 | // Thumbnail URL | 188 | // Thumbnail URL |
4759 | 189 | $row['thumbnail'] = ''; | 189 | $row['thumbnail'] = ''; |
4760 | 190 | 190 | ||
4763 | 191 | if ($row['mediatype'] == 'image') | 191 | if ($row['mediatype'] == 'image') { |
4764 | 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>'; |
4765 | 193 | } | ||
4766 | 193 | 194 | ||
4767 | 194 | $row['buttons'] = array(); | 195 | $row['buttons'] = array(); |
4768 | 195 | 196 | ||
4769 | @@ -257,7 +258,7 @@ | |||
4770 | 257 | $response = new ResponseManager(); | 258 | $response = new ResponseManager(); |
4771 | 258 | 259 | ||
4772 | 259 | // Get a list of the enabled modules and then create buttons for them | 260 | // Get a list of the enabled modules and then create buttons for them |
4774 | 260 | if (!$enabledModules = new ModuleManager($db, $user, 0, '', -1)) | 261 | if (!$enabledModules = new ModuleManager($user, 0, '', -1)) |
4775 | 261 | trigger_error($enabledModules->message, E_USER_ERROR); | 262 | trigger_error($enabledModules->message, E_USER_ERROR); |
4776 | 262 | 263 | ||
4777 | 263 | $buttons = array(); | 264 | $buttons = array(); |
4778 | @@ -300,7 +301,7 @@ | |||
4779 | 300 | $id = uniqid(); | 301 | $id = uniqid(); |
4780 | 301 | Theme::Set('id', $id); | 302 | Theme::Set('id', $id); |
4781 | 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">'); |
4783 | 303 | Theme::Set('pager', ResponseManager::Pager($id, 'form_grid_pager')); | 304 | Theme::Set('pager', ResponseManager::Pager($id, 'grid_pager')); |
4784 | 304 | 305 | ||
4785 | 305 | // Module types filter | 306 | // Module types filter |
4786 | 306 | $modules = $this->user->ModuleAuth(0, '', 1); | 307 | $modules = $this->user->ModuleAuth(0, '', 1); |
4787 | 307 | 308 | ||
4788 | === modified file 'server/lib/pages/display.class.php' | |||
4789 | --- server/lib/pages/display.class.php 2014-09-16 10:59:55 +0000 | |||
4790 | +++ server/lib/pages/display.class.php 2014-10-21 16:06:16 +0000 | |||
4791 | @@ -27,14 +27,12 @@ | |||
4792 | 27 | $this->db =& $db; | 27 | $this->db =& $db; |
4793 | 28 | $this->user =& $user; | 28 | $this->user =& $user; |
4794 | 29 | 29 | ||
4795 | 30 | Kit::ClassLoader('Display'); | ||
4796 | 31 | |||
4797 | 32 | $this->sub_page = Kit::GetParam('sp', _GET, _WORD, 'view'); | 30 | $this->sub_page = Kit::GetParam('sp', _GET, _WORD, 'view'); |
4798 | 33 | $this->ajax = Kit::GetParam('ajax', _REQUEST, _WORD, 'false'); | 31 | $this->ajax = Kit::GetParam('ajax', _REQUEST, _WORD, 'false'); |
4799 | 34 | $displayid = Kit::GetParam('displayid', _REQUEST, _INT, 0); | 32 | $displayid = Kit::GetParam('displayid', _REQUEST, _INT, 0); |
4800 | 35 | 33 | ||
4801 | 36 | // validate displays so we get a realistic view of the table | 34 | // validate displays so we get a realistic view of the table |
4803 | 37 | $this->validateDisplays(); | 35 | Display::ValidateDisplays(); |
4804 | 38 | } | 36 | } |
4805 | 39 | 37 | ||
4806 | 40 | /** | 38 | /** |
4807 | @@ -56,12 +54,14 @@ | |||
4808 | 56 | $filter_displaygroup = Session::Get('display', 'filter_displaygroup'); | 54 | $filter_displaygroup = Session::Get('display', 'filter_displaygroup'); |
4809 | 57 | $filter_display = Session::Get('display', 'filter_display'); | 55 | $filter_display = Session::Get('display', 'filter_display'); |
4810 | 58 | $filter_showThumbnail = Session::Get('display', 'filter_showThumbnail'); | 56 | $filter_showThumbnail = Session::Get('display', 'filter_showThumbnail'); |
4811 | 57 | $filter_autoRefresh = Session::Get('display', 'filter_autoRefresh'); | ||
4812 | 59 | } | 58 | } |
4813 | 60 | else { | 59 | else { |
4814 | 61 | $filter_pinned = 0; | 60 | $filter_pinned = 0; |
4815 | 62 | $filter_displaygroup = NULL; | 61 | $filter_displaygroup = NULL; |
4816 | 63 | $filter_display = NULL; | 62 | $filter_display = NULL; |
4817 | 64 | $filter_showThumbnail = 0; | 63 | $filter_showThumbnail = 0; |
4818 | 64 | $filter_autoRefresh = 0; | ||
4819 | 65 | } | 65 | } |
4820 | 66 | 66 | ||
4821 | 67 | $formFields = array(); | 67 | $formFields = array(); |
4822 | @@ -76,13 +76,26 @@ | |||
4823 | 76 | $displayGroups, | 76 | $displayGroups, |
4824 | 77 | 'displaygroupid', | 77 | 'displaygroupid', |
4825 | 78 | 'displaygroup', | 78 | 'displaygroup', |
4826 | 79 | NULL, | ||
4827 | 80 | 'd'); | ||
4828 | 81 | |||
4829 | 82 | $formFields[] = FormManager::AddCombo( | ||
4830 | 83 | 'filter_showThumbnail', | ||
4831 | 84 | __('Thumbnails'), | ||
4832 | 85 | $filter_showThumbnail, | ||
4833 | 86 | array( | ||
4834 | 87 | array('key' => 0, 'value' => __('None')), | ||
4835 | 88 | array('key' => 1, 'value' => __('Always')), | ||
4836 | 89 | array('key' => 2, 'value' => __('When Logged In')), | ||
4837 | 90 | ), | ||
4838 | 91 | 'key', | ||
4839 | 92 | 'value', | ||
4840 | 79 | NULL, | 93 | NULL, |
4841 | 80 | 'd'); | ||
4842 | 81 | |||
4843 | 82 | $formFields[] = FormManager::AddCheckbox('filter_showThumbnail', __('Show Thumbnails'), | ||
4844 | 83 | $filter_showThumbnail, NULL, | ||
4845 | 84 | 't'); | 94 | 't'); |
4846 | 85 | 95 | ||
4847 | 96 | $formFields[] = FormManager::AddNumber('filter_autoRefresh', __('Auto Refresh'), $filter_autoRefresh, | ||
4848 | 97 | NULL, 'r'); | ||
4849 | 98 | |||
4850 | 86 | $formFields[] = FormManager::AddCheckbox('XiboFilterPinned', __('Keep Open'), | 99 | $formFields[] = FormManager::AddCheckbox('XiboFilterPinned', __('Keep Open'), |
4851 | 87 | $filter_pinned, NULL, | 100 | $filter_pinned, NULL, |
4852 | 88 | 'k'); | 101 | 'k'); |
4853 | @@ -141,7 +154,7 @@ | |||
4854 | 141 | $displayObject->wakeOnLanTime = Kit::GetParam('wakeOnLanTime', _POST, _STRING); | 154 | $displayObject->wakeOnLanTime = Kit::GetParam('wakeOnLanTime', _POST, _STRING); |
4855 | 142 | $displayObject->broadCastAddress = Kit::GetParam('broadCastAddress', _POST, _STRING); | 155 | $displayObject->broadCastAddress = Kit::GetParam('broadCastAddress', _POST, _STRING); |
4856 | 143 | $displayObject->secureOn = Kit::GetParam('secureOn', _POST, _STRING); | 156 | $displayObject->secureOn = Kit::GetParam('secureOn', _POST, _STRING); |
4858 | 144 | $displayObject->cidr = Kit::GetParam('cidr', _POST, _INT); | 157 | $displayObject->cidr = Kit::GetParam('cidr', _POST, _STRING); |
4859 | 145 | $displayObject->latitude = Kit::GetParam('latitude', _POST, _DOUBLE); | 158 | $displayObject->latitude = Kit::GetParam('latitude', _POST, _DOUBLE); |
4860 | 146 | $displayObject->longitude = Kit::GetParam('longitude', _POST, _DOUBLE); | 159 | $displayObject->longitude = Kit::GetParam('longitude', _POST, _DOUBLE); |
4861 | 147 | $displayObject->displayProfileId = Kit::GetParam('displayprofileid', _POST, _INT); | 160 | $displayObject->displayProfileId = Kit::GetParam('displayprofileid', _POST, _INT); |
4862 | @@ -225,8 +238,8 @@ | |||
4863 | 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?'), |
4864 | 226 | 'a'); | 239 | 'a'); |
4865 | 227 | 240 | ||
4868 | 228 | $formFields[] = FormManager::AddNumber('alert_timeout', __('Alert Timeout'), $displayObject->alertTimeout, | 241 | $formFields[] = FormManager::AddCheckbox('alert_timeout', __('Use the Global Timeout?'), $displayObject->alertTimeout, |
4869 | 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?'), |
4870 | 230 | 'o'); | 243 | 'o'); |
4871 | 231 | 244 | ||
4872 | 232 | Theme::Set('form_fields_maintenance', $formFields); | 245 | Theme::Set('form_fields_maintenance', $formFields); |
4873 | @@ -259,7 +272,7 @@ | |||
4874 | 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'); |
4875 | 260 | 273 | ||
4876 | 261 | $formFields[] = FormManager::AddText('cidr', __('Wake on LAN CIDR'), $displayObject->cidr, | 274 | $formFields[] = FormManager::AddText('cidr', __('Wake on LAN CIDR'), $displayObject->cidr, |
4878 | 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'); |
4879 | 263 | 276 | ||
4880 | 264 | Theme::Set('form_fields_wol', $formFields); | 277 | Theme::Set('form_fields_wol', $formFields); |
4881 | 265 | 278 | ||
4882 | @@ -327,6 +340,7 @@ | |||
4883 | 327 | $db =& $this->db; | 340 | $db =& $this->db; |
4884 | 328 | $user =& $this->user; | 341 | $user =& $this->user; |
4885 | 329 | $response = new ResponseManager(); | 342 | $response = new ResponseManager(); |
4886 | 343 | $dateFormat = Config::GetSetting('DATE_FORMAT'); | ||
4887 | 330 | 344 | ||
4888 | 331 | // Filter by Name | 345 | // Filter by Name |
4889 | 332 | $filter_display = Kit::GetParam('filter_display', _POST, _STRING); | 346 | $filter_display = Kit::GetParam('filter_display', _POST, _STRING); |
4890 | @@ -337,9 +351,13 @@ | |||
4891 | 337 | setSession('display', 'filter_displaygroup', $filter_displaygroupid); | 351 | setSession('display', 'filter_displaygroup', $filter_displaygroupid); |
4892 | 338 | 352 | ||
4893 | 339 | // Thumbnail? | 353 | // Thumbnail? |
4895 | 340 | $filter_showThumbnail = Kit::GetParam('filter_showThumbnail', _REQUEST, _CHECKBOX); | 354 | $filter_showThumbnail = Kit::GetParam('filter_showThumbnail', _REQUEST, _INT); |
4896 | 341 | setSession('display', 'filter_showThumbnail', $filter_showThumbnail); | 355 | setSession('display', 'filter_showThumbnail', $filter_showThumbnail); |
4897 | 342 | 356 | ||
4898 | 357 | // filter_autoRefresh? | ||
4899 | 358 | $filter_autoRefresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0); | ||
4900 | 359 | setSession('display', 'filter_autoRefresh', $filter_autoRefresh); | ||
4901 | 360 | |||
4902 | 343 | // Pinned option? | 361 | // Pinned option? |
4903 | 344 | setSession('display', 'DisplayFilter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off')); | 362 | setSession('display', 'DisplayFilter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off')); |
4904 | 345 | 363 | ||
4905 | @@ -358,22 +376,19 @@ | |||
4906 | 358 | $cols = array( | 376 | $cols = array( |
4907 | 359 | array('name' => 'displayid', 'title' => __('ID')), | 377 | array('name' => 'displayid', 'title' => __('ID')), |
4908 | 360 | array('name' => 'licensed', 'title' => __('License'), 'icons' => true), | 378 | array('name' => 'licensed', 'title' => __('License'), 'icons' => true), |
4914 | 361 | array('name' => 'display', 'title' => __('Display')), | 379 | array('name' => 'displayWithLink', 'title' => __('Display')), |
4915 | 362 | array('name' => 'description', 'title' => __('Description')), | 380 | array('name' => 'description', 'title' => __('Description'), 'hidden' => ($filter_showThumbnail == 1 || $filter_showThumbnail == 2)), |
4916 | 363 | array('name' => 'layout', 'title' => __('Default Layout')), | 381 | array('name' => 'layout', 'title' => __('Default Layout'), 'hidden' => ($filter_showThumbnail == 1 || $filter_showThumbnail == 2)), |
4917 | 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)), |
4918 | 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)), |
4919 | 366 | array('name' => 'loggedin', 'title' => __('Logged In'), 'icons' => true), | 384 | array('name' => 'loggedin', 'title' => __('Logged In'), 'icons' => true), |
4920 | 367 | array('name' => 'lastaccessed', 'title' => __('Last Accessed')), | 385 | array('name' => 'lastaccessed', 'title' => __('Last Accessed')), |
4923 | 368 | array('name' => 'clientaddress', 'title' => __('IP Address')), | 386 | array('name' => 'clientaddress', 'title' => __('IP Address'), 'hidden' => ($filter_showThumbnail == 1)), |
4924 | 369 | array('name' => 'macaddress', 'title' => __('Mac Address')) | 387 | array('name' => 'macaddress', 'title' => __('Mac Address'), 'hidden' => ($filter_showThumbnail == 1)), |
4925 | 388 | array('name' => 'screenShotRequested', 'title' => __('Screen shot?'), 'icons' => true, 'hidden' => ($filter_showThumbnail == 0)), | ||
4926 | 389 | array('name' => 'thumbnail', 'title' => __('Thumbnail'), 'hidden' => ($filter_showThumbnail == 0)) | ||
4927 | 370 | ); | 390 | ); |
4928 | 371 | 391 | ||
4929 | 372 | if ($filter_showThumbnail == 1) { | ||
4930 | 373 | $cols[] = array('name' => 'screenShotRequested', 'title' => __('Screen shot?'), 'icons' => true); | ||
4931 | 374 | $cols[] = array('name' => 'thumbnail', 'title' => __('Thumbnail')); | ||
4932 | 375 | } | ||
4933 | 376 | |||
4934 | 377 | Theme::Set('table_cols', $cols); | 392 | Theme::Set('table_cols', $cols); |
4935 | 378 | Theme::Set('rowClass', 'mediainventorystatus'); | 393 | Theme::Set('rowClass', 'mediainventorystatus'); |
4936 | 379 | 394 | ||
4937 | @@ -387,11 +402,11 @@ | |||
4938 | 387 | if ($linkTarget == '') | 402 | if ($linkTarget == '') |
4939 | 388 | $linkTarget = '_top'; | 403 | $linkTarget = '_top'; |
4940 | 389 | 404 | ||
4942 | 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']); |
4943 | 391 | } | 406 | } |
4944 | 392 | 407 | ||
4945 | 393 | // Format last accessed | 408 | // Format last accessed |
4947 | 394 | $row['lastaccessed'] = date("Y-m-d H:i:s", $row['lastaccessed']); | 409 | $row['lastaccessed'] = date($dateFormat, $row['lastaccessed']); |
4948 | 395 | 410 | ||
4949 | 396 | // Create some login lights | 411 | // Create some login lights |
4950 | 397 | $row['mediainventorystatus'] = ($row['mediainventorystatus'] == 1) ? 'success' : (($row['mediainventorystatus'] == 2) ? 'danger' : 'warning'); | 412 | $row['mediainventorystatus'] = ($row['mediainventorystatus'] == 1) ? 'success' : (($row['mediainventorystatus'] == 2) ? 'danger' : 'warning'); |
4951 | @@ -399,7 +414,10 @@ | |||
4952 | 399 | // Thumbnail | 414 | // Thumbnail |
4953 | 400 | $row['thumbnail'] = ''; | 415 | $row['thumbnail'] = ''; |
4954 | 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')) { |
4956 | 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>'; |
4957 | 418 | } | ||
4958 | 419 | else if ($filter_showThumbnail == 2) { | ||
4959 | 420 | $row['thumbnail'] = '<i class="fa fa-times-circle"></i>'; | ||
4960 | 403 | } | 421 | } |
4961 | 404 | 422 | ||
4962 | 405 | // Edit and Delete buttons first | 423 | // Edit and Delete buttons first |
4963 | @@ -454,7 +472,13 @@ | |||
4964 | 454 | $row['buttons'][] = array( | 472 | $row['buttons'][] = array( |
4965 | 455 | 'id' => 'display_button_requestScreenShot', | 473 | 'id' => 'display_button_requestScreenShot', |
4966 | 456 | 'url' => 'index.php?p=display&q=RequestScreenShotForm&displayId=' . $row['displayid'], | 474 | 'url' => 'index.php?p=display&q=RequestScreenShotForm&displayId=' . $row['displayid'], |
4968 | 457 | 'text' => __('Request Screen Shot') | 475 | 'text' => __('Request Screen Shot'), |
4969 | 476 | 'multi-select' => true, | ||
4970 | 477 | 'dataAttributes' => array( | ||
4971 | 478 | array('name' => 'multiselectlink', 'value' => 'index.php?p=display&q=RequestScreenShot'), | ||
4972 | 479 | array('name' => 'rowtitle', 'value' => $row['display']), | ||
4973 | 480 | array('name' => 'displayId', 'value' => $row['displayid']) | ||
4974 | 481 | ) | ||
4975 | 458 | ); | 482 | ); |
4976 | 459 | 483 | ||
4977 | 460 | $row['buttons'][] = array('linkType' => 'divider'); | 484 | $row['buttons'][] = array('linkType' => 'divider'); |
4978 | @@ -523,55 +547,11 @@ | |||
4979 | 523 | $output = Theme::RenderReturn('table_render'); | 547 | $output = Theme::RenderReturn('table_render'); |
4980 | 524 | 548 | ||
4981 | 525 | $response->SetGridResponse($output); | 549 | $response->SetGridResponse($output); |
4982 | 550 | $response->refresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0); | ||
4983 | 526 | $response->Respond(); | 551 | $response->Respond(); |
4984 | 527 | } | 552 | } |
4985 | 528 | 553 | ||
4986 | 529 | /** | 554 | /** |
4987 | 530 | * Assess each Display to correctly set the logged in flag based on last accessed time | ||
4988 | 531 | * @return | ||
4989 | 532 | */ | ||
4990 | 533 | function validateDisplays() | ||
4991 | 534 | { | ||
4992 | 535 | $db =& $this->db; | ||
4993 | 536 | |||
4994 | 537 | // Get the global timeout (overrides the alert timeout on the display if 0 | ||
4995 | 538 | $globalTimeout = Config::GetSetting('MAINTENANCE_ALERT_TOUT'); | ||
4996 | 539 | |||
4997 | 540 | // Get a list of all displays and there last accessed / alert timeout value | ||
4998 | 541 | $SQL = ""; | ||
4999 | 542 | $SQL .= "SELECT displayid, lastaccessed, alert_timeout FROM display "; | ||
5000 | 543 |
The diff has been truncated for viewing.