Merge lp:~dangarner/xibo/server-130 into lp:xibo/1.3

Proposed by Dan Garner
Status: Merged
Merged at revision: 218
Proposed branch: lp:~dangarner/xibo/server-130
Merge into: lp:xibo/1.3
Diff against target: 363 lines (+176/-26)
11 files modified
server/install/database/41.sql (+5/-0)
server/lib/data/template.data.class.php (+41/-0)
server/lib/include.php (+2/-2)
server/lib/pages/content.class.php (+3/-1)
server/lib/pages/stats.class.php (+2/-0)
server/lib/pages/template.class.php (+73/-18)
server/lib/service/rest.class.php (+23/-0)
server/modules/flash.module.php (+3/-2)
server/modules/image.module.php (+3/-2)
server/modules/module_user_general.php (+19/-0)
server/modules/powerpoint.module.php (+2/-1)
To merge this branch: bzr merge lp:~dangarner/xibo/server-130
Reviewer Review Type Date Requested Status
Xibo Maintainters Pending
Review via email: mp+68152@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'server/install/database/41.sql'
2--- server/install/database/41.sql 1970-01-01 00:00:00 +0000
3+++ server/install/database/41.sql 2011-07-16 11:26:18 +0000
4@@ -0,0 +1,5 @@
5+
6+
7+UPDATE `version` SET `app_ver` = '1.3.0', `XmdsVersion` = 2;
8+UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
9+UPDATE `version` SET `DBVersion` = '41';
10\ No newline at end of file
11
12=== added file 'server/lib/data/template.data.class.php'
13--- server/lib/data/template.data.class.php 1970-01-01 00:00:00 +0000
14+++ server/lib/data/template.data.class.php 2011-07-16 11:26:18 +0000
15@@ -0,0 +1,41 @@
16+<?php
17+/*
18+ * Xibo - Digitial Signage - http://www.xibo.org.uk
19+ * Copyright (C) 2011 Daniel Garner
20+ *
21+ * This file is part of Xibo.
22+ *
23+ * Xibo is free software: you can redistribute it and/or modify
24+ * it under the terms of the GNU Affero General Public License as published by
25+ * the Free Software Foundation, either version 3 of the License, or
26+ * any later version.
27+ *
28+ * Xibo is distributed in the hope that it will be useful,
29+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
30+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+ * GNU Affero General Public License for more details.
32+ *
33+ * You should have received a copy of the GNU Affero General Public License
34+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
35+ */
36+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
37+
38+class Template extends Data
39+{
40+ /**
41+ * Deletes a layout
42+ * @param <type> $layoutId
43+ * @return <type>
44+ */
45+ public function Delete($templateId)
46+ {
47+ $db =& $this->db;
48+
49+ // Remove the Layout
50+ if (!$db->query(sprintf('DELETE FROM template WHERE TemplateId = %d', $templateId)))
51+ return $this->SetError(25105, __('Unable to delete template'));
52+
53+ return true;
54+ }
55+}
56+?>
57\ No newline at end of file
58
59=== modified file 'server/lib/include.php'
60--- server/lib/include.php 2011-06-05 15:27:06 +0000
61+++ server/lib/include.php 2011-07-16 11:26:18 +0000
62@@ -107,8 +107,8 @@
63 Config::Version($db);
64
65 // Does the version in the DB match the version of the code?
66-if (DBVERSION != '28')
67- die(sprintf('Incompatible database version detected. Please ensure your database and website versions match. You have %d and the website for %d', DBVERSION, 27));
68+if (DBVERSION != '41')
69+ die(sprintf('Incompatible database version detected. Please ensure your database and website versions match. You have %d and the website for %d', DBVERSION, 41));
70
71 // What is the production mode of the server?
72 if(Config::GetSetting($db, "SERVER_MODE")=="Test") ini_set('display_errors', 1);
73
74=== modified file 'server/lib/pages/content.class.php'
75--- server/lib/pages/content.class.php 2010-10-03 19:12:25 +0000
76+++ server/lib/pages/content.class.php 2011-07-16 11:26:18 +0000
77@@ -205,7 +205,8 @@
78 {
79 $SQL .= " AND media.retired = 0 ";
80 }
81-
82+ $SQL .= " ORDER BY media.name ";
83+
84 Debug::LogEntry($db, 'audit', $SQL);
85
86 if (!$results = $db->query($SQL))
87@@ -514,6 +515,7 @@
88 {
89 $SQL.= " AND media.name LIKE '%" . sprintf('%s', $name) . "%'";
90 }
91+ $SQL .= " ORDER BY media.name ";
92
93 if(!$results = $db->query($SQL))
94 {
95
96=== modified file 'server/lib/pages/stats.class.php'
97--- server/lib/pages/stats.class.php 2009-12-31 11:38:50 +0000
98+++ server/lib/pages/stats.class.php 2011-07-16 11:26:18 +0000
99@@ -117,6 +117,8 @@
100 {
101 $SQL .= sprintf(" AND stat.displayID = %d ", $displayID);
102 }
103+
104+ $SQL .= " ORDER BY stat.start ";
105
106 Debug::LogEntry($db, 'audit', $SQL, 'Stats', 'OutputCSV');
107
108
109=== modified file 'server/lib/pages/template.class.php'
110--- server/lib/pages/template.class.php 2009-02-22 20:38:02 +0000
111+++ server/lib/pages/template.class.php 2011-07-16 11:26:18 +0000
112@@ -112,8 +112,9 @@
113
114 $tags = "";
115 if (isset($_SESSION['template']['tags'])) $tags = $_SESSION['template']['tags'];
116-
117- $is_system = $_SESSION['template']['is_system'];
118+
119+ $is_system = 'all';
120+ if (isset($_SESSION['template']['is_system'])) $is_system = $_SESSION['template']['is_system'];
121
122 $system_list = dropdownlist("SELECT 'all','All' UNION SELECT '1','Yes' UNION SELECT '0','No'","is_system",$is_system);
123
124@@ -219,7 +220,7 @@
125
126 while ($row = $db->get_row($results))
127 {
128- $templateid = $row[0];
129+ $templateId = Kit::ValidateParam($row[0], _INT);
130 $template = $row[1];
131 $issystem = $row[2];
132 $tags = $row[3];
133@@ -232,9 +233,14 @@
134 $group = $user->getGroupFromID($userid);
135
136 //get the permissions
137- list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid);
138+ list($see_permissions, $edit_permissions) = $user->eval_permission($userid, $permissionid);
139
140 $buttons = "No available Actions";
141+
142+ if ($edit_permissions && $issystem == 'No')
143+ {
144+ $buttons = '<button class="XiboFormButton" href="index.php?p=template&q=DeleteTemplateForm&templateId=' . $templateId . '"><span>' . __('Delete') . '</span></button>';
145+ }
146
147 if ($see_permissions)
148 {
149@@ -442,20 +448,69 @@
150 return false;
151 }
152
153- /**
154- * Deletes a template
155- * @return
156- */
157- function DeleteTemplate()
158- {
159- $db =& $this->db;
160-
161- $templateid = $_REQUEST['templateid'];
162-
163- //ajax request handler
164- trigger_error('Deleting of templates currently unavailable.', E_USER_ERROR);
165- return false;
166- }
167+ /**
168+ * Deletes a template
169+ * @return
170+ */
171+ function DeleteTemplate()
172+ {
173+ $db =& $this->db;
174+ $user =& $this->user;
175+ $response = new ResponseManager();
176+ $helpManager = new HelpManager($db, $user);
177+
178+ $templateId = Kit::GetParam('templateId', _POST, _INT);
179+
180+ if ($templateId == 0)
181+ trigger_error(__('No template found'), E_USER_ERROR);
182+
183+ // Is this user allowed to delete this template?
184+ if (!$this->user->TemplateAuth($templateId))
185+ trigger_error(__('Access denied'), E_USER_ERROR);
186+
187+ // Use the data class
188+ Kit::ClassLoader('template');
189+ $template = new Template($db);
190+
191+ // Delete the template
192+ if (!$template->Delete($templateId))
193+ trigger_error($layout->GetErrorMessage(), E_USER_ERROR);
194+
195+ $response->SetFormSubmitResponse(__('The Template has been Deleted'));
196+ $response->Respond();
197+ }
198+
199+ /**
200+ * Shows the form to delete a template
201+ */
202+ public function DeleteTemplateForm()
203+ {
204+ $db =& $this->db;
205+ $user =& $this->user;
206+ $response = new ResponseManager();
207+ $helpManager = new HelpManager($db, $user);
208+
209+ $templateId = Kit::GetParam('templateId', _GET, _INT);
210+
211+ if ($templateId == 0)
212+ trigger_error(__('No template found'), E_USER_ERROR);
213+
214+ // Construct some messages to display
215+ $msgWarn = __('Are you sure you want to delete this template?');
216+
217+ $form = <<<END
218+ <form id="DeleteTemplateForm" class="XiboForm" method="post" action="index.php?p=template&q=DeleteTemplate">
219+ <input type="hidden" name="templateId" value="$templateId">
220+ <p>$msgWarn</p>
221+ </form>
222+END;
223+
224+ $response->SetFormRequestResponse($form, __('Delete a Template'), '350px', '275px');
225+ $response->AddButton(__('Help'), 'XiboHelpRender("' . $helpManager->Link('Template', 'Delete') . '")');
226+ $response->AddButton(__('No'), 'XiboDialogClose()');
227+ $response->AddButton(__('Yes'), '$("#DeleteTemplateForm").submit()');
228+ $response->Respond();
229+ }
230
231 /**
232 * Gets the Xml for the specified layout
233
234=== modified file 'server/lib/service/rest.class.php'
235--- server/lib/service/rest.class.php 2011-01-30 10:29:25 +0000
236+++ server/lib/service/rest.class.php 2011-07-16 11:26:18 +0000
237@@ -806,6 +806,29 @@
238 }
239
240 /**
241+ * Delete Template
242+ * @return <XiboAPIResponse>
243+ */
244+ public function TemplateDelete()
245+ {
246+ if (!$this->user->PageAuth('template'))
247+ return $this->Error(1, 'Access Denied');
248+
249+ Kit::ClassLoader('Template');
250+
251+ $template = new Template($this->db);
252+ $templateId = $this->GetParam('templateId', _INT);
253+
254+ if (!$this->user->TemplateAuth($templateId))
255+ return $this->Error(1, 'Access Denied');
256+
257+ if (!$template->Delete($templateId))
258+ return $this->Error($layout->GetErrorNumber(), $layout->GetErrorMessage());
259+
260+ return $this->Respond($this->ReturnId('success', true));
261+ }
262+
263+ /**
264 * Lists enabled modules
265 * @return <XiboAPIResponse>
266 */
267
268=== modified file 'server/modules/flash.module.php'
269--- server/modules/flash.module.php 2010-08-01 12:35:20 +0000
270+++ server/modules/flash.module.php 2011-07-16 11:26:18 +0000
271@@ -102,7 +102,8 @@
272 $session->setSecurityToken($securityToken);
273
274 //Get the default value for the shared list
275- $default = Config::GetSetting($db,"defaultMedia");
276+ $default = Config::GetSetting($db, 'defaultMedia');
277+ $defaultDuration = Config::GetSetting($db, 'jpg_length');
278
279 $permissionid = 0;
280
281@@ -165,7 +166,7 @@
282 </tr>
283 <tr>
284 <td><label for="duration" title="The duration in seconds this flash should be displayed (may be overridden on each layout)">Duration<span class="required">*</span></label></td>
285- <td><input id="duration" name="duration" type="text" value="$this->duration"></td>
286+ <td><input id="duration" name="duration" type="text" value="$defaultDuration"></td>
287 <td><label for="permissionid">Sharing<span class="required">*</span></label></td>
288 <td>
289 $shared_list
290
291=== modified file 'server/modules/image.module.php'
292--- server/modules/image.module.php 2010-08-01 12:35:20 +0000
293+++ server/modules/image.module.php 2011-07-16 11:26:18 +0000
294@@ -102,7 +102,8 @@
295 $session->setSecurityToken($securityToken);
296
297 //Get the default value for the shared list
298- $default = Config::GetSetting($db,"defaultMedia");
299+ $default = Config::GetSetting($db, 'defaultMedia');
300+ $defaultDuration = Config::GetSetting($db, 'jpg_length');
301
302 $permissionid = 0;
303
304@@ -174,7 +175,7 @@
305 </tr>
306 <tr>
307 <td><label for="duration" title="The duration in seconds this image should be displayed (may be overridden on each layout)">Duration<span class="required">*</span></label></td>
308- <td><input id="duration" name="duration" type="text" value="$this->duration"></td>
309+ <td><input id="duration" name="duration" type="text" value="$defaultDuration"></td>
310 <td><label for="permissionid">Sharing<span class="required">*</span></label></td>
311 <td>
312 $shared_list
313
314=== modified file 'server/modules/module_user_general.php'
315--- server/modules/module_user_general.php 2010-10-19 20:41:35 +0000
316+++ server/modules/module_user_general.php 2011-07-16 11:26:18 +0000
317@@ -900,6 +900,25 @@
318 }
319
320 /**
321+ *Authorises a user against a template Id
322+ * @param <type> $templateId
323+ * @return <type>
324+ */
325+ public function TemplateAuth($templateId)
326+ {
327+ // TODO: Extend to cover group access and all that
328+ if (!$userId = $this->db->GetSingleValue(sprintf("SELECT UserID FROM template WHERE TemplateID = %d", $templateId), 'UserID', _INT))
329+ {
330+ trigger_error($this->db->error_text);
331+ trigger_error($this->db->error());
332+
333+ return false;
334+ }
335+
336+ return ($userId == $this->userid);
337+ }
338+
339+ /**
340 * Returns an array of layouts that this user has access to
341 */
342 public function LayoutList()
343
344=== modified file 'server/modules/powerpoint.module.php'
345--- server/modules/powerpoint.module.php 2010-08-01 12:35:20 +0000
346+++ server/modules/powerpoint.module.php 2011-07-16 11:26:18 +0000
347@@ -103,6 +103,7 @@
348
349 //Get the default value for the shared list
350 $default = Config::GetSetting($db,"defaultMedia");
351+ $defaultDuration = Config::GetSetting($db, 'ppt_length');
352
353 $permissionid = 0;
354
355@@ -165,7 +166,7 @@
356 </tr>
357 <tr>
358 <td><label for="duration" title="The duration in seconds this powerpoint should be displayed (may be overridden on each layout)">Duration<span class="required">*</span></label></td>
359- <td><input id="duration" name="duration" type="text" value="$this->duration"></td>
360+ <td><input id="duration" name="duration" type="text" value="$defaultDuration"></td>
361 <td><label for="permissionid">Sharing<span class="required">*</span></label></td>
362 <td>
363 $shared_list

Subscribers

People subscribed via source and target branches

to status/vote changes: