Merge lp:~dangarner/xibo/bug-438779 into lp:~xibo-maintainers/xibo/encke
- bug-438779
- Merge into encke
Proposed by
Dan Garner
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~dangarner/xibo/bug-438779 | ||||
Merge into: | lp:~xibo-maintainers/xibo/encke | ||||
Diff against target: |
4456 lines 6 files modified
server/install/database/8.sql (+13/-0) server/lib/modules/module.class.php (+150/-117) server/modules/flash.module.php (+167/-167) server/modules/image.module.php (+170/-170) server/modules/powerpoint.module.php (+168/-168) server/modules/video.module.php (+166/-166) |
||||
To merge this branch: | bzr merge lp:~dangarner/xibo/bug-438779 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Xibo Maintainters | Pending | ||
Review via email:
|
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 | === added file 'server/install/database/8.sql' | |||
2 | --- server/install/database/8.sql 1970-01-01 00:00:00 +0000 | |||
3 | +++ server/install/database/8.sql 2009-10-01 21:40:24 +0000 | |||
4 | @@ -0,0 +1,13 @@ | |||
5 | 1 | ALTER TABLE `module` ADD `ValidExtensions` VARCHAR( 254 ) NULL ; | ||
6 | 2 | |||
7 | 3 | UPDATE `module` SET `ValidExtensions` = 'jpg,jpeg,png,bmp,gif' WHERE `module`.`ModuleID` =1 LIMIT 1 ; | ||
8 | 4 | |||
9 | 5 | UPDATE `module` SET `ValidExtensions` = 'wmv,avi,mpg,mpeg' WHERE `module`.`ModuleID` =2 LIMIT 1 ; | ||
10 | 6 | |||
11 | 7 | UPDATE `module` SET `ValidExtensions` = 'swf' WHERE `module`.`ModuleID` =3 LIMIT 1 ; | ||
12 | 8 | |||
13 | 9 | UPDATE `module` SET `ValidExtensions` = 'ppt,pps' WHERE `module`.`ModuleID` =4 LIMIT 1 ; | ||
14 | 10 | |||
15 | 11 | UPDATE `version` SET `app_ver` = '1.0.4'; | ||
16 | 12 | UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE'; | ||
17 | 13 | UPDATE `version` SET `DBVersion` = '8'; | ||
18 | 0 | 14 | ||
19 | === modified file 'server/lib/modules/module.class.php' | |||
20 | --- server/lib/modules/module.class.php 2009-09-22 18:39:19 +0000 | |||
21 | +++ server/lib/modules/module.class.php 2009-10-01 21:40:24 +0000 | |||
22 | @@ -8,7 +8,7 @@ | |||
23 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
24 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
25 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
27 | 11 | * any later version. | 11 | * any later version. |
28 | 12 | * | 12 | * |
29 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
30 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31 | @@ -27,26 +27,28 @@ | |||
32 | 27 | protected $user; | 27 | protected $user; |
33 | 28 | protected $region; | 28 | protected $region; |
34 | 29 | protected $response; | 29 | protected $response; |
36 | 30 | 30 | ||
37 | 31 | protected $layoutid; | 31 | protected $layoutid; |
38 | 32 | protected $regionid; | 32 | protected $regionid; |
41 | 33 | 33 | ||
42 | 34 | protected $mediaid; | 34 | protected $mediaid; |
43 | 35 | protected $name; | 35 | protected $name; |
44 | 36 | protected $type; | 36 | protected $type; |
45 | 37 | private $schemaVersion; | 37 | private $schemaVersion; |
46 | 38 | protected $regionSpecific; | 38 | protected $regionSpecific; |
47 | 39 | protected $duration; | 39 | protected $duration; |
48 | 40 | protected $lkid; | 40 | protected $lkid; |
49 | 41 | protected $validExtensions; | ||
50 | 42 | protected $validExtensionsText; | ||
51 | 41 | 43 | ||
52 | 42 | protected $xml; | 44 | protected $xml; |
54 | 43 | 45 | ||
55 | 44 | protected $existingMedia; | 46 | protected $existingMedia; |
56 | 45 | protected $deleteFromRegion; | 47 | protected $deleteFromRegion; |
58 | 46 | 48 | ||
59 | 47 | /** | 49 | /** |
60 | 48 | * Constructor - sets up this media object with all the available information | 50 | * Constructor - sets up this media object with all the available information |
62 | 49 | * @return | 51 | * @return |
63 | 50 | * @param $db database | 52 | * @param $db database |
64 | 51 | * @param $user user | 53 | * @param $user user |
65 | 52 | * @param $mediaid String[optional] | 54 | * @param $mediaid String[optional] |
66 | @@ -56,74 +58,77 @@ | |||
67 | 56 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 58 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
68 | 57 | { | 59 | { |
69 | 58 | include_once("lib/pages/region.class.php"); | 60 | include_once("lib/pages/region.class.php"); |
71 | 59 | 61 | ||
72 | 60 | $this->db =& $db; | 62 | $this->db =& $db; |
73 | 61 | $this->user =& $user; | 63 | $this->user =& $user; |
76 | 62 | 64 | ||
77 | 63 | $this->mediaid = $mediaid; | 65 | $this->mediaid = $mediaid; |
78 | 64 | $this->name = ''; | 66 | $this->name = ''; |
79 | 65 | $this->layoutid = $layoutid; | 67 | $this->layoutid = $layoutid; |
80 | 66 | $this->regionid = $regionid; | 68 | $this->regionid = $regionid; |
82 | 67 | 69 | ||
83 | 68 | $this->region = new region($db, $user); | 70 | $this->region = new region($db, $user); |
84 | 69 | $this->response = new ResponseManager(); | 71 | $this->response = new ResponseManager(); |
86 | 70 | 72 | ||
87 | 71 | $this->existingMedia = false; | 73 | $this->existingMedia = false; |
88 | 72 | $this->deleteFromRegion = false; | 74 | $this->deleteFromRegion = false; |
89 | 73 | $this->lkid = ''; | 75 | $this->lkid = ''; |
90 | 74 | $this->duration = ''; | 76 | $this->duration = ''; |
92 | 75 | 77 | ||
93 | 76 | // Determine which type this module is | 78 | // Determine which type this module is |
94 | 77 | $this->SetModuleInformation(); | 79 | $this->SetModuleInformation(); |
96 | 78 | 80 | ||
97 | 79 | Debug::LogEntry($db, 'audit', 'New module created with MediaID: ' . $mediaid . ' LayoutID: ' . $layoutid . ' and RegionID: ' . $regionid); | 81 | Debug::LogEntry($db, 'audit', 'New module created with MediaID: ' . $mediaid . ' LayoutID: ' . $layoutid . ' and RegionID: ' . $regionid); |
99 | 80 | 82 | ||
100 | 81 | // Either the information from the region - or some blanks | 83 | // Either the information from the region - or some blanks |
101 | 82 | $this->SetMediaInformation($this->layoutid, $this->regionid, $mediaid); | 84 | $this->SetMediaInformation($this->layoutid, $this->regionid, $mediaid); |
103 | 83 | 85 | ||
104 | 84 | return true; | 86 | return true; |
105 | 85 | } | 87 | } |
107 | 86 | 88 | ||
108 | 87 | /** | 89 | /** |
109 | 88 | * Sets the module information | 90 | * Sets the module information |
111 | 89 | * @return | 91 | * @return |
112 | 90 | */ | 92 | */ |
113 | 91 | final private function SetModuleInformation() | 93 | final private function SetModuleInformation() |
114 | 92 | { | 94 | { |
115 | 93 | $db =& $this->db; | 95 | $db =& $this->db; |
116 | 94 | $type = $this->type; | 96 | $type = $this->type; |
118 | 95 | 97 | ||
119 | 96 | if ($type == '') | 98 | if ($type == '') |
120 | 97 | { | 99 | { |
121 | 98 | $this->response->SetError(__('Unable to create Module [No type given] - please refer to the Module Documentation.')); | 100 | $this->response->SetError(__('Unable to create Module [No type given] - please refer to the Module Documentation.')); |
122 | 99 | $this->response->Respond(); | 101 | $this->response->Respond(); |
123 | 100 | } | 102 | } |
125 | 101 | 103 | ||
126 | 102 | $SQL = sprintf("SELECT * FROM module WHERE Module = '%s'", $db->escape_string($type)); | 104 | $SQL = sprintf("SELECT * FROM module WHERE Module = '%s'", $db->escape_string($type)); |
129 | 103 | 105 | ||
130 | 104 | if (!$result = $db->query($SQL)) | 106 | if (!$result = $db->query($SQL)) |
131 | 105 | { | 107 | { |
132 | 106 | $this->response->SetError(__('Unable to create Module [Cannot find type in the database] - please refer to the Module Documentation.')); | 108 | $this->response->SetError(__('Unable to create Module [Cannot find type in the database] - please refer to the Module Documentation.')); |
133 | 107 | $this->response->Respond(); | 109 | $this->response->Respond(); |
134 | 108 | } | 110 | } |
136 | 109 | 111 | ||
137 | 110 | if ($db->num_rows($result) != 1) | 112 | if ($db->num_rows($result) != 1) |
138 | 111 | { | 113 | { |
139 | 112 | $this->response->SetError(__('Unable to create Module [No registered modules of this type] - please refer to the Module Documentation.')); | 114 | $this->response->SetError(__('Unable to create Module [No registered modules of this type] - please refer to the Module Documentation.')); |
140 | 113 | $this->response->Respond(); | 115 | $this->response->Respond(); |
141 | 114 | } | 116 | } |
143 | 115 | 117 | ||
144 | 116 | $row = $db->get_assoc_row($result); | 118 | $row = $db->get_assoc_row($result); |
149 | 117 | 119 | ||
150 | 118 | $this->schemaVersion = Kit::ValidateParam($row['SchemaVersion'], _INT); | 120 | $this->schemaVersion = Kit::ValidateParam($row['SchemaVersion'], _INT); |
151 | 119 | $this->regionSpecific = Kit::ValidateParam($row['RegionSpecific'], _INT); | 121 | $this->regionSpecific = Kit::ValidateParam($row['RegionSpecific'], _INT); |
152 | 120 | 122 | $this->validExtensionsText = Kit::ValidateParam($row['ValidExtensions'], _STRING); | |
153 | 123 | $this->validExtensions = explode(',', $this->validExtensionsText); | ||
154 | 124 | $this->validExtensionsText = str_replace(',', ', ', $this->validExtensionsText); | ||
155 | 125 | |||
156 | 121 | return true; | 126 | return true; |
157 | 122 | } | 127 | } |
159 | 123 | 128 | ||
160 | 124 | /** | 129 | /** |
161 | 125 | * Gets the information about this Media on this region on this layout | 130 | * Gets the information about this Media on this region on this layout |
163 | 126 | * @return | 131 | * @return |
164 | 127 | * @param $layoutid Object | 132 | * @param $layoutid Object |
165 | 128 | * @param $regionid Object | 133 | * @param $regionid Object |
166 | 129 | * @param $mediaid Object | 134 | * @param $mediaid Object |
167 | @@ -133,28 +138,28 @@ | |||
168 | 133 | $db =& $this->db; | 138 | $db =& $this->db; |
169 | 134 | $region =& $this->region; | 139 | $region =& $this->region; |
170 | 135 | $xmlDoc = new DOMDocument(); | 140 | $xmlDoc = new DOMDocument(); |
172 | 136 | 141 | ||
173 | 137 | if ($this->mediaid != '' && $this->regionid != '' && $this->layoutid != '') | 142 | if ($this->mediaid != '' && $this->regionid != '' && $this->layoutid != '') |
174 | 138 | { | 143 | { |
175 | 139 | $this->existingMedia = true; | 144 | $this->existingMedia = true; |
177 | 140 | 145 | ||
178 | 141 | // Set the layout Xml | 146 | // Set the layout Xml |
179 | 142 | $layoutXml = $region->GetLayoutXml($layoutid); | 147 | $layoutXml = $region->GetLayoutXml($layoutid); |
181 | 143 | 148 | ||
182 | 144 | Debug::LogEntry($db, 'audit', 'Layout XML retrieved: ' . $layoutXml); | 149 | Debug::LogEntry($db, 'audit', 'Layout XML retrieved: ' . $layoutXml); |
184 | 145 | 150 | ||
185 | 146 | $layoutDoc = new DOMDocument(); | 151 | $layoutDoc = new DOMDocument(); |
186 | 147 | $layoutDoc->loadXML($layoutXml); | 152 | $layoutDoc->loadXML($layoutXml); |
188 | 148 | 153 | ||
189 | 149 | $layoutXpath = new DOMXPath($layoutDoc); | 154 | $layoutXpath = new DOMXPath($layoutDoc); |
191 | 150 | 155 | ||
192 | 151 | // Get the media node and extract the info | 156 | // Get the media node and extract the info |
193 | 152 | $mediaNodeXpath = $layoutXpath->query("//region[@id='$regionid']/media[@id='$mediaid']"); | 157 | $mediaNodeXpath = $layoutXpath->query("//region[@id='$regionid']/media[@id='$mediaid']"); |
195 | 153 | 158 | ||
196 | 154 | if ($mediaNodeXpath->length > 0) | 159 | if ($mediaNodeXpath->length > 0) |
197 | 155 | { | 160 | { |
198 | 156 | Debug::LogEntry($db, 'audit', 'Media Node Found.'); | 161 | Debug::LogEntry($db, 'audit', 'Media Node Found.'); |
200 | 157 | 162 | ||
201 | 158 | // Create a Media node in the DOMDocument for us to replace | 163 | // Create a Media node in the DOMDocument for us to replace |
202 | 159 | $xmlDoc->loadXML('<root/>'); | 164 | $xmlDoc->loadXML('<root/>'); |
203 | 160 | } | 165 | } |
204 | @@ -163,13 +168,13 @@ | |||
205 | 163 | $this->response->SetError(__('Cannot find this media item. Please refresh the region options.')); | 168 | $this->response->SetError(__('Cannot find this media item. Please refresh the region options.')); |
206 | 164 | $this->response->Respond(); | 169 | $this->response->Respond(); |
207 | 165 | } | 170 | } |
209 | 166 | 171 | ||
210 | 167 | $mediaNode = $mediaNodeXpath->item(0); | 172 | $mediaNode = $mediaNodeXpath->item(0); |
211 | 168 | $mediaNode->setAttribute('schemaVersion', $this->schemaVersion); | 173 | $mediaNode->setAttribute('schemaVersion', $this->schemaVersion); |
213 | 169 | 174 | ||
214 | 170 | $this->duration = $mediaNode->getAttribute('duration'); | 175 | $this->duration = $mediaNode->getAttribute('duration'); |
215 | 171 | $this->lkid = $mediaNode->getAttribute('lkid'); | 176 | $this->lkid = $mediaNode->getAttribute('lkid'); |
217 | 172 | 177 | ||
218 | 173 | $mediaNode = $xmlDoc->importNode($mediaNode, true); | 178 | $mediaNode = $xmlDoc->importNode($mediaNode, true); |
219 | 174 | $xmlDoc->documentElement->appendChild($mediaNode); | 179 | $xmlDoc->documentElement->appendChild($mediaNode); |
220 | 175 | } | 180 | } |
221 | @@ -181,25 +186,25 @@ | |||
222 | 181 | // But this is some existing media | 186 | // But this is some existing media |
223 | 182 | // Therefore make sure we get the bare minimum! | 187 | // Therefore make sure we get the bare minimum! |
224 | 183 | $this->existingMedia = true; | 188 | $this->existingMedia = true; |
226 | 184 | 189 | ||
227 | 185 | // Load what we know about this media into the object | 190 | // Load what we know about this media into the object |
228 | 186 | $SQL = "SELECT duration, name FROM media WHERE mediaID = '$mediaid'"; | 191 | $SQL = "SELECT duration, name FROM media WHERE mediaID = '$mediaid'"; |
230 | 187 | 192 | ||
231 | 188 | Debug::LogEntry($db, 'audit', $SQL, 'Module', 'SetMediaInformation'); | 193 | Debug::LogEntry($db, 'audit', $SQL, 'Module', 'SetMediaInformation'); |
233 | 189 | 194 | ||
234 | 190 | if (!$result = $db->query($SQL)) | 195 | if (!$result = $db->query($SQL)) |
235 | 191 | { | 196 | { |
236 | 192 | trigger_error($db->error()); //log the error | 197 | trigger_error($db->error()); //log the error |
237 | 193 | } | 198 | } |
239 | 194 | 199 | ||
240 | 195 | if ($db->num_rows($result) != 0) | 200 | if ($db->num_rows($result) != 0) |
241 | 196 | { | 201 | { |
242 | 197 | $row = $db->get_row($result); | 202 | $row = $db->get_row($result); |
244 | 198 | $this->duration = $row[0]; | 203 | $this->duration = $row[0]; |
245 | 199 | $this->name = $row[1]; | 204 | $this->name = $row[1]; |
246 | 200 | } | 205 | } |
247 | 201 | } | 206 | } |
249 | 202 | 207 | ||
250 | 203 | $xml = <<<XML | 208 | $xml = <<<XML |
251 | 204 | <root> | 209 | <root> |
252 | 205 | <media id="" type="$this->type" duration="" lkid="" schemaVersion="$this->schemaVersion"> | 210 | <media id="" type="$this->type" duration="" lkid="" schemaVersion="$this->schemaVersion"> |
253 | @@ -210,32 +215,32 @@ | |||
254 | 210 | XML; | 215 | XML; |
255 | 211 | $xmlDoc->loadXML($xml); | 216 | $xmlDoc->loadXML($xml); |
256 | 212 | } | 217 | } |
258 | 213 | 218 | ||
259 | 214 | $this->xml = $xmlDoc; | 219 | $this->xml = $xmlDoc; |
261 | 215 | 220 | ||
262 | 216 | Debug::LogEntry($db, 'audit', 'XML is: ' . $this->xml->saveXML()); | 221 | Debug::LogEntry($db, 'audit', 'XML is: ' . $this->xml->saveXML()); |
264 | 217 | 222 | ||
265 | 218 | return true; | 223 | return true; |
266 | 219 | } | 224 | } |
268 | 220 | 225 | ||
269 | 221 | /** | 226 | /** |
270 | 222 | * Sets the Layout and Region Information | 227 | * Sets the Layout and Region Information |
272 | 223 | * @return | 228 | * @return |
273 | 224 | * @param $layoutid Object | 229 | * @param $layoutid Object |
274 | 225 | * @param $regionid Object | 230 | * @param $regionid Object |
275 | 226 | * @param $mediaid Object | 231 | * @param $mediaid Object |
276 | 227 | */ | 232 | */ |
277 | 228 | public function SetRegionInformation($layoutid, $regionid) | 233 | public function SetRegionInformation($layoutid, $regionid) |
279 | 229 | { | 234 | { |
280 | 230 | $this->layoutid = $layoutid; | 235 | $this->layoutid = $layoutid; |
281 | 231 | $this->regionid = $regionid; | 236 | $this->regionid = $regionid; |
283 | 232 | 237 | ||
284 | 233 | return true; | 238 | return true; |
285 | 234 | } | 239 | } |
287 | 235 | 240 | ||
288 | 236 | /** | 241 | /** |
289 | 237 | * This Media item represented as XML | 242 | * This Media item represented as XML |
291 | 238 | * @return | 243 | * @return |
292 | 239 | */ | 244 | */ |
293 | 240 | final public function AsXml() | 245 | final public function AsXml() |
294 | 241 | { | 246 | { |
295 | @@ -248,17 +253,17 @@ | |||
296 | 248 | // LkID is done by the region code (where applicable - otherwise it will be left blank) | 253 | // LkID is done by the region code (where applicable - otherwise it will be left blank) |
297 | 249 | $mediaNodes = $this->xml->getElementsByTagName('media'); | 254 | $mediaNodes = $this->xml->getElementsByTagName('media'); |
298 | 250 | $mediaNode = $mediaNodes->item(0); | 255 | $mediaNode = $mediaNodes->item(0); |
300 | 251 | 256 | ||
301 | 252 | $mediaNode->setAttribute('id', $this->mediaid); | 257 | $mediaNode->setAttribute('id', $this->mediaid); |
302 | 253 | $mediaNode->setAttribute('duration', $this->duration); | 258 | $mediaNode->setAttribute('duration', $this->duration); |
303 | 254 | $mediaNode->setAttribute('type', $this->type); | 259 | $mediaNode->setAttribute('type', $this->type); |
305 | 255 | 260 | ||
306 | 256 | return $this->xml->saveXML($mediaNode); | 261 | return $this->xml->saveXML($mediaNode); |
307 | 257 | } | 262 | } |
309 | 258 | 263 | ||
310 | 259 | /** | 264 | /** |
313 | 260 | * Adds the name/value element to the XML Options sequence | 265 | * Adds the name/value element to the XML Options sequence |
314 | 261 | * @return | 266 | * @return |
315 | 262 | * @param $name String | 267 | * @param $name String |
316 | 263 | * @param $value String | 268 | * @param $value String |
317 | 264 | */ | 269 | */ |
318 | @@ -266,25 +271,25 @@ | |||
319 | 266 | { | 271 | { |
320 | 267 | $db =& $this->db; | 272 | $db =& $this->db; |
321 | 268 | if ($name == '') return; | 273 | if ($name == '') return; |
325 | 269 | 274 | ||
326 | 270 | Debug::LogEntry($db, 'audit', sprintf('IN with Name=%s and value=%s', $name, $value), 'module', 'Set Option'); | 275 | Debug::LogEntry($db, 'audit', sprintf('IN with Name=%s and value=%s', $name, $value), 'module', 'Set Option'); |
327 | 271 | 276 | ||
328 | 272 | // Get the options node from this document | 277 | // Get the options node from this document |
329 | 273 | $optionNodes = $this->xml->getElementsByTagName('options'); | 278 | $optionNodes = $this->xml->getElementsByTagName('options'); |
330 | 274 | // There is only 1 | 279 | // There is only 1 |
331 | 275 | $optionNode = $optionNodes->item(0); | 280 | $optionNode = $optionNodes->item(0); |
333 | 276 | 281 | ||
334 | 277 | // Create a new option node | 282 | // Create a new option node |
335 | 278 | $newNode = $this->xml->createElement($name, $value); | 283 | $newNode = $this->xml->createElement($name, $value); |
337 | 279 | 284 | ||
338 | 280 | Debug::LogEntry($db, 'audit', sprintf('Created a new Option Node with Name=%s and value=%s', $name, $value), 'module', 'Set Option'); | 285 | Debug::LogEntry($db, 'audit', sprintf('Created a new Option Node with Name=%s and value=%s', $name, $value), 'module', 'Set Option'); |
340 | 281 | 286 | ||
341 | 282 | // Check to see if we already have this option or not | 287 | // Check to see if we already have this option or not |
342 | 283 | $xpath = new DOMXPath($this->xml); | 288 | $xpath = new DOMXPath($this->xml); |
344 | 284 | 289 | ||
345 | 285 | // Xpath for it | 290 | // Xpath for it |
346 | 286 | $userOptions = $xpath->query('//options/' . $name); | 291 | $userOptions = $xpath->query('//options/' . $name); |
348 | 287 | 292 | ||
349 | 288 | if ($userOptions->length == 0) | 293 | if ($userOptions->length == 0) |
350 | 289 | { | 294 | { |
351 | 290 | // Append the new node to the list | 295 | // Append the new node to the list |
352 | @@ -293,28 +298,28 @@ | |||
353 | 293 | else | 298 | else |
354 | 294 | { | 299 | { |
355 | 295 | // Replace the old node we found with XPath with the new node we just created | 300 | // Replace the old node we found with XPath with the new node we just created |
357 | 296 | $optionNode->replaceChild($newNode, $userOptions->item(0)); | 301 | $optionNode->replaceChild($newNode, $userOptions->item(0)); |
358 | 297 | } | 302 | } |
359 | 298 | } | 303 | } |
361 | 299 | 304 | ||
362 | 300 | /** | 305 | /** |
363 | 301 | * Gets the value for the option in Parameter 1 | 306 | * Gets the value for the option in Parameter 1 |
365 | 302 | * @return | 307 | * @return |
366 | 303 | * @param $name String The Option Name | 308 | * @param $name String The Option Name |
367 | 304 | * @param $default Object[optional] The Default Value | 309 | * @param $default Object[optional] The Default Value |
368 | 305 | */ | 310 | */ |
369 | 306 | final protected function GetOption($name, $default = false) | 311 | final protected function GetOption($name, $default = false) |
370 | 307 | { | 312 | { |
371 | 308 | $db =& $this->db; | 313 | $db =& $this->db; |
373 | 309 | 314 | ||
374 | 310 | if ($name == '') return false; | 315 | if ($name == '') return false; |
376 | 311 | 316 | ||
377 | 312 | // Check to see if we already have this option or not | 317 | // Check to see if we already have this option or not |
378 | 313 | $xpath = new DOMXPath($this->xml); | 318 | $xpath = new DOMXPath($this->xml); |
380 | 314 | 319 | ||
381 | 315 | // Xpath for it | 320 | // Xpath for it |
382 | 316 | $userOptions = $xpath->query('//options/' . $name); | 321 | $userOptions = $xpath->query('//options/' . $name); |
384 | 317 | 322 | ||
385 | 318 | if ($userOptions->length == 0) | 323 | if ($userOptions->length == 0) |
386 | 319 | { | 324 | { |
387 | 320 | // We do not have an option - return the default | 325 | // We do not have an option - return the default |
388 | @@ -328,37 +333,37 @@ | |||
389 | 328 | return $userOptions->item(0)->nodeValue; | 333 | return $userOptions->item(0)->nodeValue; |
390 | 329 | } | 334 | } |
391 | 330 | } | 335 | } |
393 | 331 | 336 | ||
394 | 332 | /** | 337 | /** |
395 | 333 | * Sets the RAW XML string that is given as the content for Raw | 338 | * Sets the RAW XML string that is given as the content for Raw |
397 | 334 | * @return | 339 | * @return |
398 | 335 | * @param $xml String | 340 | * @param $xml String |
399 | 336 | * @param $replace Boolean[optional] | 341 | * @param $replace Boolean[optional] |
400 | 337 | */ | 342 | */ |
401 | 338 | final protected function SetRaw($xml, $replace = false) | 343 | final protected function SetRaw($xml, $replace = false) |
402 | 339 | { | 344 | { |
403 | 340 | if ($xml == '') return; | 345 | if ($xml == '') return; |
405 | 341 | 346 | ||
406 | 342 | // Load the XML we are given into its own document | 347 | // Load the XML we are given into its own document |
407 | 343 | $rawNode = new DOMDocument(); | 348 | $rawNode = new DOMDocument(); |
408 | 344 | $rawNode->loadXML('<raw>' . $xml . '</raw>'); | 349 | $rawNode->loadXML('<raw>' . $xml . '</raw>'); |
410 | 345 | 350 | ||
411 | 346 | // Import the Raw node into this document (with all sub nodes) | 351 | // Import the Raw node into this document (with all sub nodes) |
412 | 347 | $importedNode = $this->xml->importNode($rawNode->documentElement, true); | 352 | $importedNode = $this->xml->importNode($rawNode->documentElement, true); |
414 | 348 | 353 | ||
415 | 349 | // Get the Raw Xml node from our document | 354 | // Get the Raw Xml node from our document |
416 | 350 | $rawNodes = $this->xml->getElementsByTagName('raw'); | 355 | $rawNodes = $this->xml->getElementsByTagName('raw'); |
417 | 351 | 356 | ||
418 | 352 | // There is only 1 | 357 | // There is only 1 |
419 | 353 | $rawNode = $rawNodes->item(0); | 358 | $rawNode = $rawNodes->item(0); |
421 | 354 | 359 | ||
422 | 355 | // Append the imported node (at the end of whats already there) | 360 | // Append the imported node (at the end of whats already there) |
423 | 356 | $rawNode->parentNode->replaceChild($importedNode, $rawNode); | 361 | $rawNode->parentNode->replaceChild($importedNode, $rawNode); |
424 | 357 | } | 362 | } |
426 | 358 | 363 | ||
427 | 359 | /** | 364 | /** |
428 | 360 | * Gets the XML string from RAW | 365 | * Gets the XML string from RAW |
430 | 361 | * @return | 366 | * @return |
431 | 362 | */ | 367 | */ |
432 | 363 | final protected function GetRaw() | 368 | final protected function GetRaw() |
433 | 364 | { | 369 | { |
434 | @@ -367,21 +372,21 @@ | |||
435 | 367 | 372 | ||
436 | 368 | // There is only 1 | 373 | // There is only 1 |
437 | 369 | $rawNode = $rawNodes->item(0); | 374 | $rawNode = $rawNodes->item(0); |
439 | 370 | 375 | ||
440 | 371 | // Return it as a XML string | 376 | // Return it as a XML string |
441 | 372 | return $this->xml->saveXML($rawNode); | 377 | return $this->xml->saveXML($rawNode); |
442 | 373 | } | 378 | } |
444 | 374 | 379 | ||
445 | 375 | /** | 380 | /** |
446 | 376 | * Updates the region information with this media record | 381 | * Updates the region information with this media record |
448 | 377 | * @return | 382 | * @return |
449 | 378 | */ | 383 | */ |
450 | 379 | final public function UpdateRegion() | 384 | final public function UpdateRegion() |
451 | 380 | { | 385 | { |
452 | 381 | // By this point we expect to have a MediaID, duration | 386 | // By this point we expect to have a MediaID, duration |
453 | 382 | $layoutid = $this->layoutid; | 387 | $layoutid = $this->layoutid; |
454 | 383 | $regionid = $this->regionid; | 388 | $regionid = $this->regionid; |
456 | 384 | 389 | ||
457 | 385 | if ($this->deleteFromRegion) | 390 | if ($this->deleteFromRegion) |
458 | 386 | { | 391 | { |
459 | 387 | // We call region delete | 392 | // We call region delete |
460 | @@ -412,18 +417,27 @@ | |||
461 | 412 | } | 417 | } |
462 | 413 | } | 418 | } |
463 | 414 | } | 419 | } |
465 | 415 | 420 | ||
466 | 416 | return true; | 421 | return true; |
467 | 417 | } | 422 | } |
469 | 418 | 423 | ||
470 | 424 | /** | ||
471 | 425 | * Determines whether or not the provided file extension is valid for this module | ||
472 | 426 | * | ||
473 | 427 | */ | ||
474 | 428 | final protected function IsValidExtension($extension) | ||
475 | 429 | { | ||
476 | 430 | return in_array($extension, $this->validExtensions); | ||
477 | 431 | } | ||
478 | 432 | |||
479 | 419 | /** | 433 | /** |
480 | 420 | * Return the Delete Form as HTML | 434 | * Return the Delete Form as HTML |
482 | 421 | * @return | 435 | * @return |
483 | 422 | */ | 436 | */ |
484 | 423 | public function DeleteForm() | 437 | public function DeleteForm() |
485 | 424 | { | 438 | { |
486 | 425 | $db =& $this->db; | 439 | $db =& $this->db; |
488 | 426 | 440 | ||
489 | 427 | //Parameters | 441 | //Parameters |
490 | 428 | $layoutid = $this->layoutid; | 442 | $layoutid = $this->layoutid; |
491 | 429 | $regionid = $this->regionid; | 443 | $regionid = $this->regionid; |
492 | @@ -445,96 +459,115 @@ | |||
493 | 445 | <input class="XiboFormButton" id="btnCancel" type="button" title="$msgTitle" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="No" /> | 459 | <input class="XiboFormButton" id="btnCancel" type="button" title="$msgTitle" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="No" /> |
494 | 446 | </form> | 460 | </form> |
495 | 447 | END; | 461 | END; |
497 | 448 | 462 | ||
498 | 449 | $this->response->html = $form; | 463 | $this->response->html = $form; |
499 | 450 | $this->response->dialogTitle = __('Delete Item'); | 464 | $this->response->dialogTitle = __('Delete Item'); |
500 | 451 | $this->response->dialogSize = true; | 465 | $this->response->dialogSize = true; |
501 | 452 | $this->response->dialogWidth = '450px'; | 466 | $this->response->dialogWidth = '450px'; |
502 | 453 | $this->response->dialogHeight = '150px'; | 467 | $this->response->dialogHeight = '150px'; |
503 | 454 | 468 | ||
505 | 455 | return $this->response; | 469 | return $this->response; |
506 | 456 | } | 470 | } |
508 | 457 | 471 | ||
509 | 458 | /** | 472 | /** |
510 | 459 | * Delete Media from the Database | 473 | * Delete Media from the Database |
512 | 460 | * @return | 474 | * @return |
513 | 461 | */ | 475 | */ |
515 | 462 | public function DeleteMedia() | 476 | public function DeleteMedia() |
516 | 463 | { | 477 | { |
517 | 464 | $db =& $this->db; | 478 | $db =& $this->db; |
519 | 465 | 479 | ||
520 | 466 | $layoutid = $this->layoutid; | 480 | $layoutid = $this->layoutid; |
521 | 467 | $regionid = $this->regionid; | 481 | $regionid = $this->regionid; |
523 | 468 | 482 | ||
524 | 469 | $url = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions"; | 483 | $url = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions"; |
526 | 470 | 484 | ||
527 | 471 | $this->deleteFromRegion = true; | 485 | $this->deleteFromRegion = true; |
528 | 472 | $this->UpdateRegion(); | 486 | $this->UpdateRegion(); |
530 | 473 | 487 | ||
531 | 474 | // We want to load a new form | 488 | // We want to load a new form |
532 | 475 | $this->response->loadForm = true; | 489 | $this->response->loadForm = true; |
533 | 476 | $this->response->loadFormUri= $url; | 490 | $this->response->loadFormUri= $url; |
536 | 477 | 491 | ||
537 | 478 | return $this->response; | 492 | return $this->response; |
538 | 479 | } | 493 | } |
540 | 480 | 494 | ||
541 | 481 | /** | 495 | /** |
542 | 482 | * Default AddForm | 496 | * Default AddForm |
544 | 483 | * @return | 497 | * @return |
545 | 484 | */ | 498 | */ |
546 | 485 | public function AddForm() | 499 | public function AddForm() |
547 | 486 | { | 500 | { |
548 | 487 | $form = '<p>' . __('Not yet implemented by this module.') . '</p>'; | 501 | $form = '<p>' . __('Not yet implemented by this module.') . '</p>'; |
549 | 488 | END; | 502 | END; |
551 | 489 | 503 | ||
552 | 490 | $this->response->html = $form; | 504 | $this->response->html = $form; |
553 | 491 | $this->response->dialogTitle = __('Add Item'); | 505 | $this->response->dialogTitle = __('Add Item'); |
554 | 492 | $this->response->dialogSize = true; | 506 | $this->response->dialogSize = true; |
555 | 493 | $this->response->dialogWidth = '450px'; | 507 | $this->response->dialogWidth = '450px'; |
556 | 494 | $this->response->dialogHeight = '150px'; | 508 | $this->response->dialogHeight = '150px'; |
557 | 495 | 509 | ||
559 | 496 | return $this->response; | 510 | return $this->response; |
560 | 497 | } | 511 | } |
562 | 498 | 512 | ||
563 | 499 | /** | 513 | /** |
564 | 500 | * Default Edit Form | 514 | * Default Edit Form |
566 | 501 | * @return | 515 | * @return |
567 | 502 | */ | 516 | */ |
568 | 503 | public function EditForm() | 517 | public function EditForm() |
569 | 504 | { | 518 | { |
570 | 519 | <<<<<<< TREE | ||
571 | 505 | $form = '<p>' . __('Not yet implemented by this module.') . '</p>'; | 520 | $form = '<p>' . __('Not yet implemented by this module.') . '</p>'; |
572 | 506 | 521 | ||
573 | 522 | ======= | ||
574 | 523 | $form = <<<END | ||
575 | 524 | <p>Not yet implemented by this module.</p> | ||
576 | 525 | END; | ||
577 | 526 | |||
578 | 527 | >>>>>>> MERGE-SOURCE | ||
579 | 507 | $this->response->html = $form; | 528 | $this->response->html = $form; |
580 | 508 | $this->response->dialogTitle = __('Add Item'); | 529 | $this->response->dialogTitle = __('Add Item'); |
581 | 509 | $this->response->dialogSize = true; | 530 | $this->response->dialogSize = true; |
582 | 510 | $this->response->dialogWidth = '450px'; | 531 | $this->response->dialogWidth = '450px'; |
583 | 511 | $this->response->dialogHeight = '150px'; | 532 | $this->response->dialogHeight = '150px'; |
584 | 512 | 533 | ||
586 | 513 | return $this->response; | 534 | return $this->response; |
587 | 514 | } | 535 | } |
589 | 515 | 536 | ||
590 | 516 | /** | 537 | /** |
591 | 517 | * Default Add Media | 538 | * Default Add Media |
593 | 518 | * @return | 539 | * @return |
594 | 519 | */ | 540 | */ |
595 | 520 | public function AddMedia() | 541 | public function AddMedia() |
596 | 521 | { | 542 | { |
597 | 522 | // We want to load a new form | 543 | // We want to load a new form |
598 | 544 | <<<<<<< TREE | ||
599 | 523 | $this->response->message = __('Add Media has not been implemented for this module.'); | 545 | $this->response->message = __('Add Media has not been implemented for this module.'); |
600 | 524 | 546 | ||
601 | 525 | return $this->response; | 547 | return $this->response; |
602 | 548 | ======= | ||
603 | 549 | $this->response->message = 'Add Media has not been implemented for this module.'; | ||
604 | 550 | |||
605 | 551 | return $this->response; | ||
606 | 552 | >>>>>>> MERGE-SOURCE | ||
607 | 526 | } | 553 | } |
609 | 527 | 554 | ||
610 | 528 | /** | 555 | /** |
611 | 529 | * Default EditMedia | 556 | * Default EditMedia |
613 | 530 | * @return | 557 | * @return |
614 | 531 | */ | 558 | */ |
615 | 532 | public function EditMedia() | 559 | public function EditMedia() |
616 | 533 | { | 560 | { |
617 | 534 | // We want to load a new form | 561 | // We want to load a new form |
618 | 562 | <<<<<<< TREE | ||
619 | 535 | $this->response->message = __('Edit Media has not been implemented for this module.'); | 563 | $this->response->message = __('Edit Media has not been implemented for this module.'); |
620 | 536 | 564 | ||
621 | 537 | return $this->response; | 565 | return $this->response; |
622 | 566 | ======= | ||
623 | 567 | $this->response->message = 'Edit Media has not been implemented for this module.'; | ||
624 | 568 | |||
625 | 569 | return $this->response; | ||
626 | 570 | >>>>>>> MERGE-SOURCE | ||
627 | 538 | } | 571 | } |
628 | 539 | 572 | ||
629 | 540 | /** | 573 | /** |
630 | @@ -544,10 +577,10 @@ | |||
631 | 544 | public function GetName() | 577 | public function GetName() |
632 | 545 | { | 578 | { |
633 | 546 | $db =& $this->db; | 579 | $db =& $this->db; |
635 | 547 | 580 | ||
636 | 548 | Debug::LogEntry($db, 'audit', sprintf('Module name returned for MediaID: %s is %s', $this->mediaid, $this->name), 'Module', 'GetName'); | 581 | Debug::LogEntry($db, 'audit', sprintf('Module name returned for MediaID: %s is %s', $this->mediaid, $this->name), 'Module', 'GetName'); |
638 | 549 | 582 | ||
639 | 550 | return $this->name; | 583 | return $this->name; |
640 | 551 | } | 584 | } |
641 | 552 | } | 585 | } |
643 | 553 | ?> | 586 | ?> |
644 | 554 | \ No newline at end of file | 587 | \ No newline at end of file |
645 | 555 | 588 | ||
646 | === modified file 'server/modules/flash.module.php' | |||
647 | --- server/modules/flash.module.php 2009-06-28 10:47:06 +0000 | |||
648 | +++ server/modules/flash.module.php 2009-10-01 21:40:25 +0000 | |||
649 | @@ -8,7 +8,7 @@ | |||
650 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
651 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
652 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
654 | 11 | * any later version. | 11 | * any later version. |
655 | 12 | * | 12 | * |
656 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
657 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
658 | @@ -17,31 +17,31 @@ | |||
659 | 17 | * | 17 | * |
660 | 18 | * You should have received a copy of the GNU Affero General Public License | 18 | * You should have received a copy of the GNU Affero General Public License |
661 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
663 | 20 | */ | 20 | */ |
664 | 21 | class flash extends Module | 21 | class flash extends Module |
665 | 22 | { | 22 | { |
666 | 23 | // Custom Media information | 23 | // Custom Media information |
667 | 24 | private $uri; | 24 | private $uri; |
668 | 25 | private $maxFileSize; | 25 | private $maxFileSize; |
669 | 26 | private $maxFileSizeBytes; | 26 | private $maxFileSizeBytes; |
671 | 27 | 27 | ||
672 | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
673 | 29 | { | 29 | { |
674 | 30 | // Must set the type of the class | 30 | // Must set the type of the class |
675 | 31 | $this->type = 'flash'; | 31 | $this->type = 'flash'; |
677 | 32 | 32 | ||
678 | 33 | // Get the max upload size from PHP | 33 | // Get the max upload size from PHP |
679 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); |
680 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); |
683 | 36 | 36 | ||
684 | 37 | // Must call the parent class | 37 | // Must call the parent class |
685 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); |
686 | 39 | } | 39 | } |
688 | 40 | 40 | ||
689 | 41 | /** | 41 | /** |
690 | 42 | * Sets the Layout and Region Information | 42 | * Sets the Layout and Region Information |
691 | 43 | * it will then fill in any blanks it has about this media if it can | 43 | * it will then fill in any blanks it has about this media if it can |
693 | 44 | * @return | 44 | * @return |
694 | 45 | * @param $layoutid Object | 45 | * @param $layoutid Object |
695 | 46 | * @param $regionid Object | 46 | * @param $regionid Object |
696 | 47 | * @param $mediaid Object | 47 | * @param $mediaid Object |
697 | @@ -53,75 +53,75 @@ | |||
698 | 53 | $this->regionid = $regionid; | 53 | $this->regionid = $regionid; |
699 | 54 | $mediaid = $this->mediaid; | 54 | $mediaid = $this->mediaid; |
700 | 55 | $this->existingMedia = false; | 55 | $this->existingMedia = false; |
702 | 56 | 56 | ||
703 | 57 | if ($this->regionSpecific == 1) return; | 57 | if ($this->regionSpecific == 1) return; |
705 | 58 | 58 | ||
706 | 59 | // Load what we know about this media into the object | 59 | // Load what we know about this media into the object |
707 | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
709 | 61 | 61 | ||
710 | 62 | if (!$result = $db->query($SQL)) | 62 | if (!$result = $db->query($SQL)) |
711 | 63 | { | 63 | { |
712 | 64 | trigger_error($db->error()); //log the error | 64 | trigger_error($db->error()); //log the error |
713 | 65 | return false; | 65 | return false; |
714 | 66 | } | 66 | } |
716 | 67 | 67 | ||
717 | 68 | if ($db->num_rows($result) != 1) | 68 | if ($db->num_rows($result) != 1) |
718 | 69 | { | 69 | { |
719 | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
720 | 71 | return false; | 71 | return false; |
721 | 72 | } | 72 | } |
723 | 73 | 73 | ||
724 | 74 | $row = $db->get_row($result); | 74 | $row = $db->get_row($result); |
725 | 75 | $duration = $row[2]; | 75 | $duration = $row[2]; |
726 | 76 | $storedAs = $row[7]; | 76 | $storedAs = $row[7]; |
728 | 77 | 77 | ||
729 | 78 | // Required Attributes | 78 | // Required Attributes |
730 | 79 | $this->duration = $duration; | 79 | $this->duration = $duration; |
732 | 80 | 80 | ||
733 | 81 | // Any Options | 81 | // Any Options |
734 | 82 | $this->SetOption('uri', $storedAs); | 82 | $this->SetOption('uri', $storedAs); |
736 | 83 | 83 | ||
737 | 84 | return true; | 84 | return true; |
738 | 85 | } | 85 | } |
740 | 86 | 86 | ||
741 | 87 | /** | 87 | /** |
742 | 88 | * Return the Add Form as HTML | 88 | * Return the Add Form as HTML |
744 | 89 | * @return | 89 | * @return |
745 | 90 | */ | 90 | */ |
746 | 91 | public function AddForm() | 91 | public function AddForm() |
747 | 92 | { | 92 | { |
748 | 93 | global $session; | 93 | global $session; |
749 | 94 | $db =& $this->db; | 94 | $db =& $this->db; |
750 | 95 | $user =& $this->user; | 95 | $user =& $this->user; |
753 | 96 | 96 | ||
754 | 97 | // Would like to get the regions width / height | 97 | // Would like to get the regions width / height |
755 | 98 | $layoutid = $this->layoutid; | 98 | $layoutid = $this->layoutid; |
756 | 99 | $regionid = $this->regionid; | 99 | $regionid = $this->regionid; |
758 | 100 | 100 | ||
759 | 101 | // Set the Session / Security information | 101 | // Set the Session / Security information |
760 | 102 | $sessionId = session_id(); | 102 | $sessionId = session_id(); |
761 | 103 | $securityToken = CreateFormToken(); | 103 | $securityToken = CreateFormToken(); |
763 | 104 | 104 | ||
764 | 105 | $session->setSecurityToken($securityToken); | 105 | $session->setSecurityToken($securityToken); |
766 | 106 | 106 | ||
767 | 107 | //Get the default value for the shared list | 107 | //Get the default value for the shared list |
768 | 108 | $default = Config::GetSetting($db,"defaultMedia"); | 108 | $default = Config::GetSetting($db,"defaultMedia"); |
769 | 109 | 109 | ||
770 | 110 | $permissionid = 0; | 110 | $permissionid = 0; |
771 | 111 | 111 | ||
773 | 112 | if($default=="private") | 112 | if($default=="private") |
774 | 113 | { | 113 | { |
775 | 114 | $permissionid = 1; | 114 | $permissionid = 1; |
776 | 115 | } | 115 | } |
778 | 116 | 116 | ||
779 | 117 | //shared list | 117 | //shared list |
780 | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
782 | 119 | 119 | ||
783 | 120 | //Save button is different depending on if we are on a region or not | 120 | //Save button is different depending on if we are on a region or not |
784 | 121 | if ($regionid != "") | 121 | if ($regionid != "") |
785 | 122 | { | 122 | { |
786 | 123 | setSession('content','mediatype','flash'); | 123 | setSession('content','mediatype','flash'); |
788 | 124 | 124 | ||
789 | 125 | $save_button = <<<END | 125 | $save_button = <<<END |
790 | 126 | <input id="btnSave" type="submit" value="Save" disabled /> | 126 | <input id="btnSave" type="submit" value="Save" disabled /> |
791 | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
792 | @@ -135,7 +135,7 @@ | |||
793 | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> |
794 | 136 | END; | 136 | END; |
795 | 137 | } | 137 | } |
797 | 138 | 138 | ||
798 | 139 | $form = <<<FORM | 139 | $form = <<<FORM |
799 | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
800 | 141 | <div> | 141 | <div> |
801 | @@ -144,7 +144,7 @@ | |||
802 | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
803 | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
804 | 146 | <table> | 146 | <table> |
806 | 147 | <tr> | 147 | <tr> |
807 | 148 | <td><label for="file">Flash File<span class="required">*</span></label></td> | 148 | <td><label for="file">Flash File<span class="required">*</span></label></td> |
808 | 149 | <td colspan="3"> | 149 | <td colspan="3"> |
809 | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
810 | @@ -172,11 +172,11 @@ | |||
811 | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
812 | 173 | <td> | 173 | <td> |
813 | 174 | $shared_list | 174 | $shared_list |
815 | 175 | </td> | 175 | </td> |
816 | 176 | </tr> | 176 | </tr> |
817 | 177 | <tr> | 177 | <tr> |
818 | 178 | <td></td> | 178 | <td></td> |
820 | 179 | <td>This form accepts: <span class="required">swf</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> | 179 | <td>This form accepts: <span class="required">$this->validExtensionsText</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> |
821 | 180 | </tr> | 180 | </tr> |
822 | 181 | <tr> | 181 | <tr> |
823 | 182 | <td></td> | 182 | <td></td> |
824 | @@ -194,49 +194,49 @@ | |||
825 | 194 | 194 | ||
826 | 195 | return $this->response; | 195 | return $this->response; |
827 | 196 | } | 196 | } |
829 | 197 | 197 | ||
830 | 198 | /** | 198 | /** |
831 | 199 | * Return the Edit Form as HTML | 199 | * Return the Edit Form as HTML |
833 | 200 | * @return | 200 | * @return |
834 | 201 | */ | 201 | */ |
835 | 202 | public function EditForm() | 202 | public function EditForm() |
836 | 203 | { | 203 | { |
837 | 204 | global $session; | 204 | global $session; |
838 | 205 | $db =& $this->db; | 205 | $db =& $this->db; |
839 | 206 | $user =& $this->user; | 206 | $user =& $this->user; |
842 | 207 | 207 | ||
843 | 208 | // Would like to get the regions width / height | 208 | // Would like to get the regions width / height |
844 | 209 | $layoutid = $this->layoutid; | 209 | $layoutid = $this->layoutid; |
845 | 210 | $regionid = $this->regionid; | 210 | $regionid = $this->regionid; |
846 | 211 | $mediaid = $this->mediaid; | 211 | $mediaid = $this->mediaid; |
847 | 212 | $lkid = $this->lkid; | 212 | $lkid = $this->lkid; |
848 | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
850 | 214 | 214 | ||
851 | 215 | // Set the Session / Security information | 215 | // Set the Session / Security information |
852 | 216 | $sessionId = session_id(); | 216 | $sessionId = session_id(); |
853 | 217 | $securityToken = CreateFormToken(); | 217 | $securityToken = CreateFormToken(); |
855 | 218 | 218 | ||
856 | 219 | $session->setSecurityToken($securityToken); | 219 | $session->setSecurityToken($securityToken); |
858 | 220 | 220 | ||
859 | 221 | // Load what we know about this media into the object | 221 | // Load what we know about this media into the object |
860 | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
862 | 223 | 223 | ||
863 | 224 | if (!$result = $db->query($SQL)) | 224 | if (!$result = $db->query($SQL)) |
864 | 225 | { | 225 | { |
865 | 226 | trigger_error($db->error()); //log the error | 226 | trigger_error($db->error()); //log the error |
867 | 227 | 227 | ||
868 | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
869 | 229 | return false; | 229 | return false; |
870 | 230 | } | 230 | } |
872 | 231 | 231 | ||
873 | 232 | if ($db->num_rows($result) != 1) | 232 | if ($db->num_rows($result) != 1) |
874 | 233 | { | 233 | { |
875 | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
877 | 235 | 235 | ||
878 | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
879 | 237 | return false; | 237 | return false; |
880 | 238 | } | 238 | } |
882 | 239 | 239 | ||
883 | 240 | $row = $db->get_row($result); | 240 | $row = $db->get_row($result); |
884 | 241 | $name = $row[0]; | 241 | $name = $row[0]; |
885 | 242 | $originalFilename = $row[1]; | 242 | $originalFilename = $row[1]; |
886 | @@ -246,23 +246,23 @@ | |||
887 | 246 | $storedAs = $row[5]; | 246 | $storedAs = $row[5]; |
888 | 247 | $isEdited = $row[6]; | 247 | $isEdited = $row[6]; |
889 | 248 | $editedMediaID = $row[7]; | 248 | $editedMediaID = $row[7]; |
891 | 249 | 249 | ||
892 | 250 | // derive the ext | 250 | // derive the ext |
893 | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
895 | 252 | 252 | ||
896 | 253 | //Calc the permissions on it aswell | 253 | //Calc the permissions on it aswell |
897 | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
899 | 255 | 255 | ||
900 | 256 | //shared list | 256 | //shared list |
901 | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
903 | 258 | 258 | ||
904 | 259 | //Save button is different depending on if we are on a region or not | 259 | //Save button is different depending on if we are on a region or not |
905 | 260 | if ($regionid != "") | 260 | if ($regionid != "") |
906 | 261 | { | 261 | { |
907 | 262 | setSession('content','mediatype','flash'); | 262 | setSession('content','mediatype','flash'); |
909 | 263 | 263 | ||
910 | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
912 | 265 | 265 | ||
913 | 266 | $save_button = <<<END | 266 | $save_button = <<<END |
914 | 267 | <input id="btnSave" type="submit" value="Save" /> | 267 | <input id="btnSave" type="submit" value="Save" /> |
915 | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
916 | @@ -272,13 +272,13 @@ | |||
917 | 272 | else | 272 | else |
918 | 273 | { | 273 | { |
919 | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; |
921 | 275 | 275 | ||
922 | 276 | $save_button = <<<END | 276 | $save_button = <<<END |
923 | 277 | <input id="btnSave" type="submit" value="Save" /> | 277 | <input id="btnSave" type="submit" value="Save" /> |
924 | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> |
925 | 279 | END; | 279 | END; |
926 | 280 | } | 280 | } |
928 | 281 | 281 | ||
929 | 282 | $form = <<<FORM | 282 | $form = <<<FORM |
930 | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
931 | 284 | <div> | 284 | <div> |
932 | @@ -287,7 +287,7 @@ | |||
933 | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
934 | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
935 | 289 | <table> | 289 | <table> |
937 | 290 | <tr> | 290 | <tr> |
938 | 291 | <td><label for="file">New Flash File<span class="required">*</span></label></td> | 291 | <td><label for="file">New Flash File<span class="required">*</span></label></td> |
939 | 292 | <td colspan="3"> | 292 | <td colspan="3"> |
940 | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
941 | @@ -319,11 +319,11 @@ | |||
942 | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
943 | 320 | <td> | 320 | <td> |
944 | 321 | $shared_list | 321 | $shared_list |
946 | 322 | </td> | 322 | </td> |
947 | 323 | </tr> | 323 | </tr> |
948 | 324 | <tr> | 324 | <tr> |
949 | 325 | <td></td> | 325 | <td></td> |
951 | 326 | <td>This form accepts: <span class="required">swf</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> | 326 | <td>This form accepts: <span class="required">$this->validExtensionsText</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> |
952 | 327 | </tr> | 327 | </tr> |
953 | 328 | <tr> | 328 | <tr> |
954 | 329 | <td></td> | 329 | <td></td> |
955 | @@ -343,50 +343,50 @@ | |||
956 | 343 | $this->response->dialogWidth = '450px'; | 343 | $this->response->dialogWidth = '450px'; |
957 | 344 | $this->response->dialogHeight = '280px'; | 344 | $this->response->dialogHeight = '280px'; |
958 | 345 | 345 | ||
960 | 346 | return $this->response; | 346 | return $this->response; |
961 | 347 | } | 347 | } |
963 | 348 | 348 | ||
964 | 349 | /** | 349 | /** |
965 | 350 | * Return the Delete Form as HTML | 350 | * Return the Delete Form as HTML |
967 | 351 | * @return | 351 | * @return |
968 | 352 | */ | 352 | */ |
969 | 353 | public function DeleteForm() | 353 | public function DeleteForm() |
970 | 354 | { | 354 | { |
971 | 355 | $db =& $this->db; | 355 | $db =& $this->db; |
972 | 356 | $user =& $this->user; | 356 | $user =& $this->user; |
975 | 357 | 357 | ||
976 | 358 | // Would like to get the regions width / height | 358 | // Would like to get the regions width / height |
977 | 359 | $layoutid = $this->layoutid; | 359 | $layoutid = $this->layoutid; |
978 | 360 | $regionid = $this->regionid; | 360 | $regionid = $this->regionid; |
979 | 361 | $mediaid = $this->mediaid; | 361 | $mediaid = $this->mediaid; |
980 | 362 | $lkid = $this->lkid; | 362 | $lkid = $this->lkid; |
981 | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
983 | 364 | 364 | ||
984 | 365 | $options = ""; | 365 | $options = ""; |
985 | 366 | //Always have the abilty to unassign from the region | 366 | //Always have the abilty to unassign from the region |
986 | 367 | $options .= "unassign|Unassign from this region only"; | 367 | $options .= "unassign|Unassign from this region only"; |
988 | 368 | 368 | ||
989 | 369 | // Load what we know about this media into the object | 369 | // Load what we know about this media into the object |
990 | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
992 | 371 | 371 | ||
993 | 372 | if (!$result = $db->query($SQL)) | 372 | if (!$result = $db->query($SQL)) |
994 | 373 | { | 373 | { |
995 | 374 | trigger_error($db->error()); //log the error | 374 | trigger_error($db->error()); //log the error |
997 | 375 | 375 | ||
998 | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
999 | 377 | $this->response->keepOpen = true; | 377 | $this->response->keepOpen = true; |
1000 | 378 | return $this->response; | 378 | return $this->response; |
1001 | 379 | } | 379 | } |
1003 | 380 | 380 | ||
1004 | 381 | if ($db->num_rows($result) != 1) | 381 | if ($db->num_rows($result) != 1) |
1005 | 382 | { | 382 | { |
1006 | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
1008 | 384 | 384 | ||
1009 | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
1010 | 386 | $this->response->keepOpen = true; | 386 | $this->response->keepOpen = true; |
1011 | 387 | return $this->response; | 387 | return $this->response; |
1012 | 388 | } | 388 | } |
1014 | 389 | 389 | ||
1015 | 390 | $row = $db->get_row($result); | 390 | $row = $db->get_row($result); |
1016 | 391 | $name = $row[0]; | 391 | $name = $row[0]; |
1017 | 392 | $duration = $row[2]; | 392 | $duration = $row[2]; |
1018 | @@ -397,18 +397,18 @@ | |||
1019 | 397 | $storedAs = $row[7]; | 397 | $storedAs = $row[7]; |
1020 | 398 | $isEdited = $row[8]; | 398 | $isEdited = $row[8]; |
1021 | 399 | $editedMediaID = $row[9]; | 399 | $editedMediaID = $row[9]; |
1023 | 400 | 400 | ||
1024 | 401 | // derive the ext | 401 | // derive the ext |
1025 | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
1027 | 403 | 403 | ||
1028 | 404 | //Calc the permissions on it aswell | 404 | //Calc the permissions on it aswell |
1029 | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
1031 | 406 | 406 | ||
1032 | 407 | //Is this user allowed to edit this media? | 407 | //Is this user allowed to edit this media? |
1033 | 408 | if ($edit_permissions) | 408 | if ($edit_permissions) |
1034 | 409 | { | 409 | { |
1035 | 410 | $options .= ",retire|Unassign from this region and retire"; | 410 | $options .= ",retire|Unassign from this region and retire"; |
1037 | 411 | 411 | ||
1038 | 412 | //Is this media retired? | 412 | //Is this media retired? |
1039 | 413 | if ($editedMediaID != "") | 413 | if ($editedMediaID != "") |
1040 | 414 | { | 414 | { |
1041 | @@ -418,7 +418,7 @@ | |||
1042 | 418 | { | 418 | { |
1043 | 419 | $revised = false; | 419 | $revised = false; |
1044 | 420 | } | 420 | } |
1046 | 421 | 421 | ||
1047 | 422 | //Is this media being used anywhere else? | 422 | //Is this media being used anywhere else? |
1048 | 423 | if ($layoutid == "") | 423 | if ($layoutid == "") |
1049 | 424 | { | 424 | { |
1050 | @@ -429,8 +429,8 @@ | |||
1051 | 429 | { | 429 | { |
1052 | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; |
1053 | 431 | } | 431 | } |
1056 | 432 | 432 | ||
1057 | 433 | if (!$results = $db->query($SQL)) | 433 | if (!$results = $db->query($SQL)) |
1058 | 434 | { | 434 | { |
1059 | 435 | trigger_error($db->error()); | 435 | trigger_error($db->error()); |
1060 | 436 | 436 | ||
1061 | @@ -457,9 +457,9 @@ | |||
1062 | 457 | return $this->response; | 457 | return $this->response; |
1063 | 458 | } | 458 | } |
1064 | 459 | } | 459 | } |
1066 | 460 | 460 | ||
1067 | 461 | $options = ltrim($options, ","); | 461 | $options = ltrim($options, ","); |
1069 | 462 | 462 | ||
1070 | 463 | $deleteOptions = listcontent($options,"options"); | 463 | $deleteOptions = listcontent($options,"options"); |
1071 | 464 | 464 | ||
1072 | 465 | //we can delete | 465 | //we can delete |
1073 | @@ -474,19 +474,19 @@ | |||
1074 | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> |
1075 | 475 | </form> | 475 | </form> |
1076 | 476 | END; | 476 | END; |
1078 | 477 | 477 | ||
1079 | 478 | $this->response->html = $form; | 478 | $this->response->html = $form; |
1080 | 479 | $this->response->dialogTitle = 'Delete Flash'; | 479 | $this->response->dialogTitle = 'Delete Flash'; |
1081 | 480 | $this->response->dialogSize = true; | 480 | $this->response->dialogSize = true; |
1082 | 481 | $this->response->dialogWidth = '450px'; | 481 | $this->response->dialogWidth = '450px'; |
1083 | 482 | $this->response->dialogHeight = '280px'; | 482 | $this->response->dialogHeight = '280px'; |
1084 | 483 | 483 | ||
1086 | 484 | return $this->response; | 484 | return $this->response; |
1087 | 485 | } | 485 | } |
1089 | 486 | 486 | ||
1090 | 487 | /** | 487 | /** |
1091 | 488 | * Add Media to the Database | 488 | * Add Media to the Database |
1093 | 489 | * @return | 489 | * @return |
1094 | 490 | */ | 490 | */ |
1095 | 491 | public function AddMedia() | 491 | public function AddMedia() |
1096 | 492 | { | 492 | { |
1097 | @@ -495,62 +495,62 @@ | |||
1098 | 495 | $regionid = $this->regionid; | 495 | $regionid = $this->regionid; |
1099 | 496 | $mediaid = $this->mediaid; | 496 | $mediaid = $this->mediaid; |
1100 | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1102 | 498 | 498 | ||
1103 | 499 | // File data | 499 | // File data |
1104 | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
1106 | 501 | 501 | ||
1107 | 502 | if ($tmpName == '') | 502 | if ($tmpName == '') |
1108 | 503 | { | 503 | { |
1109 | 504 | $this->response->SetError('Cannot save Flash details. <br/> You must have picked a file.'); | 504 | $this->response->SetError('Cannot save Flash details. <br/> You must have picked a file.'); |
1110 | 505 | $this->response->keepOpen = true; | 505 | $this->response->keepOpen = true; |
1111 | 506 | return $this->response; | 506 | return $this->response; |
1112 | 507 | } | 507 | } |
1114 | 508 | 508 | ||
1115 | 509 | // File name and extension (orignial name) | 509 | // File name and extension (orignial name) |
1116 | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
1117 | 511 | $fileName = basename($fileName); | 511 | $fileName = basename($fileName); |
1118 | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
1120 | 513 | 513 | ||
1121 | 514 | // Other properties | 514 | // Other properties |
1122 | 515 | $name = Kit::GetParam('name', _POST, _STRING); | 515 | $name = Kit::GetParam('name', _POST, _STRING); |
1123 | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
1124 | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
1126 | 518 | 518 | ||
1127 | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); |
1129 | 520 | 520 | ||
1130 | 521 | // Validation | 521 | // Validation |
1132 | 522 | if ($ext != "swf") | 522 | if (!$this->IsValidExtension($ext)) |
1133 | 523 | { | 523 | { |
1135 | 524 | $this->response->SetError('Only SWF files are accepted - Are you sure this is an flash?'); | 524 | $this->response->SetError('Your file has an extension not supported by this Media Type.'); |
1136 | 525 | $this->response->keepOpen = true; | 525 | $this->response->keepOpen = true; |
1137 | 526 | return $this->response; | 526 | return $this->response; |
1138 | 527 | } | 527 | } |
1140 | 528 | 528 | ||
1141 | 529 | // Make sure the name isnt too long | 529 | // Make sure the name isnt too long |
1143 | 530 | if (strlen($name) > 100) | 530 | if (strlen($name) > 100) |
1144 | 531 | { | 531 | { |
1145 | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); |
1146 | 533 | $this->response->keepOpen = true; | 533 | $this->response->keepOpen = true; |
1147 | 534 | return $this->response; | 534 | return $this->response; |
1148 | 535 | } | 535 | } |
1150 | 536 | 536 | ||
1151 | 537 | if ($duration == 0) | 537 | if ($duration == 0) |
1152 | 538 | { | 538 | { |
1153 | 539 | $this->response->SetError('You must enter a duration.'); | 539 | $this->response->SetError('You must enter a duration.'); |
1154 | 540 | $this->response->keepOpen = true; | 540 | $this->response->keepOpen = true; |
1155 | 541 | return $this->response; | 541 | return $this->response; |
1156 | 542 | } | 542 | } |
1158 | 543 | 543 | ||
1159 | 544 | // Ensure the name is not already in the database | 544 | // Ensure the name is not already in the database |
1160 | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); |
1161 | 546 | 546 | ||
1163 | 547 | if(!$result = $db->query($SQL)) | 547 | if(!$result = $db->query($SQL)) |
1164 | 548 | { | 548 | { |
1165 | 549 | trigger_error($db->error()); | 549 | trigger_error($db->error()); |
1166 | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
1167 | 551 | $this->response->keepOpen = true; | 551 | $this->response->keepOpen = true; |
1168 | 552 | return $this->response; | 552 | return $this->response; |
1170 | 553 | } | 553 | } |
1171 | 554 | 554 | ||
1172 | 555 | if ($db->num_rows($result) != 0) | 555 | if ($db->num_rows($result) != 0) |
1173 | 556 | { | 556 | { |
1174 | @@ -558,11 +558,11 @@ | |||
1175 | 558 | $this->response->keepOpen = true; | 558 | $this->response->keepOpen = true; |
1176 | 559 | return $this->response; | 559 | return $this->response; |
1177 | 560 | } | 560 | } |
1179 | 561 | 561 | ||
1180 | 562 | // All OK to insert this record | 562 | // All OK to insert this record |
1181 | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
1182 | 564 | $SQL .= "VALUES ('%s', 'flash', '%s', '%s', %d, %d, 0) "; | 564 | $SQL .= "VALUES ('%s', 'flash', '%s', '%s', %d, %d, 0) "; |
1184 | 565 | 565 | ||
1185 | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
1186 | 567 | 567 | ||
1187 | 568 | if (!$mediaid = $db->insert_query($SQL)) | 568 | if (!$mediaid = $db->insert_query($SQL)) |
1188 | @@ -572,19 +572,19 @@ | |||
1189 | 572 | $this->response->keepOpen = true; | 572 | $this->response->keepOpen = true; |
1190 | 573 | return $this->response; | 573 | return $this->response; |
1191 | 574 | } | 574 | } |
1193 | 575 | 575 | ||
1194 | 576 | // File upload directory.. get this from the settings object | 576 | // File upload directory.. get this from the settings object |
1195 | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
1197 | 578 | 578 | ||
1198 | 579 | // What are we going to store this media as... | 579 | // What are we going to store this media as... |
1199 | 580 | $storedAs = $mediaid.".".$ext; | 580 | $storedAs = $mediaid.".".$ext; |
1201 | 581 | 581 | ||
1202 | 582 | // Now we need to move the file | 582 | // Now we need to move the file |
1203 | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) |
1204 | 584 | { | 584 | { |
1205 | 585 | // If we couldnt move it - we need to delete the media record we just added | 585 | // If we couldnt move it - we need to delete the media record we just added |
1206 | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); |
1208 | 587 | 587 | ||
1209 | 588 | if (!$db->query($SQL)) | 588 | if (!$db->query($SQL)) |
1210 | 589 | { | 589 | { |
1211 | 590 | trigger_error($db->error()); | 590 | trigger_error($db->error()); |
1212 | @@ -593,23 +593,23 @@ | |||
1213 | 593 | return $this->response; | 593 | return $this->response; |
1214 | 594 | } | 594 | } |
1215 | 595 | } | 595 | } |
1217 | 596 | 596 | ||
1218 | 597 | // Update the media record to include this information | 597 | // Update the media record to include this information |
1219 | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); |
1221 | 599 | 599 | ||
1222 | 600 | if (!$db->query($SQL)) | 600 | if (!$db->query($SQL)) |
1223 | 601 | { | 601 | { |
1224 | 602 | trigger_error($db->error()); | 602 | trigger_error($db->error()); |
1225 | 603 | return true; | 603 | return true; |
1226 | 604 | } | 604 | } |
1228 | 605 | 605 | ||
1229 | 606 | // Required Attributes | 606 | // Required Attributes |
1230 | 607 | $this->mediaid = $mediaid; | 607 | $this->mediaid = $mediaid; |
1231 | 608 | $this->duration = $duration; | 608 | $this->duration = $duration; |
1233 | 609 | 609 | ||
1234 | 610 | // Any Options | 610 | // Any Options |
1235 | 611 | $this->SetOption('uri', $storedAs); | 611 | $this->SetOption('uri', $storedAs); |
1237 | 612 | 612 | ||
1238 | 613 | // Should have built the media object entirely by this time | 613 | // Should have built the media object entirely by this time |
1239 | 614 | if ($regionid != '') | 614 | if ($regionid != '') |
1240 | 615 | { | 615 | { |
1241 | @@ -619,18 +619,18 @@ | |||
1242 | 619 | } | 619 | } |
1243 | 620 | else | 620 | else |
1244 | 621 | { | 621 | { |
1246 | 622 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 622 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
1247 | 623 | } | 623 | } |
1249 | 624 | 624 | ||
1250 | 625 | // We want to load a new form | 625 | // We want to load a new form |
1251 | 626 | $this->response->loadForm = true; | 626 | $this->response->loadForm = true; |
1253 | 627 | 627 | ||
1254 | 628 | return $this->response; | 628 | return $this->response; |
1255 | 629 | } | 629 | } |
1257 | 630 | 630 | ||
1258 | 631 | /** | 631 | /** |
1259 | 632 | * Edit Media in the Database | 632 | * Edit Media in the Database |
1261 | 633 | * @return | 633 | * @return |
1262 | 634 | */ | 634 | */ |
1263 | 635 | public function EditMedia() | 635 | public function EditMedia() |
1264 | 636 | { | 636 | { |
1265 | @@ -639,13 +639,13 @@ | |||
1266 | 639 | $regionid = $this->regionid; | 639 | $regionid = $this->regionid; |
1267 | 640 | $mediaid = $this->mediaid; | 640 | $mediaid = $this->mediaid; |
1268 | 641 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 641 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1270 | 642 | 642 | ||
1271 | 643 | // Stored As from the XML | 643 | // Stored As from the XML |
1272 | 644 | $storedAs = $this->GetOption('uri'); | 644 | $storedAs = $this->GetOption('uri'); |
1274 | 645 | 645 | ||
1275 | 646 | // File data | 646 | // File data |
1276 | 647 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 647 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
1278 | 648 | 648 | ||
1279 | 649 | if ($tmpName == '') | 649 | if ($tmpName == '') |
1280 | 650 | { | 650 | { |
1281 | 651 | $fileRevision = false; | 651 | $fileRevision = false; |
1282 | @@ -653,30 +653,30 @@ | |||
1283 | 653 | else | 653 | else |
1284 | 654 | { | 654 | { |
1285 | 655 | $fileRevision = true; | 655 | $fileRevision = true; |
1287 | 656 | 656 | ||
1288 | 657 | // File name and extension (orignial name) | 657 | // File name and extension (orignial name) |
1289 | 658 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 658 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
1290 | 659 | $fileName = basename($fileName); | 659 | $fileName = basename($fileName); |
1291 | 660 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 660 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
1294 | 661 | 661 | ||
1295 | 662 | if ($ext != "swf") | 662 | if (!$this->IsValidExtension($ext)) |
1296 | 663 | { | 663 | { |
1298 | 664 | $this->response->SetError('Only SWF files are accepted - Are you sure this is an flash?'); | 664 | $this->response->SetError('Your file has an extension not supported by this Media Type.'); |
1299 | 665 | $this->response->keepOpen = true; | 665 | $this->response->keepOpen = true; |
1300 | 666 | return $this->response; | 666 | return $this->response; |
1301 | 667 | } | 667 | } |
1302 | 668 | } | 668 | } |
1304 | 669 | 669 | ||
1305 | 670 | // Other properties | 670 | // Other properties |
1306 | 671 | $name = Kit::GetParam('name', _POST, _STRING); | 671 | $name = Kit::GetParam('name', _POST, _STRING); |
1307 | 672 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 672 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
1308 | 673 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 673 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
1310 | 674 | 674 | ||
1311 | 675 | if ($name == '') | 675 | if ($name == '') |
1312 | 676 | { | 676 | { |
1313 | 677 | if ($fileRevision) | 677 | if ($fileRevision) |
1314 | 678 | { | 678 | { |
1316 | 679 | $name = Kit::ValidateParam($fileName, _FILENAME); | 679 | $name = Kit::ValidateParam($fileName, _FILENAME); |
1317 | 680 | } | 680 | } |
1318 | 681 | else | 681 | else |
1319 | 682 | { | 682 | { |
1320 | @@ -684,33 +684,33 @@ | |||
1321 | 684 | $this->response->keepOpen = true; | 684 | $this->response->keepOpen = true; |
1322 | 685 | return $this->response; | 685 | return $this->response; |
1323 | 686 | } | 686 | } |
1326 | 687 | } | 687 | } |
1327 | 688 | 688 | ||
1328 | 689 | // Make sure the name isnt too long | 689 | // Make sure the name isnt too long |
1330 | 690 | if (strlen($name) > 100) | 690 | if (strlen($name) > 100) |
1331 | 691 | { | 691 | { |
1332 | 692 | $this->response->SetError('The name cannot be longer than 100 characters'); | 692 | $this->response->SetError('The name cannot be longer than 100 characters'); |
1333 | 693 | $this->response->keepOpen = true; | 693 | $this->response->keepOpen = true; |
1334 | 694 | return $this->response; | 694 | return $this->response; |
1335 | 695 | } | 695 | } |
1337 | 696 | 696 | ||
1338 | 697 | if ($duration == 0) | 697 | if ($duration == 0) |
1339 | 698 | { | 698 | { |
1340 | 699 | $this->response->SetError('You must enter a duration.'); | 699 | $this->response->SetError('You must enter a duration.'); |
1341 | 700 | $this->response->keepOpen = true; | 700 | $this->response->keepOpen = true; |
1342 | 701 | return $this->response; | 701 | return $this->response; |
1343 | 702 | } | 702 | } |
1345 | 703 | 703 | ||
1346 | 704 | // Ensure the name is not already in the database | 704 | // Ensure the name is not already in the database |
1347 | 705 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); | 705 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); |
1348 | 706 | 706 | ||
1350 | 707 | if(!$result = $db->query($SQL)) | 707 | if(!$result = $db->query($SQL)) |
1351 | 708 | { | 708 | { |
1352 | 709 | trigger_error($db->error()); | 709 | trigger_error($db->error()); |
1353 | 710 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 710 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
1354 | 711 | $this->response->keepOpen = true; | 711 | $this->response->keepOpen = true; |
1355 | 712 | return $this->response; | 712 | return $this->response; |
1357 | 713 | } | 713 | } |
1358 | 714 | 714 | ||
1359 | 715 | if ($db->num_rows($result) != 0) | 715 | if ($db->num_rows($result) != 0) |
1360 | 716 | { | 716 | { |
1361 | @@ -718,34 +718,34 @@ | |||
1362 | 718 | $this->response->keepOpen = true; | 718 | $this->response->keepOpen = true; |
1363 | 719 | return $this->response; | 719 | return $this->response; |
1364 | 720 | } | 720 | } |
1366 | 721 | 721 | ||
1367 | 722 | //Are we revising this media - or just plain editing | 722 | //Are we revising this media - or just plain editing |
1368 | 723 | if ($fileRevision) | 723 | if ($fileRevision) |
1369 | 724 | { | 724 | { |
1370 | 725 | // All OK to insert this record | 725 | // All OK to insert this record |
1371 | 726 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 726 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
1372 | 727 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; | 727 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; |
1374 | 728 | 728 | ||
1375 | 729 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 729 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
1377 | 730 | 730 | ||
1378 | 731 | if (!$new_mediaid = $db->insert_query($SQL)) | 731 | if (!$new_mediaid = $db->insert_query($SQL)) |
1379 | 732 | { | 732 | { |
1380 | 733 | trigger_error($db->error()); | 733 | trigger_error($db->error()); |
1381 | 734 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); | 734 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); |
1382 | 735 | } | 735 | } |
1384 | 736 | 736 | ||
1385 | 737 | //What are we going to store this media as... | 737 | //What are we going to store this media as... |
1386 | 738 | $storedAs = $new_mediaid.".".$ext; | 738 | $storedAs = $new_mediaid.".".$ext; |
1388 | 739 | 739 | ||
1389 | 740 | // File upload directory.. get this from the settings object | 740 | // File upload directory.. get this from the settings object |
1390 | 741 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 741 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
1392 | 742 | 742 | ||
1393 | 743 | //Now we need to move the file | 743 | //Now we need to move the file |
1394 | 744 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) | 744 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) |
1395 | 745 | { | 745 | { |
1396 | 746 | //If we couldnt move it - we need to delete the media record we just added | 746 | //If we couldnt move it - we need to delete the media record we just added |
1397 | 747 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; | 747 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; |
1399 | 748 | 748 | ||
1400 | 749 | if (!$db->insert_query($SQL)) | 749 | if (!$db->insert_query($SQL)) |
1401 | 750 | { | 750 | { |
1402 | 751 | $this->response->SetError('Error rolling back transcation.'); | 751 | $this->response->SetError('Error rolling back transcation.'); |
1403 | @@ -753,7 +753,7 @@ | |||
1404 | 753 | return $this->response; | 753 | return $this->response; |
1405 | 754 | } | 754 | } |
1406 | 755 | } | 755 | } |
1408 | 756 | 756 | ||
1409 | 757 | //Update the media record to include this information | 757 | //Update the media record to include this information |
1410 | 758 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; | 758 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; |
1411 | 759 | if (!$db->query($SQL)) | 759 | if (!$db->query($SQL)) |
1412 | @@ -763,13 +763,13 @@ | |||
1413 | 763 | $this->response->keepOpen = true; | 763 | $this->response->keepOpen = true; |
1414 | 764 | return $this->response; | 764 | return $this->response; |
1415 | 765 | } | 765 | } |
1417 | 766 | 766 | ||
1418 | 767 | // Update the existing record with the new record's id | 767 | // Update the existing record with the new record's id |
1419 | 768 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; | 768 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; |
1420 | 769 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; | 769 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; |
1422 | 770 | 770 | ||
1423 | 771 | Debug::LogEntry($db, 'audit', $SQL); | 771 | Debug::LogEntry($db, 'audit', $SQL); |
1425 | 772 | 772 | ||
1426 | 773 | if (!$db->query($SQL)) | 773 | if (!$db->query($SQL)) |
1427 | 774 | { | 774 | { |
1428 | 775 | trigger_error($db->error()); | 775 | trigger_error($db->error()); |
1429 | @@ -783,54 +783,54 @@ | |||
1430 | 783 | { | 783 | { |
1431 | 784 | // Editing the existing record | 784 | // Editing the existing record |
1432 | 785 | $new_mediaid = $mediaid; | 785 | $new_mediaid = $mediaid; |
1434 | 786 | 786 | ||
1435 | 787 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; | 787 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; |
1436 | 788 | $SQL .= " WHERE mediaID = %d "; | 788 | $SQL .= " WHERE mediaID = %d "; |
1437 | 789 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); | 789 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); |
1439 | 790 | 790 | ||
1440 | 791 | Debug::LogEntry($db, 'audit', $SQL); | 791 | Debug::LogEntry($db, 'audit', $SQL); |
1442 | 792 | 792 | ||
1443 | 793 | if (!$db->query($SQL)) | 793 | if (!$db->query($SQL)) |
1444 | 794 | { | 794 | { |
1445 | 795 | trigger_error($db->error()); | 795 | trigger_error($db->error()); |
1447 | 796 | 796 | ||
1448 | 797 | $this->response->SetError('Database error editing this media record.'); | 797 | $this->response->SetError('Database error editing this media record.'); |
1449 | 798 | $this->response->keepOpen = true; | 798 | $this->response->keepOpen = true; |
1450 | 799 | return $this->response; | 799 | return $this->response; |
1451 | 800 | } | 800 | } |
1452 | 801 | } | 801 | } |
1454 | 802 | 802 | ||
1455 | 803 | // Required Attributes | 803 | // Required Attributes |
1456 | 804 | $this->mediaid = $new_mediaid; | 804 | $this->mediaid = $new_mediaid; |
1457 | 805 | $this->duration = $duration; | 805 | $this->duration = $duration; |
1459 | 806 | 806 | ||
1460 | 807 | // Any Options | 807 | // Any Options |
1461 | 808 | $this->SetOption('uri', $storedAs); | 808 | $this->SetOption('uri', $storedAs); |
1463 | 809 | 809 | ||
1464 | 810 | // Should have built the media object entirely by this time | 810 | // Should have built the media object entirely by this time |
1465 | 811 | if ($regionid != '') | 811 | if ($regionid != '') |
1466 | 812 | { | 812 | { |
1467 | 813 | // This saves the Media Object to the Region | 813 | // This saves the Media Object to the Region |
1468 | 814 | $this->UpdateRegion(); | 814 | $this->UpdateRegion(); |
1470 | 815 | 815 | ||
1471 | 816 | $this->response->loadForm = true; | 816 | $this->response->loadForm = true; |
1472 | 817 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; | 817 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; |
1473 | 818 | } | 818 | } |
1474 | 819 | else | 819 | else |
1475 | 820 | { | 820 | { |
1477 | 821 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 821 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
1478 | 822 | $this->response->message = 'Edited the Flash.'; | 822 | $this->response->message = 'Edited the Flash.'; |
1480 | 823 | 823 | ||
1481 | 824 | } | 824 | } |
1483 | 825 | 825 | ||
1484 | 826 | return $this->response; | 826 | return $this->response; |
1485 | 827 | } | 827 | } |
1487 | 828 | 828 | ||
1488 | 829 | /** | 829 | /** |
1489 | 830 | * Delete Media from the Database | 830 | * Delete Media from the Database |
1491 | 831 | * @return | 831 | * @return |
1492 | 832 | */ | 832 | */ |
1494 | 833 | public function DeleteMedia() | 833 | public function DeleteMedia() |
1495 | 834 | { | 834 | { |
1496 | 835 | $db =& $this->db; | 835 | $db =& $this->db; |
1497 | 836 | $layoutid = $this->layoutid; | 836 | $layoutid = $this->layoutid; |
1498 | @@ -838,10 +838,10 @@ | |||
1499 | 838 | $mediaid = $this->mediaid; | 838 | $mediaid = $this->mediaid; |
1500 | 839 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 839 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1501 | 840 | $options = Kit::GetParam('options', _POST, _WORD); | 840 | $options = Kit::GetParam('options', _POST, _WORD); |
1503 | 841 | 841 | ||
1504 | 842 | // Stored As from the XML | 842 | // Stored As from the XML |
1505 | 843 | $this->uri = $this->GetOption('uri'); | 843 | $this->uri = $this->GetOption('uri'); |
1507 | 844 | 844 | ||
1508 | 845 | // Do we need to remove this from a layout? | 845 | // Do we need to remove this from a layout? |
1509 | 846 | if ($layoutid != '') | 846 | if ($layoutid != '') |
1510 | 847 | { | 847 | { |
1511 | @@ -853,72 +853,72 @@ | |||
1512 | 853 | // Set this message now in preparation | 853 | // Set this message now in preparation |
1513 | 854 | $this->response->message = 'Deleted the Media.'; | 854 | $this->response->message = 'Deleted the Media.'; |
1514 | 855 | } | 855 | } |
1516 | 856 | 856 | ||
1517 | 857 | // If we are set to retire we retire | 857 | // If we are set to retire we retire |
1518 | 858 | if ($options == "retire") | 858 | if ($options == "retire") |
1519 | 859 | { | 859 | { |
1520 | 860 | //Update the media record to say it is retired | 860 | //Update the media record to say it is retired |
1521 | 861 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; | 861 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; |
1523 | 862 | 862 | ||
1524 | 863 | if (!$db->query($SQL)) | 863 | if (!$db->query($SQL)) |
1525 | 864 | { | 864 | { |
1526 | 865 | trigger_error($db->error()); | 865 | trigger_error($db->error()); |
1528 | 866 | 866 | ||
1529 | 867 | $this->response->SetError('Database error retiring this media record.'); | 867 | $this->response->SetError('Database error retiring this media record.'); |
1530 | 868 | $this->response->keepOpen = true; | 868 | $this->response->keepOpen = true; |
1531 | 869 | return $this->response; | 869 | return $this->response; |
1532 | 870 | } | 870 | } |
1533 | 871 | } | 871 | } |
1535 | 872 | 872 | ||
1536 | 873 | //If we are set to delete, we delete | 873 | //If we are set to delete, we delete |
1537 | 874 | if ($options == "delete") | 874 | if ($options == "delete") |
1538 | 875 | { | 875 | { |
1539 | 876 | //Update the media record to say it is retired | 876 | //Update the media record to say it is retired |
1540 | 877 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; | 877 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; |
1542 | 878 | 878 | ||
1543 | 879 | if (!$db->query($SQL)) | 879 | if (!$db->query($SQL)) |
1544 | 880 | { | 880 | { |
1545 | 881 | trigger_error($db->error()); | 881 | trigger_error($db->error()); |
1547 | 882 | 882 | ||
1548 | 883 | $this->response->SetError('Database error deleting this media record.'); | 883 | $this->response->SetError('Database error deleting this media record.'); |
1549 | 884 | $this->response->keepOpen = true; | 884 | $this->response->keepOpen = true; |
1550 | 885 | return $this->response; | 885 | return $this->response; |
1551 | 886 | } | 886 | } |
1553 | 887 | 887 | ||
1554 | 888 | $this->DeleteMediaFiles(); | 888 | $this->DeleteMediaFiles(); |
1555 | 889 | } | 889 | } |
1556 | 890 | 890 | ||
1557 | 891 | return $this->response; | 891 | return $this->response; |
1558 | 892 | } | 892 | } |
1560 | 893 | 893 | ||
1561 | 894 | /** | 894 | /** |
1562 | 895 | * Deletes the media files associated with this record | 895 | * Deletes the media files associated with this record |
1564 | 896 | * @return | 896 | * @return |
1565 | 897 | */ | 897 | */ |
1566 | 898 | private function DeleteMediaFiles() | 898 | private function DeleteMediaFiles() |
1567 | 899 | { | 899 | { |
1568 | 900 | $db =& $this->db; | 900 | $db =& $this->db; |
1570 | 901 | 901 | ||
1571 | 902 | //Library location | 902 | //Library location |
1572 | 903 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 903 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
1574 | 904 | 904 | ||
1575 | 905 | //3 things to check for.. | 905 | //3 things to check for.. |
1576 | 906 | //the actual file, the thumbnail, the background | 906 | //the actual file, the thumbnail, the background |
1577 | 907 | if (file_exists($databaseDir.$this->uri)) | 907 | if (file_exists($databaseDir.$this->uri)) |
1578 | 908 | { | 908 | { |
1579 | 909 | unlink($databaseDir.$this->uri); | 909 | unlink($databaseDir.$this->uri); |
1580 | 910 | } | 910 | } |
1582 | 911 | 911 | ||
1583 | 912 | if (file_exists($databaseDir."tn_".$this->uri)) | 912 | if (file_exists($databaseDir."tn_".$this->uri)) |
1584 | 913 | { | 913 | { |
1585 | 914 | unlink($databaseDir."tn_".$this->uri); | 914 | unlink($databaseDir."tn_".$this->uri); |
1586 | 915 | } | 915 | } |
1588 | 916 | 916 | ||
1589 | 917 | if (file_exists($databaseDir."bg_".$this->uri)) | 917 | if (file_exists($databaseDir."bg_".$this->uri)) |
1590 | 918 | { | 918 | { |
1591 | 919 | unlink($databaseDir."bg_".$this->uri); | 919 | unlink($databaseDir."bg_".$this->uri); |
1592 | 920 | } | 920 | } |
1594 | 921 | 921 | ||
1595 | 922 | return true; | 922 | return true; |
1596 | 923 | } | 923 | } |
1597 | 924 | } | 924 | } |
1598 | 925 | 925 | ||
1599 | === modified file 'server/modules/image.module.php' | |||
1600 | --- server/modules/image.module.php 2009-06-28 10:47:06 +0000 | |||
1601 | +++ server/modules/image.module.php 2009-10-01 21:40:25 +0000 | |||
1602 | @@ -8,7 +8,7 @@ | |||
1603 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
1604 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
1605 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
1607 | 11 | * any later version. | 11 | * any later version. |
1608 | 12 | * | 12 | * |
1609 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
1610 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1611 | @@ -17,31 +17,31 @@ | |||
1612 | 17 | * | 17 | * |
1613 | 18 | * You should have received a copy of the GNU Affero General Public License | 18 | * You should have received a copy of the GNU Affero General Public License |
1614 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
1616 | 20 | */ | 20 | */ |
1617 | 21 | class image extends Module | 21 | class image extends Module |
1618 | 22 | { | 22 | { |
1619 | 23 | // Custom Media information | 23 | // Custom Media information |
1620 | 24 | private $uri; | 24 | private $uri; |
1621 | 25 | private $maxFileSize; | 25 | private $maxFileSize; |
1622 | 26 | private $maxFileSizeBytes; | 26 | private $maxFileSizeBytes; |
1624 | 27 | 27 | ||
1625 | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
1626 | 29 | { | 29 | { |
1627 | 30 | // Must set the type of the class | 30 | // Must set the type of the class |
1628 | 31 | $this->type = 'image'; | 31 | $this->type = 'image'; |
1630 | 32 | 32 | ||
1631 | 33 | // Get the max upload size from PHP | 33 | // Get the max upload size from PHP |
1632 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); |
1633 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); |
1636 | 36 | 36 | ||
1637 | 37 | // Must call the parent class | 37 | // Must call the parent class |
1638 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); |
1639 | 39 | } | 39 | } |
1641 | 40 | 40 | ||
1642 | 41 | /** | 41 | /** |
1643 | 42 | * Sets the Layout and Region Information | 42 | * Sets the Layout and Region Information |
1644 | 43 | * it will then fill in any blanks it has about this media if it can | 43 | * it will then fill in any blanks it has about this media if it can |
1646 | 44 | * @return | 44 | * @return |
1647 | 45 | * @param $layoutid Object | 45 | * @param $layoutid Object |
1648 | 46 | * @param $regionid Object | 46 | * @param $regionid Object |
1649 | 47 | * @param $mediaid Object | 47 | * @param $mediaid Object |
1650 | @@ -53,75 +53,75 @@ | |||
1651 | 53 | $this->regionid = $regionid; | 53 | $this->regionid = $regionid; |
1652 | 54 | $mediaid = $this->mediaid; | 54 | $mediaid = $this->mediaid; |
1653 | 55 | $this->existingMedia = false; | 55 | $this->existingMedia = false; |
1655 | 56 | 56 | ||
1656 | 57 | if ($this->regionSpecific == 1) return; | 57 | if ($this->regionSpecific == 1) return; |
1658 | 58 | 58 | ||
1659 | 59 | // Load what we know about this media into the object | 59 | // Load what we know about this media into the object |
1660 | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
1662 | 61 | 61 | ||
1663 | 62 | if (!$result = $db->query($SQL)) | 62 | if (!$result = $db->query($SQL)) |
1664 | 63 | { | 63 | { |
1665 | 64 | trigger_error($db->error()); //log the error | 64 | trigger_error($db->error()); //log the error |
1666 | 65 | return false; | 65 | return false; |
1667 | 66 | } | 66 | } |
1669 | 67 | 67 | ||
1670 | 68 | if ($db->num_rows($result) != 1) | 68 | if ($db->num_rows($result) != 1) |
1671 | 69 | { | 69 | { |
1672 | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
1673 | 71 | return false; | 71 | return false; |
1674 | 72 | } | 72 | } |
1676 | 73 | 73 | ||
1677 | 74 | $row = $db->get_row($result); | 74 | $row = $db->get_row($result); |
1678 | 75 | $duration = $row[2]; | 75 | $duration = $row[2]; |
1679 | 76 | $storedAs = $row[7]; | 76 | $storedAs = $row[7]; |
1681 | 77 | 77 | ||
1682 | 78 | // Required Attributes | 78 | // Required Attributes |
1683 | 79 | $this->duration = $duration; | 79 | $this->duration = $duration; |
1685 | 80 | 80 | ||
1686 | 81 | // Any Options | 81 | // Any Options |
1687 | 82 | $this->SetOption('uri', $storedAs); | 82 | $this->SetOption('uri', $storedAs); |
1689 | 83 | 83 | ||
1690 | 84 | return true; | 84 | return true; |
1691 | 85 | } | 85 | } |
1693 | 86 | 86 | ||
1694 | 87 | /** | 87 | /** |
1695 | 88 | * Return the Add Form as HTML | 88 | * Return the Add Form as HTML |
1697 | 89 | * @return | 89 | * @return |
1698 | 90 | */ | 90 | */ |
1699 | 91 | public function AddForm() | 91 | public function AddForm() |
1700 | 92 | { | 92 | { |
1701 | 93 | global $session; | 93 | global $session; |
1702 | 94 | $db =& $this->db; | 94 | $db =& $this->db; |
1703 | 95 | $user =& $this->user; | 95 | $user =& $this->user; |
1706 | 96 | 96 | ||
1707 | 97 | // Would like to get the regions width / height | 97 | // Would like to get the regions width / height |
1708 | 98 | $layoutid = $this->layoutid; | 98 | $layoutid = $this->layoutid; |
1709 | 99 | $regionid = $this->regionid; | 99 | $regionid = $this->regionid; |
1711 | 100 | 100 | ||
1712 | 101 | // Set the Session / Security information | 101 | // Set the Session / Security information |
1713 | 102 | $sessionId = session_id(); | 102 | $sessionId = session_id(); |
1714 | 103 | $securityToken = CreateFormToken(); | 103 | $securityToken = CreateFormToken(); |
1716 | 104 | 104 | ||
1717 | 105 | $session->setSecurityToken($securityToken); | 105 | $session->setSecurityToken($securityToken); |
1719 | 106 | 106 | ||
1720 | 107 | //Get the default value for the shared list | 107 | //Get the default value for the shared list |
1721 | 108 | $default = Config::GetSetting($db,"defaultMedia"); | 108 | $default = Config::GetSetting($db,"defaultMedia"); |
1722 | 109 | 109 | ||
1723 | 110 | $permissionid = 0; | 110 | $permissionid = 0; |
1724 | 111 | 111 | ||
1726 | 112 | if($default=="private") | 112 | if($default=="private") |
1727 | 113 | { | 113 | { |
1728 | 114 | $permissionid = 1; | 114 | $permissionid = 1; |
1729 | 115 | } | 115 | } |
1731 | 116 | 116 | ||
1732 | 117 | //shared list | 117 | //shared list |
1733 | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
1735 | 119 | 119 | ||
1736 | 120 | //Save button is different depending on if we are on a region or not | 120 | //Save button is different depending on if we are on a region or not |
1737 | 121 | if ($regionid != "") | 121 | if ($regionid != "") |
1738 | 122 | { | 122 | { |
1739 | 123 | setSession('content','mediatype','image'); | 123 | setSession('content','mediatype','image'); |
1741 | 124 | 124 | ||
1742 | 125 | $save_button = <<<END | 125 | $save_button = <<<END |
1743 | 126 | <input id="btnSave" type="submit" value="Save" disabled /> | 126 | <input id="btnSave" type="submit" value="Save" disabled /> |
1744 | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
1745 | @@ -135,7 +135,7 @@ | |||
1746 | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> |
1747 | 136 | END; | 136 | END; |
1748 | 137 | } | 137 | } |
1750 | 138 | 138 | ||
1751 | 139 | $form = <<<FORM | 139 | $form = <<<FORM |
1752 | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
1753 | 141 | <div> | 141 | <div> |
1754 | @@ -144,7 +144,7 @@ | |||
1755 | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
1756 | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
1757 | 146 | <table> | 146 | <table> |
1759 | 147 | <tr> | 147 | <tr> |
1760 | 148 | <td><label for="file">Image File<span class="required">*</span></label></td> | 148 | <td><label for="file">Image File<span class="required">*</span></label></td> |
1761 | 149 | <td colspan="3"> | 149 | <td colspan="3"> |
1762 | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
1763 | @@ -172,11 +172,11 @@ | |||
1764 | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
1765 | 173 | <td> | 173 | <td> |
1766 | 174 | $shared_list | 174 | $shared_list |
1768 | 175 | </td> | 175 | </td> |
1769 | 176 | </tr> | 176 | </tr> |
1770 | 177 | <tr> | 177 | <tr> |
1771 | 178 | <td></td> | 178 | <td></td> |
1773 | 179 | <td>This form accepts: <span class="required">jpg, jpeg, png and gif</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> | 179 | <td>This form accepts: <span class="required">$this->validExtensionsText</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> |
1774 | 180 | </tr> | 180 | </tr> |
1775 | 181 | <tr> | 181 | <tr> |
1776 | 182 | <td></td> | 182 | <td></td> |
1777 | @@ -194,49 +194,49 @@ | |||
1778 | 194 | 194 | ||
1779 | 195 | return $this->response; | 195 | return $this->response; |
1780 | 196 | } | 196 | } |
1782 | 197 | 197 | ||
1783 | 198 | /** | 198 | /** |
1784 | 199 | * Return the Edit Form as HTML | 199 | * Return the Edit Form as HTML |
1786 | 200 | * @return | 200 | * @return |
1787 | 201 | */ | 201 | */ |
1788 | 202 | public function EditForm() | 202 | public function EditForm() |
1789 | 203 | { | 203 | { |
1790 | 204 | global $session; | 204 | global $session; |
1791 | 205 | $db =& $this->db; | 205 | $db =& $this->db; |
1792 | 206 | $user =& $this->user; | 206 | $user =& $this->user; |
1795 | 207 | 207 | ||
1796 | 208 | // Would like to get the regions width / height | 208 | // Would like to get the regions width / height |
1797 | 209 | $layoutid = $this->layoutid; | 209 | $layoutid = $this->layoutid; |
1798 | 210 | $regionid = $this->regionid; | 210 | $regionid = $this->regionid; |
1799 | 211 | $mediaid = $this->mediaid; | 211 | $mediaid = $this->mediaid; |
1800 | 212 | $lkid = $this->lkid; | 212 | $lkid = $this->lkid; |
1801 | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1803 | 214 | 214 | ||
1804 | 215 | // Set the Session / Security information | 215 | // Set the Session / Security information |
1805 | 216 | $sessionId = session_id(); | 216 | $sessionId = session_id(); |
1806 | 217 | $securityToken = CreateFormToken(); | 217 | $securityToken = CreateFormToken(); |
1808 | 218 | 218 | ||
1809 | 219 | $session->setSecurityToken($securityToken); | 219 | $session->setSecurityToken($securityToken); |
1811 | 220 | 220 | ||
1812 | 221 | // Load what we know about this media into the object | 221 | // Load what we know about this media into the object |
1813 | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
1815 | 223 | 223 | ||
1816 | 224 | if (!$result = $db->query($SQL)) | 224 | if (!$result = $db->query($SQL)) |
1817 | 225 | { | 225 | { |
1818 | 226 | trigger_error($db->error()); //log the error | 226 | trigger_error($db->error()); //log the error |
1820 | 227 | 227 | ||
1821 | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
1822 | 229 | return false; | 229 | return false; |
1823 | 230 | } | 230 | } |
1825 | 231 | 231 | ||
1826 | 232 | if ($db->num_rows($result) != 1) | 232 | if ($db->num_rows($result) != 1) |
1827 | 233 | { | 233 | { |
1828 | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
1830 | 235 | 235 | ||
1831 | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
1832 | 237 | return false; | 237 | return false; |
1833 | 238 | } | 238 | } |
1835 | 239 | 239 | ||
1836 | 240 | $row = $db->get_row($result); | 240 | $row = $db->get_row($result); |
1837 | 241 | $name = $row[0]; | 241 | $name = $row[0]; |
1838 | 242 | $originalFilename = $row[1]; | 242 | $originalFilename = $row[1]; |
1839 | @@ -246,23 +246,23 @@ | |||
1840 | 246 | $storedAs = $row[5]; | 246 | $storedAs = $row[5]; |
1841 | 247 | $isEdited = $row[6]; | 247 | $isEdited = $row[6]; |
1842 | 248 | $editedMediaID = $row[7]; | 248 | $editedMediaID = $row[7]; |
1844 | 249 | 249 | ||
1845 | 250 | // derive the ext | 250 | // derive the ext |
1846 | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
1848 | 252 | 252 | ||
1849 | 253 | //Calc the permissions on it aswell | 253 | //Calc the permissions on it aswell |
1850 | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
1852 | 255 | 255 | ||
1853 | 256 | //shared list | 256 | //shared list |
1854 | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
1856 | 258 | 258 | ||
1857 | 259 | //Save button is different depending on if we are on a region or not | 259 | //Save button is different depending on if we are on a region or not |
1858 | 260 | if ($regionid != "") | 260 | if ($regionid != "") |
1859 | 261 | { | 261 | { |
1860 | 262 | setSession('content','mediatype','image'); | 262 | setSession('content','mediatype','image'); |
1862 | 263 | 263 | ||
1863 | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
1865 | 265 | 265 | ||
1866 | 266 | $save_button = <<<END | 266 | $save_button = <<<END |
1867 | 267 | <input id="btnSave" type="submit" value="Save" /> | 267 | <input id="btnSave" type="submit" value="Save" /> |
1868 | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
1869 | @@ -272,13 +272,13 @@ | |||
1870 | 272 | else | 272 | else |
1871 | 273 | { | 273 | { |
1872 | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; |
1874 | 275 | 275 | ||
1875 | 276 | $save_button = <<<END | 276 | $save_button = <<<END |
1876 | 277 | <input id="btnSave" type="submit" value="Save" /> | 277 | <input id="btnSave" type="submit" value="Save" /> |
1877 | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> |
1878 | 279 | END; | 279 | END; |
1879 | 280 | } | 280 | } |
1881 | 281 | 281 | ||
1882 | 282 | $form = <<<FORM | 282 | $form = <<<FORM |
1883 | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
1884 | 284 | <div> | 284 | <div> |
1885 | @@ -287,7 +287,7 @@ | |||
1886 | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
1887 | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
1888 | 289 | <table> | 289 | <table> |
1890 | 290 | <tr> | 290 | <tr> |
1891 | 291 | <td><label for="file">New Image File<span class="required">*</span></label></td> | 291 | <td><label for="file">New Image File<span class="required">*</span></label></td> |
1892 | 292 | <td colspan="3"> | 292 | <td colspan="3"> |
1893 | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
1894 | @@ -319,11 +319,11 @@ | |||
1895 | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
1896 | 320 | <td> | 320 | <td> |
1897 | 321 | $shared_list | 321 | $shared_list |
1899 | 322 | </td> | 322 | </td> |
1900 | 323 | </tr> | 323 | </tr> |
1901 | 324 | <tr> | 324 | <tr> |
1902 | 325 | <td></td> | 325 | <td></td> |
1904 | 326 | <td>This form accepts: <span class="required">jpg, jpeg, png and gif</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> | 326 | <td>This form accepts: <span class="required">$this->validExtensionsText</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> |
1905 | 327 | </tr> | 327 | </tr> |
1906 | 328 | <tr> | 328 | <tr> |
1907 | 329 | <td></td> | 329 | <td></td> |
1908 | @@ -343,50 +343,50 @@ | |||
1909 | 343 | $this->response->dialogWidth = '450px'; | 343 | $this->response->dialogWidth = '450px'; |
1910 | 344 | $this->response->dialogHeight = '280px'; | 344 | $this->response->dialogHeight = '280px'; |
1911 | 345 | 345 | ||
1913 | 346 | return $this->response; | 346 | return $this->response; |
1914 | 347 | } | 347 | } |
1916 | 348 | 348 | ||
1917 | 349 | /** | 349 | /** |
1918 | 350 | * Return the Delete Form as HTML | 350 | * Return the Delete Form as HTML |
1920 | 351 | * @return | 351 | * @return |
1921 | 352 | */ | 352 | */ |
1922 | 353 | public function DeleteForm() | 353 | public function DeleteForm() |
1923 | 354 | { | 354 | { |
1924 | 355 | $db =& $this->db; | 355 | $db =& $this->db; |
1925 | 356 | $user =& $this->user; | 356 | $user =& $this->user; |
1928 | 357 | 357 | ||
1929 | 358 | // Would like to get the regions width / height | 358 | // Would like to get the regions width / height |
1930 | 359 | $layoutid = $this->layoutid; | 359 | $layoutid = $this->layoutid; |
1931 | 360 | $regionid = $this->regionid; | 360 | $regionid = $this->regionid; |
1932 | 361 | $mediaid = $this->mediaid; | 361 | $mediaid = $this->mediaid; |
1933 | 362 | $lkid = $this->lkid; | 362 | $lkid = $this->lkid; |
1934 | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1936 | 364 | 364 | ||
1937 | 365 | $options = ""; | 365 | $options = ""; |
1938 | 366 | //Always have the abilty to unassign from the region | 366 | //Always have the abilty to unassign from the region |
1939 | 367 | $options .= "unassign|Unassign from this region only"; | 367 | $options .= "unassign|Unassign from this region only"; |
1941 | 368 | 368 | ||
1942 | 369 | // Load what we know about this media into the object | 369 | // Load what we know about this media into the object |
1943 | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
1945 | 371 | 371 | ||
1946 | 372 | if (!$result = $db->query($SQL)) | 372 | if (!$result = $db->query($SQL)) |
1947 | 373 | { | 373 | { |
1948 | 374 | trigger_error($db->error()); //log the error | 374 | trigger_error($db->error()); //log the error |
1950 | 375 | 375 | ||
1951 | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
1952 | 377 | $this->response->keepOpen = true; | 377 | $this->response->keepOpen = true; |
1953 | 378 | return $this->response; | 378 | return $this->response; |
1954 | 379 | } | 379 | } |
1956 | 380 | 380 | ||
1957 | 381 | if ($db->num_rows($result) != 1) | 381 | if ($db->num_rows($result) != 1) |
1958 | 382 | { | 382 | { |
1959 | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
1961 | 384 | 384 | ||
1962 | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
1963 | 386 | $this->response->keepOpen = true; | 386 | $this->response->keepOpen = true; |
1964 | 387 | return $this->response; | 387 | return $this->response; |
1965 | 388 | } | 388 | } |
1967 | 389 | 389 | ||
1968 | 390 | $row = $db->get_row($result); | 390 | $row = $db->get_row($result); |
1969 | 391 | $name = $row[0]; | 391 | $name = $row[0]; |
1970 | 392 | $duration = $row[2]; | 392 | $duration = $row[2]; |
1971 | @@ -397,18 +397,18 @@ | |||
1972 | 397 | $storedAs = $row[7]; | 397 | $storedAs = $row[7]; |
1973 | 398 | $isEdited = $row[8]; | 398 | $isEdited = $row[8]; |
1974 | 399 | $editedMediaID = $row[9]; | 399 | $editedMediaID = $row[9]; |
1976 | 400 | 400 | ||
1977 | 401 | // derive the ext | 401 | // derive the ext |
1978 | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
1980 | 403 | 403 | ||
1981 | 404 | //Calc the permissions on it aswell | 404 | //Calc the permissions on it aswell |
1982 | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
1984 | 406 | 406 | ||
1985 | 407 | //Is this user allowed to edit this media? | 407 | //Is this user allowed to edit this media? |
1986 | 408 | if ($edit_permissions) | 408 | if ($edit_permissions) |
1987 | 409 | { | 409 | { |
1988 | 410 | $options .= ",retire|Unassign from this region and retire"; | 410 | $options .= ",retire|Unassign from this region and retire"; |
1990 | 411 | 411 | ||
1991 | 412 | //Is this media retired? | 412 | //Is this media retired? |
1992 | 413 | if ($editedMediaID != "") | 413 | if ($editedMediaID != "") |
1993 | 414 | { | 414 | { |
1994 | @@ -418,7 +418,7 @@ | |||
1995 | 418 | { | 418 | { |
1996 | 419 | $revised = false; | 419 | $revised = false; |
1997 | 420 | } | 420 | } |
1999 | 421 | 421 | ||
2000 | 422 | //Is this media being used anywhere else? | 422 | //Is this media being used anywhere else? |
2001 | 423 | if ($layoutid == "") | 423 | if ($layoutid == "") |
2002 | 424 | { | 424 | { |
2003 | @@ -429,8 +429,8 @@ | |||
2004 | 429 | { | 429 | { |
2005 | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; |
2006 | 431 | } | 431 | } |
2009 | 432 | 432 | ||
2010 | 433 | if (!$results = $db->query($SQL)) | 433 | if (!$results = $db->query($SQL)) |
2011 | 434 | { | 434 | { |
2012 | 435 | trigger_error($db->error()); | 435 | trigger_error($db->error()); |
2013 | 436 | 436 | ||
2014 | @@ -457,9 +457,9 @@ | |||
2015 | 457 | return $this->response; | 457 | return $this->response; |
2016 | 458 | } | 458 | } |
2017 | 459 | } | 459 | } |
2019 | 460 | 460 | ||
2020 | 461 | $options = ltrim($options, ","); | 461 | $options = ltrim($options, ","); |
2022 | 462 | 462 | ||
2023 | 463 | $deleteOptions = listcontent($options,"options"); | 463 | $deleteOptions = listcontent($options,"options"); |
2024 | 464 | 464 | ||
2025 | 465 | //we can delete | 465 | //we can delete |
2026 | @@ -474,19 +474,19 @@ | |||
2027 | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> |
2028 | 475 | </form> | 475 | </form> |
2029 | 476 | END; | 476 | END; |
2031 | 477 | 477 | ||
2032 | 478 | $this->response->html = $form; | 478 | $this->response->html = $form; |
2033 | 479 | $this->response->dialogTitle = 'Delete Image'; | 479 | $this->response->dialogTitle = 'Delete Image'; |
2034 | 480 | $this->response->dialogSize = true; | 480 | $this->response->dialogSize = true; |
2035 | 481 | $this->response->dialogWidth = '450px'; | 481 | $this->response->dialogWidth = '450px'; |
2036 | 482 | $this->response->dialogHeight = '280px'; | 482 | $this->response->dialogHeight = '280px'; |
2037 | 483 | 483 | ||
2039 | 484 | return $this->response; | 484 | return $this->response; |
2040 | 485 | } | 485 | } |
2042 | 486 | 486 | ||
2043 | 487 | /** | 487 | /** |
2044 | 488 | * Add Media to the Database | 488 | * Add Media to the Database |
2046 | 489 | * @return | 489 | * @return |
2047 | 490 | */ | 490 | */ |
2048 | 491 | public function AddMedia() | 491 | public function AddMedia() |
2049 | 492 | { | 492 | { |
2050 | @@ -495,62 +495,62 @@ | |||
2051 | 495 | $regionid = $this->regionid; | 495 | $regionid = $this->regionid; |
2052 | 496 | $mediaid = $this->mediaid; | 496 | $mediaid = $this->mediaid; |
2053 | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2055 | 498 | 498 | ||
2056 | 499 | // File data | 499 | // File data |
2057 | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
2059 | 501 | 501 | ||
2060 | 502 | if ($tmpName == '') | 502 | if ($tmpName == '') |
2061 | 503 | { | 503 | { |
2062 | 504 | $this->response->SetError('Cannot save Image details. <br/> You must have picked a file.'); | 504 | $this->response->SetError('Cannot save Image details. <br/> You must have picked a file.'); |
2063 | 505 | $this->response->keepOpen = true; | 505 | $this->response->keepOpen = true; |
2064 | 506 | return $this->response; | 506 | return $this->response; |
2065 | 507 | } | 507 | } |
2067 | 508 | 508 | ||
2068 | 509 | // File name and extension (orignial name) | 509 | // File name and extension (orignial name) |
2069 | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
2070 | 511 | $fileName = basename($fileName); | 511 | $fileName = basename($fileName); |
2071 | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
2073 | 513 | 513 | ||
2074 | 514 | // Other properties | 514 | // Other properties |
2075 | 515 | $name = Kit::GetParam('name', _POST, _STRING); | 515 | $name = Kit::GetParam('name', _POST, _STRING); |
2076 | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
2077 | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
2079 | 518 | 518 | ||
2080 | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); |
2082 | 520 | 520 | ||
2083 | 521 | // Validation | 521 | // Validation |
2085 | 522 | if ($ext != "jpeg" && $ext != "jpg" && $ext != "png" && $ext != "gif") | 522 | if (!$this->IsValidExtension($ext)) |
2086 | 523 | { | 523 | { |
2088 | 524 | $this->response->SetError('Only images are accepted - Are you sure this is an image?'); | 524 | $this->response->SetError('Your file has an extension not supported by Media Type.'); |
2089 | 525 | $this->response->keepOpen = true; | 525 | $this->response->keepOpen = true; |
2090 | 526 | return $this->response; | 526 | return $this->response; |
2091 | 527 | } | 527 | } |
2093 | 528 | 528 | ||
2094 | 529 | // Make sure the name isnt too long | 529 | // Make sure the name isnt too long |
2096 | 530 | if (strlen($name) > 100) | 530 | if (strlen($name) > 100) |
2097 | 531 | { | 531 | { |
2098 | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); |
2099 | 533 | $this->response->keepOpen = true; | 533 | $this->response->keepOpen = true; |
2100 | 534 | return $this->response; | 534 | return $this->response; |
2101 | 535 | } | 535 | } |
2103 | 536 | 536 | ||
2104 | 537 | if ($duration == 0) | 537 | if ($duration == 0) |
2105 | 538 | { | 538 | { |
2106 | 539 | $this->response->SetError('You must enter a duration.'); | 539 | $this->response->SetError('You must enter a duration.'); |
2107 | 540 | $this->response->keepOpen = true; | 540 | $this->response->keepOpen = true; |
2108 | 541 | return $this->response; | 541 | return $this->response; |
2109 | 542 | } | 542 | } |
2111 | 543 | 543 | ||
2112 | 544 | // Ensure the name is not already in the database | 544 | // Ensure the name is not already in the database |
2113 | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); |
2114 | 546 | 546 | ||
2116 | 547 | if(!$result = $db->query($SQL)) | 547 | if(!$result = $db->query($SQL)) |
2117 | 548 | { | 548 | { |
2118 | 549 | trigger_error($db->error()); | 549 | trigger_error($db->error()); |
2119 | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
2120 | 551 | $this->response->keepOpen = true; | 551 | $this->response->keepOpen = true; |
2121 | 552 | return $this->response; | 552 | return $this->response; |
2123 | 553 | } | 553 | } |
2124 | 554 | 554 | ||
2125 | 555 | if ($db->num_rows($result) != 0) | 555 | if ($db->num_rows($result) != 0) |
2126 | 556 | { | 556 | { |
2127 | @@ -558,11 +558,11 @@ | |||
2128 | 558 | $this->response->keepOpen = true; | 558 | $this->response->keepOpen = true; |
2129 | 559 | return $this->response; | 559 | return $this->response; |
2130 | 560 | } | 560 | } |
2132 | 561 | 561 | ||
2133 | 562 | // All OK to insert this record | 562 | // All OK to insert this record |
2134 | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
2135 | 564 | $SQL .= "VALUES ('%s', 'image', '%s', '%s', %d, %d, 0) "; | 564 | $SQL .= "VALUES ('%s', 'image', '%s', '%s', %d, %d, 0) "; |
2137 | 565 | 565 | ||
2138 | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
2139 | 567 | 567 | ||
2140 | 568 | if (!$mediaid = $db->insert_query($SQL)) | 568 | if (!$mediaid = $db->insert_query($SQL)) |
2141 | @@ -572,19 +572,19 @@ | |||
2142 | 572 | $this->response->keepOpen = true; | 572 | $this->response->keepOpen = true; |
2143 | 573 | return $this->response; | 573 | return $this->response; |
2144 | 574 | } | 574 | } |
2146 | 575 | 575 | ||
2147 | 576 | // File upload directory.. get this from the settings object | 576 | // File upload directory.. get this from the settings object |
2148 | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
2150 | 578 | 578 | ||
2151 | 579 | // What are we going to store this media as... | 579 | // What are we going to store this media as... |
2152 | 580 | $storedAs = $mediaid.".".$ext; | 580 | $storedAs = $mediaid.".".$ext; |
2154 | 581 | 581 | ||
2155 | 582 | // Now we need to move the file | 582 | // Now we need to move the file |
2156 | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) |
2157 | 584 | { | 584 | { |
2158 | 585 | // If we couldnt move it - we need to delete the media record we just added | 585 | // If we couldnt move it - we need to delete the media record we just added |
2159 | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); |
2161 | 587 | 587 | ||
2162 | 588 | if (!$db->query($SQL)) | 588 | if (!$db->query($SQL)) |
2163 | 589 | { | 589 | { |
2164 | 590 | trigger_error($db->error()); | 590 | trigger_error($db->error()); |
2165 | @@ -593,26 +593,26 @@ | |||
2166 | 593 | return $this->response; | 593 | return $this->response; |
2167 | 594 | } | 594 | } |
2168 | 595 | } | 595 | } |
2170 | 596 | 596 | ||
2171 | 597 | // Update the media record to include this information | 597 | // Update the media record to include this information |
2172 | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); |
2174 | 599 | 599 | ||
2175 | 600 | if (!$db->query($SQL)) | 600 | if (!$db->query($SQL)) |
2176 | 601 | { | 601 | { |
2177 | 602 | trigger_error($db->error()); | 602 | trigger_error($db->error()); |
2178 | 603 | return true; | 603 | return true; |
2179 | 604 | } | 604 | } |
2181 | 605 | 605 | ||
2182 | 606 | // Create the thumb nail | 606 | // Create the thumb nail |
2183 | 607 | ResizeImage($databaseDir.$storedAs, $databaseDir."tn_".$storedAs, 80, 80); | 607 | ResizeImage($databaseDir.$storedAs, $databaseDir."tn_".$storedAs, 80, 80); |
2185 | 608 | 608 | ||
2186 | 609 | // Required Attributes | 609 | // Required Attributes |
2187 | 610 | $this->mediaid = $mediaid; | 610 | $this->mediaid = $mediaid; |
2188 | 611 | $this->duration = $duration; | 611 | $this->duration = $duration; |
2190 | 612 | 612 | ||
2191 | 613 | // Any Options | 613 | // Any Options |
2192 | 614 | $this->SetOption('uri', $storedAs); | 614 | $this->SetOption('uri', $storedAs); |
2194 | 615 | 615 | ||
2195 | 616 | // Should have built the media object entirely by this time | 616 | // Should have built the media object entirely by this time |
2196 | 617 | if ($regionid != '') | 617 | if ($regionid != '') |
2197 | 618 | { | 618 | { |
2198 | @@ -622,18 +622,18 @@ | |||
2199 | 622 | } | 622 | } |
2200 | 623 | else | 623 | else |
2201 | 624 | { | 624 | { |
2203 | 625 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 625 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
2204 | 626 | } | 626 | } |
2206 | 627 | 627 | ||
2207 | 628 | // We want to load a new form | 628 | // We want to load a new form |
2208 | 629 | $this->response->loadForm = true; | 629 | $this->response->loadForm = true; |
2210 | 630 | 630 | ||
2211 | 631 | return $this->response; | 631 | return $this->response; |
2212 | 632 | } | 632 | } |
2214 | 633 | 633 | ||
2215 | 634 | /** | 634 | /** |
2216 | 635 | * Edit Media in the Database | 635 | * Edit Media in the Database |
2218 | 636 | * @return | 636 | * @return |
2219 | 637 | */ | 637 | */ |
2220 | 638 | public function EditMedia() | 638 | public function EditMedia() |
2221 | 639 | { | 639 | { |
2222 | @@ -642,13 +642,13 @@ | |||
2223 | 642 | $regionid = $this->regionid; | 642 | $regionid = $this->regionid; |
2224 | 643 | $mediaid = $this->mediaid; | 643 | $mediaid = $this->mediaid; |
2225 | 644 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 644 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2227 | 645 | 645 | ||
2228 | 646 | // Stored As from the XML | 646 | // Stored As from the XML |
2229 | 647 | $storedAs = $this->GetOption('uri'); | 647 | $storedAs = $this->GetOption('uri'); |
2231 | 648 | 648 | ||
2232 | 649 | // File data | 649 | // File data |
2233 | 650 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 650 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
2235 | 651 | 651 | ||
2236 | 652 | if ($tmpName == '') | 652 | if ($tmpName == '') |
2237 | 653 | { | 653 | { |
2238 | 654 | $fileRevision = false; | 654 | $fileRevision = false; |
2239 | @@ -656,30 +656,30 @@ | |||
2240 | 656 | else | 656 | else |
2241 | 657 | { | 657 | { |
2242 | 658 | $fileRevision = true; | 658 | $fileRevision = true; |
2244 | 659 | 659 | ||
2245 | 660 | // File name and extension (orignial name) | 660 | // File name and extension (orignial name) |
2246 | 661 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 661 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
2247 | 662 | $fileName = basename($fileName); | 662 | $fileName = basename($fileName); |
2248 | 663 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 663 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
2251 | 664 | 664 | ||
2252 | 665 | if ($ext != "jpeg" && $ext != "jpg" && $ext != "png" && $ext != "gif") | 665 | if (!$this->IsValidExtension($ext)) |
2253 | 666 | { | 666 | { |
2255 | 667 | $this->response->SetError('Only images are accepted - Are you sure this is an image?'); | 667 | $this->response->SetError('Your file has an extension not supported by this Media Type.'); |
2256 | 668 | $this->response->keepOpen = true; | 668 | $this->response->keepOpen = true; |
2257 | 669 | return $this->response; | 669 | return $this->response; |
2258 | 670 | } | 670 | } |
2259 | 671 | } | 671 | } |
2261 | 672 | 672 | ||
2262 | 673 | // Other properties | 673 | // Other properties |
2263 | 674 | $name = Kit::GetParam('name', _POST, _STRING); | 674 | $name = Kit::GetParam('name', _POST, _STRING); |
2264 | 675 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 675 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
2265 | 676 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 676 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
2267 | 677 | 677 | ||
2268 | 678 | if ($name == '') | 678 | if ($name == '') |
2269 | 679 | { | 679 | { |
2270 | 680 | if ($fileRevision) | 680 | if ($fileRevision) |
2271 | 681 | { | 681 | { |
2273 | 682 | $name = Kit::ValidateParam($fileName, _FILENAME); | 682 | $name = Kit::ValidateParam($fileName, _FILENAME); |
2274 | 683 | } | 683 | } |
2275 | 684 | else | 684 | else |
2276 | 685 | { | 685 | { |
2277 | @@ -687,33 +687,33 @@ | |||
2278 | 687 | $this->response->keepOpen = true; | 687 | $this->response->keepOpen = true; |
2279 | 688 | return $this->response; | 688 | return $this->response; |
2280 | 689 | } | 689 | } |
2283 | 690 | } | 690 | } |
2284 | 691 | 691 | ||
2285 | 692 | // Make sure the name isnt too long | 692 | // Make sure the name isnt too long |
2287 | 693 | if (strlen($name) > 100) | 693 | if (strlen($name) > 100) |
2288 | 694 | { | 694 | { |
2289 | 695 | $this->response->SetError('The name cannot be longer than 100 characters'); | 695 | $this->response->SetError('The name cannot be longer than 100 characters'); |
2290 | 696 | $this->response->keepOpen = true; | 696 | $this->response->keepOpen = true; |
2291 | 697 | return $this->response; | 697 | return $this->response; |
2292 | 698 | } | 698 | } |
2294 | 699 | 699 | ||
2295 | 700 | if ($duration == 0) | 700 | if ($duration == 0) |
2296 | 701 | { | 701 | { |
2297 | 702 | $this->response->SetError('You must enter a duration.'); | 702 | $this->response->SetError('You must enter a duration.'); |
2298 | 703 | $this->response->keepOpen = true; | 703 | $this->response->keepOpen = true; |
2299 | 704 | return $this->response; | 704 | return $this->response; |
2300 | 705 | } | 705 | } |
2302 | 706 | 706 | ||
2303 | 707 | // Ensure the name is not already in the database | 707 | // Ensure the name is not already in the database |
2304 | 708 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); | 708 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); |
2305 | 709 | 709 | ||
2307 | 710 | if(!$result = $db->query($SQL)) | 710 | if(!$result = $db->query($SQL)) |
2308 | 711 | { | 711 | { |
2309 | 712 | trigger_error($db->error()); | 712 | trigger_error($db->error()); |
2310 | 713 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 713 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
2311 | 714 | $this->response->keepOpen = true; | 714 | $this->response->keepOpen = true; |
2312 | 715 | return $this->response; | 715 | return $this->response; |
2314 | 716 | } | 716 | } |
2315 | 717 | 717 | ||
2316 | 718 | if ($db->num_rows($result) != 0) | 718 | if ($db->num_rows($result) != 0) |
2317 | 719 | { | 719 | { |
2318 | @@ -721,34 +721,34 @@ | |||
2319 | 721 | $this->response->keepOpen = true; | 721 | $this->response->keepOpen = true; |
2320 | 722 | return $this->response; | 722 | return $this->response; |
2321 | 723 | } | 723 | } |
2323 | 724 | 724 | ||
2324 | 725 | //Are we revising this media - or just plain editing | 725 | //Are we revising this media - or just plain editing |
2325 | 726 | if ($fileRevision) | 726 | if ($fileRevision) |
2326 | 727 | { | 727 | { |
2327 | 728 | // All OK to insert this record | 728 | // All OK to insert this record |
2328 | 729 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 729 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
2329 | 730 | $SQL .= "VALUES ('%s', 'image', '%s', '%s', %d, %d, 0) "; | 730 | $SQL .= "VALUES ('%s', 'image', '%s', '%s', %d, %d, 0) "; |
2331 | 731 | 731 | ||
2332 | 732 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 732 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
2334 | 733 | 733 | ||
2335 | 734 | if (!$new_mediaid = $db->insert_query($SQL)) | 734 | if (!$new_mediaid = $db->insert_query($SQL)) |
2336 | 735 | { | 735 | { |
2337 | 736 | trigger_error($db->error()); | 736 | trigger_error($db->error()); |
2338 | 737 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); | 737 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); |
2339 | 738 | } | 738 | } |
2341 | 739 | 739 | ||
2342 | 740 | //What are we going to store this media as... | 740 | //What are we going to store this media as... |
2343 | 741 | $storedAs = $new_mediaid.".".$ext; | 741 | $storedAs = $new_mediaid.".".$ext; |
2345 | 742 | 742 | ||
2346 | 743 | // File upload directory.. get this from the settings object | 743 | // File upload directory.. get this from the settings object |
2347 | 744 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 744 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
2349 | 745 | 745 | ||
2350 | 746 | //Now we need to move the file | 746 | //Now we need to move the file |
2351 | 747 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) | 747 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) |
2352 | 748 | { | 748 | { |
2353 | 749 | //If we couldnt move it - we need to delete the media record we just added | 749 | //If we couldnt move it - we need to delete the media record we just added |
2354 | 750 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; | 750 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; |
2356 | 751 | 751 | ||
2357 | 752 | if (!$db->insert_query($SQL)) | 752 | if (!$db->insert_query($SQL)) |
2358 | 753 | { | 753 | { |
2359 | 754 | $this->response->SetError('Error rolling back transcation.'); | 754 | $this->response->SetError('Error rolling back transcation.'); |
2360 | @@ -756,7 +756,7 @@ | |||
2361 | 756 | return $this->response; | 756 | return $this->response; |
2362 | 757 | } | 757 | } |
2363 | 758 | } | 758 | } |
2365 | 759 | 759 | ||
2366 | 760 | //Update the media record to include this information | 760 | //Update the media record to include this information |
2367 | 761 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; | 761 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; |
2368 | 762 | if (!$db->query($SQL)) | 762 | if (!$db->query($SQL)) |
2369 | @@ -766,20 +766,20 @@ | |||
2370 | 766 | $this->response->keepOpen = true; | 766 | $this->response->keepOpen = true; |
2371 | 767 | return $this->response; | 767 | return $this->response; |
2372 | 768 | } | 768 | } |
2374 | 769 | 769 | ||
2375 | 770 | //Thumb | 770 | //Thumb |
2376 | 771 | if ($ext == "jpeg" || $ext == "jpg" || $ext == "png") | 771 | if ($ext == "jpeg" || $ext == "jpg" || $ext == "png") |
2377 | 772 | { | 772 | { |
2378 | 773 | //Create the thumbnail | 773 | //Create the thumbnail |
2379 | 774 | ResizeImage($databaseDir.$storedAs, $databaseDir."tn_".$storedAs, 80, 80); | 774 | ResizeImage($databaseDir.$storedAs, $databaseDir."tn_".$storedAs, 80, 80); |
2380 | 775 | } | 775 | } |
2382 | 776 | 776 | ||
2383 | 777 | // Update the existing record with the new record's id | 777 | // Update the existing record with the new record's id |
2384 | 778 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; | 778 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; |
2385 | 779 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; | 779 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; |
2387 | 780 | 780 | ||
2388 | 781 | Debug::LogEntry($db, 'audit', $SQL); | 781 | Debug::LogEntry($db, 'audit', $SQL); |
2390 | 782 | 782 | ||
2391 | 783 | if (!$db->query($SQL)) | 783 | if (!$db->query($SQL)) |
2392 | 784 | { | 784 | { |
2393 | 785 | trigger_error($db->error()); | 785 | trigger_error($db->error()); |
2394 | @@ -793,54 +793,54 @@ | |||
2395 | 793 | { | 793 | { |
2396 | 794 | // Editing the existing record | 794 | // Editing the existing record |
2397 | 795 | $new_mediaid = $mediaid; | 795 | $new_mediaid = $mediaid; |
2399 | 796 | 796 | ||
2400 | 797 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; | 797 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; |
2401 | 798 | $SQL .= " WHERE mediaID = %d "; | 798 | $SQL .= " WHERE mediaID = %d "; |
2402 | 799 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); | 799 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); |
2404 | 800 | 800 | ||
2405 | 801 | Debug::LogEntry($db, 'audit', $SQL); | 801 | Debug::LogEntry($db, 'audit', $SQL); |
2407 | 802 | 802 | ||
2408 | 803 | if (!$db->query($SQL)) | 803 | if (!$db->query($SQL)) |
2409 | 804 | { | 804 | { |
2410 | 805 | trigger_error($db->error()); | 805 | trigger_error($db->error()); |
2412 | 806 | 806 | ||
2413 | 807 | $this->response->SetError('Database error editing this media record.'); | 807 | $this->response->SetError('Database error editing this media record.'); |
2414 | 808 | $this->response->keepOpen = true; | 808 | $this->response->keepOpen = true; |
2415 | 809 | return $this->response; | 809 | return $this->response; |
2416 | 810 | } | 810 | } |
2417 | 811 | } | 811 | } |
2419 | 812 | 812 | ||
2420 | 813 | // Required Attributes | 813 | // Required Attributes |
2421 | 814 | $this->mediaid = $new_mediaid; | 814 | $this->mediaid = $new_mediaid; |
2422 | 815 | $this->duration = $duration; | 815 | $this->duration = $duration; |
2424 | 816 | 816 | ||
2425 | 817 | // Any Options | 817 | // Any Options |
2426 | 818 | $this->SetOption('uri', $storedAs); | 818 | $this->SetOption('uri', $storedAs); |
2428 | 819 | 819 | ||
2429 | 820 | // Should have built the media object entirely by this time | 820 | // Should have built the media object entirely by this time |
2430 | 821 | if ($regionid != '') | 821 | if ($regionid != '') |
2431 | 822 | { | 822 | { |
2432 | 823 | // This saves the Media Object to the Region | 823 | // This saves the Media Object to the Region |
2433 | 824 | $this->UpdateRegion(); | 824 | $this->UpdateRegion(); |
2435 | 825 | 825 | ||
2436 | 826 | $this->response->loadForm = true; | 826 | $this->response->loadForm = true; |
2437 | 827 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; | 827 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; |
2438 | 828 | } | 828 | } |
2439 | 829 | else | 829 | else |
2440 | 830 | { | 830 | { |
2442 | 831 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 831 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
2443 | 832 | $this->response->message = 'Edited the Image.'; | 832 | $this->response->message = 'Edited the Image.'; |
2445 | 833 | 833 | ||
2446 | 834 | } | 834 | } |
2448 | 835 | 835 | ||
2449 | 836 | return $this->response; | 836 | return $this->response; |
2450 | 837 | } | 837 | } |
2452 | 838 | 838 | ||
2453 | 839 | /** | 839 | /** |
2454 | 840 | * Delete Media from the Database | 840 | * Delete Media from the Database |
2456 | 841 | * @return | 841 | * @return |
2457 | 842 | */ | 842 | */ |
2459 | 843 | public function DeleteMedia() | 843 | public function DeleteMedia() |
2460 | 844 | { | 844 | { |
2461 | 845 | $db =& $this->db; | 845 | $db =& $this->db; |
2462 | 846 | $layoutid = $this->layoutid; | 846 | $layoutid = $this->layoutid; |
2463 | @@ -848,10 +848,10 @@ | |||
2464 | 848 | $mediaid = $this->mediaid; | 848 | $mediaid = $this->mediaid; |
2465 | 849 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 849 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2466 | 850 | $options = Kit::GetParam('options', _POST, _WORD); | 850 | $options = Kit::GetParam('options', _POST, _WORD); |
2468 | 851 | 851 | ||
2469 | 852 | // Stored As from the XML | 852 | // Stored As from the XML |
2470 | 853 | $this->uri = $this->GetOption('uri'); | 853 | $this->uri = $this->GetOption('uri'); |
2472 | 854 | 854 | ||
2473 | 855 | // Do we need to remove this from a layout? | 855 | // Do we need to remove this from a layout? |
2474 | 856 | if ($layoutid != '') | 856 | if ($layoutid != '') |
2475 | 857 | { | 857 | { |
2476 | @@ -863,72 +863,72 @@ | |||
2477 | 863 | // Set this message now in preparation | 863 | // Set this message now in preparation |
2478 | 864 | $this->response->message = 'Deleted the Media.'; | 864 | $this->response->message = 'Deleted the Media.'; |
2479 | 865 | } | 865 | } |
2481 | 866 | 866 | ||
2482 | 867 | // If we are set to retire we retire | 867 | // If we are set to retire we retire |
2483 | 868 | if ($options == "retire") | 868 | if ($options == "retire") |
2484 | 869 | { | 869 | { |
2485 | 870 | //Update the media record to say it is retired | 870 | //Update the media record to say it is retired |
2486 | 871 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; | 871 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; |
2488 | 872 | 872 | ||
2489 | 873 | if (!$db->query($SQL)) | 873 | if (!$db->query($SQL)) |
2490 | 874 | { | 874 | { |
2491 | 875 | trigger_error($db->error()); | 875 | trigger_error($db->error()); |
2493 | 876 | 876 | ||
2494 | 877 | $this->response->SetError('Database error retiring this media record.'); | 877 | $this->response->SetError('Database error retiring this media record.'); |
2495 | 878 | $this->response->keepOpen = true; | 878 | $this->response->keepOpen = true; |
2496 | 879 | return $this->response; | 879 | return $this->response; |
2497 | 880 | } | 880 | } |
2498 | 881 | } | 881 | } |
2500 | 882 | 882 | ||
2501 | 883 | //If we are set to delete, we delete | 883 | //If we are set to delete, we delete |
2502 | 884 | if ($options == "delete") | 884 | if ($options == "delete") |
2503 | 885 | { | 885 | { |
2504 | 886 | //Update the media record to say it is retired | 886 | //Update the media record to say it is retired |
2505 | 887 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; | 887 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; |
2507 | 888 | 888 | ||
2508 | 889 | if (!$db->query($SQL)) | 889 | if (!$db->query($SQL)) |
2509 | 890 | { | 890 | { |
2510 | 891 | trigger_error($db->error()); | 891 | trigger_error($db->error()); |
2512 | 892 | 892 | ||
2513 | 893 | $this->response->SetError('Database error deleting this media record.'); | 893 | $this->response->SetError('Database error deleting this media record.'); |
2514 | 894 | $this->response->keepOpen = true; | 894 | $this->response->keepOpen = true; |
2515 | 895 | return $this->response; | 895 | return $this->response; |
2516 | 896 | } | 896 | } |
2518 | 897 | 897 | ||
2519 | 898 | $this->DeleteMediaFiles(); | 898 | $this->DeleteMediaFiles(); |
2520 | 899 | } | 899 | } |
2522 | 900 | 900 | ||
2523 | 901 | return $this->response; | 901 | return $this->response; |
2524 | 902 | } | 902 | } |
2526 | 903 | 903 | ||
2527 | 904 | /** | 904 | /** |
2528 | 905 | * Deletes the media files associated with this record | 905 | * Deletes the media files associated with this record |
2530 | 906 | * @return | 906 | * @return |
2531 | 907 | */ | 907 | */ |
2532 | 908 | private function DeleteMediaFiles() | 908 | private function DeleteMediaFiles() |
2533 | 909 | { | 909 | { |
2534 | 910 | $db =& $this->db; | 910 | $db =& $this->db; |
2536 | 911 | 911 | ||
2537 | 912 | //Library location | 912 | //Library location |
2538 | 913 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 913 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
2540 | 914 | 914 | ||
2541 | 915 | //3 things to check for.. | 915 | //3 things to check for.. |
2542 | 916 | //the actual file, the thumbnail, the background | 916 | //the actual file, the thumbnail, the background |
2543 | 917 | if (file_exists($databaseDir.$this->uri)) | 917 | if (file_exists($databaseDir.$this->uri)) |
2544 | 918 | { | 918 | { |
2545 | 919 | unlink($databaseDir.$this->uri); | 919 | unlink($databaseDir.$this->uri); |
2546 | 920 | } | 920 | } |
2548 | 921 | 921 | ||
2549 | 922 | if (file_exists($databaseDir."tn_".$this->uri)) | 922 | if (file_exists($databaseDir."tn_".$this->uri)) |
2550 | 923 | { | 923 | { |
2551 | 924 | unlink($databaseDir."tn_".$this->uri); | 924 | unlink($databaseDir."tn_".$this->uri); |
2552 | 925 | } | 925 | } |
2554 | 926 | 926 | ||
2555 | 927 | if (file_exists($databaseDir."bg_".$this->uri)) | 927 | if (file_exists($databaseDir."bg_".$this->uri)) |
2556 | 928 | { | 928 | { |
2557 | 929 | unlink($databaseDir."bg_".$this->uri); | 929 | unlink($databaseDir."bg_".$this->uri); |
2558 | 930 | } | 930 | } |
2560 | 931 | 931 | ||
2561 | 932 | return true; | 932 | return true; |
2562 | 933 | } | 933 | } |
2563 | 934 | } | 934 | } |
2564 | 935 | 935 | ||
2565 | === modified file 'server/modules/powerpoint.module.php' | |||
2566 | --- server/modules/powerpoint.module.php 2009-06-28 10:47:06 +0000 | |||
2567 | +++ server/modules/powerpoint.module.php 2009-10-01 21:40:25 +0000 | |||
2568 | @@ -8,7 +8,7 @@ | |||
2569 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
2570 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
2571 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
2573 | 11 | * any later version. | 11 | * any later version. |
2574 | 12 | * | 12 | * |
2575 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
2576 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2577 | @@ -17,31 +17,31 @@ | |||
2578 | 17 | * | 17 | * |
2579 | 18 | * You should have received a copy of the GNU Affero General Public License | 18 | * You should have received a copy of the GNU Affero General Public License |
2580 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
2582 | 20 | */ | 20 | */ |
2583 | 21 | class powerpoint extends Module | 21 | class powerpoint extends Module |
2584 | 22 | { | 22 | { |
2585 | 23 | // Custom Media information | 23 | // Custom Media information |
2586 | 24 | private $uri; | 24 | private $uri; |
2587 | 25 | private $maxFileSize; | 25 | private $maxFileSize; |
2588 | 26 | private $maxFileSizeBytes; | 26 | private $maxFileSizeBytes; |
2590 | 27 | 27 | ||
2591 | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
2592 | 29 | { | 29 | { |
2593 | 30 | // Must set the type of the class | 30 | // Must set the type of the class |
2594 | 31 | $this->type = 'powerpoint'; | 31 | $this->type = 'powerpoint'; |
2596 | 32 | 32 | ||
2597 | 33 | // Get the max upload size from PHP | 33 | // Get the max upload size from PHP |
2598 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); |
2599 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); |
2602 | 36 | 36 | ||
2603 | 37 | // Must call the parent class | 37 | // Must call the parent class |
2604 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); |
2605 | 39 | } | 39 | } |
2607 | 40 | 40 | ||
2608 | 41 | /** | 41 | /** |
2609 | 42 | * Sets the Layout and Region Information | 42 | * Sets the Layout and Region Information |
2610 | 43 | * it will then fill in any blanks it has about this media if it can | 43 | * it will then fill in any blanks it has about this media if it can |
2612 | 44 | * @return | 44 | * @return |
2613 | 45 | * @param $layoutid Object | 45 | * @param $layoutid Object |
2614 | 46 | * @param $regionid Object | 46 | * @param $regionid Object |
2615 | 47 | * @param $mediaid Object | 47 | * @param $mediaid Object |
2616 | @@ -53,75 +53,75 @@ | |||
2617 | 53 | $this->regionid = $regionid; | 53 | $this->regionid = $regionid; |
2618 | 54 | $mediaid = $this->mediaid; | 54 | $mediaid = $this->mediaid; |
2619 | 55 | $this->existingMedia = false; | 55 | $this->existingMedia = false; |
2621 | 56 | 56 | ||
2622 | 57 | if ($this->regionSpecific == 1) return; | 57 | if ($this->regionSpecific == 1) return; |
2624 | 58 | 58 | ||
2625 | 59 | // Load what we know about this media into the object | 59 | // Load what we know about this media into the object |
2626 | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
2628 | 61 | 61 | ||
2629 | 62 | if (!$result = $db->query($SQL)) | 62 | if (!$result = $db->query($SQL)) |
2630 | 63 | { | 63 | { |
2631 | 64 | trigger_error($db->error()); //log the error | 64 | trigger_error($db->error()); //log the error |
2632 | 65 | return false; | 65 | return false; |
2633 | 66 | } | 66 | } |
2635 | 67 | 67 | ||
2636 | 68 | if ($db->num_rows($result) != 1) | 68 | if ($db->num_rows($result) != 1) |
2637 | 69 | { | 69 | { |
2638 | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
2639 | 71 | return false; | 71 | return false; |
2640 | 72 | } | 72 | } |
2642 | 73 | 73 | ||
2643 | 74 | $row = $db->get_row($result); | 74 | $row = $db->get_row($result); |
2644 | 75 | $duration = $row[2]; | 75 | $duration = $row[2]; |
2645 | 76 | $storedAs = $row[7]; | 76 | $storedAs = $row[7]; |
2647 | 77 | 77 | ||
2648 | 78 | // Required Attributes | 78 | // Required Attributes |
2649 | 79 | $this->duration = $duration; | 79 | $this->duration = $duration; |
2651 | 80 | 80 | ||
2652 | 81 | // Any Options | 81 | // Any Options |
2653 | 82 | $this->SetOption('uri', $storedAs); | 82 | $this->SetOption('uri', $storedAs); |
2655 | 83 | 83 | ||
2656 | 84 | return true; | 84 | return true; |
2657 | 85 | } | 85 | } |
2659 | 86 | 86 | ||
2660 | 87 | /** | 87 | /** |
2661 | 88 | * Return the Add Form as HTML | 88 | * Return the Add Form as HTML |
2663 | 89 | * @return | 89 | * @return |
2664 | 90 | */ | 90 | */ |
2665 | 91 | public function AddForm() | 91 | public function AddForm() |
2666 | 92 | { | 92 | { |
2667 | 93 | global $session; | 93 | global $session; |
2668 | 94 | $db =& $this->db; | 94 | $db =& $this->db; |
2669 | 95 | $user =& $this->user; | 95 | $user =& $this->user; |
2672 | 96 | 96 | ||
2673 | 97 | // Would like to get the regions width / height | 97 | // Would like to get the regions width / height |
2674 | 98 | $layoutid = $this->layoutid; | 98 | $layoutid = $this->layoutid; |
2675 | 99 | $regionid = $this->regionid; | 99 | $regionid = $this->regionid; |
2677 | 100 | 100 | ||
2678 | 101 | // Set the Session / Security information | 101 | // Set the Session / Security information |
2679 | 102 | $sessionId = session_id(); | 102 | $sessionId = session_id(); |
2680 | 103 | $securityToken = CreateFormToken(); | 103 | $securityToken = CreateFormToken(); |
2682 | 104 | 104 | ||
2683 | 105 | $session->setSecurityToken($securityToken); | 105 | $session->setSecurityToken($securityToken); |
2685 | 106 | 106 | ||
2686 | 107 | //Get the default value for the shared list | 107 | //Get the default value for the shared list |
2687 | 108 | $default = Config::GetSetting($db,"defaultMedia"); | 108 | $default = Config::GetSetting($db,"defaultMedia"); |
2688 | 109 | 109 | ||
2689 | 110 | $permissionid = 0; | 110 | $permissionid = 0; |
2690 | 111 | 111 | ||
2692 | 112 | if($default=="private") | 112 | if($default=="private") |
2693 | 113 | { | 113 | { |
2694 | 114 | $permissionid = 1; | 114 | $permissionid = 1; |
2695 | 115 | } | 115 | } |
2697 | 116 | 116 | ||
2698 | 117 | //shared list | 117 | //shared list |
2699 | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
2701 | 119 | 119 | ||
2702 | 120 | //Save button is different depending on if we are on a region or not | 120 | //Save button is different depending on if we are on a region or not |
2703 | 121 | if ($regionid != "") | 121 | if ($regionid != "") |
2704 | 122 | { | 122 | { |
2705 | 123 | setSession('content','mediatype','powerpoint'); | 123 | setSession('content','mediatype','powerpoint'); |
2707 | 124 | 124 | ||
2708 | 125 | $save_button = <<<END | 125 | $save_button = <<<END |
2709 | 126 | <input id="btnSave" type="submit" value="Save" disabled /> | 126 | <input id="btnSave" type="submit" value="Save" disabled /> |
2710 | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
2711 | @@ -135,7 +135,7 @@ | |||
2712 | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> |
2713 | 136 | END; | 136 | END; |
2714 | 137 | } | 137 | } |
2716 | 138 | 138 | ||
2717 | 139 | $form = <<<FORM | 139 | $form = <<<FORM |
2718 | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
2719 | 141 | <div> | 141 | <div> |
2720 | @@ -144,7 +144,7 @@ | |||
2721 | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
2722 | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
2723 | 146 | <table> | 146 | <table> |
2725 | 147 | <tr> | 147 | <tr> |
2726 | 148 | <td><label for="file">Powerpoint File<span class="required">*</span></label></td> | 148 | <td><label for="file">Powerpoint File<span class="required">*</span></label></td> |
2727 | 149 | <td colspan="3"> | 149 | <td colspan="3"> |
2728 | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
2729 | @@ -172,11 +172,11 @@ | |||
2730 | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
2731 | 173 | <td> | 173 | <td> |
2732 | 174 | $shared_list | 174 | $shared_list |
2734 | 175 | </td> | 175 | </td> |
2735 | 176 | </tr> | 176 | </tr> |
2736 | 177 | <tr> | 177 | <tr> |
2737 | 178 | <td></td> | 178 | <td></td> |
2739 | 179 | <td>This form accepts: <span class="required">ppt/pps</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> | 179 | <td>This form accepts: <span class="required">$this->validExtensionsText</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> |
2740 | 180 | </tr> | 180 | </tr> |
2741 | 181 | <tr> | 181 | <tr> |
2742 | 182 | <td></td> | 182 | <td></td> |
2743 | @@ -194,49 +194,49 @@ | |||
2744 | 194 | 194 | ||
2745 | 195 | return $this->response; | 195 | return $this->response; |
2746 | 196 | } | 196 | } |
2748 | 197 | 197 | ||
2749 | 198 | /** | 198 | /** |
2750 | 199 | * Return the Edit Form as HTML | 199 | * Return the Edit Form as HTML |
2752 | 200 | * @return | 200 | * @return |
2753 | 201 | */ | 201 | */ |
2754 | 202 | public function EditForm() | 202 | public function EditForm() |
2755 | 203 | { | 203 | { |
2756 | 204 | global $session; | 204 | global $session; |
2757 | 205 | $db =& $this->db; | 205 | $db =& $this->db; |
2758 | 206 | $user =& $this->user; | 206 | $user =& $this->user; |
2761 | 207 | 207 | ||
2762 | 208 | // Would like to get the regions width / height | 208 | // Would like to get the regions width / height |
2763 | 209 | $layoutid = $this->layoutid; | 209 | $layoutid = $this->layoutid; |
2764 | 210 | $regionid = $this->regionid; | 210 | $regionid = $this->regionid; |
2765 | 211 | $mediaid = $this->mediaid; | 211 | $mediaid = $this->mediaid; |
2766 | 212 | $lkid = $this->lkid; | 212 | $lkid = $this->lkid; |
2767 | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2769 | 214 | 214 | ||
2770 | 215 | // Set the Session / Security information | 215 | // Set the Session / Security information |
2771 | 216 | $sessionId = session_id(); | 216 | $sessionId = session_id(); |
2772 | 217 | $securityToken = CreateFormToken(); | 217 | $securityToken = CreateFormToken(); |
2774 | 218 | 218 | ||
2775 | 219 | $session->setSecurityToken($securityToken); | 219 | $session->setSecurityToken($securityToken); |
2777 | 220 | 220 | ||
2778 | 221 | // Load what we know about this media into the object | 221 | // Load what we know about this media into the object |
2779 | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
2781 | 223 | 223 | ||
2782 | 224 | if (!$result = $db->query($SQL)) | 224 | if (!$result = $db->query($SQL)) |
2783 | 225 | { | 225 | { |
2784 | 226 | trigger_error($db->error()); //log the error | 226 | trigger_error($db->error()); //log the error |
2786 | 227 | 227 | ||
2787 | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
2788 | 229 | return false; | 229 | return false; |
2789 | 230 | } | 230 | } |
2791 | 231 | 231 | ||
2792 | 232 | if ($db->num_rows($result) != 1) | 232 | if ($db->num_rows($result) != 1) |
2793 | 233 | { | 233 | { |
2794 | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
2796 | 235 | 235 | ||
2797 | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
2798 | 237 | return false; | 237 | return false; |
2799 | 238 | } | 238 | } |
2801 | 239 | 239 | ||
2802 | 240 | $row = $db->get_row($result); | 240 | $row = $db->get_row($result); |
2803 | 241 | $name = $row[0]; | 241 | $name = $row[0]; |
2804 | 242 | $originalFilename = $row[1]; | 242 | $originalFilename = $row[1]; |
2805 | @@ -246,23 +246,23 @@ | |||
2806 | 246 | $storedAs = $row[5]; | 246 | $storedAs = $row[5]; |
2807 | 247 | $isEdited = $row[6]; | 247 | $isEdited = $row[6]; |
2808 | 248 | $editedMediaID = $row[7]; | 248 | $editedMediaID = $row[7]; |
2810 | 249 | 249 | ||
2811 | 250 | // derive the ext | 250 | // derive the ext |
2812 | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
2814 | 252 | 252 | ||
2815 | 253 | //Calc the permissions on it aswell | 253 | //Calc the permissions on it aswell |
2816 | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
2818 | 255 | 255 | ||
2819 | 256 | //shared list | 256 | //shared list |
2820 | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
2822 | 258 | 258 | ||
2823 | 259 | //Save button is different depending on if we are on a region or not | 259 | //Save button is different depending on if we are on a region or not |
2824 | 260 | if ($regionid != "") | 260 | if ($regionid != "") |
2825 | 261 | { | 261 | { |
2826 | 262 | setSession('content','mediatype','powerpoint'); | 262 | setSession('content','mediatype','powerpoint'); |
2828 | 263 | 263 | ||
2829 | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
2831 | 265 | 265 | ||
2832 | 266 | $save_button = <<<END | 266 | $save_button = <<<END |
2833 | 267 | <input id="btnSave" type="submit" value="Save" /> | 267 | <input id="btnSave" type="submit" value="Save" /> |
2834 | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
2835 | @@ -272,13 +272,13 @@ | |||
2836 | 272 | else | 272 | else |
2837 | 273 | { | 273 | { |
2838 | 274 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 274 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
2840 | 275 | 275 | ||
2841 | 276 | $save_button = <<<END | 276 | $save_button = <<<END |
2842 | 277 | <input id="btnSave" type="submit" value="Save" /> | 277 | <input id="btnSave" type="submit" value="Save" /> |
2843 | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> |
2844 | 279 | END; | 279 | END; |
2845 | 280 | } | 280 | } |
2847 | 281 | 281 | ||
2848 | 282 | $form = <<<FORM | 282 | $form = <<<FORM |
2849 | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
2850 | 284 | <div> | 284 | <div> |
2851 | @@ -287,7 +287,7 @@ | |||
2852 | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
2853 | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
2854 | 289 | <table> | 289 | <table> |
2856 | 290 | <tr> | 290 | <tr> |
2857 | 291 | <td><label for="file">New Powerpoint File<span class="required">*</span></label></td> | 291 | <td><label for="file">New Powerpoint File<span class="required">*</span></label></td> |
2858 | 292 | <td colspan="3"> | 292 | <td colspan="3"> |
2859 | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
2860 | @@ -319,11 +319,11 @@ | |||
2861 | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
2862 | 320 | <td> | 320 | <td> |
2863 | 321 | $shared_list | 321 | $shared_list |
2865 | 322 | </td> | 322 | </td> |
2866 | 323 | </tr> | 323 | </tr> |
2867 | 324 | <tr> | 324 | <tr> |
2868 | 325 | <td></td> | 325 | <td></td> |
2870 | 326 | <td>This form accepts: <span class="required">ppt/pps</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> | 326 | <td>This form accepts: <span class="required">$this->validExtensionsText</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> |
2871 | 327 | </tr> | 327 | </tr> |
2872 | 328 | <tr> | 328 | <tr> |
2873 | 329 | <td></td> | 329 | <td></td> |
2874 | @@ -343,50 +343,50 @@ | |||
2875 | 343 | $this->response->dialogWidth = '450px'; | 343 | $this->response->dialogWidth = '450px'; |
2876 | 344 | $this->response->dialogHeight = '280px'; | 344 | $this->response->dialogHeight = '280px'; |
2877 | 345 | 345 | ||
2879 | 346 | return $this->response; | 346 | return $this->response; |
2880 | 347 | } | 347 | } |
2882 | 348 | 348 | ||
2883 | 349 | /** | 349 | /** |
2884 | 350 | * Return the Delete Form as HTML | 350 | * Return the Delete Form as HTML |
2886 | 351 | * @return | 351 | * @return |
2887 | 352 | */ | 352 | */ |
2888 | 353 | public function DeleteForm() | 353 | public function DeleteForm() |
2889 | 354 | { | 354 | { |
2890 | 355 | $db =& $this->db; | 355 | $db =& $this->db; |
2891 | 356 | $user =& $this->user; | 356 | $user =& $this->user; |
2894 | 357 | 357 | ||
2895 | 358 | // Would like to get the regions width / height | 358 | // Would like to get the regions width / height |
2896 | 359 | $layoutid = $this->layoutid; | 359 | $layoutid = $this->layoutid; |
2897 | 360 | $regionid = $this->regionid; | 360 | $regionid = $this->regionid; |
2898 | 361 | $mediaid = $this->mediaid; | 361 | $mediaid = $this->mediaid; |
2899 | 362 | $lkid = $this->lkid; | 362 | $lkid = $this->lkid; |
2900 | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2902 | 364 | 364 | ||
2903 | 365 | $options = ""; | 365 | $options = ""; |
2904 | 366 | //Always have the abilty to unassign from the region | 366 | //Always have the abilty to unassign from the region |
2905 | 367 | $options .= "unassign|Unassign from this region only"; | 367 | $options .= "unassign|Unassign from this region only"; |
2907 | 368 | 368 | ||
2908 | 369 | // Load what we know about this media into the object | 369 | // Load what we know about this media into the object |
2909 | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
2911 | 371 | 371 | ||
2912 | 372 | if (!$result = $db->query($SQL)) | 372 | if (!$result = $db->query($SQL)) |
2913 | 373 | { | 373 | { |
2914 | 374 | trigger_error($db->error()); //log the error | 374 | trigger_error($db->error()); //log the error |
2916 | 375 | 375 | ||
2917 | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
2918 | 377 | $this->response->keepOpen = true; | 377 | $this->response->keepOpen = true; |
2919 | 378 | return $this->response; | 378 | return $this->response; |
2920 | 379 | } | 379 | } |
2922 | 380 | 380 | ||
2923 | 381 | if ($db->num_rows($result) != 1) | 381 | if ($db->num_rows($result) != 1) |
2924 | 382 | { | 382 | { |
2925 | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
2927 | 384 | 384 | ||
2928 | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
2929 | 386 | $this->response->keepOpen = true; | 386 | $this->response->keepOpen = true; |
2930 | 387 | return $this->response; | 387 | return $this->response; |
2931 | 388 | } | 388 | } |
2933 | 389 | 389 | ||
2934 | 390 | $row = $db->get_row($result); | 390 | $row = $db->get_row($result); |
2935 | 391 | $name = $row[0]; | 391 | $name = $row[0]; |
2936 | 392 | $duration = $row[2]; | 392 | $duration = $row[2]; |
2937 | @@ -397,18 +397,18 @@ | |||
2938 | 397 | $storedAs = $row[7]; | 397 | $storedAs = $row[7]; |
2939 | 398 | $isEdited = $row[8]; | 398 | $isEdited = $row[8]; |
2940 | 399 | $editedMediaID = $row[9]; | 399 | $editedMediaID = $row[9]; |
2942 | 400 | 400 | ||
2943 | 401 | // derive the ext | 401 | // derive the ext |
2944 | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
2946 | 403 | 403 | ||
2947 | 404 | //Calc the permissions on it aswell | 404 | //Calc the permissions on it aswell |
2948 | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
2950 | 406 | 406 | ||
2951 | 407 | //Is this user allowed to edit this media? | 407 | //Is this user allowed to edit this media? |
2952 | 408 | if ($edit_permissions) | 408 | if ($edit_permissions) |
2953 | 409 | { | 409 | { |
2954 | 410 | $options .= ",retire|Unassign from this region and retire"; | 410 | $options .= ",retire|Unassign from this region and retire"; |
2956 | 411 | 411 | ||
2957 | 412 | //Is this media retired? | 412 | //Is this media retired? |
2958 | 413 | if ($editedMediaID != "") | 413 | if ($editedMediaID != "") |
2959 | 414 | { | 414 | { |
2960 | @@ -418,7 +418,7 @@ | |||
2961 | 418 | { | 418 | { |
2962 | 419 | $revised = false; | 419 | $revised = false; |
2963 | 420 | } | 420 | } |
2965 | 421 | 421 | ||
2966 | 422 | //Is this media being used anywhere else? | 422 | //Is this media being used anywhere else? |
2967 | 423 | if ($layoutid == "") | 423 | if ($layoutid == "") |
2968 | 424 | { | 424 | { |
2969 | @@ -429,8 +429,8 @@ | |||
2970 | 429 | { | 429 | { |
2971 | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; |
2972 | 431 | } | 431 | } |
2975 | 432 | 432 | ||
2976 | 433 | if (!$results = $db->query($SQL)) | 433 | if (!$results = $db->query($SQL)) |
2977 | 434 | { | 434 | { |
2978 | 435 | trigger_error($db->error()); | 435 | trigger_error($db->error()); |
2979 | 436 | 436 | ||
2980 | @@ -457,9 +457,9 @@ | |||
2981 | 457 | return $this->response; | 457 | return $this->response; |
2982 | 458 | } | 458 | } |
2983 | 459 | } | 459 | } |
2985 | 460 | 460 | ||
2986 | 461 | $options = ltrim($options, ","); | 461 | $options = ltrim($options, ","); |
2988 | 462 | 462 | ||
2989 | 463 | $deleteOptions = listcontent($options,"options"); | 463 | $deleteOptions = listcontent($options,"options"); |
2990 | 464 | 464 | ||
2991 | 465 | //we can delete | 465 | //we can delete |
2992 | @@ -474,19 +474,19 @@ | |||
2993 | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> |
2994 | 475 | </form> | 475 | </form> |
2995 | 476 | END; | 476 | END; |
2997 | 477 | 477 | ||
2998 | 478 | $this->response->html = $form; | 478 | $this->response->html = $form; |
2999 | 479 | $this->response->dialogTitle = 'Delete Powerpoint'; | 479 | $this->response->dialogTitle = 'Delete Powerpoint'; |
3000 | 480 | $this->response->dialogSize = true; | 480 | $this->response->dialogSize = true; |
3001 | 481 | $this->response->dialogWidth = '450px'; | 481 | $this->response->dialogWidth = '450px'; |
3002 | 482 | $this->response->dialogHeight = '280px'; | 482 | $this->response->dialogHeight = '280px'; |
3003 | 483 | 483 | ||
3005 | 484 | return $this->response; | 484 | return $this->response; |
3006 | 485 | } | 485 | } |
3008 | 486 | 486 | ||
3009 | 487 | /** | 487 | /** |
3010 | 488 | * Add Media to the Database | 488 | * Add Media to the Database |
3012 | 489 | * @return | 489 | * @return |
3013 | 490 | */ | 490 | */ |
3014 | 491 | public function AddMedia() | 491 | public function AddMedia() |
3015 | 492 | { | 492 | { |
3016 | @@ -495,62 +495,62 @@ | |||
3017 | 495 | $regionid = $this->regionid; | 495 | $regionid = $this->regionid; |
3018 | 496 | $mediaid = $this->mediaid; | 496 | $mediaid = $this->mediaid; |
3019 | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3021 | 498 | 498 | ||
3022 | 499 | // File data | 499 | // File data |
3023 | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
3025 | 501 | 501 | ||
3026 | 502 | if ($tmpName == '') | 502 | if ($tmpName == '') |
3027 | 503 | { | 503 | { |
3028 | 504 | $this->response->SetError('Cannot save Powerpoint details. <br/> You must have picked a file.'); | 504 | $this->response->SetError('Cannot save Powerpoint details. <br/> You must have picked a file.'); |
3029 | 505 | $this->response->keepOpen = true; | 505 | $this->response->keepOpen = true; |
3030 | 506 | return $this->response; | 506 | return $this->response; |
3031 | 507 | } | 507 | } |
3033 | 508 | 508 | ||
3034 | 509 | // File name and extension (orignial name) | 509 | // File name and extension (orignial name) |
3035 | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
3036 | 511 | $fileName = basename($fileName); | 511 | $fileName = basename($fileName); |
3037 | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
3039 | 513 | 513 | ||
3040 | 514 | // Other properties | 514 | // Other properties |
3041 | 515 | $name = Kit::GetParam('name', _POST, _STRING); | 515 | $name = Kit::GetParam('name', _POST, _STRING); |
3042 | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
3043 | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
3045 | 518 | 518 | ||
3046 | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); |
3048 | 520 | 520 | ||
3049 | 521 | // Validation | 521 | // Validation |
3051 | 522 | if ($ext != "ppt") | 522 | if (!$this->IsValidExtension($ext)) |
3052 | 523 | { | 523 | { |
3054 | 524 | $this->response->SetError('Only PPT files are accepted - Are you sure this is an powerpoint?'); | 524 | $this->response->SetError('Your file has an extension not supported by this Media Type.'); |
3055 | 525 | $this->response->keepOpen = true; | 525 | $this->response->keepOpen = true; |
3056 | 526 | return $this->response; | 526 | return $this->response; |
3057 | 527 | } | 527 | } |
3059 | 528 | 528 | ||
3060 | 529 | // Make sure the name isnt too long | 529 | // Make sure the name isnt too long |
3062 | 530 | if (strlen($name) > 100) | 530 | if (strlen($name) > 100) |
3063 | 531 | { | 531 | { |
3064 | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); |
3065 | 533 | $this->response->keepOpen = true; | 533 | $this->response->keepOpen = true; |
3066 | 534 | return $this->response; | 534 | return $this->response; |
3067 | 535 | } | 535 | } |
3069 | 536 | 536 | ||
3070 | 537 | if ($duration == 0) | 537 | if ($duration == 0) |
3071 | 538 | { | 538 | { |
3072 | 539 | $this->response->SetError('You must enter a duration.'); | 539 | $this->response->SetError('You must enter a duration.'); |
3073 | 540 | $this->response->keepOpen = true; | 540 | $this->response->keepOpen = true; |
3074 | 541 | return $this->response; | 541 | return $this->response; |
3075 | 542 | } | 542 | } |
3077 | 543 | 543 | ||
3078 | 544 | // Ensure the name is not already in the database | 544 | // Ensure the name is not already in the database |
3079 | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); |
3080 | 546 | 546 | ||
3082 | 547 | if(!$result = $db->query($SQL)) | 547 | if(!$result = $db->query($SQL)) |
3083 | 548 | { | 548 | { |
3084 | 549 | trigger_error($db->error()); | 549 | trigger_error($db->error()); |
3085 | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
3086 | 551 | $this->response->keepOpen = true; | 551 | $this->response->keepOpen = true; |
3087 | 552 | return $this->response; | 552 | return $this->response; |
3089 | 553 | } | 553 | } |
3090 | 554 | 554 | ||
3091 | 555 | if ($db->num_rows($result) != 0) | 555 | if ($db->num_rows($result) != 0) |
3092 | 556 | { | 556 | { |
3093 | @@ -558,11 +558,11 @@ | |||
3094 | 558 | $this->response->keepOpen = true; | 558 | $this->response->keepOpen = true; |
3095 | 559 | return $this->response; | 559 | return $this->response; |
3096 | 560 | } | 560 | } |
3098 | 561 | 561 | ||
3099 | 562 | // All OK to insert this record | 562 | // All OK to insert this record |
3100 | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
3101 | 564 | $SQL .= "VALUES ('%s', 'powerpoint', '%s', '%s', %d, %d, 0) "; | 564 | $SQL .= "VALUES ('%s', 'powerpoint', '%s', '%s', %d, %d, 0) "; |
3103 | 565 | 565 | ||
3104 | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
3105 | 567 | 567 | ||
3106 | 568 | if (!$mediaid = $db->insert_query($SQL)) | 568 | if (!$mediaid = $db->insert_query($SQL)) |
3107 | @@ -572,19 +572,19 @@ | |||
3108 | 572 | $this->response->keepOpen = true; | 572 | $this->response->keepOpen = true; |
3109 | 573 | return $this->response; | 573 | return $this->response; |
3110 | 574 | } | 574 | } |
3112 | 575 | 575 | ||
3113 | 576 | // File upload directory.. get this from the settings object | 576 | // File upload directory.. get this from the settings object |
3114 | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
3116 | 578 | 578 | ||
3117 | 579 | // What are we going to store this media as... | 579 | // What are we going to store this media as... |
3118 | 580 | $storedAs = $mediaid.".".$ext; | 580 | $storedAs = $mediaid.".".$ext; |
3120 | 581 | 581 | ||
3121 | 582 | // Now we need to move the file | 582 | // Now we need to move the file |
3122 | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) |
3123 | 584 | { | 584 | { |
3124 | 585 | // If we couldnt move it - we need to delete the media record we just added | 585 | // If we couldnt move it - we need to delete the media record we just added |
3125 | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); |
3127 | 587 | 587 | ||
3128 | 588 | if (!$db->query($SQL)) | 588 | if (!$db->query($SQL)) |
3129 | 589 | { | 589 | { |
3130 | 590 | trigger_error($db->error()); | 590 | trigger_error($db->error()); |
3131 | @@ -593,23 +593,23 @@ | |||
3132 | 593 | return $this->response; | 593 | return $this->response; |
3133 | 594 | } | 594 | } |
3134 | 595 | } | 595 | } |
3136 | 596 | 596 | ||
3137 | 597 | // Update the media record to include this information | 597 | // Update the media record to include this information |
3138 | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); |
3140 | 599 | 599 | ||
3141 | 600 | if (!$db->query($SQL)) | 600 | if (!$db->query($SQL)) |
3142 | 601 | { | 601 | { |
3143 | 602 | trigger_error($db->error()); | 602 | trigger_error($db->error()); |
3144 | 603 | return true; | 603 | return true; |
3145 | 604 | } | 604 | } |
3147 | 605 | 605 | ||
3148 | 606 | // Required Attributes | 606 | // Required Attributes |
3149 | 607 | $this->mediaid = $mediaid; | 607 | $this->mediaid = $mediaid; |
3150 | 608 | $this->duration = $duration; | 608 | $this->duration = $duration; |
3152 | 609 | 609 | ||
3153 | 610 | // Any Options | 610 | // Any Options |
3154 | 611 | $this->SetOption('uri', $storedAs); | 611 | $this->SetOption('uri', $storedAs); |
3156 | 612 | 612 | ||
3157 | 613 | // Should have built the media object entirely by this time | 613 | // Should have built the media object entirely by this time |
3158 | 614 | if ($regionid != '') | 614 | if ($regionid != '') |
3159 | 615 | { | 615 | { |
3160 | @@ -619,18 +619,18 @@ | |||
3161 | 619 | } | 619 | } |
3162 | 620 | else | 620 | else |
3163 | 621 | { | 621 | { |
3165 | 622 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 622 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
3166 | 623 | } | 623 | } |
3168 | 624 | 624 | ||
3169 | 625 | // We want to load a new form | 625 | // We want to load a new form |
3170 | 626 | $this->response->loadForm = true; | 626 | $this->response->loadForm = true; |
3172 | 627 | 627 | ||
3173 | 628 | return $this->response; | 628 | return $this->response; |
3174 | 629 | } | 629 | } |
3176 | 630 | 630 | ||
3177 | 631 | /** | 631 | /** |
3178 | 632 | * Edit Media in the Database | 632 | * Edit Media in the Database |
3180 | 633 | * @return | 633 | * @return |
3181 | 634 | */ | 634 | */ |
3182 | 635 | public function EditMedia() | 635 | public function EditMedia() |
3183 | 636 | { | 636 | { |
3184 | @@ -639,13 +639,13 @@ | |||
3185 | 639 | $regionid = $this->regionid; | 639 | $regionid = $this->regionid; |
3186 | 640 | $mediaid = $this->mediaid; | 640 | $mediaid = $this->mediaid; |
3187 | 641 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 641 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3189 | 642 | 642 | ||
3190 | 643 | // Stored As from the XML | 643 | // Stored As from the XML |
3191 | 644 | $storedAs = $this->GetOption('uri'); | 644 | $storedAs = $this->GetOption('uri'); |
3193 | 645 | 645 | ||
3194 | 646 | // File data | 646 | // File data |
3195 | 647 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 647 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
3197 | 648 | 648 | ||
3198 | 649 | if ($tmpName == '') | 649 | if ($tmpName == '') |
3199 | 650 | { | 650 | { |
3200 | 651 | $fileRevision = false; | 651 | $fileRevision = false; |
3201 | @@ -653,30 +653,30 @@ | |||
3202 | 653 | else | 653 | else |
3203 | 654 | { | 654 | { |
3204 | 655 | $fileRevision = true; | 655 | $fileRevision = true; |
3206 | 656 | 656 | ||
3207 | 657 | // File name and extension (orignial name) | 657 | // File name and extension (orignial name) |
3208 | 658 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 658 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
3209 | 659 | $fileName = basename($fileName); | 659 | $fileName = basename($fileName); |
3210 | 660 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 660 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
3213 | 661 | 661 | ||
3214 | 662 | if ($ext != "ppt") | 662 | if (!$this->IsValidExtension($ext)) |
3215 | 663 | { | 663 | { |
3217 | 664 | $this->response->SetError('Only PPT files are accepted - Are you sure this is a powerpoint?'); | 664 | $this->response->SetError('Your file has an extension not supported by this Media Type.'); |
3218 | 665 | $this->response->keepOpen = true; | 665 | $this->response->keepOpen = true; |
3219 | 666 | return $this->response; | 666 | return $this->response; |
3220 | 667 | } | 667 | } |
3221 | 668 | } | 668 | } |
3223 | 669 | 669 | ||
3224 | 670 | // Other properties | 670 | // Other properties |
3225 | 671 | $name = Kit::GetParam('name', _POST, _STRING); | 671 | $name = Kit::GetParam('name', _POST, _STRING); |
3226 | 672 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 672 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
3227 | 673 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 673 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
3229 | 674 | 674 | ||
3230 | 675 | if ($name == '') | 675 | if ($name == '') |
3231 | 676 | { | 676 | { |
3232 | 677 | if ($fileRevision) | 677 | if ($fileRevision) |
3233 | 678 | { | 678 | { |
3235 | 679 | $name = Kit::ValidateParam($fileName, _FILENAME); | 679 | $name = Kit::ValidateParam($fileName, _FILENAME); |
3236 | 680 | } | 680 | } |
3237 | 681 | else | 681 | else |
3238 | 682 | { | 682 | { |
3239 | @@ -684,33 +684,33 @@ | |||
3240 | 684 | $this->response->keepOpen = true; | 684 | $this->response->keepOpen = true; |
3241 | 685 | return $this->response; | 685 | return $this->response; |
3242 | 686 | } | 686 | } |
3245 | 687 | } | 687 | } |
3246 | 688 | 688 | ||
3247 | 689 | // Make sure the name isnt too long | 689 | // Make sure the name isnt too long |
3249 | 690 | if (strlen($name) > 100) | 690 | if (strlen($name) > 100) |
3250 | 691 | { | 691 | { |
3251 | 692 | $this->response->SetError('The name cannot be longer than 100 characters'); | 692 | $this->response->SetError('The name cannot be longer than 100 characters'); |
3252 | 693 | $this->response->keepOpen = true; | 693 | $this->response->keepOpen = true; |
3253 | 694 | return $this->response; | 694 | return $this->response; |
3254 | 695 | } | 695 | } |
3256 | 696 | 696 | ||
3257 | 697 | if ($duration == 0) | 697 | if ($duration == 0) |
3258 | 698 | { | 698 | { |
3259 | 699 | $this->response->SetError('You must enter a duration.'); | 699 | $this->response->SetError('You must enter a duration.'); |
3260 | 700 | $this->response->keepOpen = true; | 700 | $this->response->keepOpen = true; |
3261 | 701 | return $this->response; | 701 | return $this->response; |
3262 | 702 | } | 702 | } |
3264 | 703 | 703 | ||
3265 | 704 | // Ensure the name is not already in the database | 704 | // Ensure the name is not already in the database |
3266 | 705 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); | 705 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); |
3267 | 706 | 706 | ||
3269 | 707 | if(!$result = $db->query($SQL)) | 707 | if(!$result = $db->query($SQL)) |
3270 | 708 | { | 708 | { |
3271 | 709 | trigger_error($db->error()); | 709 | trigger_error($db->error()); |
3272 | 710 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 710 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
3273 | 711 | $this->response->keepOpen = true; | 711 | $this->response->keepOpen = true; |
3274 | 712 | return $this->response; | 712 | return $this->response; |
3276 | 713 | } | 713 | } |
3277 | 714 | 714 | ||
3278 | 715 | if ($db->num_rows($result) != 0) | 715 | if ($db->num_rows($result) != 0) |
3279 | 716 | { | 716 | { |
3280 | @@ -718,34 +718,34 @@ | |||
3281 | 718 | $this->response->keepOpen = true; | 718 | $this->response->keepOpen = true; |
3282 | 719 | return $this->response; | 719 | return $this->response; |
3283 | 720 | } | 720 | } |
3285 | 721 | 721 | ||
3286 | 722 | //Are we revising this media - or just plain editing | 722 | //Are we revising this media - or just plain editing |
3287 | 723 | if ($fileRevision) | 723 | if ($fileRevision) |
3288 | 724 | { | 724 | { |
3289 | 725 | // All OK to insert this record | 725 | // All OK to insert this record |
3290 | 726 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 726 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
3291 | 727 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; | 727 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; |
3293 | 728 | 728 | ||
3294 | 729 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 729 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
3296 | 730 | 730 | ||
3297 | 731 | if (!$new_mediaid = $db->insert_query($SQL)) | 731 | if (!$new_mediaid = $db->insert_query($SQL)) |
3298 | 732 | { | 732 | { |
3299 | 733 | trigger_error($db->error()); | 733 | trigger_error($db->error()); |
3300 | 734 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); | 734 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); |
3301 | 735 | } | 735 | } |
3303 | 736 | 736 | ||
3304 | 737 | //What are we going to store this media as... | 737 | //What are we going to store this media as... |
3305 | 738 | $storedAs = $new_mediaid.".".$ext; | 738 | $storedAs = $new_mediaid.".".$ext; |
3307 | 739 | 739 | ||
3308 | 740 | // File upload directory.. get this from the settings object | 740 | // File upload directory.. get this from the settings object |
3309 | 741 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 741 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
3311 | 742 | 742 | ||
3312 | 743 | //Now we need to move the file | 743 | //Now we need to move the file |
3313 | 744 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) | 744 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) |
3314 | 745 | { | 745 | { |
3315 | 746 | //If we couldnt move it - we need to delete the media record we just added | 746 | //If we couldnt move it - we need to delete the media record we just added |
3316 | 747 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; | 747 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; |
3318 | 748 | 748 | ||
3319 | 749 | if (!$db->insert_query($SQL)) | 749 | if (!$db->insert_query($SQL)) |
3320 | 750 | { | 750 | { |
3321 | 751 | $this->response->SetError('Error rolling back transcation.'); | 751 | $this->response->SetError('Error rolling back transcation.'); |
3322 | @@ -753,7 +753,7 @@ | |||
3323 | 753 | return $this->response; | 753 | return $this->response; |
3324 | 754 | } | 754 | } |
3325 | 755 | } | 755 | } |
3327 | 756 | 756 | ||
3328 | 757 | //Update the media record to include this information | 757 | //Update the media record to include this information |
3329 | 758 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; | 758 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; |
3330 | 759 | if (!$db->query($SQL)) | 759 | if (!$db->query($SQL)) |
3331 | @@ -763,13 +763,13 @@ | |||
3332 | 763 | $this->response->keepOpen = true; | 763 | $this->response->keepOpen = true; |
3333 | 764 | return $this->response; | 764 | return $this->response; |
3334 | 765 | } | 765 | } |
3336 | 766 | 766 | ||
3337 | 767 | // Update the existing record with the new record's id | 767 | // Update the existing record with the new record's id |
3338 | 768 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; | 768 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; |
3339 | 769 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; | 769 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; |
3341 | 770 | 770 | ||
3342 | 771 | Debug::LogEntry($db, 'audit', $SQL); | 771 | Debug::LogEntry($db, 'audit', $SQL); |
3344 | 772 | 772 | ||
3345 | 773 | if (!$db->query($SQL)) | 773 | if (!$db->query($SQL)) |
3346 | 774 | { | 774 | { |
3347 | 775 | trigger_error($db->error()); | 775 | trigger_error($db->error()); |
3348 | @@ -783,54 +783,54 @@ | |||
3349 | 783 | { | 783 | { |
3350 | 784 | // Editing the existing record | 784 | // Editing the existing record |
3351 | 785 | $new_mediaid = $mediaid; | 785 | $new_mediaid = $mediaid; |
3353 | 786 | 786 | ||
3354 | 787 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; | 787 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; |
3355 | 788 | $SQL .= " WHERE mediaID = %d "; | 788 | $SQL .= " WHERE mediaID = %d "; |
3356 | 789 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); | 789 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); |
3358 | 790 | 790 | ||
3359 | 791 | Debug::LogEntry($db, 'audit', $SQL); | 791 | Debug::LogEntry($db, 'audit', $SQL); |
3361 | 792 | 792 | ||
3362 | 793 | if (!$db->query($SQL)) | 793 | if (!$db->query($SQL)) |
3363 | 794 | { | 794 | { |
3364 | 795 | trigger_error($db->error()); | 795 | trigger_error($db->error()); |
3366 | 796 | 796 | ||
3367 | 797 | $this->response->SetError('Database error editing this media record.'); | 797 | $this->response->SetError('Database error editing this media record.'); |
3368 | 798 | $this->response->keepOpen = true; | 798 | $this->response->keepOpen = true; |
3369 | 799 | return $this->response; | 799 | return $this->response; |
3370 | 800 | } | 800 | } |
3371 | 801 | } | 801 | } |
3373 | 802 | 802 | ||
3374 | 803 | // Required Attributes | 803 | // Required Attributes |
3375 | 804 | $this->mediaid = $new_mediaid; | 804 | $this->mediaid = $new_mediaid; |
3376 | 805 | $this->duration = $duration; | 805 | $this->duration = $duration; |
3378 | 806 | 806 | ||
3379 | 807 | // Any Options | 807 | // Any Options |
3380 | 808 | $this->SetOption('uri', $storedAs); | 808 | $this->SetOption('uri', $storedAs); |
3382 | 809 | 809 | ||
3383 | 810 | // Should have built the media object entirely by this time | 810 | // Should have built the media object entirely by this time |
3384 | 811 | if ($regionid != '') | 811 | if ($regionid != '') |
3385 | 812 | { | 812 | { |
3386 | 813 | // This saves the Media Object to the Region | 813 | // This saves the Media Object to the Region |
3387 | 814 | $this->UpdateRegion(); | 814 | $this->UpdateRegion(); |
3389 | 815 | 815 | ||
3390 | 816 | $this->response->loadForm = true; | 816 | $this->response->loadForm = true; |
3391 | 817 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; | 817 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; |
3392 | 818 | } | 818 | } |
3393 | 819 | else | 819 | else |
3394 | 820 | { | 820 | { |
3396 | 821 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 821 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
3397 | 822 | $this->response->message = 'Edited the Powerpoint.'; | 822 | $this->response->message = 'Edited the Powerpoint.'; |
3399 | 823 | 823 | ||
3400 | 824 | } | 824 | } |
3402 | 825 | 825 | ||
3403 | 826 | return $this->response; | 826 | return $this->response; |
3404 | 827 | } | 827 | } |
3406 | 828 | 828 | ||
3407 | 829 | /** | 829 | /** |
3408 | 830 | * Delete Media from the Database | 830 | * Delete Media from the Database |
3410 | 831 | * @return | 831 | * @return |
3411 | 832 | */ | 832 | */ |
3413 | 833 | public function DeleteMedia() | 833 | public function DeleteMedia() |
3414 | 834 | { | 834 | { |
3415 | 835 | $db =& $this->db; | 835 | $db =& $this->db; |
3416 | 836 | $layoutid = $this->layoutid; | 836 | $layoutid = $this->layoutid; |
3417 | @@ -838,10 +838,10 @@ | |||
3418 | 838 | $mediaid = $this->mediaid; | 838 | $mediaid = $this->mediaid; |
3419 | 839 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 839 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3420 | 840 | $options = Kit::GetParam('options', _POST, _WORD); | 840 | $options = Kit::GetParam('options', _POST, _WORD); |
3422 | 841 | 841 | ||
3423 | 842 | // Stored As from the XML | 842 | // Stored As from the XML |
3424 | 843 | $this->uri = $this->GetOption('uri'); | 843 | $this->uri = $this->GetOption('uri'); |
3426 | 844 | 844 | ||
3427 | 845 | // Do we need to remove this from a layout? | 845 | // Do we need to remove this from a layout? |
3428 | 846 | if ($layoutid != '') | 846 | if ($layoutid != '') |
3429 | 847 | { | 847 | { |
3430 | @@ -853,72 +853,72 @@ | |||
3431 | 853 | // Set this message now in preparation | 853 | // Set this message now in preparation |
3432 | 854 | $this->response->message = 'Deleted the Media.'; | 854 | $this->response->message = 'Deleted the Media.'; |
3433 | 855 | } | 855 | } |
3435 | 856 | 856 | ||
3436 | 857 | // If we are set to retire we retire | 857 | // If we are set to retire we retire |
3437 | 858 | if ($options == "retire") | 858 | if ($options == "retire") |
3438 | 859 | { | 859 | { |
3439 | 860 | //Update the media record to say it is retired | 860 | //Update the media record to say it is retired |
3440 | 861 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; | 861 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; |
3442 | 862 | 862 | ||
3443 | 863 | if (!$db->query($SQL)) | 863 | if (!$db->query($SQL)) |
3444 | 864 | { | 864 | { |
3445 | 865 | trigger_error($db->error()); | 865 | trigger_error($db->error()); |
3447 | 866 | 866 | ||
3448 | 867 | $this->response->SetError('Database error retiring this media record.'); | 867 | $this->response->SetError('Database error retiring this media record.'); |
3449 | 868 | $this->response->keepOpen = true; | 868 | $this->response->keepOpen = true; |
3450 | 869 | return $this->response; | 869 | return $this->response; |
3451 | 870 | } | 870 | } |
3452 | 871 | } | 871 | } |
3454 | 872 | 872 | ||
3455 | 873 | //If we are set to delete, we delete | 873 | //If we are set to delete, we delete |
3456 | 874 | if ($options == "delete") | 874 | if ($options == "delete") |
3457 | 875 | { | 875 | { |
3458 | 876 | //Update the media record to say it is retired | 876 | //Update the media record to say it is retired |
3459 | 877 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; | 877 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; |
3461 | 878 | 878 | ||
3462 | 879 | if (!$db->query($SQL)) | 879 | if (!$db->query($SQL)) |
3463 | 880 | { | 880 | { |
3464 | 881 | trigger_error($db->error()); | 881 | trigger_error($db->error()); |
3466 | 882 | 882 | ||
3467 | 883 | $this->response->SetError('Database error deleting this media record.'); | 883 | $this->response->SetError('Database error deleting this media record.'); |
3468 | 884 | $this->response->keepOpen = true; | 884 | $this->response->keepOpen = true; |
3469 | 885 | return $this->response; | 885 | return $this->response; |
3470 | 886 | } | 886 | } |
3472 | 887 | 887 | ||
3473 | 888 | $this->DeleteMediaFiles(); | 888 | $this->DeleteMediaFiles(); |
3474 | 889 | } | 889 | } |
3476 | 890 | 890 | ||
3477 | 891 | return $this->response; | 891 | return $this->response; |
3478 | 892 | } | 892 | } |
3480 | 893 | 893 | ||
3481 | 894 | /** | 894 | /** |
3482 | 895 | * Deletes the media files associated with this record | 895 | * Deletes the media files associated with this record |
3484 | 896 | * @return | 896 | * @return |
3485 | 897 | */ | 897 | */ |
3486 | 898 | private function DeleteMediaFiles() | 898 | private function DeleteMediaFiles() |
3487 | 899 | { | 899 | { |
3488 | 900 | $db =& $this->db; | 900 | $db =& $this->db; |
3490 | 901 | 901 | ||
3491 | 902 | //Library location | 902 | //Library location |
3492 | 903 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 903 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
3494 | 904 | 904 | ||
3495 | 905 | //3 things to check for.. | 905 | //3 things to check for.. |
3496 | 906 | //the actual file, the thumbnail, the background | 906 | //the actual file, the thumbnail, the background |
3497 | 907 | if (file_exists($databaseDir.$this->uri)) | 907 | if (file_exists($databaseDir.$this->uri)) |
3498 | 908 | { | 908 | { |
3499 | 909 | unlink($databaseDir.$this->uri); | 909 | unlink($databaseDir.$this->uri); |
3500 | 910 | } | 910 | } |
3502 | 911 | 911 | ||
3503 | 912 | if (file_exists($databaseDir."tn_".$this->uri)) | 912 | if (file_exists($databaseDir."tn_".$this->uri)) |
3504 | 913 | { | 913 | { |
3505 | 914 | unlink($databaseDir."tn_".$this->uri); | 914 | unlink($databaseDir."tn_".$this->uri); |
3506 | 915 | } | 915 | } |
3508 | 916 | 916 | ||
3509 | 917 | if (file_exists($databaseDir."bg_".$this->uri)) | 917 | if (file_exists($databaseDir."bg_".$this->uri)) |
3510 | 918 | { | 918 | { |
3511 | 919 | unlink($databaseDir."bg_".$this->uri); | 919 | unlink($databaseDir."bg_".$this->uri); |
3512 | 920 | } | 920 | } |
3514 | 921 | 921 | ||
3515 | 922 | return true; | 922 | return true; |
3516 | 923 | } | 923 | } |
3517 | 924 | } | 924 | } |
3518 | 925 | 925 | ||
3519 | === modified file 'server/modules/video.module.php' | |||
3520 | --- server/modules/video.module.php 2009-06-28 10:47:06 +0000 | |||
3521 | +++ server/modules/video.module.php 2009-10-01 21:40:25 +0000 | |||
3522 | @@ -8,7 +8,7 @@ | |||
3523 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
3524 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
3525 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
3527 | 11 | * any later version. | 11 | * any later version. |
3528 | 12 | * | 12 | * |
3529 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
3530 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3531 | @@ -17,31 +17,31 @@ | |||
3532 | 17 | * | 17 | * |
3533 | 18 | * You should have received a copy of the GNU Affero General Public License | 18 | * You should have received a copy of the GNU Affero General Public License |
3534 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
3536 | 20 | */ | 20 | */ |
3537 | 21 | class video extends Module | 21 | class video extends Module |
3538 | 22 | { | 22 | { |
3539 | 23 | // Custom Media information | 23 | // Custom Media information |
3540 | 24 | private $uri; | 24 | private $uri; |
3541 | 25 | private $maxFileSize; | 25 | private $maxFileSize; |
3542 | 26 | private $maxFileSizeBytes; | 26 | private $maxFileSizeBytes; |
3544 | 27 | 27 | ||
3545 | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
3546 | 29 | { | 29 | { |
3547 | 30 | // Must set the type of the class | 30 | // Must set the type of the class |
3548 | 31 | $this->type = 'video'; | 31 | $this->type = 'video'; |
3550 | 32 | 32 | ||
3551 | 33 | // Get the max upload size from PHP | 33 | // Get the max upload size from PHP |
3552 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); |
3553 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); |
3556 | 36 | 36 | ||
3557 | 37 | // Must call the parent class | 37 | // Must call the parent class |
3558 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); |
3559 | 39 | } | 39 | } |
3561 | 40 | 40 | ||
3562 | 41 | /** | 41 | /** |
3563 | 42 | * Sets the Layout and Region Information | 42 | * Sets the Layout and Region Information |
3564 | 43 | * it will then fill in any blanks it has about this media if it can | 43 | * it will then fill in any blanks it has about this media if it can |
3566 | 44 | * @return | 44 | * @return |
3567 | 45 | * @param $layoutid Object | 45 | * @param $layoutid Object |
3568 | 46 | * @param $regionid Object | 46 | * @param $regionid Object |
3569 | 47 | * @param $mediaid Object | 47 | * @param $mediaid Object |
3570 | @@ -53,75 +53,75 @@ | |||
3571 | 53 | $this->regionid = $regionid; | 53 | $this->regionid = $regionid; |
3572 | 54 | $mediaid = $this->mediaid; | 54 | $mediaid = $this->mediaid; |
3573 | 55 | $this->existingMedia = false; | 55 | $this->existingMedia = false; |
3575 | 56 | 56 | ||
3576 | 57 | if ($this->regionSpecific == 1) return; | 57 | if ($this->regionSpecific == 1) return; |
3578 | 58 | 58 | ||
3579 | 59 | // Load what we know about this media into the object | 59 | // Load what we know about this media into the object |
3580 | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
3582 | 61 | 61 | ||
3583 | 62 | if (!$result = $db->query($SQL)) | 62 | if (!$result = $db->query($SQL)) |
3584 | 63 | { | 63 | { |
3585 | 64 | trigger_error($db->error()); //log the error | 64 | trigger_error($db->error()); //log the error |
3586 | 65 | return false; | 65 | return false; |
3587 | 66 | } | 66 | } |
3589 | 67 | 67 | ||
3590 | 68 | if ($db->num_rows($result) != 1) | 68 | if ($db->num_rows($result) != 1) |
3591 | 69 | { | 69 | { |
3592 | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
3593 | 71 | return false; | 71 | return false; |
3594 | 72 | } | 72 | } |
3596 | 73 | 73 | ||
3597 | 74 | $row = $db->get_row($result); | 74 | $row = $db->get_row($result); |
3598 | 75 | $duration = $row[2]; | 75 | $duration = $row[2]; |
3599 | 76 | $storedAs = $row[7]; | 76 | $storedAs = $row[7]; |
3601 | 77 | 77 | ||
3602 | 78 | // Required Attributes | 78 | // Required Attributes |
3603 | 79 | $this->duration = $duration; | 79 | $this->duration = $duration; |
3605 | 80 | 80 | ||
3606 | 81 | // Any Options | 81 | // Any Options |
3607 | 82 | $this->SetOption('uri', $storedAs); | 82 | $this->SetOption('uri', $storedAs); |
3609 | 83 | 83 | ||
3610 | 84 | return true; | 84 | return true; |
3611 | 85 | } | 85 | } |
3613 | 86 | 86 | ||
3614 | 87 | /** | 87 | /** |
3615 | 88 | * Return the Add Form as HTML | 88 | * Return the Add Form as HTML |
3617 | 89 | * @return | 89 | * @return |
3618 | 90 | */ | 90 | */ |
3619 | 91 | public function AddForm() | 91 | public function AddForm() |
3620 | 92 | { | 92 | { |
3621 | 93 | global $session; | 93 | global $session; |
3622 | 94 | $db =& $this->db; | 94 | $db =& $this->db; |
3623 | 95 | $user =& $this->user; | 95 | $user =& $this->user; |
3626 | 96 | 96 | ||
3627 | 97 | // Would like to get the regions width / height | 97 | // Would like to get the regions width / height |
3628 | 98 | $layoutid = $this->layoutid; | 98 | $layoutid = $this->layoutid; |
3629 | 99 | $regionid = $this->regionid; | 99 | $regionid = $this->regionid; |
3631 | 100 | 100 | ||
3632 | 101 | // Set the Session / Security information | 101 | // Set the Session / Security information |
3633 | 102 | $sessionId = session_id(); | 102 | $sessionId = session_id(); |
3634 | 103 | $securityToken = CreateFormToken(); | 103 | $securityToken = CreateFormToken(); |
3636 | 104 | 104 | ||
3637 | 105 | $session->setSecurityToken($securityToken); | 105 | $session->setSecurityToken($securityToken); |
3639 | 106 | 106 | ||
3640 | 107 | //Get the default value for the shared list | 107 | //Get the default value for the shared list |
3641 | 108 | $default = Config::GetSetting($db,"defaultMedia"); | 108 | $default = Config::GetSetting($db,"defaultMedia"); |
3642 | 109 | 109 | ||
3643 | 110 | $permissionid = 0; | 110 | $permissionid = 0; |
3644 | 111 | 111 | ||
3646 | 112 | if($default=="private") | 112 | if($default=="private") |
3647 | 113 | { | 113 | { |
3648 | 114 | $permissionid = 1; | 114 | $permissionid = 1; |
3649 | 115 | } | 115 | } |
3651 | 116 | 116 | ||
3652 | 117 | //shared list | 117 | //shared list |
3653 | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
3655 | 119 | 119 | ||
3656 | 120 | //Save button is different depending on if we are on a region or not | 120 | //Save button is different depending on if we are on a region or not |
3657 | 121 | if ($regionid != "") | 121 | if ($regionid != "") |
3658 | 122 | { | 122 | { |
3659 | 123 | setSession('content','mediatype','video'); | 123 | setSession('content','mediatype','video'); |
3661 | 124 | 124 | ||
3662 | 125 | $save_button = <<<END | 125 | $save_button = <<<END |
3663 | 126 | <input id="btnSave" type="submit" value="Save" disabled /> | 126 | <input id="btnSave" type="submit" value="Save" disabled /> |
3664 | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
3665 | @@ -135,7 +135,7 @@ | |||
3666 | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> |
3667 | 136 | END; | 136 | END; |
3668 | 137 | } | 137 | } |
3670 | 138 | 138 | ||
3671 | 139 | $form = <<<FORM | 139 | $form = <<<FORM |
3672 | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
3673 | 141 | <div> | 141 | <div> |
3674 | @@ -144,7 +144,7 @@ | |||
3675 | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
3676 | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
3677 | 146 | <table> | 146 | <table> |
3679 | 147 | <tr> | 147 | <tr> |
3680 | 148 | <td><label for="file">Video File<span class="required">*</span></label></td> | 148 | <td><label for="file">Video File<span class="required">*</span></label></td> |
3681 | 149 | <td colspan="3"> | 149 | <td colspan="3"> |
3682 | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
3683 | @@ -172,11 +172,11 @@ | |||
3684 | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
3685 | 173 | <td> | 173 | <td> |
3686 | 174 | $shared_list | 174 | $shared_list |
3688 | 175 | </td> | 175 | </td> |
3689 | 176 | </tr> | 176 | </tr> |
3690 | 177 | <tr> | 177 | <tr> |
3691 | 178 | <td></td> | 178 | <td></td> |
3693 | 179 | <td>This form accepts: <span class="required">wmv, mpeg and mpg</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> | 179 | <td>This form accepts: <span class="required">$this->validExtensionsText</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> |
3694 | 180 | </tr> | 180 | </tr> |
3695 | 181 | <tr> | 181 | <tr> |
3696 | 182 | <td></td> | 182 | <td></td> |
3697 | @@ -194,49 +194,49 @@ | |||
3698 | 194 | 194 | ||
3699 | 195 | return $this->response; | 195 | return $this->response; |
3700 | 196 | } | 196 | } |
3702 | 197 | 197 | ||
3703 | 198 | /** | 198 | /** |
3704 | 199 | * Return the Edit Form as HTML | 199 | * Return the Edit Form as HTML |
3706 | 200 | * @return | 200 | * @return |
3707 | 201 | */ | 201 | */ |
3708 | 202 | public function EditForm() | 202 | public function EditForm() |
3709 | 203 | { | 203 | { |
3710 | 204 | global $session; | 204 | global $session; |
3711 | 205 | $db =& $this->db; | 205 | $db =& $this->db; |
3712 | 206 | $user =& $this->user; | 206 | $user =& $this->user; |
3715 | 207 | 207 | ||
3716 | 208 | // Would like to get the regions width / height | 208 | // Would like to get the regions width / height |
3717 | 209 | $layoutid = $this->layoutid; | 209 | $layoutid = $this->layoutid; |
3718 | 210 | $regionid = $this->regionid; | 210 | $regionid = $this->regionid; |
3719 | 211 | $mediaid = $this->mediaid; | 211 | $mediaid = $this->mediaid; |
3720 | 212 | $lkid = $this->lkid; | 212 | $lkid = $this->lkid; |
3721 | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3723 | 214 | 214 | ||
3724 | 215 | // Set the Session / Security information | 215 | // Set the Session / Security information |
3725 | 216 | $sessionId = session_id(); | 216 | $sessionId = session_id(); |
3726 | 217 | $securityToken = CreateFormToken(); | 217 | $securityToken = CreateFormToken(); |
3728 | 218 | 218 | ||
3729 | 219 | $session->setSecurityToken($securityToken); | 219 | $session->setSecurityToken($securityToken); |
3731 | 220 | 220 | ||
3732 | 221 | // Load what we know about this media into the object | 221 | // Load what we know about this media into the object |
3733 | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
3735 | 223 | 223 | ||
3736 | 224 | if (!$result = $db->query($SQL)) | 224 | if (!$result = $db->query($SQL)) |
3737 | 225 | { | 225 | { |
3738 | 226 | trigger_error($db->error()); //log the error | 226 | trigger_error($db->error()); //log the error |
3740 | 227 | 227 | ||
3741 | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
3742 | 229 | return false; | 229 | return false; |
3743 | 230 | } | 230 | } |
3745 | 231 | 231 | ||
3746 | 232 | if ($db->num_rows($result) != 1) | 232 | if ($db->num_rows($result) != 1) |
3747 | 233 | { | 233 | { |
3748 | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
3750 | 235 | 235 | ||
3751 | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
3752 | 237 | return false; | 237 | return false; |
3753 | 238 | } | 238 | } |
3755 | 239 | 239 | ||
3756 | 240 | $row = $db->get_row($result); | 240 | $row = $db->get_row($result); |
3757 | 241 | $name = $row[0]; | 241 | $name = $row[0]; |
3758 | 242 | $originalFilename = $row[1]; | 242 | $originalFilename = $row[1]; |
3759 | @@ -246,23 +246,23 @@ | |||
3760 | 246 | $storedAs = $row[5]; | 246 | $storedAs = $row[5]; |
3761 | 247 | $isEdited = $row[6]; | 247 | $isEdited = $row[6]; |
3762 | 248 | $editedMediaID = $row[7]; | 248 | $editedMediaID = $row[7]; |
3764 | 249 | 249 | ||
3765 | 250 | // derive the ext | 250 | // derive the ext |
3766 | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
3768 | 252 | 252 | ||
3769 | 253 | //Calc the permissions on it aswell | 253 | //Calc the permissions on it aswell |
3770 | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
3772 | 255 | 255 | ||
3773 | 256 | //shared list | 256 | //shared list |
3774 | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
3776 | 258 | 258 | ||
3777 | 259 | //Save button is different depending on if we are on a region or not | 259 | //Save button is different depending on if we are on a region or not |
3778 | 260 | if ($regionid != "") | 260 | if ($regionid != "") |
3779 | 261 | { | 261 | { |
3780 | 262 | setSession('content','mediatype','image'); | 262 | setSession('content','mediatype','image'); |
3782 | 263 | 263 | ||
3783 | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
3785 | 265 | 265 | ||
3786 | 266 | $save_button = <<<END | 266 | $save_button = <<<END |
3787 | 267 | <input id="btnSave" type="submit" value="Save" /> | 267 | <input id="btnSave" type="submit" value="Save" /> |
3788 | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
3789 | @@ -272,13 +272,13 @@ | |||
3790 | 272 | else | 272 | else |
3791 | 273 | { | 273 | { |
3792 | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; |
3794 | 275 | 275 | ||
3795 | 276 | $save_button = <<<END | 276 | $save_button = <<<END |
3796 | 277 | <input id="btnSave" type="submit" value="Save" /> | 277 | <input id="btnSave" type="submit" value="Save" /> |
3797 | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> |
3798 | 279 | END; | 279 | END; |
3799 | 280 | } | 280 | } |
3801 | 281 | 281 | ||
3802 | 282 | $form = <<<FORM | 282 | $form = <<<FORM |
3803 | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
3804 | 284 | <div> | 284 | <div> |
3805 | @@ -287,7 +287,7 @@ | |||
3806 | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
3807 | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
3808 | 289 | <table> | 289 | <table> |
3810 | 290 | <tr> | 290 | <tr> |
3811 | 291 | <td><label for="file">New Video File<span class="required">*</span></label></td> | 291 | <td><label for="file">New Video File<span class="required">*</span></label></td> |
3812 | 292 | <td colspan="3"> | 292 | <td colspan="3"> |
3813 | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
3814 | @@ -319,11 +319,11 @@ | |||
3815 | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
3816 | 320 | <td> | 320 | <td> |
3817 | 321 | $shared_list | 321 | $shared_list |
3819 | 322 | </td> | 322 | </td> |
3820 | 323 | </tr> | 323 | </tr> |
3821 | 324 | <tr> | 324 | <tr> |
3822 | 325 | <td></td> | 325 | <td></td> |
3824 | 326 | <td>This form accepts: <span class="required">wmv, mpeg and mpg</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> | 326 | <td>This form accepts: <span class="required">$this->validExtensionsText</span> files up to a maximum size of <span class="required">$this->maxFileSize</span>.</td> |
3825 | 327 | </tr> | 327 | </tr> |
3826 | 328 | <tr> | 328 | <tr> |
3827 | 329 | <td></td> | 329 | <td></td> |
3828 | @@ -343,50 +343,50 @@ | |||
3829 | 343 | $this->response->dialogWidth = '450px'; | 343 | $this->response->dialogWidth = '450px'; |
3830 | 344 | $this->response->dialogHeight = '280px'; | 344 | $this->response->dialogHeight = '280px'; |
3831 | 345 | 345 | ||
3833 | 346 | return $this->response; | 346 | return $this->response; |
3834 | 347 | } | 347 | } |
3836 | 348 | 348 | ||
3837 | 349 | /** | 349 | /** |
3838 | 350 | * Return the Delete Form as HTML | 350 | * Return the Delete Form as HTML |
3840 | 351 | * @return | 351 | * @return |
3841 | 352 | */ | 352 | */ |
3842 | 353 | public function DeleteForm() | 353 | public function DeleteForm() |
3843 | 354 | { | 354 | { |
3844 | 355 | $db =& $this->db; | 355 | $db =& $this->db; |
3845 | 356 | $user =& $this->user; | 356 | $user =& $this->user; |
3848 | 357 | 357 | ||
3849 | 358 | // Would like to get the regions width / height | 358 | // Would like to get the regions width / height |
3850 | 359 | $layoutid = $this->layoutid; | 359 | $layoutid = $this->layoutid; |
3851 | 360 | $regionid = $this->regionid; | 360 | $regionid = $this->regionid; |
3852 | 361 | $mediaid = $this->mediaid; | 361 | $mediaid = $this->mediaid; |
3853 | 362 | $lkid = $this->lkid; | 362 | $lkid = $this->lkid; |
3854 | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3856 | 364 | 364 | ||
3857 | 365 | $options = ""; | 365 | $options = ""; |
3858 | 366 | //Always have the abilty to unassign from the region | 366 | //Always have the abilty to unassign from the region |
3859 | 367 | $options .= "unassign|Unassign from this region only"; | 367 | $options .= "unassign|Unassign from this region only"; |
3861 | 368 | 368 | ||
3862 | 369 | // Load what we know about this media into the object | 369 | // Load what we know about this media into the object |
3863 | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
3865 | 371 | 371 | ||
3866 | 372 | if (!$result = $db->query($SQL)) | 372 | if (!$result = $db->query($SQL)) |
3867 | 373 | { | 373 | { |
3868 | 374 | trigger_error($db->error()); //log the error | 374 | trigger_error($db->error()); //log the error |
3870 | 375 | 375 | ||
3871 | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
3872 | 377 | $this->response->keepOpen = true; | 377 | $this->response->keepOpen = true; |
3873 | 378 | return $this->response; | 378 | return $this->response; |
3874 | 379 | } | 379 | } |
3876 | 380 | 380 | ||
3877 | 381 | if ($db->num_rows($result) != 1) | 381 | if ($db->num_rows($result) != 1) |
3878 | 382 | { | 382 | { |
3879 | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
3881 | 384 | 384 | ||
3882 | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
3883 | 386 | $this->response->keepOpen = true; | 386 | $this->response->keepOpen = true; |
3884 | 387 | return $this->response; | 387 | return $this->response; |
3885 | 388 | } | 388 | } |
3887 | 389 | 389 | ||
3888 | 390 | $row = $db->get_row($result); | 390 | $row = $db->get_row($result); |
3889 | 391 | $name = $row[0]; | 391 | $name = $row[0]; |
3890 | 392 | $duration = $row[2]; | 392 | $duration = $row[2]; |
3891 | @@ -397,18 +397,18 @@ | |||
3892 | 397 | $storedAs = $row[7]; | 397 | $storedAs = $row[7]; |
3893 | 398 | $isEdited = $row[8]; | 398 | $isEdited = $row[8]; |
3894 | 399 | $editedMediaID = $row[9]; | 399 | $editedMediaID = $row[9]; |
3896 | 400 | 400 | ||
3897 | 401 | // derive the ext | 401 | // derive the ext |
3898 | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
3900 | 403 | 403 | ||
3901 | 404 | //Calc the permissions on it aswell | 404 | //Calc the permissions on it aswell |
3902 | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
3904 | 406 | 406 | ||
3905 | 407 | //Is this user allowed to edit this media? | 407 | //Is this user allowed to edit this media? |
3906 | 408 | if ($edit_permissions) | 408 | if ($edit_permissions) |
3907 | 409 | { | 409 | { |
3908 | 410 | $options .= ",retire|Unassign from this region and retire"; | 410 | $options .= ",retire|Unassign from this region and retire"; |
3910 | 411 | 411 | ||
3911 | 412 | //Is this media retired? | 412 | //Is this media retired? |
3912 | 413 | if ($editedMediaID != "") | 413 | if ($editedMediaID != "") |
3913 | 414 | { | 414 | { |
3914 | @@ -418,7 +418,7 @@ | |||
3915 | 418 | { | 418 | { |
3916 | 419 | $revised = false; | 419 | $revised = false; |
3917 | 420 | } | 420 | } |
3919 | 421 | 421 | ||
3920 | 422 | //Is this media being used anywhere else? | 422 | //Is this media being used anywhere else? |
3921 | 423 | if ($layoutid == "") | 423 | if ($layoutid == "") |
3922 | 424 | { | 424 | { |
3923 | @@ -429,8 +429,8 @@ | |||
3924 | 429 | { | 429 | { |
3925 | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; |
3926 | 431 | } | 431 | } |
3929 | 432 | 432 | ||
3930 | 433 | if (!$results = $db->query($SQL)) | 433 | if (!$results = $db->query($SQL)) |
3931 | 434 | { | 434 | { |
3932 | 435 | trigger_error($db->error()); | 435 | trigger_error($db->error()); |
3933 | 436 | 436 | ||
3934 | @@ -457,9 +457,9 @@ | |||
3935 | 457 | return $this->response; | 457 | return $this->response; |
3936 | 458 | } | 458 | } |
3937 | 459 | } | 459 | } |
3939 | 460 | 460 | ||
3940 | 461 | $options = ltrim($options, ","); | 461 | $options = ltrim($options, ","); |
3942 | 462 | 462 | ||
3943 | 463 | $deleteOptions = listcontent($options,"options"); | 463 | $deleteOptions = listcontent($options,"options"); |
3944 | 464 | 464 | ||
3945 | 465 | //we can delete | 465 | //we can delete |
3946 | @@ -474,19 +474,19 @@ | |||
3947 | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> |
3948 | 475 | </form> | 475 | </form> |
3949 | 476 | END; | 476 | END; |
3951 | 477 | 477 | ||
3952 | 478 | $this->response->html = $form; | 478 | $this->response->html = $form; |
3953 | 479 | $this->response->dialogTitle = 'Delete Video'; | 479 | $this->response->dialogTitle = 'Delete Video'; |
3954 | 480 | $this->response->dialogSize = true; | 480 | $this->response->dialogSize = true; |
3955 | 481 | $this->response->dialogWidth = '450px'; | 481 | $this->response->dialogWidth = '450px'; |
3956 | 482 | $this->response->dialogHeight = '280px'; | 482 | $this->response->dialogHeight = '280px'; |
3957 | 483 | 483 | ||
3959 | 484 | return $this->response; | 484 | return $this->response; |
3960 | 485 | } | 485 | } |
3962 | 486 | 486 | ||
3963 | 487 | /** | 487 | /** |
3964 | 488 | * Add Media to the Database | 488 | * Add Media to the Database |
3966 | 489 | * @return | 489 | * @return |
3967 | 490 | */ | 490 | */ |
3968 | 491 | public function AddMedia() | 491 | public function AddMedia() |
3969 | 492 | { | 492 | { |
3970 | @@ -495,55 +495,55 @@ | |||
3971 | 495 | $regionid = $this->regionid; | 495 | $regionid = $this->regionid; |
3972 | 496 | $mediaid = $this->mediaid; | 496 | $mediaid = $this->mediaid; |
3973 | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3975 | 498 | 498 | ||
3976 | 499 | // File data | 499 | // File data |
3977 | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
3979 | 501 | 501 | ||
3980 | 502 | if ($tmpName == '') | 502 | if ($tmpName == '') |
3981 | 503 | { | 503 | { |
3982 | 504 | $this->response->SetError('Cannot save Video details. <br/> You must have picked a file.'); | 504 | $this->response->SetError('Cannot save Video details. <br/> You must have picked a file.'); |
3983 | 505 | $this->response->keepOpen = true; | 505 | $this->response->keepOpen = true; |
3984 | 506 | return $this->response; | 506 | return $this->response; |
3985 | 507 | } | 507 | } |
3987 | 508 | 508 | ||
3988 | 509 | // File name and extension (orignial name) | 509 | // File name and extension (orignial name) |
3989 | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
3990 | 511 | $fileName = basename($fileName); | 511 | $fileName = basename($fileName); |
3991 | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
3993 | 513 | 513 | ||
3994 | 514 | // Other properties | 514 | // Other properties |
3995 | 515 | $name = Kit::GetParam('name', _POST, _STRING); | 515 | $name = Kit::GetParam('name', _POST, _STRING); |
3996 | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
3997 | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
3999 | 518 | 518 | ||
4000 | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); |
4002 | 520 | 520 | ||
4003 | 521 | // Validation | 521 | // Validation |
4005 | 522 | if ($ext != "wmv" && $ext != "mpeg" && $ext != "mpg") | 522 | if (!$this->IsValidExtension($ext)) |
4006 | 523 | { | 523 | { |
4008 | 524 | $this->response->SetError('Only Vidoes are accepted - wmv, mpeg, mpg [this is ' . $ext . ']'); | 524 | $this->response->SetError('Your file has an extension not supported by this Media Type.'); |
4009 | 525 | $this->response->keepOpen = true; | 525 | $this->response->keepOpen = true; |
4010 | 526 | return $this->response; | 526 | return $this->response; |
4011 | 527 | } | 527 | } |
4013 | 528 | 528 | ||
4014 | 529 | // Make sure the name isnt too long | 529 | // Make sure the name isnt too long |
4016 | 530 | if (strlen($name) > 100) | 530 | if (strlen($name) > 100) |
4017 | 531 | { | 531 | { |
4018 | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); |
4019 | 533 | $this->response->keepOpen = true; | 533 | $this->response->keepOpen = true; |
4020 | 534 | return $this->response; | 534 | return $this->response; |
4021 | 535 | } | 535 | } |
4023 | 536 | 536 | ||
4024 | 537 | // Ensure the name is not already in the database | 537 | // Ensure the name is not already in the database |
4025 | 538 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); | 538 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); |
4026 | 539 | 539 | ||
4028 | 540 | if(!$result = $db->query($SQL)) | 540 | if(!$result = $db->query($SQL)) |
4029 | 541 | { | 541 | { |
4030 | 542 | trigger_error($db->error()); | 542 | trigger_error($db->error()); |
4031 | 543 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 543 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
4032 | 544 | $this->response->keepOpen = true; | 544 | $this->response->keepOpen = true; |
4033 | 545 | return $this->response; | 545 | return $this->response; |
4035 | 546 | } | 546 | } |
4036 | 547 | 547 | ||
4037 | 548 | if ($db->num_rows($result) != 0) | 548 | if ($db->num_rows($result) != 0) |
4038 | 549 | { | 549 | { |
4039 | @@ -551,11 +551,11 @@ | |||
4040 | 551 | $this->response->keepOpen = true; | 551 | $this->response->keepOpen = true; |
4041 | 552 | return $this->response; | 552 | return $this->response; |
4042 | 553 | } | 553 | } |
4044 | 554 | 554 | ||
4045 | 555 | // All OK to insert this record | 555 | // All OK to insert this record |
4046 | 556 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 556 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
4047 | 557 | $SQL .= "VALUES ('%s', 'video', '%s', '%s', %d, %d, 0) "; | 557 | $SQL .= "VALUES ('%s', 'video', '%s', '%s', %d, %d, 0) "; |
4049 | 558 | 558 | ||
4050 | 559 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 559 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
4051 | 560 | 560 | ||
4052 | 561 | if (!$mediaid = $db->insert_query($SQL)) | 561 | if (!$mediaid = $db->insert_query($SQL)) |
4053 | @@ -565,19 +565,19 @@ | |||
4054 | 565 | $this->response->keepOpen = true; | 565 | $this->response->keepOpen = true; |
4055 | 566 | return $this->response; | 566 | return $this->response; |
4056 | 567 | } | 567 | } |
4058 | 568 | 568 | ||
4059 | 569 | // File upload directory.. get this from the settings object | 569 | // File upload directory.. get this from the settings object |
4060 | 570 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 570 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
4062 | 571 | 571 | ||
4063 | 572 | // What are we going to store this media as... | 572 | // What are we going to store this media as... |
4064 | 573 | $storedAs = $mediaid.".".$ext; | 573 | $storedAs = $mediaid.".".$ext; |
4066 | 574 | 574 | ||
4067 | 575 | // Now we need to move the file | 575 | // Now we need to move the file |
4068 | 576 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) | 576 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) |
4069 | 577 | { | 577 | { |
4070 | 578 | // If we couldnt move it - we need to delete the media record we just added | 578 | // If we couldnt move it - we need to delete the media record we just added |
4071 | 579 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); | 579 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); |
4073 | 580 | 580 | ||
4074 | 581 | if (!$db->query($SQL)) | 581 | if (!$db->query($SQL)) |
4075 | 582 | { | 582 | { |
4076 | 583 | trigger_error($db->error()); | 583 | trigger_error($db->error()); |
4077 | @@ -586,23 +586,23 @@ | |||
4078 | 586 | return $this->response; | 586 | return $this->response; |
4079 | 587 | } | 587 | } |
4080 | 588 | } | 588 | } |
4082 | 589 | 589 | ||
4083 | 590 | // Update the media record to include this information | 590 | // Update the media record to include this information |
4084 | 591 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); | 591 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); |
4086 | 592 | 592 | ||
4087 | 593 | if (!$db->query($SQL)) | 593 | if (!$db->query($SQL)) |
4088 | 594 | { | 594 | { |
4089 | 595 | trigger_error($db->error()); | 595 | trigger_error($db->error()); |
4090 | 596 | return true; | 596 | return true; |
4091 | 597 | } | 597 | } |
4093 | 598 | 598 | ||
4094 | 599 | // Required Attributes | 599 | // Required Attributes |
4095 | 600 | $this->mediaid = $mediaid; | 600 | $this->mediaid = $mediaid; |
4096 | 601 | $this->duration = $duration; | 601 | $this->duration = $duration; |
4098 | 602 | 602 | ||
4099 | 603 | // Any Options | 603 | // Any Options |
4100 | 604 | $this->SetOption('uri', $storedAs); | 604 | $this->SetOption('uri', $storedAs); |
4102 | 605 | 605 | ||
4103 | 606 | // Should have built the media object entirely by this time | 606 | // Should have built the media object entirely by this time |
4104 | 607 | if ($regionid != '') | 607 | if ($regionid != '') |
4105 | 608 | { | 608 | { |
4106 | @@ -612,18 +612,18 @@ | |||
4107 | 612 | } | 612 | } |
4108 | 613 | else | 613 | else |
4109 | 614 | { | 614 | { |
4111 | 615 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 615 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
4112 | 616 | } | 616 | } |
4114 | 617 | 617 | ||
4115 | 618 | // We want to load a new form | 618 | // We want to load a new form |
4116 | 619 | $this->response->loadForm = true; | 619 | $this->response->loadForm = true; |
4118 | 620 | 620 | ||
4119 | 621 | return $this->response; | 621 | return $this->response; |
4120 | 622 | } | 622 | } |
4122 | 623 | 623 | ||
4123 | 624 | /** | 624 | /** |
4124 | 625 | * Edit Media in the Database | 625 | * Edit Media in the Database |
4126 | 626 | * @return | 626 | * @return |
4127 | 627 | */ | 627 | */ |
4128 | 628 | public function EditMedia() | 628 | public function EditMedia() |
4129 | 629 | { | 629 | { |
4130 | @@ -632,13 +632,13 @@ | |||
4131 | 632 | $regionid = $this->regionid; | 632 | $regionid = $this->regionid; |
4132 | 633 | $mediaid = $this->mediaid; | 633 | $mediaid = $this->mediaid; |
4133 | 634 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 634 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
4135 | 635 | 635 | ||
4136 | 636 | // Stored As from the XML | 636 | // Stored As from the XML |
4137 | 637 | $storedAs = $this->GetOption('uri'); | 637 | $storedAs = $this->GetOption('uri'); |
4139 | 638 | 638 | ||
4140 | 639 | // File data | 639 | // File data |
4141 | 640 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 640 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
4143 | 641 | 641 | ||
4144 | 642 | if ($tmpName == '') | 642 | if ($tmpName == '') |
4145 | 643 | { | 643 | { |
4146 | 644 | $fileRevision = false; | 644 | $fileRevision = false; |
4147 | @@ -646,31 +646,31 @@ | |||
4148 | 646 | else | 646 | else |
4149 | 647 | { | 647 | { |
4150 | 648 | $fileRevision = true; | 648 | $fileRevision = true; |
4152 | 649 | 649 | ||
4153 | 650 | // File name and extension (orignial name) | 650 | // File name and extension (orignial name) |
4154 | 651 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 651 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
4155 | 652 | $fileName = basename($fileName); | 652 | $fileName = basename($fileName); |
4156 | 653 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 653 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
4158 | 654 | 654 | ||
4159 | 655 | // Validation | 655 | // Validation |
4161 | 656 | if ($ext != "wmv" && $ext != "mpeg" && $ext != "mpg") | 656 | if (!$this->IsValidExtension($ext)) |
4162 | 657 | { | 657 | { |
4164 | 658 | $this->response->SetError('Only Vidoes are accepted - wmv, mpeg, mpg [this is ' . $ext . ']'); | 658 | $this->response->SetError('Your file has an extension not supported by this Media Type.'); |
4165 | 659 | $this->response->keepOpen = true; | 659 | $this->response->keepOpen = true; |
4166 | 660 | return $this->response; | 660 | return $this->response; |
4167 | 661 | } | 661 | } |
4168 | 662 | } | 662 | } |
4170 | 663 | 663 | ||
4171 | 664 | // Other properties | 664 | // Other properties |
4172 | 665 | $name = Kit::GetParam('name', _POST, _STRING); | 665 | $name = Kit::GetParam('name', _POST, _STRING); |
4173 | 666 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 666 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
4174 | 667 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 667 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
4176 | 668 | 668 | ||
4177 | 669 | if ($name == '') | 669 | if ($name == '') |
4178 | 670 | { | 670 | { |
4179 | 671 | if ($fileRevision) | 671 | if ($fileRevision) |
4180 | 672 | { | 672 | { |
4182 | 673 | $name = Kit::ValidateParam($fileName, _FILENAME); | 673 | $name = Kit::ValidateParam($fileName, _FILENAME); |
4183 | 674 | } | 674 | } |
4184 | 675 | else | 675 | else |
4185 | 676 | { | 676 | { |
4186 | @@ -678,26 +678,26 @@ | |||
4187 | 678 | $this->response->keepOpen = true; | 678 | $this->response->keepOpen = true; |
4188 | 679 | return $this->response; | 679 | return $this->response; |
4189 | 680 | } | 680 | } |
4192 | 681 | } | 681 | } |
4193 | 682 | 682 | ||
4194 | 683 | // Make sure the name isnt too long | 683 | // Make sure the name isnt too long |
4196 | 684 | if (strlen($name) > 100) | 684 | if (strlen($name) > 100) |
4197 | 685 | { | 685 | { |
4198 | 686 | $this->response->SetError('The name cannot be longer than 100 characters'); | 686 | $this->response->SetError('The name cannot be longer than 100 characters'); |
4199 | 687 | $this->response->keepOpen = true; | 687 | $this->response->keepOpen = true; |
4200 | 688 | return $this->response; | 688 | return $this->response; |
4201 | 689 | } | 689 | } |
4203 | 690 | 690 | ||
4204 | 691 | // Ensure the name is not already in the database | 691 | // Ensure the name is not already in the database |
4205 | 692 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); | 692 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); |
4206 | 693 | 693 | ||
4208 | 694 | if(!$result = $db->query($SQL)) | 694 | if(!$result = $db->query($SQL)) |
4209 | 695 | { | 695 | { |
4210 | 696 | trigger_error($db->error()); | 696 | trigger_error($db->error()); |
4211 | 697 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 697 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
4212 | 698 | $this->response->keepOpen = true; | 698 | $this->response->keepOpen = true; |
4213 | 699 | return $this->response; | 699 | return $this->response; |
4215 | 700 | } | 700 | } |
4216 | 701 | 701 | ||
4217 | 702 | if ($db->num_rows($result) != 0) | 702 | if ($db->num_rows($result) != 0) |
4218 | 703 | { | 703 | { |
4219 | @@ -705,34 +705,34 @@ | |||
4220 | 705 | $this->response->keepOpen = true; | 705 | $this->response->keepOpen = true; |
4221 | 706 | return $this->response; | 706 | return $this->response; |
4222 | 707 | } | 707 | } |
4224 | 708 | 708 | ||
4225 | 709 | //Are we revising this media - or just plain editing | 709 | //Are we revising this media - or just plain editing |
4226 | 710 | if ($fileRevision) | 710 | if ($fileRevision) |
4227 | 711 | { | 711 | { |
4228 | 712 | // All OK to insert this record | 712 | // All OK to insert this record |
4229 | 713 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 713 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
4230 | 714 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; | 714 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; |
4232 | 715 | 715 | ||
4233 | 716 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 716 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
4235 | 717 | 717 | ||
4236 | 718 | if (!$new_mediaid = $db->insert_query($SQL)) | 718 | if (!$new_mediaid = $db->insert_query($SQL)) |
4237 | 719 | { | 719 | { |
4238 | 720 | trigger_error($db->error()); | 720 | trigger_error($db->error()); |
4239 | 721 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); | 721 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); |
4240 | 722 | } | 722 | } |
4242 | 723 | 723 | ||
4243 | 724 | //What are we going to store this media as... | 724 | //What are we going to store this media as... |
4244 | 725 | $storedAs = $new_mediaid.".".$ext; | 725 | $storedAs = $new_mediaid.".".$ext; |
4246 | 726 | 726 | ||
4247 | 727 | // File upload directory.. get this from the settings object | 727 | // File upload directory.. get this from the settings object |
4248 | 728 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 728 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
4250 | 729 | 729 | ||
4251 | 730 | //Now we need to move the file | 730 | //Now we need to move the file |
4252 | 731 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) | 731 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) |
4253 | 732 | { | 732 | { |
4254 | 733 | //If we couldnt move it - we need to delete the media record we just added | 733 | //If we couldnt move it - we need to delete the media record we just added |
4255 | 734 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; | 734 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; |
4257 | 735 | 735 | ||
4258 | 736 | if (!$db->insert_query($SQL)) | 736 | if (!$db->insert_query($SQL)) |
4259 | 737 | { | 737 | { |
4260 | 738 | $this->response->SetError('Error rolling back transcation.'); | 738 | $this->response->SetError('Error rolling back transcation.'); |
4261 | @@ -740,7 +740,7 @@ | |||
4262 | 740 | return $this->response; | 740 | return $this->response; |
4263 | 741 | } | 741 | } |
4264 | 742 | } | 742 | } |
4266 | 743 | 743 | ||
4267 | 744 | // Update the media record to include this information | 744 | // Update the media record to include this information |
4268 | 745 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; | 745 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; |
4269 | 746 | if (!$db->query($SQL)) | 746 | if (!$db->query($SQL)) |
4270 | @@ -750,13 +750,13 @@ | |||
4271 | 750 | $this->response->keepOpen = true; | 750 | $this->response->keepOpen = true; |
4272 | 751 | return $this->response; | 751 | return $this->response; |
4273 | 752 | } | 752 | } |
4275 | 753 | 753 | ||
4276 | 754 | // Update the existing record with the new record's id | 754 | // Update the existing record with the new record's id |
4277 | 755 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; | 755 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; |
4278 | 756 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; | 756 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; |
4280 | 757 | 757 | ||
4281 | 758 | Debug::LogEntry($db, 'audit', $SQL); | 758 | Debug::LogEntry($db, 'audit', $SQL); |
4283 | 759 | 759 | ||
4284 | 760 | if (!$db->query($SQL)) | 760 | if (!$db->query($SQL)) |
4285 | 761 | { | 761 | { |
4286 | 762 | trigger_error($db->error()); | 762 | trigger_error($db->error()); |
4287 | @@ -770,54 +770,54 @@ | |||
4288 | 770 | { | 770 | { |
4289 | 771 | // Editing the existing record | 771 | // Editing the existing record |
4290 | 772 | $new_mediaid = $mediaid; | 772 | $new_mediaid = $mediaid; |
4292 | 773 | 773 | ||
4293 | 774 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; | 774 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; |
4294 | 775 | $SQL .= " WHERE mediaID = %d "; | 775 | $SQL .= " WHERE mediaID = %d "; |
4295 | 776 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); | 776 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); |
4297 | 777 | 777 | ||
4298 | 778 | Debug::LogEntry($db, 'audit', $SQL); | 778 | Debug::LogEntry($db, 'audit', $SQL); |
4300 | 779 | 779 | ||
4301 | 780 | if (!$db->query($SQL)) | 780 | if (!$db->query($SQL)) |
4302 | 781 | { | 781 | { |
4303 | 782 | trigger_error($db->error()); | 782 | trigger_error($db->error()); |
4305 | 783 | 783 | ||
4306 | 784 | $this->response->SetError('Database error editing this media record.'); | 784 | $this->response->SetError('Database error editing this media record.'); |
4307 | 785 | $this->response->keepOpen = true; | 785 | $this->response->keepOpen = true; |
4308 | 786 | return $this->response; | 786 | return $this->response; |
4309 | 787 | } | 787 | } |
4310 | 788 | } | 788 | } |
4312 | 789 | 789 | ||
4313 | 790 | // Required Attributes | 790 | // Required Attributes |
4314 | 791 | $this->mediaid = $new_mediaid; | 791 | $this->mediaid = $new_mediaid; |
4315 | 792 | $this->duration = $duration; | 792 | $this->duration = $duration; |
4317 | 793 | 793 | ||
4318 | 794 | // Any Options | 794 | // Any Options |
4319 | 795 | $this->SetOption('uri', $storedAs); | 795 | $this->SetOption('uri', $storedAs); |
4321 | 796 | 796 | ||
4322 | 797 | // Should have built the media object entirely by this time | 797 | // Should have built the media object entirely by this time |
4323 | 798 | if ($regionid != '') | 798 | if ($regionid != '') |
4324 | 799 | { | 799 | { |
4325 | 800 | // This saves the Media Object to the Region | 800 | // This saves the Media Object to the Region |
4326 | 801 | $this->UpdateRegion(); | 801 | $this->UpdateRegion(); |
4328 | 802 | 802 | ||
4329 | 803 | $this->response->loadForm = true; | 803 | $this->response->loadForm = true; |
4330 | 804 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; | 804 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; |
4331 | 805 | } | 805 | } |
4332 | 806 | else | 806 | else |
4333 | 807 | { | 807 | { |
4335 | 808 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 808 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
4336 | 809 | $this->response->message = 'Edited the Video.'; | 809 | $this->response->message = 'Edited the Video.'; |
4338 | 810 | 810 | ||
4339 | 811 | } | 811 | } |
4341 | 812 | 812 | ||
4342 | 813 | return $this->response; | 813 | return $this->response; |
4343 | 814 | } | 814 | } |
4345 | 815 | 815 | ||
4346 | 816 | /** | 816 | /** |
4347 | 817 | * Delete Media from the Database | 817 | * Delete Media from the Database |
4349 | 818 | * @return | 818 | * @return |
4350 | 819 | */ | 819 | */ |
4352 | 820 | public function DeleteMedia() | 820 | public function DeleteMedia() |
4353 | 821 | { | 821 | { |
4354 | 822 | $db =& $this->db; | 822 | $db =& $this->db; |
4355 | 823 | $layoutid = $this->layoutid; | 823 | $layoutid = $this->layoutid; |
4356 | @@ -825,10 +825,10 @@ | |||
4357 | 825 | $mediaid = $this->mediaid; | 825 | $mediaid = $this->mediaid; |
4358 | 826 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 826 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
4359 | 827 | $options = Kit::GetParam('options', _POST, _WORD); | 827 | $options = Kit::GetParam('options', _POST, _WORD); |
4361 | 828 | 828 | ||
4362 | 829 | // Stored As from the XML | 829 | // Stored As from the XML |
4363 | 830 | $this->uri = $this->GetOption('uri'); | 830 | $this->uri = $this->GetOption('uri'); |
4365 | 831 | 831 | ||
4366 | 832 | // Do we need to remove this from a layout? | 832 | // Do we need to remove this from a layout? |
4367 | 833 | if ($layoutid != '') | 833 | if ($layoutid != '') |
4368 | 834 | { | 834 | { |
4369 | @@ -840,72 +840,72 @@ | |||
4370 | 840 | // Set this message now in preparation | 840 | // Set this message now in preparation |
4371 | 841 | $this->response->message = 'Deleted the Media.'; | 841 | $this->response->message = 'Deleted the Media.'; |
4372 | 842 | } | 842 | } |
4374 | 843 | 843 | ||
4375 | 844 | // If we are set to retire we retire | 844 | // If we are set to retire we retire |
4376 | 845 | if ($options == "retire") | 845 | if ($options == "retire") |
4377 | 846 | { | 846 | { |
4378 | 847 | //Update the media record to say it is retired | 847 | //Update the media record to say it is retired |
4379 | 848 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; | 848 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; |
4381 | 849 | 849 | ||
4382 | 850 | if (!$db->query($SQL)) | 850 | if (!$db->query($SQL)) |
4383 | 851 | { | 851 | { |
4384 | 852 | trigger_error($db->error()); | 852 | trigger_error($db->error()); |
4386 | 853 | 853 | ||
4387 | 854 | $this->response->SetError('Database error retiring this media record.'); | 854 | $this->response->SetError('Database error retiring this media record.'); |
4388 | 855 | $this->response->keepOpen = true; | 855 | $this->response->keepOpen = true; |
4389 | 856 | return $this->response; | 856 | return $this->response; |
4390 | 857 | } | 857 | } |
4391 | 858 | } | 858 | } |
4393 | 859 | 859 | ||
4394 | 860 | //If we are set to delete, we delete | 860 | //If we are set to delete, we delete |
4395 | 861 | if ($options == "delete") | 861 | if ($options == "delete") |
4396 | 862 | { | 862 | { |
4397 | 863 | //Update the media record to say it is retired | 863 | //Update the media record to say it is retired |
4398 | 864 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; | 864 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; |
4400 | 865 | 865 | ||
4401 | 866 | if (!$db->query($SQL)) | 866 | if (!$db->query($SQL)) |
4402 | 867 | { | 867 | { |
4403 | 868 | trigger_error($db->error()); | 868 | trigger_error($db->error()); |
4405 | 869 | 869 | ||
4406 | 870 | $this->response->SetError('Database error deleting this media record.'); | 870 | $this->response->SetError('Database error deleting this media record.'); |
4407 | 871 | $this->response->keepOpen = true; | 871 | $this->response->keepOpen = true; |
4408 | 872 | return $this->response; | 872 | return $this->response; |
4409 | 873 | } | 873 | } |
4411 | 874 | 874 | ||
4412 | 875 | $this->DeleteMediaFiles(); | 875 | $this->DeleteMediaFiles(); |
4413 | 876 | } | 876 | } |
4415 | 877 | 877 | ||
4416 | 878 | return $this->response; | 878 | return $this->response; |
4417 | 879 | } | 879 | } |
4419 | 880 | 880 | ||
4420 | 881 | /** | 881 | /** |
4421 | 882 | * Deletes the media files associated with this record | 882 | * Deletes the media files associated with this record |
4423 | 883 | * @return | 883 | * @return |
4424 | 884 | */ | 884 | */ |
4425 | 885 | private function DeleteMediaFiles() | 885 | private function DeleteMediaFiles() |
4426 | 886 | { | 886 | { |
4427 | 887 | $db =& $this->db; | 887 | $db =& $this->db; |
4429 | 888 | 888 | ||
4430 | 889 | //Library location | 889 | //Library location |
4431 | 890 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 890 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
4433 | 891 | 891 | ||
4434 | 892 | //3 things to check for.. | 892 | //3 things to check for.. |
4435 | 893 | //the actual file, the thumbnail, the background | 893 | //the actual file, the thumbnail, the background |
4436 | 894 | if (file_exists($databaseDir.$this->uri)) | 894 | if (file_exists($databaseDir.$this->uri)) |
4437 | 895 | { | 895 | { |
4438 | 896 | unlink($databaseDir.$this->uri); | 896 | unlink($databaseDir.$this->uri); |
4439 | 897 | } | 897 | } |
4441 | 898 | 898 | ||
4442 | 899 | if (file_exists($databaseDir."tn_".$this->uri)) | 899 | if (file_exists($databaseDir."tn_".$this->uri)) |
4443 | 900 | { | 900 | { |
4444 | 901 | unlink($databaseDir."tn_".$this->uri); | 901 | unlink($databaseDir."tn_".$this->uri); |
4445 | 902 | } | 902 | } |
4447 | 903 | 903 | ||
4448 | 904 | if (file_exists($databaseDir."bg_".$this->uri)) | 904 | if (file_exists($databaseDir."bg_".$this->uri)) |
4449 | 905 | { | 905 | { |
4450 | 906 | unlink($databaseDir."bg_".$this->uri); | 906 | unlink($databaseDir."bg_".$this->uri); |
4451 | 907 | } | 907 | } |
4453 | 908 | 908 | ||
4454 | 909 | return true; | 909 | return true; |
4455 | 910 | } | 910 | } |
4456 | 911 | } | 911 | } |