Merge lp:~quam-plures-core/quam-plures/qp5_smallstep into lp:quam-plures
- qp5_smallstep
- Merge into trunk
Proposed by
EdB
Status: | Merged |
---|---|
Merged at revision: | 7658 |
Proposed branch: | lp:~quam-plures-core/quam-plures/qp5_smallstep |
Merge into: | lp:quam-plures |
Diff against target: |
16242 lines (+6594/-6617) 19 files modified
qp_inc/_application.php (+1/-1) qp_inc/_core/_template.funcs.php (+111/-140) qp_inc/_core/model/__core.install.php (+279/-277) qp_inc/files/files.ctrl.php (+1234/-1268) qp_inc/plugins/_plugin.class.php (+2155/-2427) qp_inc/users/model/_user.class.php (+976/-887) qp_inc/users/users.ctrl.php (+709/-698) qp_inc/users/views/_user.form.php (+283/-267) qp_install/_functions_dbupgrade.php (+22/-0) qp_install/_functions_install.php (+192/-195) qp_install/index.php (+25/-28) qp_plugins/commenttags_plugin/_commenttags.plugin.php (+15/-17) qp_plugins/quicktags_plugin/_quicktags.plugin.php (+38/-50) qp_plugins/smilies_plugin/_smilies.plugin.php (+45/-49) qp_plugins/tinymce_plugin/_tinymce.plugin.php (+110/-110) qp_rsc/js/functions.js (+11/-11) qp_rsc/js/functions.min.js (+236/-0) qp_templates/photoblog/index.main.php (+7/-12) qp_view_admin/login/_login_form.main.php (+145/-180) |
To merge this branch: | bzr merge lp:~quam-plures-core/quam-plures/qp5_smallstep |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Quam Plures Core Team | Pending | ||
Review via email: mp+151713@code.launchpad.net |
Commit message
Description of the change
Ran through some quick testing and it doesn't look like anything is broken, so yay one small step :)
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'qp_inc/_application.php' |
2 | --- qp_inc/_application.php 2013-02-28 16:40:18 +0000 |
3 | +++ qp_inc/_application.php 2013-03-05 23:36:23 +0000 |
4 | @@ -22,7 +22,7 @@ |
5 | $files_version = '1.10'; |
6 | |
7 | // The database version, incrememented by 1 with each change in upgrade_dbase_tables() |
8 | -$app_db_version = 15; |
9 | +$app_db_version = 17; |
10 | |
11 | $app_version = $files_version.'.'.$app_db_version; |
12 | |
13 | |
14 | === modified file 'qp_inc/_core/_template.funcs.php' |
15 | --- qp_inc/_core/_template.funcs.php 2012-07-29 20:36:41 +0000 |
16 | +++ qp_inc/_core/_template.funcs.php 2013-03-05 23:36:23 +0000 |
17 | @@ -1,63 +1,37 @@ |
18 | <?php |
19 | /** |
20 | - * This file implements misc functions that handle output of the HTML page. |
21 | - * |
22 | - * This file is part of Quam Plures - {@link http://quamplures.net/} |
23 | - * See also {@link https://launchpad.net/quam-plures}. |
24 | - * |
25 | - * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/} |
26 | - * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/} |
27 | - * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}. |
28 | - * |
29 | - * {@internal License choice |
30 | - * - If you have received this file as part of a package, please find the license.txt file in |
31 | - * the same folder or the closest folder above for complete license terms. |
32 | - * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) |
33 | - * then you must choose one of the following licenses before using the file: |
34 | - * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php |
35 | - * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php |
36 | - * }} |
37 | - * |
38 | - * {@internal Open Source relicensing agreement: |
39 | - * Daniel HAHLER grants Francois PLANQUE the right to license |
40 | - * Daniel HAHLER's contributions to this file and the b2evolution project |
41 | - * under any OSI approved OSS license (http://www.opensource.org/licenses/). |
42 | - * }} |
43 | - * |
44 | - * {@internal Below is a list of authors who have contributed to design/coding of this file: }} |
45 | - * @author blueyed: Daniel HAHLER. |
46 | - * @author fplanque: Francois PLANQUE. |
47 | - * |
48 | - * @package pond |
49 | + * This file implements misc functions that handle output of the HTML page |
50 | + * |
51 | + * @author {@link http://wonderwinds.com/ Ed Bennett} |
52 | + * @author {@link http://daniel.hahler.de/ Daniel HAHLER} |
53 | + * @author {@link http://fplanque.net/ Francois PLANQUE} |
54 | + * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project} |
55 | + * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 |
56 | + * @package core |
57 | */ |
58 | -if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
59 | - |
60 | +if(!defined('QP_MAIN_INIT')) die('fail'); |
61 | |
62 | /** |
63 | * T-Tag: Outputs content-type header, sets charset |
64 | */ |
65 | function header_content_type( $type = 'text/html', $charset = '#' ) |
66 | { |
67 | + global $content_type_header; |
68 | global $io_charset; |
69 | - global $content_type_header; |
70 | |
71 | $content_type_header = 'Content-type: '.$type; |
72 | - |
73 | - if( !empty($charset) ) |
74 | + if( ! empty($charset) ) |
75 | { |
76 | if( $charset == '#' ) |
77 | { |
78 | $charset = $io_charset; |
79 | } |
80 | - |
81 | $content_type_header .= '; charset='.$charset; |
82 | } |
83 | - |
84 | header( $content_type_header ); |
85 | } |
86 | |
87 | |
88 | - |
89 | /** |
90 | * Sends HTTP header to redirect to the previous location (which |
91 | * can be given as function parameter, GET parameter (redirect_to), |
92 | @@ -78,9 +52,9 @@ |
93 | global $Hit, $app_baseurl, $Blog, $srvc_url_sensitive; |
94 | global $Session, $Debuglog, $Messages; |
95 | |
96 | - // TODO: fp> get this out to the caller, make a helper func like get_returnto_url() |
97 | if( empty($redirect_to) ) |
98 | - { // see if there's a redirect_to request param given: |
99 | + { |
100 | + // see if there's a redirect_to request param given: |
101 | $redirect_to = param( 'redirect_to', 'string', '' ); |
102 | |
103 | if( empty($redirect_to) ) |
104 | @@ -91,7 +65,7 @@ |
105 | } |
106 | elseif( isset($Blog) && is_object($Blog) ) |
107 | { |
108 | - $redirect_to = $Blog->get('url'); |
109 | + $redirect_to = $Blog->get( 'url' ); |
110 | } |
111 | else |
112 | { |
113 | @@ -108,7 +82,7 @@ |
114 | |
115 | if( $redirect_to[0] == '/' ) |
116 | { |
117 | - // TODO: until all calls to header_redirect are cleaned up: |
118 | + // @todo (0000): until all calls to header_redirect are cleaned up: |
119 | global $ReqHost; |
120 | $redirect_to = $ReqHost.$redirect_to; |
121 | // debug_die( '$redirect_to must be an absolute URL' ); |
122 | @@ -122,12 +96,9 @@ |
123 | // blueyed> Removed the removing of "action" here, as it is used to trigger certain views. Instead, "confirm(ed)?" gets removed now |
124 | // fp> which views please (important to list in order to remove asap) |
125 | // dh> sorry, don't remember |
126 | - // TODO: fp> action should actually not be used to trigger views. This should be changed at some point. |
127 | - // TODO: fp> confirm should be normalized to confirmed |
128 | $redirect_to = preg_replace( '~(?<=\?|&) (login|pwd|confirm(ed)?) = [^&]+ ~x', '', $redirect_to ); |
129 | } |
130 | |
131 | - // TODO: fp> change $permanent to $status in the params |
132 | if( is_integer($permanent) ) |
133 | { |
134 | $status = $permanent; |
135 | @@ -136,7 +107,6 @@ |
136 | { |
137 | $status = $permanent ? 301 : 303; |
138 | } |
139 | - $Debuglog->add('Redirecting to '.$redirect_to.' (status '.$status.')'); |
140 | |
141 | // Transfer of Debuglog to next page: |
142 | if( $Debuglog->count('all') ) |
143 | @@ -186,10 +156,10 @@ |
144 | */ |
145 | function header_nocache() |
146 | { |
147 | - header('Expires: Tue, 25 Mar 2003 05:00:00 GMT'); |
148 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
149 | - header('Cache-Control: no-cache, must-revalidate'); |
150 | - header('Pragma: no-cache'); |
151 | + header( 'Expires: Tue, 25 Mar 2003 05:00:00 GMT' ); |
152 | + header( 'Last-Modified: '.gmdate( 'D, d M Y H:i:s' ).' GMT' ); |
153 | + header( 'Cache-Control: no-cache, must-revalidate' ); |
154 | + header( 'Pragma: no-cache' ); |
155 | } |
156 | |
157 | |
158 | @@ -200,28 +170,28 @@ |
159 | * |
160 | * <code> |
161 | * $params = array_merge( array( |
162 | - * 'auto_pilot' => 'none', |
163 | - * 'title_before' => '', |
164 | - * 'title_after' => '', |
165 | - * 'title_none' => '', |
166 | - * 'title_single_disp' => true, |
167 | + * 'auto_pilot' => 'none', |
168 | + * 'title_before' => '', |
169 | + * 'title_after' => '', |
170 | + * 'title_none' => '', |
171 | + * 'title_single_disp' => true, |
172 | * 'title_single_before' => '#', // see below |
173 | - * 'title_single_after' => '#', // see below |
174 | - * 'title_page_disp' => true, |
175 | - * 'title_page_before' => '#', // see below |
176 | - * 'title_page_after' => '#', // see below |
177 | - * 'glue' => ' - ', |
178 | - * 'format' => 'htmlbody', |
179 | - * 'arcdir_text' => T_('Archive Directory'), |
180 | - * 'catdir_text' => T_('Category Directory'), |
181 | - * 'comments_text' => T_('Latest Comments'), |
182 | - * 'credits_text' => T_('Software Credits'), |
183 | + * 'title_single_after' => '#', // see below |
184 | + * 'title_page_disp' => true, |
185 | + * 'title_page_before' => '#', // see below |
186 | + * 'title_page_after' => '#', // see below |
187 | + * 'glue' => ' - ', |
188 | + * 'format' => 'htmlbody', |
189 | + * 'arcdir_text' => T_('Archive Directory'), |
190 | + * 'catdir_text' => T_('Category Directory'), |
191 | + * 'comments_text' => T_('Latest Comments'), |
192 | + * 'credits_text' => T_('Software Credits'), |
193 | * 'feedback-popup_text' => T_('Feedback'), |
194 | - * 'mediaidx_text' => T_('Photo Index'), |
195 | - * 'msgform_text' => T_('Send an Email Message'), |
196 | - * 'profile_text' => T_('User Profile'), |
197 | - * 'subs_text' => T_('Subscriptions'), |
198 | - * 'user_text' => T_('User'), |
199 | + * 'mediaidx_text' => T_('Photo Index'), |
200 | + * 'msgform_text' => T_('Send an Email Message'), |
201 | + * 'profile_text' => T_('User Profile'), |
202 | + * 'subs_text' => T_('Subscriptions'), |
203 | + * 'user_text' => T_('User'), |
204 | * ), $params ); |
205 | * </code> |
206 | * |
207 | @@ -232,45 +202,49 @@ |
208 | * |
209 | * 'auto_pilot' => 'seo_title' uses the SEO title autopilot. (default: "none") |
210 | * |
211 | - * @todo (legacy): single month: Respect locales datefmt |
212 | - * @todo (legacy): single post: posts do no get proper checking (wether they are in the requested blog or wether their permissions match user rights, |
213 | - * thus the title sometimes gets displayed even when it should not. We need to pre-query the ItemList instead!! |
214 | - * @todo (legacy): make it complete with all possible params! |
215 | + * @todo (0000): single month: Respect locales datefmt |
216 | + * @todo (0000): single post: posts do no get proper checking (wether they are in the requested |
217 | + * blog or whether their permissions match user rights, thus the title sometimes gets displayed |
218 | + * even when it should not. We need to pre-query the ItemList instead!! |
219 | + * @todo (0000): make it complete with all possible params! |
220 | */ |
221 | function request_title( $params = array() ) |
222 | { |
223 | - global $MainList, $preview, $disp; |
224 | + global $disp; |
225 | + global $MainList; |
226 | + global $preview; |
227 | |
228 | $params = array_merge( array( |
229 | - 'auto_pilot' => 'none', |
230 | - 'title_before' => '', |
231 | - 'title_after' => '', |
232 | - 'title_none' => '', |
233 | - 'title_single_disp' => true, |
234 | + 'auto_pilot' => 'none', |
235 | + 'title_before' => '', |
236 | + 'title_after' => '', |
237 | + 'title_none' => '', |
238 | + 'title_single_disp' => true, |
239 | 'title_single_before' => '#', |
240 | - 'title_single_after' => '#', |
241 | - 'title_page_disp' => true, |
242 | - 'title_page_before' => '#', |
243 | - 'title_page_after' => '#', |
244 | - 'glue' => ' - ', |
245 | - 'format' => 'htmlbody', |
246 | - 'arcdir_text' => T_('Archive Directory'), |
247 | - 'catdir_text' => T_('Category Directory'), |
248 | - 'comments_text' => T_('Latest Comments'), |
249 | - 'credits_text' => T_('Software Credits'), |
250 | + 'title_single_after' => '#', |
251 | + 'title_page_disp' => true, |
252 | + 'title_page_before' => '#', |
253 | + 'title_page_after' => '#', |
254 | + 'glue' => ' - ', |
255 | + 'format' => 'htmlbody', |
256 | + 'arcdir_text' => T_('Archive Directory'), |
257 | + 'catdir_text' => T_('Category Directory'), |
258 | + 'comments_text' => T_('Latest Comments'), |
259 | + 'credits_text' => T_('Software Credits'), |
260 | 'feedback-popup_text' => T_('Feedback'), |
261 | - 'mediaidx_text' => T_('Photo Index'), |
262 | - 'msgform_text' => T_('Send an Email Message'), |
263 | - 'profile_text' => T_('User Profile'), |
264 | - 'subs_text' => T_('Subscriptions'), |
265 | - 'user_text' => T_('User'), |
266 | + 'mediaidx_text' => T_('Photo Index'), |
267 | + 'msgform_text' => T_('Send an Email Message'), |
268 | + 'profile_text' => T_('User Profile'), |
269 | + 'subs_text' => T_('Subscriptions'), |
270 | + 'user_text' => T_('User'), |
271 | ), $params ); |
272 | |
273 | if( $params['auto_pilot'] == 'seo_title' ) |
274 | - { // We want to use the SEO title autopilot. Do overrides: |
275 | + { |
276 | + // We want to use the SEO title autopilot. Do overrides: |
277 | global $Blog; |
278 | $params['format'] = 'htmlhead'; |
279 | - $params['title_after'] = $params['glue'].$Blog->get('name'); |
280 | + $params['title_after'] = $params['glue'].$Blog->get( 'name' ); |
281 | $params['title_single_after'] = ''; |
282 | $params['title_page_after'] = ''; |
283 | $params['title_none'] = $Blog->dget('name','htmlhead'); |
284 | @@ -303,7 +277,7 @@ |
285 | global $Item; |
286 | if( isset( $Item ) ) |
287 | { |
288 | - $r[] = sprintf( /* TRANS: %s is an item title */ $params['comments_text'] . T_(' on %s'), $Item->get('title') ); |
289 | + $r[] = sprintf( /* TRANS: %s is an item title */ $params['comments_text'].T_(' on %s'), $Item->get('title') ); |
290 | } |
291 | else |
292 | { |
293 | @@ -315,7 +289,7 @@ |
294 | // We are requesting the comments on a specific post: |
295 | // Should be in first position |
296 | $Item = & $MainList->get_by_idx( 0 ); |
297 | - $r[] = sprintf( /* TRANS: %s is an item title */ $params['feedback-popup_text'] . T_(' on %s'), $Item->get('title') ); |
298 | + $r[] = sprintf( /* TRANS: %s is an item title */ $params['feedback-popup_text'].T_(' on %s'), $Item->get('title') ); |
299 | break; |
300 | |
301 | case 'profile': |
302 | @@ -342,13 +316,15 @@ |
303 | case 'page': |
304 | // We are displaying a single message: |
305 | if( $preview ) |
306 | - { // We are requesting a post preview: |
307 | + { |
308 | + // We are requesting a post preview |
309 | $r[] = T_('PREVIEW'); |
310 | } |
311 | elseif( $params['title_'.$disp.'_disp'] && isset( $MainList ) ) |
312 | { |
313 | $r = array_merge( $r, $MainList->get_filter_titles( array( 'visibility', 'hide_future' ), $params ) ); |
314 | } |
315 | + |
316 | if( $params['title_'.$disp.'_before'] != '#' ) |
317 | { |
318 | $before = $params['title_'.$disp.'_before']; |
319 | @@ -377,12 +353,12 @@ |
320 | $r = implode( $params['glue'], $r ); |
321 | $r = $before.format_to_output( $r, $params['format'] ).$after; |
322 | } |
323 | - elseif( !empty( $params['title_none'] ) ) |
324 | + elseif( ! empty( $params['title_none'] ) ) |
325 | { |
326 | $r = $params['title_none']; |
327 | } |
328 | |
329 | - if( !empty( $r ) ) |
330 | + if( ! empty( $r ) ) |
331 | { // We have something to display: |
332 | echo $r; |
333 | } |
334 | @@ -402,7 +378,7 @@ |
335 | $base_tag_set = $url; |
336 | echo '<base href="'.$url.'"'; |
337 | |
338 | - if( !empty($target) ) |
339 | + if( ! empty( $target ) ) |
340 | { |
341 | echo ' target="'.$target.'"'; |
342 | } |
343 | @@ -444,8 +420,7 @@ |
344 | |
345 | /** |
346 | * T-Tag: Outputs a <meta name="generator"> tag which contains information about this application. |
347 | - * |
348 | - * @deprecated No longer outputs meta generator. Left for backwards compatibility |
349 | + * @deprecated deprecated in Quam Plures v1 due to it adds no value to an installation |
350 | */ |
351 | function meta_generator_tag() |
352 | { |
353 | @@ -462,11 +437,11 @@ |
354 | { |
355 | global $Blog, $app_baseurl; |
356 | |
357 | - if( !empty( $Blog ) ) |
358 | + if( ! empty( $Blog ) ) |
359 | { |
360 | echo $before.'<a href="'.$Blog->get( 'url' ).'">'.$blog_text.'</a>'.$after; |
361 | } |
362 | - elseif( !empty($home_text) ) |
363 | + elseif( ! empty( $home_text ) ) |
364 | { |
365 | echo $before.'<a href="'.$app_baseurl.'">'.$home_text.'</a>'.$after; |
366 | } |
367 | @@ -481,7 +456,6 @@ |
368 | * If 'jquery' is used and $debug is set to true, the 'jquery_debug' is automatically swapped in. |
369 | * Any javascript added to the page is also added to the $required_js array, which is then checked to prevent adding the same code twice |
370 | * |
371 | - * @todo dh>merge with require_css() |
372 | * @param string alias, url or filename (relative to qp_rsc/js) for javascript file |
373 | * @param boolean Is the file's path relative to the base path/url? |
374 | * Use false if file is in $rsc_url/js/ |
375 | @@ -498,9 +472,10 @@ |
376 | '#jqueryUI_debug#' => 'jquery.ui.all.js', |
377 | ); |
378 | |
379 | - // TODO: dh> I think dependencies should get handled where the files are included! |
380 | + // @todo (0000): dh> I think dependencies should get handled where the files are included! |
381 | if( in_array( $js_file, array( '#jqueryUI#', '#jqueryUI_debug#' ) ) ) |
382 | - { // Dependency : ensure jQuery is loaded |
383 | + { |
384 | + // Dependency : ensure jQuery is loaded |
385 | require_js( '#jquery#' ); |
386 | } |
387 | elseif( $js_file == 'communication.js' ) |
388 | @@ -515,9 +490,9 @@ |
389 | $js_url = $js_file; |
390 | $absolute = TRUE; |
391 | } |
392 | - elseif( !empty( $js_aliases[$js_file]) ) |
393 | + elseif( ! empty( $js_aliases[$js_file]) ) |
394 | { // It's an alias |
395 | - if ( $js_file == '#jquery#' && $debug ) $js_file = '#jquery_debug#'; |
396 | + if( $js_file == '#jquery#' && $debug ) $js_file = '#jquery_debug#'; |
397 | $js_file = $js_aliases[$js_file]; |
398 | } |
399 | |
400 | @@ -546,12 +521,11 @@ |
401 | * Accepts absolute urls, filenames relative to the qp_rsc/css directory. |
402 | * Set $relative_to_base to TRUE to prevent this function from adding on the rsc_path |
403 | * |
404 | - * @todo dh>merge with require_js() |
405 | * @param string alias, url or filename (relative to qp_rsc/css) for CSS file |
406 | * @param boolean|string Is the file's path relative to the base path/url? |
407 | - * Use true to not add any prefix ("$rsc_url/css/"). |
408 | - * @param string title. The title for the link tag |
409 | - * @param string media. ie, 'print' |
410 | + * Use true to not add any prefix ("$rsc_url/css/"). |
411 | + * @param string The title for the link tag |
412 | + * @param string Media (ie 'print') |
413 | */ |
414 | function require_css( $css_file, $relative_to_base = false, $title = NULL, $media = NULL ) |
415 | { |
416 | @@ -572,7 +546,7 @@ |
417 | } |
418 | else |
419 | { |
420 | - $css_url = $rsc_url . 'css/' . $css_file; |
421 | + $css_url = $rsc_url.'css/'.$css_file; |
422 | } |
423 | |
424 | // Add to headlines, if not done already: |
425 | @@ -581,11 +555,11 @@ |
426 | $required_css[] = strtolower($css_url); |
427 | |
428 | $start_link_tag = '<link rel="stylesheet"'; |
429 | - if ( !empty( $title ) ) $start_link_tag .= ' title="' . $title . '"'; |
430 | - if ( !empty( $media ) ) $start_link_tag .= ' media="' . $media . '"'; |
431 | + if( ! empty( $title ) ) $start_link_tag .= ' title="'.$title.'"'; |
432 | + if( ! empty( $media ) ) $start_link_tag .= ' media="'.$media.'"'; |
433 | $start_link_tag .= ' type="text/css" href="'; |
434 | $end_link_tag = '" />'; |
435 | - add_headline( $start_link_tag . $css_url . $end_link_tag ); |
436 | + add_headline( $start_link_tag.$css_url.$end_link_tag ); |
437 | } |
438 | |
439 | } |
440 | @@ -653,7 +627,7 @@ |
441 | global $js_translations; |
442 | if( $string != $translation ) |
443 | { // it's translated |
444 | - $js_translations[ $string ] = $translation; |
445 | + $js_translations[$string] = $translation; |
446 | } |
447 | } |
448 | |
449 | @@ -702,11 +676,9 @@ |
450 | |
451 | /** |
452 | * T-Tag: Registers all the javascripts needed by the toolbar menu |
453 | - * |
454 | - * @todo (legacy): fp> include basic.css ? -- rename to add_headlines_for* -- potential |
455 | - * problem with inclusion order of CSS files!! |
456 | - * dh> would be nice to have the batch of CSS in a separate file. basic.css would |
457 | - * get included first always, then e.g. this toolbar.css. |
458 | + * @todo (0000): fp> include basic.css ? -- rename to add_headlines_for* -- potential |
459 | + * problem with inclusion order of CSS files!! dh> would be nice to have the batch of CSS in |
460 | + * a separate file. basic.css would get included first always, then e.g. this toolbar.css. |
461 | */ |
462 | function add_js_for_toolbar() |
463 | { |
464 | @@ -716,8 +688,8 @@ |
465 | } |
466 | |
467 | require_js( '#jquery#' ); |
468 | - require_js( 'functions.js' ); // for rollovers AddEvent - TODO: change to jQuery |
469 | - require_js( 'rollovers.js' ); // TODO: change to jQuery |
470 | + require_js( 'functions.min.js' ); // for rollovers AddEvent - TODO: change to jQuery |
471 | + require_js( 'rollovers.js' ); // @todo (0000): change to jQuery |
472 | // Superfish menus: |
473 | require_js( 'hoverintent.js' ); |
474 | require_js( 'superfish.js' ); |
475 | @@ -736,7 +708,6 @@ |
476 | |
477 | /** |
478 | * T-Tag: Outputs the collected HTML HEAD lines. |
479 | - * |
480 | * @see add_headline() |
481 | * @return string |
482 | */ |
483 | @@ -810,8 +781,8 @@ |
484 | |
485 | /** |
486 | * T-Tag: Display links to previous and next posts in single post mode |
487 | - * |
488 | * @uses ItemList2::prevnext_item_links() |
489 | + * @param array Associative array of parameters |
490 | */ |
491 | function item_prevnext_links( $params = array() ) |
492 | { |
493 | @@ -830,13 +801,13 @@ |
494 | * <code> |
495 | * $params = array_merge( array( |
496 | * 'block_start' => '<div class="action_messages">', |
497 | - * 'block_end' => '</div>', |
498 | + * 'block_end' => '</div>', |
499 | * ), $params ); |
500 | * </code> |
501 | - * |
502 | * @todo Tblue: Default values taken from Log::disp() ... this seems redundant |
503 | * @uses Log::disp() |
504 | * @uses Log::display() |
505 | + * @param array Associative array of parameters |
506 | */ |
507 | function messages( $params = array() ) |
508 | { |
509 | @@ -844,7 +815,7 @@ |
510 | |
511 | $params = array_merge( array( |
512 | 'block_start' => '<div class="action_messages">', |
513 | - 'block_end' => '</div>', |
514 | + 'block_end' => '</div>', |
515 | ), $params ); |
516 | |
517 | $Messages->disp( $params['block_start'], $params['block_end'] ); |
518 | @@ -853,8 +824,8 @@ |
519 | |
520 | /** |
521 | * T-Tag: Display links to previous and next posts in multi-post (or list) mode |
522 | - * |
523 | * @uses ItemListLight::page_links() |
524 | + * @param array Associative array of parameters |
525 | */ |
526 | function mainlist_page_links( $params = array() ) |
527 | { |
528 | @@ -869,7 +840,6 @@ |
529 | |
530 | /** |
531 | * T-Tag: Return an Item or NULL |
532 | - * |
533 | * @uses ItemListLight::get_item() |
534 | */ |
535 | function & mainlist_get_item() |
536 | @@ -881,7 +851,8 @@ |
537 | $Item = & $MainList->get_item(); |
538 | |
539 | if( $Item && $Item->ID === $featured_displayed_item_ID ) |
540 | - { // This post was already displayed as a Featured post, let's skip it and get the next one: |
541 | + { |
542 | + // This post was already displayed as a Featured post, let's skip it and get the next one: |
543 | $Item = & $MainList->get_item(); |
544 | } |
545 | } |
546 | @@ -895,8 +866,8 @@ |
547 | |
548 | /** |
549 | * T-Tag: Display a message if MainList is empty |
550 | - * |
551 | * @uses Results::display_if_empty() |
552 | + * @param array Associative array of parameters |
553 | */ |
554 | function display_if_empty( $params = array() ) |
555 | { |
556 | @@ -916,7 +887,7 @@ |
557 | */ |
558 | function star_rating( $stars, $class = 'middle' ) |
559 | { |
560 | - if( is_null($stars) ) |
561 | + if( is_null( $stars ) ) |
562 | { |
563 | return; |
564 | } |
565 | @@ -925,15 +896,15 @@ |
566 | { |
567 | if( $i <= $stars ) |
568 | { |
569 | - echo get_icon( 'star_on', 'imgtag', array( 'class'=>$class ) ); |
570 | + echo get_icon( 'star_on', 'imgtag', array( 'class' => $class ) ); |
571 | } |
572 | elseif( $i-.5 <= $stars ) |
573 | { |
574 | - echo get_icon( 'star_half', 'imgtag', array( 'class'=>$class ) ); |
575 | + echo get_icon( 'star_half', 'imgtag', array( 'class' => $class ) ); |
576 | } |
577 | else |
578 | { |
579 | - echo get_icon( 'star_off', 'imgtag', array( 'class'=>$class ) ); |
580 | + echo get_icon( 'star_off', 'imgtag', array( 'class' => $class ) ); |
581 | } |
582 | } |
583 | } |
584 | |
585 | === modified file 'qp_inc/_core/model/__core.install.php' |
586 | --- qp_inc/_core/model/__core.install.php 2013-02-28 16:40:18 +0000 |
587 | +++ qp_inc/_core/model/__core.install.php 2013-03-05 23:36:23 +0000 |
588 | @@ -64,86 +64,23 @@ |
589 | UNIQUE KEY blog_urlname (blog_urlname) |
590 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
591 | |
592 | - 'T_groups' => array( 'Creating table for Groups', |
593 | - "CREATE TABLE T_groups ( |
594 | - grp_ID INT(11) NOT NULL auto_increment, |
595 | - grp_name VARCHAR(50) NOT NULL default '', |
596 | - grp_perm_admin enum('none','hidden','visible') NOT NULL default 'visible', |
597 | - grp_perm_blogs enum('user','viewall','editall') NOT NULL default 'user', |
598 | - grp_perm_bypass_antispam TINYINT(1) NOT NULL DEFAULT 0, |
599 | - grp_perm_xhtmlvalidation VARCHAR(10) NOT NULL default 'always', |
600 | - grp_perm_xhtmlvalidation_xmlrpc VARCHAR(10) NOT NULL default 'always', |
601 | - grp_perm_xhtml_css_tweaks TINYINT(1) NOT NULL DEFAULT 0, |
602 | - grp_perm_xhtml_iframes TINYINT(1) NOT NULL DEFAULT 0, |
603 | - grp_perm_xhtml_javascript TINYINT(1) NOT NULL DEFAULT 0, |
604 | - grp_perm_xhtml_objects TINYINT(1) NOT NULL DEFAULT 0, |
605 | - grp_perm_stats enum('none','user','view','edit') NOT NULL default 'none', |
606 | - grp_perm_spamblacklist enum('none','view','edit') NOT NULL default 'none', |
607 | - grp_perm_options enum('none','view','edit') NOT NULL default 'none', |
608 | - grp_perm_users enum('none','view','edit') NOT NULL default 'none', |
609 | - grp_perm_templates TINYINT NOT NULL DEFAULT 0, |
610 | - grp_perm_files enum('none','view','add','edit','all') NOT NULL default 'none', |
611 | - PRIMARY KEY grp_ID (grp_ID) |
612 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
613 | - |
614 | - 'T_settings' => array( 'Creating table for Settings', |
615 | - "CREATE TABLE T_settings ( |
616 | - set_name VARCHAR( 30 ) NOT NULL , |
617 | - set_value VARCHAR( 255 ) NULL , |
618 | - PRIMARY KEY ( set_name ) |
619 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
620 | - |
621 | - 'T_global__cache' => array( 'Creating table for Caches', |
622 | - "CREATE TABLE T_global__cache ( |
623 | - cach_name VARCHAR( 30 ) NOT NULL , |
624 | - cach_cache MEDIUMBLOB NULL , |
625 | - PRIMARY KEY ( cach_name ) |
626 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
627 | - |
628 | - 'T_users' => array( 'Creating table for Users', |
629 | - "CREATE TABLE T_users ( |
630 | - user_ID INT(11) unsigned NOT NULL auto_increment, |
631 | - user_login VARCHAR(20) NOT NULL, |
632 | - user_pass CHAR(40) NOT NULL, |
633 | - user_firstname VARCHAR(50) NULL, |
634 | - user_lastname VARCHAR(50) NULL, |
635 | - user_nickname VARCHAR(50) NULL, |
636 | - user_email VARCHAR(255) NOT NULL, |
637 | - user_url VARCHAR(255) NULL, |
638 | - user_ip VARCHAR(15) NULL, |
639 | - user_domain VARCHAR(200) NULL, |
640 | - user_browser VARCHAR(200) NULL, |
641 | - dateYMDhour datetime NOT NULL DEFAULT '2000-01-01 00:00:00', |
642 | - user_level int unsigned DEFAULT 0 NOT NULL, |
643 | - user_locale VARCHAR(20) DEFAULT 'en-EU' NOT NULL, |
644 | - user_idmode VARCHAR(20) NOT NULL DEFAULT 'login', |
645 | - user_allow_msgform TINYINT NOT NULL DEFAULT '1', |
646 | - user_notify tinyint(1) NOT NULL default 1, |
647 | - user_showonline tinyint(1) NOT NULL default 1, |
648 | - user_grp_ID INT(4) NOT NULL default 1, |
649 | - user_validated tinyint(1) NOT NULL DEFAULT 0, |
650 | - PRIMARY KEY user_ID (user_ID), |
651 | - UNIQUE user_login (user_login), |
652 | - KEY user_grp_ID (user_grp_ID) |
653 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
654 | - |
655 | - 'T_templates__template' => array( 'Creating table for installed templates', |
656 | - "CREATE TABLE T_templates__template ( |
657 | - template_ID INT(10) unsigned NOT NULL auto_increment, |
658 | - template_name VARCHAR(32) NOT NULL, |
659 | - template_type enum('xhtml','feed','other') NOT NULL default 'xhtml', |
660 | - template_folder VARCHAR(32) NOT NULL, |
661 | - PRIMARY KEY template_ID (template_ID), |
662 | - UNIQUE template_folder( template_folder ), |
663 | - KEY template_name( template_name ) |
664 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
665 | - |
666 | - 'T_templates__container' => array( 'Creating table for template containers', |
667 | - "CREATE TABLE T_templates__container ( |
668 | - sco_template_ID INT(10) unsigned NOT NULL, |
669 | - sco_name VARCHAR(40) NOT NULL, |
670 | - PRIMARY KEY (sco_template_ID, sco_name) |
671 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
672 | + 'T_coll_group_perms' => array( 'Creating table for blog-group permissions', |
673 | + "CREATE TABLE T_coll_group_perms ( |
674 | + bloggroup_blog_ID INT(11) unsigned NOT NULL default 0, |
675 | + bloggroup_group_ID INT(11) unsigned NOT NULL default 0, |
676 | + bloggroup_ismember TINYINT NOT NULL default 0, |
677 | + bloggroup_perm_poststatuses set('published','deprecated','protected','private','draft','redirected') NOT NULL default '', |
678 | + bloggroup_perm_edit ENUM('no','own','lt','le','all','redirected') NOT NULL default 'no', |
679 | + bloggroup_perm_delpost TINYINT NOT NULL default 0, |
680 | + bloggroup_perm_comments TINYINT NOT NULL default 0, |
681 | + bloggroup_perm_cats TINYINT NOT NULL default 0, |
682 | + bloggroup_perm_properties TINYINT NOT NULL default 0, |
683 | + bloggroup_perm_admin TINYINT NOT NULL default 0, |
684 | + bloggroup_perm_media_upload TINYINT NOT NULL default 0, |
685 | + bloggroup_perm_media_browse TINYINT NOT NULL default 0, |
686 | + bloggroup_perm_media_change TINYINT NOT NULL default 0, |
687 | + PRIMARY KEY bloggroup_pk (bloggroup_blog_ID,bloggroup_group_ID) |
688 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
689 | |
690 | 'T_coll_settings' => array( 'Creating collection settings table', |
691 | "CREATE TABLE T_coll_settings ( |
692 | @@ -153,18 +90,22 @@ |
693 | PRIMARY KEY ( cset_coll_ID, cset_name ) |
694 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
695 | |
696 | - 'T_widget' => array( 'Creating components table', |
697 | - "CREATE TABLE T_widget ( |
698 | - wi_ID INT(10) UNSIGNED auto_increment, |
699 | - wi_coll_ID INT(11) UNSIGNED NOT NULL, |
700 | - wi_sco_name VARCHAR( 40 ) NOT NULL, |
701 | - wi_order INT(10) NOT NULL, |
702 | - wi_enabled TINYINT(1) NOT NULL DEFAULT 1, |
703 | - wi_type ENUM( 'widget', 'plugin' ) NOT NULL DEFAULT 'widget', |
704 | - wi_code VARCHAR(32) NOT NULL, |
705 | - wi_params TEXT NULL, |
706 | - PRIMARY KEY ( wi_ID ), |
707 | - UNIQUE wi_order( wi_coll_ID, wi_sco_name, wi_order ) |
708 | + 'T_coll_user_perms' => array( 'Creating table for Blog-User permissions', |
709 | + "CREATE TABLE T_coll_user_perms ( |
710 | + bloguser_blog_ID INT(11) unsigned NOT NULL default 0, |
711 | + bloguser_user_ID INT(11) unsigned NOT NULL default 0, |
712 | + bloguser_ismember TINYINT NOT NULL default 0, |
713 | + bloguser_perm_poststatuses set('published','deprecated','protected','private','draft','redirected') NOT NULL default '', |
714 | + bloguser_perm_edit ENUM('no','own','lt','le','all','redirected') NOT NULL default 'no', |
715 | + bloguser_perm_delpost TINYINT NOT NULL default 0, |
716 | + bloguser_perm_comments TINYINT NOT NULL default 0, |
717 | + bloguser_perm_cats TINYINT NOT NULL default 0, |
718 | + bloguser_perm_properties TINYINT NOT NULL default 0, |
719 | + bloguser_perm_admin TINYINT NOT NULL default 0, |
720 | + bloguser_perm_media_upload TINYINT NOT NULL default 0, |
721 | + bloguser_perm_media_browse TINYINT NOT NULL default 0, |
722 | + bloguser_perm_media_change TINYINT NOT NULL default 0, |
723 | + PRIMARY KEY bloguser_pk (bloguser_blog_ID,bloguser_user_ID) |
724 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
725 | |
726 | 'T_categories' => array( 'Creating table for Categories', |
727 | @@ -183,6 +124,99 @@ |
728 | KEY cat_order (cat_order) |
729 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
730 | |
731 | + 'T_comments' => array( 'Creating table for Comments', |
732 | + "CREATE TABLE T_comments ( |
733 | + comment_ID INT(11) unsigned NOT NULL auto_increment, |
734 | + comment_post_ID INT(11) unsigned NOT NULL default '0', |
735 | + comment_type ENUM('comment','linkback','trackback') NOT NULL default 'comment', |
736 | + comment_status ENUM('published','deprecated','protected','private','draft','redirected') DEFAULT 'published' NOT NULL, |
737 | + comment_author_ID INT unsigned NULL default NULL, |
738 | + comment_author VARCHAR(100) NULL, |
739 | + comment_author_email VARCHAR(255) NULL, |
740 | + comment_author_url VARCHAR(255) NULL, |
741 | + comment_author_IP VARCHAR(23) NOT NULL default '', |
742 | + comment_date DATETIME NOT NULL DEFAULT '2000-01-01 00:00:00', |
743 | + comment_content text NOT NULL, |
744 | + comment_rating TINYINT(1) NULL DEFAULT NULL, |
745 | + comment_featured TINYINT(1) NOT NULL DEFAULT 0, |
746 | + comment_nofollow TINYINT(1) NOT NULL DEFAULT 1, |
747 | + comment_karma INT(11) NOT NULL DEFAULT 0, |
748 | + comment_spam_karma TINYINT NULL, |
749 | + comment_allow_msgform TINYINT NOT NULL DEFAULT 0, |
750 | + PRIMARY KEY comment_ID (comment_ID), |
751 | + KEY comment_post_ID (comment_post_ID), |
752 | + KEY comment_date (comment_date), |
753 | + KEY comment_type (comment_type) |
754 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
755 | + |
756 | + 'T_cron__log' => array( 'Creating cron tasks table', |
757 | + "CREATE TABLE T_cron__log( |
758 | + clog_ctsk_ID INT(10) unsigned not null, |
759 | + clog_realstart_datetime DATETIME not null DEFAULT '2000-01-01 00:00:00', |
760 | + clog_realstop_datetime DATETIME, |
761 | + clog_status ENUM('started','finished','error','timeout') not null default 'started', |
762 | + clog_messages text, |
763 | + PRIMARY KEY ( clog_ctsk_ID ) |
764 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
765 | + |
766 | + 'T_cron__task' => array( 'Creating cron tasks table', |
767 | + "CREATE TABLE T_cron__task( |
768 | + ctsk_ID INT(10) unsigned not null AUTO_INCREMENT, |
769 | + ctsk_start_datetime DATETIME not null DEFAULT '2000-01-01 00:00:00', |
770 | + ctsk_repeat_after INT(10) unsigned, |
771 | + ctsk_name VARCHAR(50) not null, |
772 | + ctsk_controller VARCHAR(50) not null, |
773 | + ctsk_params text, |
774 | + PRIMARY KEY ( ctsk_ID ) |
775 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
776 | + |
777 | + 'T_files' => array( 'Creating table for File Meta Data', |
778 | + "CREATE TABLE T_files ( |
779 | + file_ID INT(11) unsigned not null AUTO_INCREMENT, |
780 | + file_root_type ENUM('absolute','user','collection','shared','templates') not null default 'absolute', |
781 | + file_root_ID INT(11) unsigned not null default 0, |
782 | + file_path VARCHAR(255) not null default '', |
783 | + file_title VARCHAR(255), |
784 | + file_alt VARCHAR(255), |
785 | + file_desc text, |
786 | + PRIMARY KEY ( file_ID ), |
787 | + unique file (file_root_type, file_root_ID, file_path) |
788 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
789 | + |
790 | + 'T_filetypes' => array( 'Creating table for file types', |
791 | + "CREATE TABLE T_filetypes ( |
792 | + ftyp_ID INT(11) unsigned NOT NULL auto_increment, |
793 | + ftyp_extensions VARCHAR(30) NOT NULL, |
794 | + ftyp_name VARCHAR(30) NOT NULL, |
795 | + ftyp_mimetype VARCHAR(50) NOT NULL, |
796 | + ftyp_icon VARCHAR(20) default NULL, |
797 | + ftyp_viewtype VARCHAR(10) NOT NULL, |
798 | + ftyp_allowed TINYINT(1) NOT NULL default 0, |
799 | + PRIMARY KEY ( ftyp_ID ) |
800 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
801 | + |
802 | + 'T_groups' => array( 'Creating table for Groups', |
803 | + "CREATE TABLE T_groups ( |
804 | + grp_ID INT(11) NOT NULL auto_increment, |
805 | + grp_name VARCHAR(50) NOT NULL default '', |
806 | + grp_perm_admin ENUM('none','hidden','visible') NOT NULL default 'visible', |
807 | + grp_perm_blogs ENUM('user','viewall','editall') NOT NULL default 'user', |
808 | + grp_perm_bypass_antispam TINYINT(1) NOT NULL DEFAULT 0, |
809 | + grp_perm_xhtmlvalidation VARCHAR(10) NOT NULL default 'always', |
810 | + grp_perm_xhtmlvalidation_xmlrpc VARCHAR(10) NOT NULL default 'always', |
811 | + grp_perm_xhtml_css_tweaks TINYINT(1) NOT NULL DEFAULT 0, |
812 | + grp_perm_xhtml_iframes TINYINT(1) NOT NULL DEFAULT 0, |
813 | + grp_perm_xhtml_javascript TINYINT(1) NOT NULL DEFAULT 0, |
814 | + grp_perm_xhtml_objects TINYINT(1) NOT NULL DEFAULT 0, |
815 | + grp_perm_stats ENUM('none','user','view','edit') NOT NULL default 'none', |
816 | + grp_perm_spamblacklist ENUM('none','view','edit') NOT NULL default 'none', |
817 | + grp_perm_options ENUM('none','view','edit') NOT NULL default 'none', |
818 | + grp_perm_users ENUM('none','view','edit') NOT NULL default 'none', |
819 | + grp_perm_templates TINYINT NOT NULL DEFAULT 0, |
820 | + grp_perm_files ENUM('none','view','add','edit','all') NOT NULL default 'none', |
821 | + PRIMARY KEY grp_ID (grp_ID) |
822 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
823 | + |
824 | 'T_items__item' => array( 'Creating table for Posts', |
825 | "CREATE TABLE T_items__item ( |
826 | post_ID INT(11) unsigned NOT NULL auto_increment, |
827 | @@ -191,15 +225,15 @@ |
828 | post_lastedit_user_ID INT(11) unsigned NULL, |
829 | post_assigned_user_ID INT(11) unsigned NULL, |
830 | post_datestart DATETIME NOT NULL DEFAULT '2000-01-01 00:00:00', |
831 | - post_datedeadline datetime NULL, |
832 | - post_datecreated datetime NULL, |
833 | + post_datedeadline DATETIME NULL, |
834 | + post_datecreated DATETIME NULL, |
835 | post_datemodified DATETIME NOT NULL DEFAULT '2000-01-01 00:00:00', |
836 | - post_status enum('published','deprecated','protected','private','draft','redirected') NOT NULL default 'published', |
837 | + post_status ENUM('published','deprecated','protected','private','draft','redirected') NOT NULL default 'published', |
838 | post_pst_ID INT(11) unsigned NULL, |
839 | post_ptyp_ID INT(10) unsigned NOT NULL DEFAULT 1, |
840 | post_locale VARCHAR(20) NOT NULL DEFAULT 'en-EU', |
841 | post_content MEDIUMTEXT NULL, |
842 | - post_excerpt text NULL, |
843 | + post_excerpt TEXT NULL, |
844 | post_title text NOT NULL, |
845 | post_urltitle VARCHAR(210) NULL DEFAULT NULL, |
846 | post_titletag VARCHAR(255) NULL DEFAULT NULL, |
847 | @@ -215,7 +249,7 @@ |
848 | post_commentsexpire DATETIME DEFAULT NULL, |
849 | post_renderers TEXT NOT NULL, |
850 | post_priority INT(11) unsigned null COMMENT 'Task priority in workflow', |
851 | - post_featured tinyint(1) NOT NULL DEFAULT 0, |
852 | + post_featured TINYINT(1) NOT NULL DEFAULT 0, |
853 | post_order DOUBLE NULL, |
854 | post_editor_code VARCHAR(32) NULL COMMENT 'Plugin code of the editor used to edit this post', |
855 | PRIMARY KEY post_ID( post_ID ), |
856 | @@ -239,54 +273,6 @@ |
857 | UNIQUE catpost ( postcat_cat_ID, postcat_post_ID ) |
858 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
859 | |
860 | - 'T_comments' => array( 'Creating table for Comments', |
861 | - "CREATE TABLE T_comments ( |
862 | - comment_ID INT(11) unsigned NOT NULL auto_increment, |
863 | - comment_post_ID INT(11) unsigned NOT NULL default '0', |
864 | - comment_type enum('comment','linkback','trackback') NOT NULL default 'comment', |
865 | - comment_status ENUM('published','deprecated','protected','private','draft','redirected') DEFAULT 'published' NOT NULL, |
866 | - comment_author_ID int unsigned NULL default NULL, |
867 | - comment_author VARCHAR(100) NULL, |
868 | - comment_author_email VARCHAR(255) NULL, |
869 | - comment_author_url VARCHAR(255) NULL, |
870 | - comment_author_IP VARCHAR(23) NOT NULL default '', |
871 | - comment_date datetime NOT NULL DEFAULT '2000-01-01 00:00:00', |
872 | - comment_content text NOT NULL, |
873 | - comment_rating TINYINT(1) NULL DEFAULT NULL, |
874 | - comment_featured TINYINT(1) NOT NULL DEFAULT 0, |
875 | - comment_nofollow TINYINT(1) NOT NULL DEFAULT 1, |
876 | - comment_karma INT(11) NOT NULL DEFAULT 0, |
877 | - comment_spam_karma TINYINT NULL, |
878 | - comment_allow_msgform TINYINT NOT NULL DEFAULT 0, |
879 | - PRIMARY KEY comment_ID (comment_ID), |
880 | - KEY comment_post_ID (comment_post_ID), |
881 | - KEY comment_date (comment_date), |
882 | - KEY comment_type (comment_type) |
883 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
884 | - |
885 | - 'T_locales' => array( 'Creating table for Locales', |
886 | - "CREATE TABLE T_locales ( |
887 | - loc_locale VARCHAR(20) NOT NULL default '', |
888 | - loc_charset VARCHAR(15) NOT NULL default 'iso-8859-1', |
889 | - loc_datefmt VARCHAR(20) NOT NULL default 'y-m-d', |
890 | - loc_timefmt VARCHAR(20) NOT NULL default 'H:i:s', |
891 | - loc_startofweek TINYINT UNSIGNED NOT NULL DEFAULT 1, |
892 | - loc_name VARCHAR(40) NOT NULL default '', |
893 | - loc_messages VARCHAR(20) NOT NULL default '', |
894 | - loc_priority tinyint(4) UNSIGNED NOT NULL default '0', |
895 | - loc_enabled tinyint(4) NOT NULL default '1', |
896 | - PRIMARY KEY loc_locale( loc_locale ) |
897 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset COMMENT='saves available locales' |
898 | - " ), |
899 | - |
900 | - 'T_usersettings' => array( 'Creating user settings table', |
901 | - "CREATE TABLE T_usersettings ( |
902 | - uset_user_ID INT(11) UNSIGNED NOT NULL, |
903 | - uset_name VARCHAR( 30 ) NOT NULL, |
904 | - uset_value VARCHAR( 255 ) NULL, |
905 | - PRIMARY KEY ( uset_user_ID, uset_name ) |
906 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
907 | - |
908 | 'T_items__prerendering' => array( 'Creating item prerendering cache table', |
909 | "CREATE TABLE T_items__prerendering( |
910 | itpr_itm_ID INT(11) UNSIGNED NOT NULL, |
911 | @@ -294,106 +280,40 @@ |
912 | itpr_renderers TEXT NOT NULL, |
913 | itpr_content_prerendered MEDIUMTEXT NULL, |
914 | itpr_datemodified TIMESTAMP NOT NULL, |
915 | - PRIMARY KEY (itpr_itm_ID, itpr_format) |
916 | + PRIMARY KEY ( itpr_itm_ID, itpr_format ) |
917 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
918 | |
919 | - 'T_items__version' => array( 'Creating item versions table', |
920 | - "CREATE TABLE T_items__version ( |
921 | - iver_itm_ID INT UNSIGNED NOT NULL , |
922 | - iver_edit_user_ID INT UNSIGNED NULL , |
923 | - iver_edit_datetime DATETIME NOT NULL , |
924 | - iver_status ENUM('published','deprecated','protected','private','draft','redirected') NULL , |
925 | - iver_title TEXT NULL , |
926 | - iver_content MEDIUMTEXT NULL , |
927 | - INDEX iver_itm_ID ( iver_itm_ID ) |
928 | - ) ENGINE = innodb ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
929 | - |
930 | 'T_items__status' => array( 'Creating table for Post Statuses', |
931 | "CREATE TABLE T_items__status ( |
932 | pst_ID INT(11) unsigned not null AUTO_INCREMENT, |
933 | pst_name VARCHAR(30) not null, |
934 | - primary key ( pst_ID ) |
935 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
936 | - |
937 | - 'T_items__type' => array( 'Creating table for Post Types', |
938 | - "CREATE TABLE T_items__type ( |
939 | - ptyp_ID INT(11) unsigned not null AUTO_INCREMENT, |
940 | - ptyp_name VARCHAR(30) not null, |
941 | - primary key (ptyp_ID) |
942 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
943 | - |
944 | - 'T_items__tag' => array( 'Creating table for Tags', |
945 | - "CREATE TABLE T_items__tag ( |
946 | - tag_ID INT(11) unsigned not null AUTO_INCREMENT, |
947 | - tag_name VARCHAR(50) not null, |
948 | - primary key (tag_ID), |
949 | - UNIQUE tag_name( tag_name ) |
950 | + PRIMARY KEY ( pst_ID ) |
951 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
952 | |
953 | 'T_items__itemtag' => array( 'Creating table for Post-to-Tag relationships', |
954 | "CREATE TABLE T_items__itemtag ( |
955 | itag_itm_ID INT(11) unsigned NOT NULL, |
956 | itag_tag_ID INT(11) unsigned NOT NULL, |
957 | - PRIMARY KEY (itag_itm_ID, itag_tag_ID), |
958 | + PRIMARY KEY ( itag_itm_ID, itag_tag_ID ), |
959 | UNIQUE tagitem ( itag_tag_ID, itag_itm_ID ) |
960 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
961 | |
962 | - 'T_files' => array( 'Creating table for File Meta Data', |
963 | - "CREATE TABLE T_files ( |
964 | - file_ID INT(11) unsigned not null AUTO_INCREMENT, |
965 | - file_root_type enum('absolute','user','collection','shared','templates') not null default 'absolute', |
966 | - file_root_ID INT(11) unsigned not null default 0, |
967 | - file_path VARCHAR(255) not null default '', |
968 | - file_title VARCHAR(255), |
969 | - file_alt VARCHAR(255), |
970 | - file_desc text, |
971 | - primary key (file_ID), |
972 | - unique file (file_root_type, file_root_ID, file_path) |
973 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
974 | - |
975 | - 'T_subscriptions' => array( 'Creating table for subscriptions', |
976 | - "CREATE TABLE T_subscriptions ( |
977 | - sub_coll_ID INT(11) unsigned not null, |
978 | - sub_user_ID INT(11) unsigned not null, |
979 | - sub_items tinyint(1) not null, |
980 | - sub_comments tinyint(1) not null, |
981 | - primary key (sub_coll_ID, sub_user_ID) |
982 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
983 | - |
984 | - 'T_coll_user_perms' => array( 'Creating table for Blog-User permissions', |
985 | - "CREATE TABLE T_coll_user_perms ( |
986 | - bloguser_blog_ID INT(11) unsigned NOT NULL default 0, |
987 | - bloguser_user_ID INT(11) unsigned NOT NULL default 0, |
988 | - bloguser_ismember tinyint NOT NULL default 0, |
989 | - bloguser_perm_poststatuses set('published','deprecated','protected','private','draft','redirected') NOT NULL default '', |
990 | - bloguser_perm_edit ENUM('no','own','lt','le','all','redirected') NOT NULL default 'no', |
991 | - bloguser_perm_delpost tinyint NOT NULL default 0, |
992 | - bloguser_perm_comments tinyint NOT NULL default 0, |
993 | - bloguser_perm_cats tinyint NOT NULL default 0, |
994 | - bloguser_perm_properties tinyint NOT NULL default 0, |
995 | - bloguser_perm_admin tinyint NOT NULL default 0, |
996 | - bloguser_perm_media_upload tinyint NOT NULL default 0, |
997 | - bloguser_perm_media_browse tinyint NOT NULL default 0, |
998 | - bloguser_perm_media_change tinyint NOT NULL default 0, |
999 | - PRIMARY KEY bloguser_pk (bloguser_blog_ID,bloguser_user_ID) |
1000 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1001 | - |
1002 | - 'T_coll_group_perms' => array( 'Creating table for blog-group permissions', |
1003 | - "CREATE TABLE T_coll_group_perms ( |
1004 | - bloggroup_blog_ID INT(11) unsigned NOT NULL default 0, |
1005 | - bloggroup_group_ID INT(11) unsigned NOT NULL default 0, |
1006 | - bloggroup_ismember tinyint NOT NULL default 0, |
1007 | - bloggroup_perm_poststatuses set('published','deprecated','protected','private','draft','redirected') NOT NULL default '', |
1008 | - bloggroup_perm_edit ENUM('no','own','lt','le','all','redirected') NOT NULL default 'no', |
1009 | - bloggroup_perm_delpost tinyint NOT NULL default 0, |
1010 | - bloggroup_perm_comments tinyint NOT NULL default 0, |
1011 | - bloggroup_perm_cats tinyint NOT NULL default 0, |
1012 | - bloggroup_perm_properties tinyint NOT NULL default 0, |
1013 | - bloggroup_perm_admin tinyint NOT NULL default 0, |
1014 | - bloggroup_perm_media_upload tinyint NOT NULL default 0, |
1015 | - bloggroup_perm_media_browse tinyint NOT NULL default 0, |
1016 | - bloggroup_perm_media_change tinyint NOT NULL default 0, |
1017 | - PRIMARY KEY bloggroup_pk (bloggroup_blog_ID,bloggroup_group_ID) |
1018 | + 'T_items__type' => array( 'Creating table for Post Types', |
1019 | + "CREATE TABLE T_items__type ( |
1020 | + ptyp_ID INT(11) unsigned not null AUTO_INCREMENT, |
1021 | + ptyp_name VARCHAR(30) not null, |
1022 | + PRIMARY KEY ( ptyp_ID ) |
1023 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1024 | + |
1025 | + 'T_items__version' => array( 'Creating item versions table', |
1026 | + "CREATE TABLE T_items__version ( |
1027 | + iver_itm_ID INT UNSIGNED NOT NULL, |
1028 | + iver_edit_user_ID INT UNSIGNED NULL, |
1029 | + iver_edit_datetime DATETIME NOT NULL, |
1030 | + iver_status ENUM('published','deprecated','protected','private','draft','redirected') NULL, |
1031 | + iver_title TEXT NULL, |
1032 | + iver_content MEDIUMTEXT NULL, |
1033 | + INDEX iver_itm_ID ( iver_itm_ID ) |
1034 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1035 | |
1036 | 'T_links' => array( 'Creating table for Post Links', |
1037 | @@ -409,23 +329,26 @@ |
1038 | link_ltype_ID INT(11) unsigned NOT NULL default 1, |
1039 | link_external_url VARCHAR(255) NULL, |
1040 | link_title TEXT NULL, |
1041 | - PRIMARY KEY (link_ID), |
1042 | + PRIMARY KEY ( link_ID ), |
1043 | INDEX link_itm_ID( link_itm_ID ), |
1044 | INDEX link_dest_itm_ID (link_dest_itm_ID), |
1045 | INDEX link_file_ID (link_file_ID) |
1046 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1047 | |
1048 | - 'T_filetypes' => array( 'Creating table for file types', |
1049 | - "CREATE TABLE T_filetypes ( |
1050 | - ftyp_ID INT(11) unsigned NOT NULL auto_increment, |
1051 | - ftyp_extensions VARCHAR(30) NOT NULL, |
1052 | - ftyp_name VARCHAR(30) NOT NULL, |
1053 | - ftyp_mimetype VARCHAR(50) NOT NULL, |
1054 | - ftyp_icon VARCHAR(20) default NULL, |
1055 | - ftyp_viewtype VARCHAR(10) NOT NULL, |
1056 | - ftyp_allowed tinyint(1) NOT NULL default 0, |
1057 | - PRIMARY KEY (ftyp_ID) |
1058 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1059 | + 'T_locales' => array( 'Creating table for Locales', |
1060 | + "CREATE TABLE T_locales ( |
1061 | + loc_locale VARCHAR(20) NOT NULL default '', |
1062 | + loc_charset VARCHAR(15) NOT NULL default 'iso-8859-1', |
1063 | + loc_datefmt VARCHAR(20) NOT NULL default 'y-m-d', |
1064 | + loc_timefmt VARCHAR(20) NOT NULL default 'H:i:s', |
1065 | + loc_startofweek TINYINT UNSIGNED NOT NULL DEFAULT 1, |
1066 | + loc_name VARCHAR(40) NOT NULL default '', |
1067 | + loc_messages VARCHAR(20) NOT NULL default '', |
1068 | + loc_priority TINYINT(4) UNSIGNED NOT NULL default '0', |
1069 | + loc_enabled TINYINT(4) NOT NULL default '1', |
1070 | + PRIMARY KEY loc_locale( loc_locale ) |
1071 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset COMMENT='saves available locales' |
1072 | + " ), |
1073 | |
1074 | 'T_plugins' => array( 'Creating plugins table', |
1075 | "CREATE TABLE T_plugins ( |
1076 | @@ -449,7 +372,7 @@ |
1077 | pevt_plug_ID INT(11) UNSIGNED NOT NULL, |
1078 | pevt_event VARCHAR(40) NOT NULL, |
1079 | pevt_enabled TINYINT NOT NULL DEFAULT 1, |
1080 | - PRIMARY KEY( pevt_plug_ID, pevt_event ) |
1081 | + PRIMARY KEY ( pevt_plug_ID, pevt_event ) |
1082 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1083 | |
1084 | 'T_pluginsettings' => array( 'Creating plugin settings table', |
1085 | @@ -460,6 +383,115 @@ |
1086 | PRIMARY KEY ( pset_plug_ID, pset_name ) |
1087 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1088 | |
1089 | + 'T_pluginusersettings' => array( 'Creating plugin user settings table', |
1090 | + "CREATE TABLE T_pluginusersettings ( |
1091 | + puset_plug_ID INT(11) UNSIGNED NOT NULL, |
1092 | + puset_user_ID INT(11) UNSIGNED NOT NULL, |
1093 | + puset_name VARCHAR( 30 ) NOT NULL, |
1094 | + puset_value TEXT NULL, |
1095 | + PRIMARY KEY ( puset_plug_ID, puset_user_ID, puset_name ) |
1096 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1097 | + |
1098 | + 'T_settings' => array( 'Creating table for Settings', |
1099 | + "CREATE TABLE T_settings ( |
1100 | + set_name VARCHAR( 30 ) NOT NULL, |
1101 | + set_value VARCHAR( 255 ) NULL, |
1102 | + PRIMARY KEY ( set_name ) |
1103 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1104 | + |
1105 | + 'T_subscriptions' => array( 'Creating table for subscriptions', |
1106 | + "CREATE TABLE T_subscriptions ( |
1107 | + sub_coll_ID INT(11) unsigned not null, |
1108 | + sub_user_ID INT(11) unsigned not null, |
1109 | + sub_items TINYINT(1) not null, |
1110 | + sub_comments TINYINT(1) not null, |
1111 | + PRIMARY KEY ( sub_coll_ID, sub_user_ID ) |
1112 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1113 | + |
1114 | + 'T_items__tag' => array( 'Creating table for Tags', |
1115 | + "CREATE TABLE T_items__tag ( |
1116 | + tag_ID INT(11) unsigned not null AUTO_INCREMENT, |
1117 | + tag_name VARCHAR(50) not null, |
1118 | + PRIMARY KEY ( tag_ID ), |
1119 | + UNIQUE tag_name( tag_name ) |
1120 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1121 | + |
1122 | + 'T_templates__template' => array( 'Creating table for installed templates', |
1123 | + "CREATE TABLE T_templates__template ( |
1124 | + template_ID INT(10) unsigned NOT NULL auto_increment, |
1125 | + template_name VARCHAR(32) NOT NULL, |
1126 | + template_type ENUM('xhtml','feed','other') NOT NULL default 'xhtml', |
1127 | + template_folder VARCHAR(32) NOT NULL, |
1128 | + PRIMARY KEY template_ID (template_ID), |
1129 | + UNIQUE template_folder( template_folder ), |
1130 | + KEY template_name( template_name ) |
1131 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1132 | + |
1133 | + 'T_templates__container' => array( 'Creating table for template containers', |
1134 | + "CREATE TABLE T_templates__container ( |
1135 | + sco_template_ID INT(10) unsigned NOT NULL, |
1136 | + sco_name VARCHAR(40) NOT NULL, |
1137 | + PRIMARY KEY ( sco_template_ID, sco_name ) |
1138 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1139 | + |
1140 | + 'T_users' => array( 'Creating users table', |
1141 | + "CREATE TABLE T_users ( |
1142 | + user_ID INT(11) unsigned NOT NULL auto_increment, |
1143 | + user_login VARCHAR(20) NOT NULL, |
1144 | + user_pass CHAR(40) NOT NULL, |
1145 | + user_firstname VARCHAR(50) NULL, |
1146 | + user_lastname VARCHAR(50) NULL, |
1147 | + user_nickname VARCHAR(50) NULL, |
1148 | + user_email VARCHAR(255) NOT NULL, |
1149 | + user_url VARCHAR(255) NULL, |
1150 | + user_ip VARCHAR(15) NULL, |
1151 | + user_domain VARCHAR(200) NULL, |
1152 | + user_browser VARCHAR(200) NULL, |
1153 | + dateYMDhour DATETIME NOT NULL DEFAULT '2000-01-01 00:00:00', |
1154 | + user_level int unsigned DEFAULT 0 NOT NULL, |
1155 | + user_locale VARCHAR(20) DEFAULT 'en-EU' NOT NULL, |
1156 | + user_idmode VARCHAR(20) NOT NULL DEFAULT 'login', |
1157 | + user_allow_msgform TINYINT NOT NULL DEFAULT '1', |
1158 | + user_notify TINYINT(1) NOT NULL default 1, |
1159 | + user_showonline TINYINT(1) NOT NULL default 1, |
1160 | + user_grp_ID INT(4) NOT NULL default 1, |
1161 | + user_validated TINYINT(1) NOT NULL DEFAULT 0, |
1162 | + user_avatar_ID INT(10) NULL, |
1163 | + user_biography TEXT NULL DEFAULT NULL, |
1164 | + PRIMARY KEY user_ID (user_ID), |
1165 | + UNIQUE user_login (user_login), |
1166 | + KEY user_grp_ID (user_grp_ID) |
1167 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1168 | + |
1169 | + 'T_global__cache' => array( 'Creating table for Caches', |
1170 | + "CREATE TABLE T_global__cache ( |
1171 | + cach_name VARCHAR( 30 ) NOT NULL, |
1172 | + cach_cache MEDIUMBLOB NULL, |
1173 | + PRIMARY KEY ( cach_name ) |
1174 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1175 | + |
1176 | + 'T_widget' => array( 'Creating components table', |
1177 | + "CREATE TABLE T_widget ( |
1178 | + wi_ID INT(10) UNSIGNED auto_increment, |
1179 | + wi_coll_ID INT(11) UNSIGNED NOT NULL, |
1180 | + wi_sco_name VARCHAR( 40 ) NOT NULL, |
1181 | + wi_order INT(10) NOT NULL, |
1182 | + wi_enabled TINYINT(1) NOT NULL DEFAULT 1, |
1183 | + wi_type ENUM( 'widget', 'plugin' ) NOT NULL DEFAULT 'widget', |
1184 | + wi_code VARCHAR(32) NOT NULL, |
1185 | + wi_params TEXT NULL, |
1186 | + PRIMARY KEY ( wi_ID ), |
1187 | + UNIQUE wi_order( wi_coll_ID, wi_sco_name, wi_order ) |
1188 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1189 | + |
1190 | + 'T_usersettings' => array( 'Creating user settings table', |
1191 | + "CREATE TABLE T_usersettings ( |
1192 | + uset_user_ID INT(11) UNSIGNED NOT NULL, |
1193 | + uset_name VARCHAR( 30 ) NOT NULL, |
1194 | + uset_value VARCHAR( 255 ) NULL, |
1195 | + PRIMARY KEY ( uset_user_ID, uset_name ) |
1196 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1197 | + |
1198 | /** |
1199 | * This table holds info about fields a plugin might want to access and |
1200 | * use. The only time it gets called is on a plugin's settings page |
1201 | @@ -472,7 +504,7 @@ |
1202 | psf_type VARCHAR(255) NOT NULL, -- probably only 'text', maybe 'checkbox', 'select' is crazy talk! |
1203 | psf_note VARCHAR(255) NOT NULL, |
1204 | psf_validate VARCHAR(255) NOT NULL, -- make sure a url is a url ... for example |
1205 | - PRIMARY KEY (psf_fieldname) |
1206 | + PRIMARY KEY ( psf_fieldname ) |
1207 | ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1208 | |
1209 | /** |
1210 | @@ -487,39 +519,9 @@ |
1211 | psv_user_ID INT(10) unsigned NOT NULL, |
1212 | psv_psf_fieldname VARCHAR(32) NOT NULL, |
1213 | psv_userfieldvalue VARCHAR(255) NOT NULL, |
1214 | - PRIMARY KEY (psv_ID) |
1215 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1216 | - |
1217 | - 'T_pluginusersettings' => array( 'Creating plugin user settings table', |
1218 | - "CREATE TABLE T_pluginusersettings ( |
1219 | - puset_plug_ID INT(11) UNSIGNED NOT NULL, |
1220 | - puset_user_ID INT(11) UNSIGNED NOT NULL, |
1221 | - puset_name VARCHAR( 30 ) NOT NULL, |
1222 | - puset_value TEXT NULL, |
1223 | - PRIMARY KEY ( puset_plug_ID, puset_user_ID, puset_name ) |
1224 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1225 | - |
1226 | - 'T_cron__task' => array( 'Creating cron tasks table', |
1227 | - "CREATE TABLE T_cron__task( |
1228 | - ctsk_ID INT(10) unsigned not null AUTO_INCREMENT, |
1229 | - ctsk_start_datetime datetime not null DEFAULT '2000-01-01 00:00:00', |
1230 | - ctsk_repeat_after INT(10) unsigned, |
1231 | - ctsk_name VARCHAR(50) not null, |
1232 | - ctsk_controller VARCHAR(50) not null, |
1233 | - ctsk_params text, |
1234 | - PRIMARY KEY (ctsk_ID) |
1235 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1236 | - |
1237 | - 'T_cron__log' => array( 'Creating cron tasks table', |
1238 | - "CREATE TABLE T_cron__log( |
1239 | - clog_ctsk_ID INT(10) unsigned not null, |
1240 | - clog_realstart_datetime datetime not null DEFAULT '2000-01-01 00:00:00', |
1241 | - clog_realstop_datetime datetime, |
1242 | - clog_status enum('started','finished','error','timeout') not null default 'started', |
1243 | - clog_messages text, |
1244 | - PRIMARY KEY (clog_ctsk_ID) |
1245 | - ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1246 | + PRIMARY KEY ( psv_ID ) |
1247 | + ) ENGINE = innodb DEFAULT CHARSET = $db_storage_charset" ), |
1248 | + |
1249 | ); |
1250 | |
1251 | - |
1252 | ?> |
1253 | |
1254 | === modified file 'qp_inc/files/files.ctrl.php' |
1255 | --- qp_inc/files/files.ctrl.php 2011-08-19 16:20:19 +0000 |
1256 | +++ qp_inc/files/files.ctrl.php 2013-03-05 23:36:23 +0000 |
1257 | @@ -1,63 +1,32 @@ |
1258 | <?php |
1259 | /** |
1260 | - * This file implements the UI controller for file management. |
1261 | + * $ctrl_mappings: 'files' || Files -> browse (not upload) |
1262 | * |
1263 | - * NOTE: $fm_mode is used for modes. Modes stay visible when browsing to a different location. |
1264 | - * Examples of modes: link item, copy file. |
1265 | + * NOTE: $fm_mode is used for modes. Modes stay visible when browsing to a different |
1266 | + * location. |
1267 | + * - Examples of modes: link item, copy file. |
1268 | * Actions disappear if you browse to a different location. |
1269 | - * Examples of actions: file properties, file edit. |
1270 | - * |
1271 | - * fp>> Movr/copy should not be a mode (too geeky). All we need is a dir selection tree inside of upload and move. |
1272 | - * |
1273 | - * This file is part of Quam Plures - {@link http://quamplures.net/} |
1274 | - * See also {@link https://launchpad.net/quam-plures}. |
1275 | - * |
1276 | - * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/} |
1277 | - * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/} |
1278 | - * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}. |
1279 | - * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}. |
1280 | - * |
1281 | - * {@internal License choice |
1282 | - * - If you have received this file as part of a package, please find the license.txt file in |
1283 | - * the same folder or the closest folder above for complete license terms. |
1284 | - * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) |
1285 | - * then you must choose one of the following licenses before using the file: |
1286 | - * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php |
1287 | - * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php |
1288 | - * }} |
1289 | - * |
1290 | - * {@internal Open Source relicensing agreement: |
1291 | - * Daniel HAHLER grants Francois PLANQUE the right to license |
1292 | - * Daniel HAHLER's contributions to this file and the b2evolution project |
1293 | - * under any OSI approved OSS license (http://www.opensource.org/licenses/). |
1294 | - * |
1295 | - * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license |
1296 | - * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project |
1297 | - * under any OSI approved OSS license (http://www.opensource.org/licenses/). |
1298 | - * }} |
1299 | - * |
1300 | - * {@internal Below is a list of authors who have contributed to design/coding of this file: }} |
1301 | - * @author blueyed: Daniel HAHLER. |
1302 | - * @author fplanque: Francois PLANQUE. |
1303 | - * |
1304 | + * - Examples of actions: file properties, file edit. |
1305 | + * |
1306 | + * @todo (1111): why does upload have it's own controller? |
1307 | + * @uses Zip_Archive |
1308 | + * @author {@link http://wonderwinds.com/ Ed Bennett} |
1309 | + * @author {@link http://progidistri.com/ PROGIDISTRI} |
1310 | + * @author {@link http://daniel.hahler.de/ Daniel HAHLER} |
1311 | + * @author {@link http://fplanque.net/ Francois PLANQUE} |
1312 | + * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project} |
1313 | + * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 |
1314 | * @package files |
1315 | */ |
1316 | -if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
1317 | - |
1318 | -/** |
1319 | - * Filelist |
1320 | - * fp>> TODO: When the user is viewing details for a file he should (by default) not be presented with the filelist in addition to the file properties |
1321 | - * In cases like that, we should try to avoid instanciating a Filelist. |
1322 | - */ |
1323 | -load_class('files/model/_filelist.class.php'); |
1324 | - |
1325 | +if(!defined('QP_MAIN_INIT')) die('fail'); |
1326 | + |
1327 | +global $dispatcher; |
1328 | global $current_User; |
1329 | -global $dispatcher; |
1330 | |
1331 | -// Check global access permissions: |
1332 | +// Check global access permissions |
1333 | if( ! $Settings->get( 'fm_enabled' ) ) |
1334 | { |
1335 | - // File Manager is disabled, so let's be kind and give them something to work with |
1336 | + // File Manager is disabled, so give them something to work with |
1337 | $AdminUI->set_coll_list_params( 'blog_ismember', 'view', array(), T_('Global'), '?blog=0' ); |
1338 | $AdminUI->set_path( 'dashboard' ); |
1339 | $AdminUI->disp_html_head(); |
1340 | @@ -67,58 +36,73 @@ |
1341 | die(); |
1342 | } |
1343 | |
1344 | -// Check permission: |
1345 | +// Check permission |
1346 | $current_User->check_perm( 'files', 'view', true ); |
1347 | |
1348 | $AdminUI->set_path( 'files', 'browse' ); |
1349 | |
1350 | -// INIT params: |
1351 | +// INIT params |
1352 | if( param( 'root_and_path', 'string', '', false ) /* not memorized (default) */ && strpos( $root_and_path, '::' ) ) |
1353 | -{ // root and path together: decode and override (used by "radio-click-dirtree") |
1354 | +{ |
1355 | + // root and path together: decode and override (used by "radio-click-dirtree") |
1356 | list( $root, $path ) = explode( '::', $root_and_path, 2 ); |
1357 | - // Memorize new root: |
1358 | + // Memorize new root |
1359 | memorize_param( 'root', 'string', NULL ); |
1360 | memorize_param( 'path', 'string', NULL ); |
1361 | } |
1362 | else |
1363 | { |
1364 | - param( 'root', 'string', NULL, true ); // the root directory from the dropdown box (user_X or blog_X; X is ID - 'user' for current user (default)) |
1365 | - param( 'path', 'string', '/', true ); // the path relative to the root dir |
1366 | - if( param( 'new_root', 'string', '' ) |
1367 | - && $new_root != $root ) |
1368 | - { // We have changed root in the select list |
1369 | + // the root directory from the dropdown box (user_X or blog_X; X is ID - 'user' for current user (default)) |
1370 | + param( 'root', 'string', NULL, true ); |
1371 | + |
1372 | + // the path relative to the root dir |
1373 | + param( 'path', 'string', '/', true ); |
1374 | + |
1375 | + if( param( 'new_root', 'string', '' ) && $new_root != $root ) |
1376 | + { |
1377 | + // We have changed root in the select list |
1378 | $root = $new_root; |
1379 | $path = ''; |
1380 | } |
1381 | } |
1382 | |
1383 | -// Load linkable objects: |
1384 | +// Load linkable objects |
1385 | if( param( 'item_ID', 'integer', NULL, true, false, false ) ) |
1386 | -{ // Load Requested iem: |
1387 | +{ |
1388 | + // Load Requested iem |
1389 | $ItemCache = & get_Cache( 'ItemCache' ); |
1390 | - if( ($edited_Item = & $ItemCache->get_by_ID( $item_ID, false )) === false ) |
1391 | - { // We could not find the contact to link: |
1392 | + |
1393 | + if( ( $edited_Item = & $ItemCache->get_by_ID( $item_ID, false ) ) === false ) |
1394 | + { |
1395 | + // We could not find the contact to link |
1396 | $Messages->add( T_('Requested item does not exist any longer.'), 'error' ); |
1397 | unset( $edited_Item ); |
1398 | forget_param( 'item_ID' ); |
1399 | unset( $item_ID ); |
1400 | } |
1401 | + |
1402 | } |
1403 | |
1404 | if( param( 'user_ID', 'integer', NULL, true, false, false ) ) |
1405 | -{ // Load Requested user: |
1406 | +{ |
1407 | + // Load Requested user |
1408 | $UserCache = & get_Cache( 'UserCache' ); |
1409 | - if( ($edited_User = & $UserCache->get_by_ID( $user_ID, false )) === false ) |
1410 | - { // We could not find the contact to link: |
1411 | + |
1412 | + if( ( $edited_User = & $UserCache->get_by_ID( $user_ID, false ) ) === false ) |
1413 | + { |
1414 | + // We could not find the contact to link |
1415 | $Messages->add( T_('Requested user does not exist any longer.'), 'error' ); |
1416 | unset( $edited_User ); |
1417 | forget_param( 'user_ID' ); |
1418 | unset( $user_ID ); |
1419 | } |
1420 | else |
1421 | - { // Found User, check perm: |
1422 | + { |
1423 | + // Found User, check perm |
1424 | if( $edited_User->ID != $current_User->ID ) |
1425 | - { // if not editing himself, must have user edit permission: |
1426 | + { |
1427 | + |
1428 | + // if not editing himself, must have user edit permission |
1429 | if( ! $current_User->check_perm( 'users', 'edit' ) ) |
1430 | { |
1431 | $Messages->add( T_('No permission to edit this user.'), 'error' ); |
1432 | @@ -126,97 +110,101 @@ |
1433 | forget_param( 'user_ID' ); |
1434 | unset( $user_ID ); |
1435 | } |
1436 | + |
1437 | } |
1438 | |
1439 | } |
1440 | + |
1441 | } |
1442 | |
1443 | -/** |
1444 | - * @global string The file manager mode we're in ('fm_upload', 'fm_move') |
1445 | - */ |
1446 | $fm_mode = param( 'fm_mode', 'string', NULL, true ); |
1447 | |
1448 | $action = param_action(); |
1449 | if( $action == 'group_action' ) |
1450 | -{ // Get the real action from the select: |
1451 | +{ |
1452 | + // Get the real action from the select |
1453 | $action = param( 'group_action', 'string', '' ); |
1454 | } |
1455 | |
1456 | -if( !empty($action) && substr( $fm_mode, 0, 5 ) != 'link_' ) |
1457 | -{ // The only modes which can tolerate simultaneous actions at this time are link_* modes (item, user...) |
1458 | +if( ! empty( $action ) && substr( $fm_mode, 0, 5 ) != 'link_' ) |
1459 | +{ |
1460 | + // The only modes which can tolerate simultaneous actions at this time are link_* modes (item, user...) |
1461 | // file_move & file_copy shouldn't actually be modes |
1462 | $fm_mode = ''; |
1463 | } |
1464 | |
1465 | -// Name of the iframe we want some actions to come back to: |
1466 | +// Name of the iframe we want some actions to come back to |
1467 | param( 'iframe_name', 'string', '', true ); |
1468 | |
1469 | -// Get root: |
1470 | +// Get root |
1471 | $ads_list_path = false; // false by default, gets set if we have a valid root |
1472 | -/** |
1473 | - * @var FileRoot |
1474 | - */ |
1475 | $fm_FileRoot = NULL; |
1476 | - |
1477 | $FileRootCache = & get_Cache( 'FileRootCache' ); |
1478 | - |
1479 | $available_Roots = $FileRootCache->get_available_FileRoots(); |
1480 | |
1481 | -if( ! empty($root) ) |
1482 | -{ // We have requested a root folder by string: |
1483 | - $fm_FileRoot = & $FileRootCache->get_by_ID($root, true); |
1484 | +if( ! empty( $root ) ) |
1485 | +{ |
1486 | + // We have requested a root folder by string |
1487 | + $fm_FileRoot = & $FileRootCache->get_by_ID( $root, true ); |
1488 | |
1489 | if( ! $fm_FileRoot || ! isset( $available_Roots[$fm_FileRoot->ID] ) ) |
1490 | - { // Root not found or not in list of available ones |
1491 | + { |
1492 | + // Root not found or not in list of available ones |
1493 | $Messages->add( T_('You don\'t have access to the requested root directory.'), 'error' ); |
1494 | $fm_FileRoot = false; |
1495 | } |
1496 | } |
1497 | -elseif( !empty($edited_Item) ) |
1498 | -{ // We have a post, check if it already has a linked file in a particular root, in which case we want to use that root! |
1499 | - // This is useful when whlicking "attach files" from teh post edit screen: it takes you to the root where you have |
1500 | - // already attached files from. Otherwise the next block below will default to the Blog's fileroot. |
1501 | - // Get list of attached files: |
1502 | +elseif( ! empty( $edited_Item ) ) |
1503 | +{ |
1504 | + // We have a post, check if it already has a linked file in a particular root, in |
1505 | + // which case we want to use that root! This is useful when whlicking "attach files" |
1506 | + // from the post edit screen: it takes you to the root where you have already attached |
1507 | + // files from. Otherwise the next block below will default to the Blog's fileroot. |
1508 | + |
1509 | + // Get list of attached files |
1510 | $FileList = $edited_Item->get_attachment_FileList( 1 ); |
1511 | - // Get first file: |
1512 | - /** |
1513 | - * @var File |
1514 | - */ |
1515 | + |
1516 | + // Get first file |
1517 | $File = & $FileList->get_next(); |
1518 | - if( !empty( $File ) ) |
1519 | - { // Obtain and use file root of first file: |
1520 | + if( ! empty( $File ) ) |
1521 | + { |
1522 | + // Obtain and use file root of first file |
1523 | $fm_FileRoot = & $File->get_FileRoot(); |
1524 | $path = dirname( $File->get_rdfs_rel_path() ).'/'; |
1525 | } |
1526 | + |
1527 | } |
1528 | |
1529 | - |
1530 | -if( empty($fm_FileRoot) && !empty($edited_User) ) |
1531 | -{ // Still not set a root, try to get it for the edited User |
1532 | +if( empty( $fm_FileRoot ) && ! empty( $edited_User ) ) |
1533 | +{ |
1534 | + // Still not set a root, try to get it for the edited User |
1535 | $fm_FileRoot = & $FileRootCache->get_by_type_and_ID( 'user', $edited_User->ID ); |
1536 | if( ! $fm_FileRoot || ! isset( $available_Roots[$fm_FileRoot->ID] ) ) |
1537 | - { // Root not found or not in list of available ones |
1538 | + { |
1539 | + // Root not found or not in list of available ones |
1540 | $fm_FileRoot = false; |
1541 | } |
1542 | } |
1543 | |
1544 | -if( empty($fm_FileRoot) && !empty($Blog) ) |
1545 | -{ // Still not set a root, try to get it for the current Blog |
1546 | +if( empty( $fm_FileRoot ) && ! empty( $Blog ) ) |
1547 | +{ |
1548 | + // Still not set a root, try to get it for the current Blog |
1549 | $fm_FileRoot = & $FileRootCache->get_by_type_and_ID( 'collection', $Blog->ID ); |
1550 | if( ! $fm_FileRoot || ! isset( $available_Roots[$fm_FileRoot->ID] ) ) |
1551 | - { // Root not found or not in list of available ones |
1552 | + { |
1553 | + // Root not found or not in list of available ones |
1554 | $fm_FileRoot = false; |
1555 | } |
1556 | } |
1557 | |
1558 | - |
1559 | if( ! $fm_FileRoot ) |
1560 | -{ // No root requested (or the requested is invalid), |
1561 | - // get the first one available: |
1562 | +{ |
1563 | + // No root requested (or the requested is invalid), get the first one available |
1564 | if( $available_Roots |
1565 | - && ( $tmp_keys = array_keys( $available_Roots ) ) |
1566 | - && $first_Root = & $available_Roots[ $tmp_keys[0] ] ) |
1567 | - { // get the first one |
1568 | + && ( $tmp_keys = array_keys( $available_Roots ) ) |
1569 | + && $first_Root = & $available_Roots[$tmp_keys[0]] ) |
1570 | + { |
1571 | + // get the first one |
1572 | $fm_FileRoot = & $first_Root; |
1573 | } |
1574 | else |
1575 | @@ -226,44 +214,50 @@ |
1576 | } |
1577 | |
1578 | if( $fm_FileRoot ) |
1579 | -{ // We have access to a file root: |
1580 | - if( empty($fm_FileRoot->ads_path) ) |
1581 | - { // Not sure it's possible to get this far, but just in case... |
1582 | +{ |
1583 | + // We have access to a file root |
1584 | + if( empty( $fm_FileRoot->ads_path ) ) |
1585 | + { |
1586 | + // Not sure it's possible to get this far, but just in case... |
1587 | $Messages->add( sprintf( T_('The root directory «%s» does not exist.'), $fm_FileRoot->ads_path ), 'error' ); |
1588 | } |
1589 | else |
1590 | - { // Root exists |
1591 | - |
1592 | - // Make sure $root is set: |
1593 | + { |
1594 | + // Root exists |
1595 | + // Make sure $root is set |
1596 | $root = $fm_FileRoot->ID; |
1597 | |
1598 | // Let's get into requested list dir... |
1599 | $non_canonical_list_path = $fm_FileRoot->ads_path.$path; |
1600 | |
1601 | - // Dereference any /../ just to make sure, and CHECK if directory exists: |
1602 | + // Dereference any /../ just to make sure, and CHECK if directory exists |
1603 | $ads_list_path = get_canonical_path( $non_canonical_list_path ); |
1604 | |
1605 | - if( !is_dir( $ads_list_path ) ) |
1606 | - { // This should never happen, but just in case the diretory does not exist: |
1607 | + if( ! is_dir( $ads_list_path ) ) |
1608 | + { |
1609 | + // This should never happen, but just in case the diretory does not exist |
1610 | $Messages->add( sprintf( T_('The directory «%s» does not exist.'), $path ), 'error' ); |
1611 | - $path = ''; // fp> added |
1612 | + $path = ''; // fp> added |
1613 | $ads_list_path = NULL; |
1614 | } |
1615 | - elseif( ! preg_match( '#^'.preg_quote($fm_FileRoot->ads_path, '#').'#', $ads_list_path ) ) |
1616 | - { // cwd is OUTSIDE OF root! |
1617 | + elseif( ! preg_match( '#^'.preg_quote( $fm_FileRoot->ads_path, '#' ).'#', $ads_list_path ) ) |
1618 | + { |
1619 | + // cwd is OUTSIDE OF root! |
1620 | $Messages->add( T_( 'You are not allowed to go outside your root directory!' ), 'error' ); |
1621 | - $path = ''; // fp> added |
1622 | + $path = ''; // fp> added |
1623 | $ads_list_path = $fm_FileRoot->ads_path; |
1624 | } |
1625 | elseif( $ads_list_path != $non_canonical_list_path ) |
1626 | - { // We have reduced the absolute path, we should also reduce the relative $path (used in urls params) |
1627 | + { |
1628 | + // We have reduced the absolute path, we should also reduce the relative $path (used in urls params) |
1629 | $path = get_canonical_path( $path ); |
1630 | } |
1631 | } |
1632 | } |
1633 | |
1634 | -if( empty($ads_list_path) ) |
1635 | -{ // We have no Root / list path, there was an error. Unset any action or mode. |
1636 | +if( empty( $ads_list_path ) ) |
1637 | +{ |
1638 | + // We have no Root / list path, there was an error. Unset any action or mode |
1639 | $action = 'nil'; |
1640 | $fm_mode = NULL; |
1641 | |
1642 | @@ -274,39 +268,25 @@ |
1643 | exit(0); |
1644 | } |
1645 | |
1646 | -$Debuglog->add( 'root: '.var_export( $root, true ), 'files' ); |
1647 | -$Debuglog->add( 'FM root: '.var_export( $fm_FileRoot, true ), 'files' ); |
1648 | -$Debuglog->add( 'FM _ads_list_path: '.var_export( $ads_list_path, true ), 'files' ); |
1649 | -$Debuglog->add( 'path: '.var_export( $path, true ), 'files' ); |
1650 | - |
1651 | - |
1652 | -/** |
1653 | - * A list of filepaths which are selected in the FM list. |
1654 | - * |
1655 | - * @todo fp> This could probably be further simpplified by using "fm_sources" for selections. |
1656 | - * Note: fm_sources is better because it also handles sources/selections on a different fileroot |
1657 | - * |
1658 | - * @global array |
1659 | - */ |
1660 | +// A list of filepaths which are selected in the FM list. |
1661 | +// @todo fp> This could probably be further simpplified by using "fm_sources" for selections. |
1662 | +// Note: fm_sources is better because it also handles sources/selections on a different fileroot |
1663 | $fm_selected = param( 'fm_selected', 'array', array(), true ); |
1664 | -$Debuglog->add( count($fm_selected).' selected files/directories', 'files' ); |
1665 | -/** |
1666 | - * The selected files (must be within current fileroot) |
1667 | - * |
1668 | - * @global Filelist |
1669 | - */ |
1670 | + |
1671 | +// The selected files (must be within current fileroot) |
1672 | $selected_Filelist = new Filelist( $fm_FileRoot, false ); |
1673 | foreach( $fm_selected as $l_source_path ) |
1674 | { |
1675 | - $selected_Filelist->add_by_subpath( urldecode($l_source_path), true ); |
1676 | + $selected_Filelist->add_by_subpath( urldecode( $l_source_path ), true ); |
1677 | } |
1678 | |
1679 | -// Load editable objects: |
1680 | +// Load editable objects |
1681 | if( param( 'link_ID', 'integer', NULL, false, false, false ) ) |
1682 | { |
1683 | $LinkCache = & get_Cache( 'LinkCache' ); |
1684 | - if( ($edited_Link = & $LinkCache->get_by_ID( $link_ID, false )) === false ) |
1685 | - { // We could not find the link to edit: |
1686 | + if( ( $edited_Link = & $LinkCache->get_by_ID( $link_ID, false ) ) === false ) |
1687 | + { |
1688 | + // We could not find the link to edit |
1689 | $Messages->add( T_('Requested link does not exist any longer.'), 'error' ); |
1690 | unset( $edited_Link ); |
1691 | forget_param( 'link_ID' ); |
1692 | @@ -317,188 +297,185 @@ |
1693 | // Check actions that need early processing: |
1694 | if( $action == 'createnew' ) |
1695 | { |
1696 | - // Check permission: |
1697 | + // Check permission |
1698 | $current_User->check_perm( 'files', 'add', true ); |
1699 | |
1700 | // create new file/dir |
1701 | param( 'create_type', 'string', true ); // 'file', 'dir' |
1702 | |
1703 | - $action = ( $create_type == 'file' ? 'createnew_file' : 'createnew_dir' ); |
1704 | + $action = ( $create_type == 'file' ? 'createnew_file' : 'createnew_dir' ); |
1705 | } |
1706 | |
1707 | switch( $action ) |
1708 | { |
1709 | case 'filter': |
1710 | - $action = 'list'; |
1711 | - break; |
1712 | + $action = 'list'; |
1713 | + break; |
1714 | |
1715 | case 'filter_unset': |
1716 | - // Clear filters! |
1717 | - $fm_filter = ''; |
1718 | - $action = 'list'; |
1719 | - break; |
1720 | + // Clear filters! |
1721 | + $fm_filter = ''; |
1722 | + $action = 'list'; |
1723 | + break; |
1724 | |
1725 | case 'createnew_dir': |
1726 | - // We are probably comming from 'createnew' but there is no guarantee! |
1727 | - // Check permission: |
1728 | - $current_User->check_perm( 'files', 'add', true ); |
1729 | - |
1730 | - if( ! $Settings->get( 'fm_enable_create_dir' ) ) |
1731 | - { // Directory creation is gloablly disabled: |
1732 | - $Messages->add( T_('Directory creation is disabled.'), 'error' ); |
1733 | - break; |
1734 | - } |
1735 | - |
1736 | - if( ! param( 'create_name', 'string', '' ) ) |
1737 | - { // No name was supplied: |
1738 | - $Messages->add( T_('Cannot create a directory without name.'), 'error' ); |
1739 | - break; |
1740 | - } |
1741 | - |
1742 | - if( $error_dirname = validate_dirname( $create_name ) ) |
1743 | - { // Not valid dirname |
1744 | - $Messages->add( $error_dirname, 'error' ); |
1745 | - break; |
1746 | - } |
1747 | - |
1748 | - // Try to get File object: |
1749 | - /** |
1750 | - * @var FileCache |
1751 | - */ |
1752 | - $FileCache = & get_Cache( 'FileCache' ); |
1753 | - /** |
1754 | - * @var File |
1755 | - */ |
1756 | - $newFile = & $FileCache->get_by_root_and_path( $fm_FileRoot->type, $fm_FileRoot->in_type_ID, $path.$create_name ); |
1757 | - |
1758 | - if( $newFile->exists() ) |
1759 | - { |
1760 | - $Messages->add( sprintf( T_('The file «%s» already exists.'), $create_name ), 'error' ); |
1761 | - break; |
1762 | - } |
1763 | - |
1764 | - if( ! $newFile->create( $create_type ) ) |
1765 | - { |
1766 | - $Messages->add( sprintf( T_('Could not create directory «%s» in «%s».'), $create_name, $fm_Filelist->_rds_list_path ), 'error' ); |
1767 | - } |
1768 | - |
1769 | - $Messages->add( sprintf( T_('The directory «%s» has been created.'), $create_name ), 'success' ); |
1770 | - |
1771 | - header_redirect( regenerate_url( '', '', '', '&' ) ); |
1772 | - // $action = 'list'; |
1773 | - break; |
1774 | - |
1775 | + // We are probably comming from 'createnew' but there is no guarantee! |
1776 | + |
1777 | + // Check permission |
1778 | + $current_User->check_perm( 'files', 'add', true ); |
1779 | + |
1780 | + if( ! $Settings->get( 'fm_enable_create_dir' ) ) |
1781 | + { |
1782 | + // Directory creation is gloablly disabled |
1783 | + $Messages->add( T_('Directory creation is disabled.'), 'error' ); |
1784 | + break; |
1785 | + } |
1786 | + |
1787 | + if( ! param( 'create_name', 'string', '' ) ) |
1788 | + { |
1789 | + // No name was supplied |
1790 | + $Messages->add( T_('Cannot create a directory without name.'), 'error' ); |
1791 | + break; |
1792 | + } |
1793 | + |
1794 | + if( $error_dirname = validate_dirname( $create_name ) ) |
1795 | + { |
1796 | + // Not valid dirname |
1797 | + $Messages->add( $error_dirname, 'error' ); |
1798 | + break; |
1799 | + } |
1800 | + |
1801 | + // Try to get File object |
1802 | + $FileCache = & get_Cache( 'FileCache' ); |
1803 | + $newFile = & $FileCache->get_by_root_and_path( $fm_FileRoot->type, $fm_FileRoot->in_type_ID, $path.$create_name ); |
1804 | + |
1805 | + if( $newFile->exists() ) |
1806 | + { |
1807 | + $Messages->add( sprintf( T_('The file «%s» already exists.'), $create_name ), 'error' ); |
1808 | + break; |
1809 | + } |
1810 | + |
1811 | + if( ! $newFile->create( $create_type ) ) |
1812 | + { |
1813 | + $Messages->add( sprintf( T_('Could not create directory «%s» in «%s».'), $create_name, $fm_Filelist->_rds_list_path ), 'error' ); |
1814 | + } |
1815 | + |
1816 | + $Messages->add( sprintf( T_('The directory «%s» has been created.'), $create_name ), 'success' ); |
1817 | + |
1818 | + header_redirect( regenerate_url( '', '', '', '&' ) ); |
1819 | + // $action = 'list'; |
1820 | + break; |
1821 | |
1822 | case 'createnew_file': |
1823 | - // We are probably comming from 'createnew' but there is no guarantee! |
1824 | - // Check permission: |
1825 | - $current_User->check_perm( 'files', 'add', true ); |
1826 | - |
1827 | - if( ! $Settings->get( 'fm_enable_create_file' ) ) |
1828 | - { // File creation is gloablly disabled: |
1829 | - $Messages->add( T_('File creation is disabled.'), 'error' ); |
1830 | - break; |
1831 | - } |
1832 | - |
1833 | - if( ! param( 'create_name', 'string', '' ) ) |
1834 | - { // No name was supplied: |
1835 | - $Messages->add( T_('Cannot create a file without name.'), 'error' ); |
1836 | - break; |
1837 | - } |
1838 | - if( $error_filename = validate_filename( $create_name, $current_User->check_perm( 'files', 'all' ) ) ) |
1839 | - { // Not valid filename or extension |
1840 | - $Messages->add( $error_filename, 'error' ); |
1841 | - break; |
1842 | - } |
1843 | - |
1844 | - // Try to get File object: |
1845 | - $FileCache = & get_Cache( 'FileCache' ); |
1846 | - $newFile = & $FileCache->get_by_root_and_path( $fm_FileRoot->type, $fm_FileRoot->in_type_ID, $path.$create_name ); |
1847 | - |
1848 | - if( $newFile->exists() ) |
1849 | - { |
1850 | - $Messages->add( sprintf( T_('The file «%s» already exists.'), $create_name ), 'error' ); |
1851 | - break; |
1852 | - } |
1853 | - |
1854 | - if( ! $newFile->create( $create_type ) ) |
1855 | - { |
1856 | - $Messages->add( sprintf( T_('Could not create file «%s» in «%s».'), $create_name, $fm_Filelist->_rds_list_path ), 'error' ); |
1857 | - } |
1858 | - |
1859 | - $Messages->add( sprintf( T_('The file «%s» has been created.'), $create_name ), 'success' ); |
1860 | - |
1861 | - header_redirect( regenerate_url( '', '', '', '&' ) ); |
1862 | - // $action = 'list'; |
1863 | - break; |
1864 | - |
1865 | - |
1866 | - case 'update_settings': |
1867 | - // Update settings NOW since they may affect the FileList |
1868 | - $UserSettings->set( 'fm_dirsnotattop', 1-param( 'option_dirsattop', 'integer', 0 ) ); |
1869 | - $UserSettings->set( 'fm_permlikelsl', param( 'option_permlikelsl', 'integer', 0 ) ); |
1870 | - $UserSettings->set( 'fm_imglistpreview', param( 'option_imglistpreview', 'integer', 0 ) ); |
1871 | - $UserSettings->set( 'fm_getimagesizes', param( 'option_getimagesizes', 'integer', 0 ) ); |
1872 | - |
1873 | - $UserSettings->set( 'fm_showtypes', param( 'option_showtypes', 'integer', 0 ) ); |
1874 | - $UserSettings->set( 'fm_showdate', param( 'option_showdate', 'string', 'compact' ) ); |
1875 | - $UserSettings->set( 'fm_showfsperms', param( 'option_showfsperms', 'integer', 0 ) ); |
1876 | - $UserSettings->set( 'fm_showfsowner', param( 'option_showfsowner', 'integer', 0 ) ); |
1877 | - $UserSettings->set( 'fm_showfsgroup', param( 'option_showfsgroup', 'integer', 0 ) ); |
1878 | - |
1879 | - $UserSettings->set( 'fm_showhidden', param( 'option_showhidden', 'integer', 0 ) ); |
1880 | - $UserSettings->set( 'fm_recursivedirsize', param( 'option_recursivedirsize', 'integer', 0 ) ); |
1881 | - $UserSettings->set( 'fm_allowfiltering', param( 'option_allowfiltering', 'string', 'simple' ) ); |
1882 | - |
1883 | - if( $UserSettings->dbupdate() ) |
1884 | - { |
1885 | - $Messages->add( T_('Your user settings have been updated.'), 'success' ); |
1886 | - } |
1887 | - |
1888 | - header_redirect( regenerate_url( '', '', '', '&' ) ); |
1889 | - // $action = 'list'; |
1890 | - break; |
1891 | + // We are probably comming from 'createnew' but there is no guarantee! |
1892 | + // Check permission |
1893 | + $current_User->check_perm( 'files', 'add', true ); |
1894 | + |
1895 | + if( ! $Settings->get( 'fm_enable_create_file' ) ) |
1896 | + { |
1897 | + // File creation is gloablly disabled |
1898 | + $Messages->add( T_('File creation is disabled.'), 'error' ); |
1899 | + break; |
1900 | + } |
1901 | + |
1902 | + if( ! param( 'create_name', 'string', '' ) ) |
1903 | + { |
1904 | + // No name was supplied |
1905 | + $Messages->add( T_('Cannot create a file without name.'), 'error' ); |
1906 | + break; |
1907 | + } |
1908 | + |
1909 | + if( $error_filename = validate_filename( $create_name, $current_User->check_perm( 'files', 'all' ) ) ) |
1910 | + { |
1911 | + // Not valid filename or extension |
1912 | + $Messages->add( $error_filename, 'error' ); |
1913 | + break; |
1914 | + } |
1915 | + |
1916 | + // Try to get File object |
1917 | + $FileCache = & get_Cache( 'FileCache' ); |
1918 | + $newFile = & $FileCache->get_by_root_and_path( $fm_FileRoot->type, $fm_FileRoot->in_type_ID, $path.$create_name ); |
1919 | + |
1920 | + if( $newFile->exists() ) |
1921 | + { |
1922 | + $Messages->add( sprintf( T_('The file «%s» already exists.'), $create_name ), 'error' ); |
1923 | + break; |
1924 | + } |
1925 | + |
1926 | + if( ! $newFile->create( $create_type ) ) |
1927 | + { |
1928 | + $Messages->add( sprintf( T_('Could not create file «%s» in «%s».'), $create_name, $fm_Filelist->_rds_list_path ), 'error' ); |
1929 | + } |
1930 | + |
1931 | + $Messages->add( sprintf( T_('The file «%s» has been created.'), $create_name ), 'success' ); |
1932 | + |
1933 | + header_redirect( regenerate_url( '', '', '', '&' ) ); |
1934 | + // $action = 'list'; |
1935 | + break; |
1936 | + |
1937 | + case 'update_settings': |
1938 | + // Update settings NOW since they may affect the FileList |
1939 | + $UserSettings->set( 'fm_dirsnotattop', 1-param( 'option_dirsattop', 'integer', 0 ) ); |
1940 | + $UserSettings->set( 'fm_permlikelsl', param( 'option_permlikelsl', 'integer', 0 ) ); |
1941 | + $UserSettings->set( 'fm_imglistpreview', param( 'option_imglistpreview', 'integer', 0 ) ); |
1942 | + $UserSettings->set( 'fm_getimagesizes', param( 'option_getimagesizes', 'integer', 0 ) ); |
1943 | + $UserSettings->set( 'fm_showtypes', param( 'option_showtypes', 'integer', 0 ) ); |
1944 | + $UserSettings->set( 'fm_showdate', param( 'option_showdate', 'string', 'compact' ) ); |
1945 | + $UserSettings->set( 'fm_showfsperms', param( 'option_showfsperms', 'integer', 0 ) ); |
1946 | + $UserSettings->set( 'fm_showfsowner', param( 'option_showfsowner', 'integer', 0 ) ); |
1947 | + $UserSettings->set( 'fm_showfsgroup', param( 'option_showfsgroup', 'integer', 0 ) ); |
1948 | + $UserSettings->set( 'fm_showhidden', param( 'option_showhidden', 'integer', 0 ) ); |
1949 | + $UserSettings->set( 'fm_recursivedirsize', param( 'option_recursivedirsize', 'integer', 0 ) ); |
1950 | + $UserSettings->set( 'fm_allowfiltering', param( 'option_allowfiltering', 'string', 'simple' ) ); |
1951 | + |
1952 | + if( $UserSettings->dbupdate() ) |
1953 | + { |
1954 | + $Messages->add( T_('Your user settings have been updated.'), 'success' ); |
1955 | + } |
1956 | + |
1957 | + header_redirect( regenerate_url( '', '', '', '&' ) ); |
1958 | + // $action = 'list'; |
1959 | + break; |
1960 | |
1961 | case 'update_file': |
1962 | - // Update File: |
1963 | - |
1964 | - if( $demo_mode ) |
1965 | - { |
1966 | - $Messages->add( 'Sorry, you cannot update files in demo mode!', 'error' ); |
1967 | - break; |
1968 | - } |
1969 | - |
1970 | - // Check permission! |
1971 | - $current_User->check_perm( 'files', 'edit', true ); |
1972 | - |
1973 | - // Get the file we want to update: |
1974 | - $edited_File = & $selected_Filelist->get_by_idx(0); |
1975 | - |
1976 | - // Check that the file is editable: |
1977 | - if( ! $edited_File->is_editable( $current_User->check_perm( 'files', 'all' ) ) ) |
1978 | - { |
1979 | - $Messages->add( sprintf( T_( 'You are not allowed to edit «%s».' ), $edited_File->dget('name') ), 'error' ); |
1980 | - break; |
1981 | - } |
1982 | - |
1983 | - param( 'file_content', 'html', '', false ); |
1984 | - |
1985 | - |
1986 | - $full_path = $edited_File->get_full_path(); |
1987 | - if( $rsc_handle = fopen( $full_path, 'w+') ) |
1988 | - { |
1989 | - fwrite( $rsc_handle, $file_content ); |
1990 | - fclose( $rsc_handle ); |
1991 | - $Messages->add( sprintf( T_( 'The file «%s» has been updated.' ), $edited_File->dget('name') ), 'success' ); |
1992 | - } |
1993 | - else |
1994 | - { |
1995 | - $Messages->add( sprintf( T_( 'The file «%s» could not be updated.' ), $edited_File->dget('name') ), 'error' ); |
1996 | - } |
1997 | - |
1998 | - header_redirect( regenerate_url( '', '', '', '&' ) ); |
1999 | - // $action = 'list'; |
2000 | - break; |
2001 | + // Update File |
2002 | + |
2003 | + if( $demo_mode ) |
2004 | + { |
2005 | + $Messages->add( 'Sorry, you cannot update files in demo mode!', 'error' ); |
2006 | + break; |
2007 | + } |
2008 | + |
2009 | + // Check permission! |
2010 | + $current_User->check_perm( 'files', 'edit', true ); |
2011 | + |
2012 | + // Get the file we want to update |
2013 | + $edited_File = & $selected_Filelist->get_by_idx(0); |
2014 | + |
2015 | + // Check that the file is editable |
2016 | + if( ! $edited_File->is_editable( $current_User->check_perm( 'files', 'all' ) ) ) |
2017 | + { |
2018 | + $Messages->add( sprintf( T_( 'You are not allowed to edit «%s».' ), $edited_File->dget( 'name' ) ), 'error' ); |
2019 | + break; |
2020 | + } |
2021 | + |
2022 | + param( 'file_content', 'html', '', false ); |
2023 | + |
2024 | + $full_path = $edited_File->get_full_path(); |
2025 | + if( $rsc_handle = fopen( $full_path, 'w+') ) |
2026 | + { |
2027 | + fwrite( $rsc_handle, $file_content ); |
2028 | + fclose( $rsc_handle ); |
2029 | + $Messages->add( sprintf( T_( 'The file «%s» has been updated.' ), $edited_File->dget( 'name' ) ), 'success' ); |
2030 | + } |
2031 | + else |
2032 | + { |
2033 | + $Messages->add( sprintf( T_( 'The file «%s» could not be updated.' ), $edited_File->dget( 'name' ) ), 'error' ); |
2034 | + } |
2035 | + |
2036 | + header_redirect( regenerate_url( '', '', '', '&' ) ); |
2037 | + // $action = 'list'; |
2038 | + break; |
2039 | } |
2040 | |
2041 | // Do we want to display the directory tree next to the files table |
2042 | @@ -506,7 +483,6 @@ |
2043 | |
2044 | // Filelist |
2045 | $fm_Filelist = new Filelist( $fm_FileRoot, $ads_list_path ); |
2046 | -$Debuglog->add( 'FM _rds_list_path: '.var_export( $fm_Filelist->_rds_list_path, true ), 'files' ); |
2047 | |
2048 | param( 'fm_filter', '', NULL, true ); |
2049 | param( 'fm_filter_regex', 'integer', 0, true ); |
2050 | @@ -517,7 +493,7 @@ |
2051 | $fm_Filelist->_dirs_not_at_top = true; |
2052 | } |
2053 | |
2054 | -if( $UserSettings->param_Request( 'fm_recursivedirsize', 'fm_recursivedirsize', 'integer', 0 ) ) // TODO: check for permission? (Server load) |
2055 | +if( $UserSettings->param_Request( 'fm_recursivedirsize', 'fm_recursivedirsize', 'integer', 0 ) ) // @todo (0000): check for permission? (Server load) |
2056 | { |
2057 | $fm_Filelist->_use_recursive_dirsize = true; |
2058 | } |
2059 | @@ -548,938 +524,936 @@ |
2060 | switch( $action ) |
2061 | { |
2062 | case 'download': |
2063 | - // TODO: We don't need the Filelist, move UP! |
2064 | - // TODO: provide optional zip formats (tgz, ..) - the used lib provides more.. |
2065 | - // TODO: use "inmemory"=>false, so that you can download bigger archives faster! |
2066 | - |
2067 | - $action_title = T_('Download'); |
2068 | - |
2069 | - if( !$selected_Filelist->count() ) |
2070 | - { |
2071 | - $Messages->add( T_('Nothing selected.'), 'error' ); |
2072 | - $action = 'list'; |
2073 | - break; |
2074 | - } |
2075 | - |
2076 | - param( 'zipname', 'string', '' ); |
2077 | - param( 'exclude_sd', 'integer', 0 ); |
2078 | - |
2079 | - if( empty($zipname) ) |
2080 | - { |
2081 | - if( param( 'action_invoked', 'integer', 0 ) ) |
2082 | - { // Action was invoked, add "hint" |
2083 | - param_error( 'zipname', T_('Please provide the name of the archive.') ); |
2084 | - } |
2085 | - if( $selected_Filelist->count() == 1 ) |
2086 | - { |
2087 | - $only_File = $selected_Filelist->get_array(); |
2088 | - $only_File = $only_File[0]; |
2089 | - |
2090 | - // TODO: once we support additional formats, use the default extension here: |
2091 | - $zipname = $only_File->get_name().'.zip'; |
2092 | - } |
2093 | - break; |
2094 | - } |
2095 | - |
2096 | - // Downloading |
2097 | - load_class('_ext/_zip_archives.php'); |
2098 | - |
2099 | - $arraylist = $selected_Filelist->get_array( 'get_rdfs_rel_path' ); |
2100 | - |
2101 | - $options = array ( |
2102 | - 'basedir' => $fm_Filelist->get_ads_list_path(), |
2103 | - 'inmemory' => 1, |
2104 | - 'recurse' => (1 - $exclude_sd), |
2105 | - ); |
2106 | - |
2107 | - $zipfile = new zip_file( $zipname ); |
2108 | - $zipfile->set_options( $options ); |
2109 | - $zipfile->add_files( $arraylist ); |
2110 | - $zipfile->create_archive(); |
2111 | - |
2112 | - if( $zipfile->error ) |
2113 | - { |
2114 | - foreach($zipfile->error as $v) |
2115 | - { |
2116 | - $Messages->add( $v, 'error' ); |
2117 | - } |
2118 | - break; |
2119 | - } |
2120 | - |
2121 | - $zipfile->download_file(); |
2122 | - exit(0); |
2123 | - /* EXITED! */ |
2124 | + // @todo (0000): provide optional zip formats (tgz, ..) - the used lib provides more |
2125 | + // @todo (0000): use "inmemory"=>false, so that you can download bigger archives faster! |
2126 | + |
2127 | + $action_title = T_('Download'); |
2128 | + |
2129 | + if( !$selected_Filelist->count() ) |
2130 | + { |
2131 | + $Messages->add( T_('Nothing selected.'), 'error' ); |
2132 | + $action = 'list'; |
2133 | + break; |
2134 | + } |
2135 | + |
2136 | + param( 'zipname', 'string', '' ); |
2137 | + param( 'exclude_sd', 'integer', 0 ); |
2138 | + |
2139 | + if( empty( $zipname ) ) |
2140 | + { |
2141 | + if( param( 'action_invoked', 'integer', 0 ) ) |
2142 | + { |
2143 | + // Action was invoked, add "hint" |
2144 | + param_error( 'zipname', T_('Please provide the name of the archive.') ); |
2145 | + } |
2146 | + if( $selected_Filelist->count() == 1 ) |
2147 | + { |
2148 | + $only_File = $selected_Filelist->get_array(); |
2149 | + $only_File = $only_File[0]; |
2150 | + |
2151 | + // @todo (0000): once we support additional formats, use the default extension here |
2152 | + $zipname = $only_File->get_name().'.zip'; |
2153 | + } |
2154 | + break; |
2155 | + } |
2156 | + |
2157 | + // Downloading |
2158 | + $arraylist = $selected_Filelist->get_array( 'get_rdfs_rel_path' ); |
2159 | + |
2160 | + $options = array( |
2161 | + 'basedir' => $fm_Filelist->get_ads_list_path(), |
2162 | + 'inmemory' => 1, |
2163 | + 'recurse' => (1 - $exclude_sd), |
2164 | + ); |
2165 | + |
2166 | + $zipfile = new zip_file( $zipname ); |
2167 | + $zipfile->set_options( $options ); |
2168 | + $zipfile->add_files( $arraylist ); |
2169 | + $zipfile->create_archive(); |
2170 | + |
2171 | + if( $zipfile->error ) |
2172 | + { |
2173 | + foreach( $zipfile->error as $v ) |
2174 | + { |
2175 | + $Messages->add( $v, 'error' ); |
2176 | + } |
2177 | + break; |
2178 | + } |
2179 | + |
2180 | + $zipfile->download_file(); |
2181 | + exit(0); |
2182 | + /* EXITED! */ |
2183 | |
2184 | |
2185 | case 'rename': |
2186 | - // TODO: We don't need the Filelist, move UP! |
2187 | - // Rename a file: |
2188 | - |
2189 | - // This will not allow to overwrite existing files, the same way Windows and MacOS do not allow it. Adding an option will only clutter the interface and satisfy geeks only. |
2190 | - if( ! $current_User->check_perm( 'files', 'edit' ) ) |
2191 | - { // We do not have permission to edit files |
2192 | - $Messages->add( T_('You have no permission to edit/modify files.'), 'error' ); |
2193 | - $action = 'list'; |
2194 | - break; |
2195 | - } |
2196 | - |
2197 | - $allow_locked_filetypes = $current_User->check_perm( 'files', 'all' ); |
2198 | - |
2199 | - if( ! $selected_Filelist->count() ) |
2200 | - { // There is nothing to rename |
2201 | - $Messages->add( T_('Nothing selected.'), 'error' ); |
2202 | - $action = 'list'; |
2203 | - break; |
2204 | - } |
2205 | - |
2206 | - param( 'confirmed', 'integer', 0 ); |
2207 | - param( 'new_names', 'array', array() ); |
2208 | - |
2209 | - // Check params for each file to rename: |
2210 | + // Rename a file |
2211 | + |
2212 | + // This will not allow to overwrite existing files, the same way Windows and MacOS |
2213 | + // do not allow it. Adding an option will only clutter the interface and satisfy geeks only. |
2214 | + if( ! $current_User->check_perm( 'files', 'edit' ) ) |
2215 | + { |
2216 | + // We do not have permission to edit files |
2217 | + $Messages->add( T_('You have no permission to edit/modify files.'), 'error' ); |
2218 | + $action = 'list'; |
2219 | + break; |
2220 | + } |
2221 | + |
2222 | + $allow_locked_filetypes = $current_User->check_perm( 'files', 'all' ); |
2223 | + |
2224 | + if( ! $selected_Filelist->count() ) |
2225 | + { |
2226 | + // There is nothing to rename |
2227 | + $Messages->add( T_('Nothing selected.'), 'error' ); |
2228 | + $action = 'list'; |
2229 | + break; |
2230 | + } |
2231 | + |
2232 | + param( 'confirmed', 'integer', 0 ); |
2233 | + param( 'new_names', 'array', array() ); |
2234 | + |
2235 | + // Check params for each file to rename |
2236 | + while( $loop_src_File = & $selected_Filelist->get_next() ) |
2237 | + { |
2238 | + if( ! isset( $new_names[$loop_src_File->get_md5_ID()] ) ) |
2239 | + { |
2240 | + // We have not yet provided a name to rename to... |
2241 | + $confirmed = 0; |
2242 | + $new_names[$loop_src_File->get_md5_ID()] = $loop_src_File->get_name(); |
2243 | + continue; |
2244 | + } |
2245 | + |
2246 | + // Check if provided name is okay |
2247 | + $new_names[$loop_src_File->get_md5_ID()] = trim( strip_tags( $new_names[$loop_src_File->get_md5_ID()] ) ); |
2248 | + |
2249 | + if( !$loop_src_File->is_dir() ) |
2250 | + { |
2251 | + if( $error_filename = validate_filename( $new_names[$loop_src_File->get_md5_ID()], $allow_locked_filetypes ) ) |
2252 | + { |
2253 | + // Not a file name or not an allowed extension |
2254 | + $confirmed = 0; |
2255 | + param_error( 'new_names['.$loop_src_File->get_md5_ID().']', $error_filename ); |
2256 | + continue; |
2257 | + } |
2258 | + } |
2259 | + elseif( $error_dirname = validate_dirname( $new_names[$loop_src_File->get_md5_ID()] ) ) |
2260 | + { |
2261 | + // directory name |
2262 | + $confirmed = 0; |
2263 | + param_error( 'new_names['.$loop_src_File->get_md5_ID().']', $error_dirname ); |
2264 | + continue; |
2265 | + } |
2266 | + } |
2267 | + |
2268 | + if( $confirmed ) |
2269 | + { |
2270 | + // Rename is confirmed, let's proceed |
2271 | + $selected_Filelist->restart(); |
2272 | while( $loop_src_File = & $selected_Filelist->get_next() ) |
2273 | { |
2274 | - if( ! isset( $new_names[$loop_src_File->get_md5_ID()] ) ) |
2275 | - { // We have not yet provided a name to rename to... |
2276 | - $confirmed = 0; |
2277 | - $new_names[$loop_src_File->get_md5_ID()] = $loop_src_File->get_name(); |
2278 | - continue; |
2279 | - } |
2280 | - |
2281 | - // Check if provided name is okay: |
2282 | - $new_names[$loop_src_File->get_md5_ID()] = trim(strip_tags($new_names[$loop_src_File->get_md5_ID()])); |
2283 | - |
2284 | - if( !$loop_src_File->is_dir() ) |
2285 | - { |
2286 | - if( $error_filename = validate_filename( $new_names[$loop_src_File->get_md5_ID()], $allow_locked_filetypes ) ) |
2287 | - { // Not a file name or not an allowed extension |
2288 | - $confirmed = 0; |
2289 | - param_error( 'new_names['.$loop_src_File->get_md5_ID().']', $error_filename ); |
2290 | - continue; |
2291 | - } |
2292 | - } |
2293 | - elseif( $error_dirname = validate_dirname( $new_names[$loop_src_File->get_md5_ID()] ) ) |
2294 | - { // directory name |
2295 | - $confirmed = 0; |
2296 | - param_error( 'new_names['.$loop_src_File->get_md5_ID().']', $error_dirname ); |
2297 | - continue; |
2298 | - } |
2299 | - } |
2300 | - |
2301 | - if( $confirmed ) |
2302 | - { // Rename is confirmed, let's proceed: |
2303 | - $selected_Filelist->restart(); |
2304 | - while( $loop_src_File = & $selected_Filelist->get_next() ) |
2305 | - { |
2306 | - $old_name = $loop_src_File->get_name(); |
2307 | - $new_name = $new_names[$loop_src_File->get_md5_ID()]; |
2308 | - |
2309 | - if( $new_name == $old_name ) |
2310 | - { // Name has not changed... |
2311 | - $Messages->add( sprintf( T_('«%s» has not been renamed'), $old_name ), 'note' ); |
2312 | - continue; |
2313 | - } |
2314 | - // Perform rename: |
2315 | - if( ! $loop_src_File->rename_to( $new_name ) ) |
2316 | - { |
2317 | - $Messages->add( sprintf( T_('«%s» could not be renamed to «%s»'), |
2318 | - $old_name, $new_name ), 'error' ); |
2319 | - continue; |
2320 | - } |
2321 | - |
2322 | - // We have moved in same dir, update caches: |
2323 | - $fm_Filelist->update_caches(); |
2324 | - |
2325 | - if( $fm_Filelist->contains( $loop_src_File ) === false ) |
2326 | - { // File not in filelist (expected if not same dir) |
2327 | - $fm_Filelist->add( $File ); |
2328 | - } |
2329 | - |
2330 | - |
2331 | - $Messages->add( sprintf( T_('«%s» has been successfully renamed to «%s»'), |
2332 | - $old_name, $new_name ), 'success' ); |
2333 | - } |
2334 | - |
2335 | - // REDIRECT / EXIT |
2336 | - header_redirect( regenerate_url( '', '', '', '&' ) ); |
2337 | - // $action = 'list'; |
2338 | - } |
2339 | - break; |
2340 | - |
2341 | + $old_name = $loop_src_File->get_name(); |
2342 | + $new_name = $new_names[$loop_src_File->get_md5_ID()]; |
2343 | + |
2344 | + if( $new_name == $old_name ) |
2345 | + { |
2346 | + // Name has not changed... |
2347 | + $Messages->add( sprintf( T_('«%s» has not been renamed'), $old_name ), 'note' ); |
2348 | + continue; |
2349 | + } |
2350 | + // Perform rename |
2351 | + if( ! $loop_src_File->rename_to( $new_name ) ) |
2352 | + { |
2353 | + $Messages->add( sprintf( T_('«%s» could not be renamed to «%s»'), |
2354 | + $old_name, $new_name ), 'error' ); |
2355 | + continue; |
2356 | + } |
2357 | + |
2358 | + // We have moved in same dir, update caches |
2359 | + $fm_Filelist->update_caches(); |
2360 | + |
2361 | + if( $fm_Filelist->contains( $loop_src_File ) === false ) |
2362 | + { |
2363 | + // File not in filelist (expected if not same dir) |
2364 | + $fm_Filelist->add( $File ); |
2365 | + } |
2366 | + |
2367 | + $Messages->add( sprintf( T_('«%s» has been successfully renamed to «%s»'), |
2368 | + $old_name, $new_name ), 'success' ); |
2369 | + } |
2370 | + |
2371 | + // REDIRECT / EXIT |
2372 | + header_redirect( regenerate_url( '', '', '', '&' ) ); |
2373 | + // $action = 'list'; |
2374 | + } |
2375 | + break; |
2376 | |
2377 | case 'delete': |
2378 | - // TODO: We don't need the Filelist, move UP! |
2379 | - // Delete a file or directory: |
2380 | - |
2381 | - if( ! $current_User->check_perm( 'files', 'edit' ) ) |
2382 | - { // We do not have permission to edit files |
2383 | - $Messages->add( T_('You have no permission to edit/modify files.'), 'error' ); |
2384 | - $action = 'list'; |
2385 | - break; |
2386 | + // Delete a file or directory |
2387 | + |
2388 | + if( ! $current_User->check_perm( 'files', 'edit' ) ) |
2389 | + { |
2390 | + // We do not have permission to edit files |
2391 | + $Messages->add( T_('You have no permission to edit/modify files.'), 'error' ); |
2392 | + $action = 'list'; |
2393 | + break; |
2394 | + } |
2395 | + |
2396 | + if( ! $selected_Filelist->count() ) |
2397 | + { |
2398 | + $Messages->add( T_('Nothing selected.'), 'error' ); |
2399 | + $action = 'list'; |
2400 | + break; |
2401 | + } |
2402 | + |
2403 | + param( 'confirmed', 'integer', 0 ); |
2404 | + // fplanque>> We cannot actually offer to delete subdirs since we cannot pre-check DB |
2405 | + |
2406 | + $selected_Filelist->restart(); |
2407 | + if( $confirmed ) |
2408 | + { |
2409 | + // Unlink files |
2410 | + while( $l_File = & $selected_Filelist->get_next() ) |
2411 | + { |
2412 | + if( $l_File->unlink() ) |
2413 | + { |
2414 | + $Messages->add( sprintf( ( $l_File->is_dir() ? T_('The directory «%s» has been deleted.') |
2415 | + : T_('The file «%s» has been deleted.') ), $l_File->dget( 'name' ) ), 'success' ); |
2416 | + $fm_Filelist->remove( $l_File ); |
2417 | + } |
2418 | + else |
2419 | + { |
2420 | + $Messages->add( sprintf( ( $l_File->is_dir() ? T_('Could not delete the directory «%s» (not empty?).') |
2421 | + : T_('Could not delete the file «%s».') ), $l_File->dget( 'name' ) ), 'error' ); |
2422 | + } |
2423 | + } |
2424 | + $action = 'list'; |
2425 | + } |
2426 | + else |
2427 | + { |
2428 | + // make sure we have loaded metas for all files in selection! |
2429 | + $selected_Filelist->load_meta(); |
2430 | + |
2431 | + // Check if there are delete restrictions on the files |
2432 | + while( $l_File = & $selected_Filelist->get_next() ) |
2433 | + { |
2434 | + // Check if there are delete restrictions on this file. |
2435 | + // We use a callback here to display the post titles. |
2436 | + $l_File->check_relations( 'delete_restrictions', array(), |
2437 | + array( 'link_file_ID' => array( 'cb' => array( $l_File, 'cb_delete_restrictions_detail' ), ), |
2438 | + ) ); |
2439 | + |
2440 | + if( $Messages->count('restrict') ) |
2441 | + { |
2442 | + // There are restrictions |
2443 | + $Messages->add( sprintf( T_('%s cannot be deleted because of the following relations:'), |
2444 | + $l_File->get_prefixed_name() ). |
2445 | + $Messages->display( NULL, NULL, false, 'restrict', '', 'ul', false ) ); |
2446 | + $Messages->clear( 'restrict' ); |
2447 | + |
2448 | + // remove it from the list of selected files (that will be offered to delete) |
2449 | + $selected_Filelist->remove( $l_File ); |
2450 | + } |
2451 | } |
2452 | |
2453 | if( ! $selected_Filelist->count() ) |
2454 | { |
2455 | - $Messages->add( T_('Nothing selected.'), 'error' ); |
2456 | - $action = 'list'; |
2457 | - break; |
2458 | - } |
2459 | - |
2460 | - param( 'confirmed', 'integer', 0 ); |
2461 | - // fplanque>> We cannot actually offer to delete subdirs since we cannot pre-check DB |
2462 | - |
2463 | - $selected_Filelist->restart(); |
2464 | - if( $confirmed ) |
2465 | - { // Unlink files: |
2466 | - while( $l_File = & $selected_Filelist->get_next() ) |
2467 | - { |
2468 | - if( $l_File->unlink() ) |
2469 | - { |
2470 | - $Messages->add( sprintf( ( $l_File->is_dir() ? T_('The directory «%s» has been deleted.') |
2471 | - : T_('The file «%s» has been deleted.') ), $l_File->dget('name') ), 'success' ); |
2472 | - $fm_Filelist->remove( $l_File ); |
2473 | - } |
2474 | - else |
2475 | - { |
2476 | - $Messages->add( sprintf( ( $l_File->is_dir() ? T_('Could not delete the directory «%s» (not empty?).') |
2477 | - : T_('Could not delete the file «%s».') ), $l_File->dget('name') ), 'error' ); |
2478 | - } |
2479 | - } |
2480 | - $action = 'list'; |
2481 | - } |
2482 | - else |
2483 | - { |
2484 | - // make sure we have loaded metas for all files in selection! |
2485 | - $selected_Filelist->load_meta(); |
2486 | - |
2487 | - // Check if there are delete restrictions on the files: |
2488 | - while( $l_File = & $selected_Filelist->get_next() ) |
2489 | - { |
2490 | - // Check if there are delete restrictions on this file. |
2491 | - // We use a callback here to display the post titles. |
2492 | - $l_File->check_relations( 'delete_restrictions', array(), array( |
2493 | - 'link_file_ID' => array( |
2494 | - 'cb' => array( $l_File, 'cb_delete_restrictions_detail' ), |
2495 | - ), |
2496 | - ) ); |
2497 | - |
2498 | - if( $Messages->count('restrict') ) |
2499 | - { // There are restrictions: |
2500 | - $Messages->add( sprintf( T_('%s cannot be deleted because of the following relations:'), |
2501 | - $l_File->get_prefixed_name() ). |
2502 | - $Messages->display( NULL, NULL, false, 'restrict', '', 'ul', false ) ); |
2503 | - $Messages->clear( 'restrict' ); |
2504 | - |
2505 | - // remove it from the list of selected files (that will be offered to delete): |
2506 | - $selected_Filelist->remove( $l_File ); |
2507 | - } |
2508 | - } |
2509 | - |
2510 | - if( ! $selected_Filelist->count() ) |
2511 | - { // no files left in list, cancel action |
2512 | - $action = 'list'; |
2513 | - } |
2514 | - } |
2515 | - break; |
2516 | - |
2517 | + // no files left in list, cancel action |
2518 | + $action = 'list'; |
2519 | + } |
2520 | + } |
2521 | + break; |
2522 | |
2523 | case 'make_post': |
2524 | case 'make_posts': |
2525 | - // TODO: We don't need the Filelist, move UP! |
2526 | - // Make posts with selected images: |
2527 | - |
2528 | - if( ! $selected_Filelist->count() ) |
2529 | - { |
2530 | - $Messages->add( T_('Nothing selected.'), 'error' ); |
2531 | - $action = 'list'; |
2532 | - break; |
2533 | - } |
2534 | - |
2535 | - // fp> TODO: this block should move to a general level |
2536 | - // Try to go to the right blog: |
2537 | - if( $fm_Filelist->get_root_type() == 'collection' ) |
2538 | - { |
2539 | - set_working_blog( $fm_Filelist->get_root_ID() ); |
2540 | - // Load the blog we're in: |
2541 | - $Blog = & $BlogCache->get_by_ID( $blog ); |
2542 | - } |
2543 | - // --- |
2544 | - |
2545 | - |
2546 | - if( empty( $Blog ) ) |
2547 | - { |
2548 | - $Messages->add( T_('No destination blog is selected.'), 'error' ); |
2549 | - break; |
2550 | - } |
2551 | - //$Blog->disp('name'); |
2552 | - |
2553 | - // Get default status (includes PERM CHECK): |
2554 | - $item_status = $Blog->get_allowed_item_status(); |
2555 | - if( empty($item_status) ) |
2556 | - { |
2557 | - $Messages->add( T_('Sorry, you have no permission to post into this blog.'), 'error' ); |
2558 | - break; |
2559 | - } |
2560 | - |
2561 | - // make sure we have loaded metas for all files in selection! |
2562 | - $selected_Filelist->load_meta(); |
2563 | - |
2564 | - // Ready to create post(s): |
2565 | - load_class('items/model/_item.class.php'); |
2566 | - |
2567 | - switch( $action ) |
2568 | - { |
2569 | - case 'make_post': |
2570 | - // SINGLE POST: |
2571 | - // Create a post: |
2572 | - $edited_Item = new Item(); |
2573 | - $edited_Item->set( 'status', $item_status ); |
2574 | - $edited_Item->set( 'main_cat_ID', $Blog->get_default_cat_ID() ); |
2575 | - |
2576 | - $l_File = & $selected_Filelist->get_next(); |
2577 | - |
2578 | - $title = $l_File->get('title'); |
2579 | - if( empty($title) ) |
2580 | - { |
2581 | - $title = $l_File->get('name'); |
2582 | - } |
2583 | - $edited_Item->set( 'title', $title ); |
2584 | - |
2585 | - $DB->begin(); |
2586 | - |
2587 | - // INSERT NEW POST INTO DB: |
2588 | - $edited_Item->dbinsert(); |
2589 | - |
2590 | - do |
2591 | - { // LOOP Through images: |
2592 | - if( ! $l_File->is_image() ) |
2593 | - { |
2594 | - $Messages->add( sprintf( T_('Cannot post «%s» because it is not an image.'), $l_File->dget('name') ), 'error' ); |
2595 | - continue; |
2596 | - } |
2597 | - |
2598 | - if( $l_File->meta == 'notfound' ) |
2599 | - { // That file has no meta data yet, create it now! |
2600 | - $l_File->dbsave(); |
2601 | - } |
2602 | - |
2603 | - // Let's make the link! |
2604 | - $edited_Link = new Link(); |
2605 | - $edited_Link->set( 'itm_ID', $edited_Item->ID ); |
2606 | - $edited_Link->set( 'file_ID', $l_File->ID ); |
2607 | - $edited_Link->dbinsert(); |
2608 | - |
2609 | - $Messages->add( sprintf( T_('«%s» has been attached.'), $l_File->dget('name') ), 'success' ); |
2610 | - |
2611 | - } while( $l_File = & $selected_Filelist->get_next() ); |
2612 | - |
2613 | - $DB->commit(); |
2614 | - |
2615 | - header_redirect( $dispatcher.'?ctrl=items&action=edit&p='.$edited_Item->ID ); // Will save $Messages |
2616 | - break; |
2617 | - |
2618 | - case 'make_posts': |
2619 | - // MULTIPLE POST (1 per image): |
2620 | - while( $l_File = & $selected_Filelist->get_next() ) |
2621 | - { |
2622 | - if( ! $l_File->is_image() ) |
2623 | - { |
2624 | - $Messages->add( sprintf( T_('Cannot post «%s» because it is not an image.'), $l_File->dget('name') ), 'error' ); |
2625 | - continue; |
2626 | - } |
2627 | - |
2628 | - // Create a post: |
2629 | - $edited_Item = new Item(); |
2630 | - $edited_Item->set( 'status', $item_status ); |
2631 | - $edited_Item->set( 'main_cat_ID', $Blog->get_default_cat_ID() ); |
2632 | - |
2633 | - $title = $l_File->get('title'); |
2634 | - if( empty($title) ) |
2635 | - { |
2636 | - $title = $l_File->get('name'); |
2637 | - } |
2638 | - $edited_Item->set( 'title', $title ); |
2639 | - |
2640 | - $DB->begin(); |
2641 | - |
2642 | - // INSERT NEW POST INTO DB: |
2643 | - $edited_Item->dbinsert(); |
2644 | - |
2645 | - if( $l_File->meta == 'notfound' ) |
2646 | - { // That file has no meta data yet, create it now! |
2647 | - $l_File->dbsave(); |
2648 | - } |
2649 | - |
2650 | - // Let's make the link! |
2651 | - $edited_Link = new Link(); |
2652 | - $edited_Link->set( 'itm_ID', $edited_Item->ID ); |
2653 | - $edited_Link->set( 'file_ID', $l_File->ID ); |
2654 | - $edited_Link->dbinsert(); |
2655 | - |
2656 | - $DB->commit(); |
2657 | - |
2658 | - $Messages->add( sprintf( T_('«%s» has been posted.'), $l_File->dget('name') ), 'success' ); |
2659 | - } |
2660 | - |
2661 | - // Note: we redirect without restoring filter. This should allow to see the new files. |
2662 | - // &filter=restore |
2663 | - header_redirect( $dispatcher.'?ctrl=items&blog='.$blog ); // Will save $Messages |
2664 | - |
2665 | - break; |
2666 | - } |
2667 | - |
2668 | - // Note: we should have EXITED here. In case we don't (error, or sth...) |
2669 | - |
2670 | - // Reset stuff so it doesn't interfere with upcomming display |
2671 | - unset( $edited_Item ); |
2672 | - unset( $edited_Link ); |
2673 | - $selected_Filelist = new Filelist( $fm_Filelist->get_FileRoot(), false ); |
2674 | - break; |
2675 | - |
2676 | - |
2677 | + // Make posts with selected images |
2678 | + if( ! $selected_Filelist->count() ) |
2679 | + { |
2680 | + $Messages->add( T_('Nothing selected.'), 'error' ); |
2681 | + $action = 'list'; |
2682 | + break; |
2683 | + } |
2684 | + |
2685 | + // fp> TODO: this block should move to a general level |
2686 | + // Try to go to the right blog: |
2687 | + if( $fm_Filelist->get_root_type() == 'collection' ) |
2688 | + { |
2689 | + set_working_blog( $fm_Filelist->get_root_ID() ); |
2690 | + // Load the blog we're in |
2691 | + $Blog = & $BlogCache->get_by_ID( $blog ); |
2692 | + } |
2693 | + |
2694 | + // --- |
2695 | + if( empty( $Blog ) ) |
2696 | + { |
2697 | + $Messages->add( T_('No destination blog is selected.'), 'error' ); |
2698 | + break; |
2699 | + } |
2700 | + // $Blog->disp('name'); |
2701 | + |
2702 | + // Get default status (includes PERM CHECK) |
2703 | + $item_status = $Blog->get_allowed_item_status(); |
2704 | + if( empty( $item_status ) ) |
2705 | + { |
2706 | + $Messages->add( T_('Sorry, you have no permission to post into this blog.'), 'error' ); |
2707 | + break; |
2708 | + } |
2709 | + |
2710 | + // make sure we have loaded metas for all files in selection! |
2711 | + $selected_Filelist->load_meta(); |
2712 | + |
2713 | + // Ready to create post(s) |
2714 | + switch( $action ) |
2715 | + { |
2716 | + // SINGLE POST |
2717 | + case 'make_post': |
2718 | + // Create a post |
2719 | + $edited_Item = new Item(); |
2720 | + $edited_Item->set( 'status', $item_status ); |
2721 | + $edited_Item->set( 'main_cat_ID', $Blog->get_default_cat_ID() ); |
2722 | + |
2723 | + $l_File = & $selected_Filelist->get_next(); |
2724 | + |
2725 | + $title = $l_File->get( 'title' ); |
2726 | + if( empty( $title ) ) |
2727 | + { |
2728 | + $title = $l_File->get( 'name' ); |
2729 | + } |
2730 | + $edited_Item->set( 'title', $title ); |
2731 | + |
2732 | + $DB->begin(); |
2733 | + |
2734 | + // INSERT NEW POST INTO DB |
2735 | + $edited_Item->dbinsert(); |
2736 | + |
2737 | + do |
2738 | + { |
2739 | + // LOOP Through images |
2740 | + if( ! $l_File->is_image() ) |
2741 | + { |
2742 | + $Messages->add( sprintf( T_('Cannot post «%s» because it is not an image.'), $l_File->dget( 'name' ) ), 'error' ); |
2743 | + continue; |
2744 | + } |
2745 | + |
2746 | + if( $l_File->meta == 'notfound' ) |
2747 | + { |
2748 | + // That file has no meta data yet, create it now! |
2749 | + $l_File->dbsave(); |
2750 | + } |
2751 | + |
2752 | + // Let's make the link! |
2753 | + $edited_Link = new Link(); |
2754 | + $edited_Link->set( 'itm_ID', $edited_Item->ID ); |
2755 | + $edited_Link->set( 'file_ID', $l_File->ID ); |
2756 | + $edited_Link->dbinsert(); |
2757 | + |
2758 | + $Messages->add( sprintf( T_('«%s» has been attached.'), $l_File->dget( 'name' ) ), 'success' ); |
2759 | + |
2760 | + } while( $l_File = & $selected_Filelist->get_next() ); |
2761 | + |
2762 | + $DB->commit(); |
2763 | + |
2764 | + header_redirect( $dispatcher.'?ctrl=items&action=edit&p='.$edited_Item->ID ); // Will save $Messages |
2765 | + break; |
2766 | + |
2767 | + case 'make_posts': |
2768 | + // MULTIPLE POST (1 per image) |
2769 | + while( $l_File = & $selected_Filelist->get_next() ) |
2770 | + { |
2771 | + if( ! $l_File->is_image() ) |
2772 | + { |
2773 | + $Messages->add( sprintf( T_('Cannot post «%s» because it is not an image.'), $l_File->dget( 'name' ) ), 'error' ); |
2774 | + continue; |
2775 | + } |
2776 | + |
2777 | + // Create a post |
2778 | + $edited_Item = new Item(); |
2779 | + $edited_Item->set( 'status', $item_status ); |
2780 | + $edited_Item->set( 'main_cat_ID', $Blog->get_default_cat_ID() ); |
2781 | + |
2782 | + $title = $l_File->get( 'title' ); |
2783 | + if( empty( $title ) ) |
2784 | + { |
2785 | + $title = $l_File->get( 'name' ); |
2786 | + } |
2787 | + $edited_Item->set( 'title', $title ); |
2788 | + |
2789 | + $DB->begin(); |
2790 | + |
2791 | + // INSERT NEW POST INTO DB |
2792 | + $edited_Item->dbinsert(); |
2793 | + |
2794 | + if( $l_File->meta == 'notfound' ) |
2795 | + { |
2796 | + // That file has no meta data yet, create it now! |
2797 | + $l_File->dbsave(); |
2798 | + } |
2799 | + |
2800 | + // Let's make the link! |
2801 | + $edited_Link = new Link(); |
2802 | + $edited_Link->set( 'itm_ID', $edited_Item->ID ); |
2803 | + $edited_Link->set( 'file_ID', $l_File->ID ); |
2804 | + $edited_Link->dbinsert(); |
2805 | + |
2806 | + $DB->commit(); |
2807 | + |
2808 | + $Messages->add( sprintf( T_('«%s» has been posted.'), $l_File->dget( 'name' ) ), 'success' ); |
2809 | + } |
2810 | + |
2811 | + // Note: we redirect without restoring filter. This should allow to see the new files. |
2812 | + // &filter=restore |
2813 | + header_redirect( $dispatcher.'?ctrl=items&blog='.$blog ); // Will save $Messages |
2814 | + |
2815 | + break; |
2816 | + } |
2817 | + |
2818 | + // Note: we should have EXITED here. In case we don't (error, or sth...) |
2819 | + // Reset stuff so it doesn't interfere with upcomming display |
2820 | + unset( $edited_Item ); |
2821 | + unset( $edited_Link ); |
2822 | + $selected_Filelist = new Filelist( $fm_Filelist->get_FileRoot(), false ); |
2823 | + break; |
2824 | + |
2825 | + // Edit Text File |
2826 | case 'edit_file': |
2827 | - // TODO: We don't need the Filelist, move UP! |
2828 | - // Edit Text File |
2829 | - |
2830 | - // Check permission! |
2831 | - $current_User->check_perm( 'files', 'edit', true ); |
2832 | - |
2833 | - // Get the file we want to edit: |
2834 | - $edited_File = & $selected_Filelist->get_by_idx(0); |
2835 | - |
2836 | - // Check that the file is editable: |
2837 | - if( ! $edited_File->is_editable( $current_User->check_perm( 'files', 'all' ) ) ) |
2838 | - { |
2839 | - $Messages->add( sprintf( T_( 'You are not allowed to edit «%s».' ), $edited_File->dget('name') ), 'error' ); |
2840 | - // Leave special display mode: |
2841 | - $action = 'list'; |
2842 | - break; |
2843 | - } |
2844 | - |
2845 | - $full_path = $edited_File->get_full_path(); |
2846 | - if( $size = filesize($full_path) ) |
2847 | - { |
2848 | - $rsc_handle = fopen( $full_path, 'r'); |
2849 | - $edited_File->content = fread( $rsc_handle, $size ); |
2850 | - fclose( $rsc_handle ); |
2851 | - } |
2852 | - else |
2853 | - { // Empty file |
2854 | - $edited_File->content = ''; |
2855 | - } |
2856 | + |
2857 | + // Check permission! |
2858 | + $current_User->check_perm( 'files', 'edit', true ); |
2859 | + |
2860 | + // Get the file we want to edit |
2861 | + $edited_File = & $selected_Filelist->get_by_idx(0); |
2862 | + |
2863 | + // Check that the file is editable |
2864 | + if( ! $edited_File->is_editable( $current_User->check_perm( 'files', 'all' ) ) ) |
2865 | + { |
2866 | + $Messages->add( sprintf( T_( 'You are not allowed to edit «%s».' ), $edited_File->dget( 'name' ) ), 'error' ); |
2867 | + // Leave special display mode |
2868 | + $action = 'list'; |
2869 | break; |
2870 | - |
2871 | - |
2872 | + } |
2873 | + |
2874 | + $full_path = $edited_File->get_full_path(); |
2875 | + if( $size = filesize( $full_path ) ) |
2876 | + { |
2877 | + $rsc_handle = fopen( $full_path, 'r'); |
2878 | + $edited_File->content = fread( $rsc_handle, $size ); |
2879 | + fclose( $rsc_handle ); |
2880 | + } |
2881 | + else |
2882 | + { |
2883 | + // Empty file |
2884 | + $edited_File->content = ''; |
2885 | + } |
2886 | + break; |
2887 | + |
2888 | + // Edit File properties (Meta Data) |
2889 | case 'edit_properties': |
2890 | - // TODO: We don't need the Filelist, move UP! |
2891 | - // Edit File properties (Meta Data) |
2892 | - |
2893 | - // Check permission! |
2894 | - $current_User->check_perm( 'files', 'edit', true ); |
2895 | - |
2896 | - $edited_File = & $selected_Filelist->get_by_idx(0); |
2897 | - $edited_File->load_meta(); |
2898 | - break; |
2899 | - |
2900 | - |
2901 | + // Check permission! |
2902 | + $current_User->check_perm( 'files', 'edit', true ); |
2903 | + |
2904 | + $edited_File = & $selected_Filelist->get_by_idx(0); |
2905 | + $edited_File->load_meta(); |
2906 | + break; |
2907 | + |
2908 | + // Update File properties (Meta Data); on success this ends the file_properties mode |
2909 | case 'update_properties': |
2910 | - // TODO: We don't need the Filelist, move UP! |
2911 | - // Update File properties (Meta Data); on success this ends the file_properties mode: |
2912 | - |
2913 | - // Check permission! |
2914 | - $current_User->check_perm( 'files', 'edit', true ); |
2915 | - |
2916 | - $edited_File = & $selected_Filelist->get_by_idx(0); |
2917 | - // Load meta data: |
2918 | - $edited_File->load_meta(); |
2919 | - |
2920 | - $edited_File->set( 'title', param( 'title', 'string', '' ) ); |
2921 | - $edited_File->set( 'alt', param( 'alt', 'string', '' ) ); |
2922 | - $edited_File->set( 'desc', param( 'desc', 'string', '' ) ); |
2923 | - |
2924 | - // Store File object into DB: |
2925 | - if( $edited_File->dbsave() ) |
2926 | - { |
2927 | - $Messages->add( sprintf( T_( 'File properties for «%s» have been updated.' ), $edited_File->dget('name') ), 'success' ); |
2928 | - } |
2929 | - else |
2930 | - { |
2931 | - $Messages->add( sprintf( T_( 'File properties for «%s» have not changed.' ), $edited_File->dget('name') ), 'note' ); |
2932 | - } |
2933 | - break; |
2934 | + // Check permission! |
2935 | + $current_User->check_perm( 'files', 'edit', true ); |
2936 | + |
2937 | + $edited_File = & $selected_Filelist->get_by_idx(0); |
2938 | + // Load meta data |
2939 | + $edited_File->load_meta(); |
2940 | + |
2941 | + $edited_File->set( 'title', param( 'title', 'string', '' ) ); |
2942 | + $edited_File->set( 'alt', param( 'alt', 'string', '' ) ); |
2943 | + $edited_File->set( 'desc', param( 'desc', 'string', '' ) ); |
2944 | + |
2945 | + // Store File object into DB |
2946 | + if( $edited_File->dbsave() ) |
2947 | + { |
2948 | + $Messages->add( sprintf( T_( 'File properties for «%s» have been updated.' ), $edited_File->dget( 'name' ) ), 'success' ); |
2949 | + } |
2950 | + else |
2951 | + { |
2952 | + $Messages->add( sprintf( T_( 'File properties for «%s» have not changed.' ), $edited_File->dget( 'name' ) ), 'note' ); |
2953 | + } |
2954 | + break; |
2955 | |
2956 | |
2957 | case 'link_user': |
2958 | - // TODO: We don't need the Filelist, move UP! |
2959 | - // Link File to User: |
2960 | - if( ! isset($edited_User) ) |
2961 | - { // No User to link to |
2962 | - $fm_mode = NULL; // not really needed but just n case... |
2963 | - break; |
2964 | - } |
2965 | - |
2966 | - // Permission HAS been checked on top of controller! |
2967 | - |
2968 | - // Get the file we want to link: |
2969 | - if( !$selected_Filelist->count() ) |
2970 | - { |
2971 | - $Messages->add( T_('Nothing selected.'), 'error' ); |
2972 | - break; |
2973 | - } |
2974 | - $edited_File = & $selected_Filelist->get_by_idx(0); |
2975 | - |
2976 | - // Load meta data AND MAKE SURE IT IS CREATED IN DB: |
2977 | - $edited_File->load_meta( true ); |
2978 | - |
2979 | - // REDIRECT / EXIT |
2980 | - header_redirect( $admin_url.'?ctrl=users&user_ID='.$edited_User->ID ); |
2981 | - break; |
2982 | - |
2983 | + // Link File (Avatar) to User |
2984 | + if( ! isset( $edited_User ) ) |
2985 | + { |
2986 | + // No User to link to |
2987 | + $fm_mode = NULL; // not really needed but just in case... |
2988 | + break; |
2989 | + } |
2990 | + |
2991 | + // Permission HAS been checked on top of controller! |
2992 | + |
2993 | + // Get the file we want to link |
2994 | + if( ! $selected_Filelist->count() ) |
2995 | + { |
2996 | + $Messages->add( T_('Nothing selected.'), 'error' ); |
2997 | + break; |
2998 | + } |
2999 | + $edited_File = & $selected_Filelist->get_by_idx( 0 ); |
3000 | + |
3001 | + // Load meta data AND MAKE SURE IT IS CREATED IN DB |
3002 | + $edited_File->load_meta( true ); |
3003 | + |
3004 | + // "Extended Identity" section - (avatar selection) |
3005 | + $edited_User->set( 'avatar_ID', $edited_File->ID ); |
3006 | + $edited_User->dbupdate(); |
3007 | + $Messages->add( T_('User avatar modified.'), 'success' ); |
3008 | + |
3009 | + // REDIRECT / EXIT |
3010 | + header_redirect( $admin_url.'?ctrl=users&user_ID='.$edited_User->ID ); |
3011 | + break; |
3012 | |
3013 | case 'link': |
3014 | - case 'link_inpost': // In the context of a post |
3015 | - // TODO: We don't need the Filelist, move UP! |
3016 | - // Link File to Item |
3017 | - |
3018 | - // Note: we are not modifying any file here, we're just linking it |
3019 | - // we only need read perm on file, but we'll need write perm on destination object (to be checked below) |
3020 | - |
3021 | - if( ! isset($edited_Item) ) |
3022 | - { // No Item to link to - end link_item mode. |
3023 | - $fm_mode = NULL; |
3024 | - break; |
3025 | - } |
3026 | - |
3027 | - // Check item EDIT permissions: |
3028 | - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); |
3029 | - |
3030 | - // Get the file we want to link: |
3031 | - if( !$selected_Filelist->count() ) |
3032 | - { |
3033 | - $Messages->add( T_('Nothing selected.'), 'error' ); |
3034 | - break; |
3035 | - } |
3036 | - $edited_File = & $selected_Filelist->get_by_idx(0); |
3037 | - |
3038 | - $DB->begin(); |
3039 | - |
3040 | - // Load meta data AND MAKE SURE IT IS CREATED IN DB: |
3041 | - $edited_File->load_meta( true ); |
3042 | - |
3043 | - // Let's make the link! |
3044 | - $edited_Link = new Link(); |
3045 | - $edited_Link->set( 'itm_ID', $edited_Item->ID ); |
3046 | - $edited_Link->set( 'file_ID', $edited_File->ID ); |
3047 | - $edited_Link->dbinsert(); |
3048 | - |
3049 | - $DB->commit(); |
3050 | - |
3051 | - $Messages->add( T_('Selected file has been linked to item.'), 'success' ); |
3052 | - |
3053 | - // In case the mode had been closed, reopen it: |
3054 | - $fm_mode = 'link_item'; |
3055 | - |
3056 | - |
3057 | - // REDIRECT / EXIT |
3058 | - if( $action == 'link_inpost' ) |
3059 | - { |
3060 | - header_redirect( $admin_url.'?ctrl=items&action=edit_links&mode=iframe&item_ID='.$edited_Item->ID ); |
3061 | - } |
3062 | - else |
3063 | - { |
3064 | - header_redirect( regenerate_url( '', '', '', '&' ) ); |
3065 | - } |
3066 | - break; |
3067 | - |
3068 | + case 'link_inpost': |
3069 | + // In the context of a post |
3070 | + // Link File to Item |
3071 | + |
3072 | + // Note: we are not modifying any file here, we're just linking it. we only need read |
3073 | + // perm on file, but we'll need write perm on destination object (to be checked below) |
3074 | + if( ! isset( $edited_Item ) ) |
3075 | + { |
3076 | + // No Item to link to - end link_item mode. |
3077 | + $fm_mode = NULL; |
3078 | + break; |
3079 | + } |
3080 | + |
3081 | + // Check item EDIT permissions |
3082 | + $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); |
3083 | + |
3084 | + // Get the file we want to link |
3085 | + if( !$selected_Filelist->count() ) |
3086 | + { |
3087 | + $Messages->add( T_('Nothing selected.'), 'error' ); |
3088 | + break; |
3089 | + } |
3090 | + $edited_File = & $selected_Filelist->get_by_idx(0); |
3091 | + |
3092 | + $DB->begin(); |
3093 | + |
3094 | + // Load meta data AND MAKE SURE IT IS CREATED IN DB |
3095 | + $edited_File->load_meta( true ); |
3096 | + |
3097 | + // Let's make the link! |
3098 | + $edited_Link = new Link(); |
3099 | + $edited_Link->set( 'itm_ID', $edited_Item->ID ); |
3100 | + $edited_Link->set( 'file_ID', $edited_File->ID ); |
3101 | + $edited_Link->dbinsert(); |
3102 | + |
3103 | + $DB->commit(); |
3104 | + |
3105 | + $Messages->add( T_('Selected file has been linked to item.'), 'success' ); |
3106 | + |
3107 | + // In case the mode had been closed, reopen it |
3108 | + $fm_mode = 'link_item'; |
3109 | + |
3110 | + |
3111 | + // REDIRECT / EXIT |
3112 | + if( $action == 'link_inpost' ) |
3113 | + { |
3114 | + header_redirect( $admin_url.'?ctrl=items&action=edit_links&mode=iframe&item_ID='.$edited_Item->ID ); |
3115 | + } |
3116 | + else |
3117 | + { |
3118 | + header_redirect( regenerate_url( '', '', '', '&' ) ); |
3119 | + } |
3120 | + break; |
3121 | |
3122 | case 'unlink': |
3123 | - // TODO: We don't need the Filelist, move UP! |
3124 | - // Unlink File from Item (or other object if extended): |
3125 | - |
3126 | - // Note: we are not modifying any file here, we're just linking it |
3127 | - // we only need read perm on file, but we'll need write perm on destination object (to be checked below) |
3128 | - |
3129 | - if( !isset( $edited_Link ) ) |
3130 | - { |
3131 | - $action = 'list'; |
3132 | - break; |
3133 | - } |
3134 | - |
3135 | - // get Item (or other object) from Link to check perm |
3136 | - $edited_Item = & $edited_Link->Item; |
3137 | - |
3138 | - // Check that we have permission to edit item: |
3139 | - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); |
3140 | - |
3141 | - // Delete from DB: |
3142 | - $msg = sprintf( T_('Link from «%s» deleted.'), $edited_Link->Item->dget('title') ); |
3143 | - $edited_Link->dbdelete( true ); |
3144 | - unset( $edited_Link ); |
3145 | - forget_param( 'link_ID' ); |
3146 | - |
3147 | - $Messages->add( $msg, 'success' ); |
3148 | + // Unlink File from Item (or other object if extended): |
3149 | + // Note: we are not modifying any file here, we're just linking it |
3150 | + // we only need read perm on file, but we'll need write perm on destination object (to be checked below) |
3151 | + |
3152 | + if( ! isset( $edited_Link ) ) |
3153 | + { |
3154 | $action = 'list'; |
3155 | - // REDIRECT / EXIT |
3156 | - header_redirect( regenerate_url( '', '', '', '&' ) ); |
3157 | break; |
3158 | - |
3159 | + } |
3160 | + |
3161 | + // get Item (or other object) from Link to check perm |
3162 | + $edited_Item = & $edited_Link->Item; |
3163 | + |
3164 | + // Check that we have permission to edit item: |
3165 | + $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); |
3166 | + |
3167 | + // Delete from DB |
3168 | + $msg = sprintf( T_('Link from «%s» deleted.'), $edited_Link->Item->dget( 'title' ) ); |
3169 | + $edited_Link->dbdelete( true ); |
3170 | + unset( $edited_Link ); |
3171 | + forget_param( 'link_ID' ); |
3172 | + |
3173 | + $Messages->add( $msg, 'success' ); |
3174 | + $action = 'list'; |
3175 | + // REDIRECT / EXIT |
3176 | + header_redirect( regenerate_url( '', '', '', '&' ) ); |
3177 | + break; |
3178 | |
3179 | case 'edit_perms': |
3180 | - // TODO: We don't need the Filelist, move UP! |
3181 | - // Edit file or directory permissions: |
3182 | - |
3183 | - if( ! $current_User->check_perm( 'files', 'edit' ) ) |
3184 | - { // We do not have permission to edit files |
3185 | - $Messages->add( T_('You have no permission to edit/modify files.'), 'error' ); |
3186 | - $action = 'list'; |
3187 | - break; |
3188 | - } |
3189 | - |
3190 | - if( ! $selected_Filelist->count() ) |
3191 | - { |
3192 | - $Messages->add( T_('Nothing selected.'), 'error' ); |
3193 | - $action = 'list'; |
3194 | - break; |
3195 | - } |
3196 | - |
3197 | - |
3198 | - param( 'perms', 'array', array() ); |
3199 | - param( 'edit_perms_default' ); // default value when multiple files are selected |
3200 | - param( 'use_default_perms', 'array', array() ); // array of file IDs that should be set to default |
3201 | - |
3202 | - if( count( $use_default_perms ) && $edit_perms_default === '' ) |
3203 | - { |
3204 | - param_error( 'edit_perms_default', T_('You have to give a default permission!') ); |
3205 | - break; |
3206 | - } |
3207 | - |
3208 | - // form params |
3209 | - $perms_read_readonly = is_windows(); |
3210 | - $field_options_read_readonly = array( |
3211 | - array( 'value' => 444, 'label' => T_('Read-only') ), |
3212 | - array( 'value' => 666, 'label' => T_('Read and write') ) ); |
3213 | - $more_than_one_selected_file = ( $selected_Filelist->count() > 1 ); |
3214 | - |
3215 | - if( count( $perms ) || count( $use_default_perms ) ) |
3216 | - { // New permissions given, change them |
3217 | - $selected_Filelist->restart(); |
3218 | - while( $l_File = & $selected_Filelist->get_next() ) |
3219 | - { |
3220 | - if( in_array( $l_File->get_md5_ID(), $use_default_perms ) ) |
3221 | - { // use default |
3222 | - $chmod = $edit_perms_default; |
3223 | - } |
3224 | - elseif( !isset($perms[ $l_File->get_md5_ID() ]) ) |
3225 | - { // happens for an empty text input or when no radio option is selected |
3226 | - $Messages->add( sprintf( T_('Permissions for «%s» have not been changed.'), $l_File->dget('name') ), 'note' ); |
3227 | - continue; |
3228 | - } |
3229 | - else |
3230 | - { // provided for this file |
3231 | - $chmod = $perms[ $l_File->get_md5_ID() ]; |
3232 | - } |
3233 | - |
3234 | - $oldperms = $l_File->get_perms( 'raw' ); |
3235 | - $newperms = $l_File->chmod( octdec( $chmod ) ); |
3236 | - |
3237 | - if( $newperms === false ) |
3238 | - { |
3239 | - $Messages->add( sprintf( T_('Failed to set permissions on «%s» to «%s».'), $l_File->dget('name'), $chmod ), 'error' ); |
3240 | - } |
3241 | - else |
3242 | - { |
3243 | - // Success, remove the file from the list of selected files: |
3244 | - $selected_Filelist->remove( $l_File ); |
3245 | - |
3246 | - if( $newperms === $oldperms ) |
3247 | - { |
3248 | - $Messages->add( sprintf( T_('Permissions for «%s» have not been changed.'), $l_File->dget('name') ), 'note' ); |
3249 | - } |
3250 | - else |
3251 | - { |
3252 | - $Messages->add( sprintf( T_('Permissions for «%s» changed to «%s».'), $l_File->dget('name'), $l_File->get_perms() ), 'success' ); |
3253 | - } |
3254 | - } |
3255 | - } |
3256 | - } |
3257 | - |
3258 | - if( !$selected_Filelist->count() ) |
3259 | - { // No file left selected... (everything worked fine) |
3260 | - $action = 'list'; |
3261 | - } |
3262 | - break; |
3263 | + // Edit file or directory permissions: |
3264 | + if( ! $current_User->check_perm( 'files', 'edit' ) ) |
3265 | + { |
3266 | + // We do not have permission to edit files |
3267 | + $Messages->add( T_('You have no permission to edit/modify files.'), 'error' ); |
3268 | + $action = 'list'; |
3269 | + break; |
3270 | + } |
3271 | + |
3272 | + if( ! $selected_Filelist->count() ) |
3273 | + { |
3274 | + $Messages->add( T_('Nothing selected.'), 'error' ); |
3275 | + $action = 'list'; |
3276 | + break; |
3277 | + } |
3278 | + |
3279 | + param( 'perms', 'array', array() ); |
3280 | + // default value when multiple files are selected |
3281 | + param( 'edit_perms_default' ); |
3282 | + // array of file IDs that should be set to default |
3283 | + param( 'use_default_perms', 'array', array() ); |
3284 | + |
3285 | + if( count( $use_default_perms ) && $edit_perms_default === '' ) |
3286 | + { |
3287 | + param_error( 'edit_perms_default', T_('You have to give a default permission!') ); |
3288 | + break; |
3289 | + } |
3290 | + |
3291 | + // form params |
3292 | + $perms_read_readonly = is_windows(); |
3293 | + $field_options_read_readonly = array( |
3294 | + array( 'value' => 444, 'label' => T_('Read-only') ), |
3295 | + array( 'value' => 666, 'label' => T_('Read and write') |
3296 | + ) ); |
3297 | + $more_than_one_selected_file = ( $selected_Filelist->count() > 1 ); |
3298 | + |
3299 | + if( count( $perms ) || count( $use_default_perms ) ) |
3300 | + { |
3301 | + // New permissions given, change them |
3302 | + $selected_Filelist->restart(); |
3303 | + while( $l_File = & $selected_Filelist->get_next() ) |
3304 | + { |
3305 | + if( in_array( $l_File->get_md5_ID(), $use_default_perms ) ) |
3306 | + { |
3307 | + // use default |
3308 | + $chmod = $edit_perms_default; |
3309 | + } |
3310 | + elseif( ! isset( $perms[$l_File->get_md5_ID()] ) ) |
3311 | + { |
3312 | + // happens for an empty text input or when no radio option is selected |
3313 | + $Messages->add( sprintf( T_('Permissions for «%s» have not been changed.'), $l_File->dget( 'name' ) ), 'note' ); |
3314 | + continue; |
3315 | + } |
3316 | + else |
3317 | + { |
3318 | + // provided for this file |
3319 | + $chmod = $perms[$l_File->get_md5_ID()]; |
3320 | + } |
3321 | + |
3322 | + $oldperms = $l_File->get_perms( 'raw' ); |
3323 | + $newperms = $l_File->chmod( octdec( $chmod ) ); |
3324 | + |
3325 | + if( $newperms === false ) |
3326 | + { |
3327 | + $Messages->add( sprintf( T_('Failed to set permissions on «%s» to «%s».'), $l_File->dget( 'name' ), $chmod ), 'error' ); |
3328 | + } |
3329 | + else |
3330 | + { |
3331 | + // Success, remove the file from the list of selected files |
3332 | + $selected_Filelist->remove( $l_File ); |
3333 | + |
3334 | + if( $newperms === $oldperms ) |
3335 | + { |
3336 | + $Messages->add( sprintf( T_('Permissions for «%s» have not been changed.'), $l_File->dget( 'name' ) ), 'note' ); |
3337 | + } |
3338 | + else |
3339 | + { |
3340 | + $Messages->add( sprintf( T_('Permissions for «%s» changed to «%s».'), $l_File->dget( 'name' ), $l_File->get_perms() ), 'success' ); |
3341 | + } |
3342 | + } |
3343 | + } |
3344 | + } |
3345 | + |
3346 | + if( !$selected_Filelist->count() ) |
3347 | + { |
3348 | + // No file left selected ... (everything worked fine) |
3349 | + $action = 'list'; |
3350 | + } |
3351 | + break; |
3352 | } |
3353 | |
3354 | -// Prepare for modes: |
3355 | +// Prepare for modes |
3356 | switch( $fm_mode ) |
3357 | { |
3358 | case 'file_copy': |
3359 | case 'file_move': |
3360 | - // ------------------------ |
3361 | - // copy/move a file: |
3362 | - // ------------------------ |
3363 | - /* |
3364 | - * fplanque>> This whole thing is flawed: |
3365 | - * 1) only geeks can possibly like to use the same interface for renaming, moving and copying |
3366 | - * 2) even the geeky unix commands won't pretend copying and moving are the same thing. They are not! |
3367 | - * Only moving and renaming are similar, and again FOR GEEKS ONLY. |
3368 | - * 3) The way this works it breaks the File meta data (I'm working on it). |
3369 | - * 4) For Move and Copy, this should use a "destination directory tree" on the right (same as for upload) |
3370 | - * 5) Given all the reasons above copy, move and rename should be clearly separated into 3 different interfaces. |
3371 | - * |
3372 | - * blueyed>> it was never meant to only use a single interface. The original mode |
3373 | - * 'file_cmr' was just a mode to handle it internally easier/more central. |
3374 | - * 'copy' is just 'move and keep the source', while 'rename' is 'move in the same dir' |
3375 | - * |
3376 | - */ |
3377 | - |
3378 | - /* |
3379 | - TODO: On error notes use prefixed names, if the roots differ. |
3380 | - Something like $fm_Filelist->get_names_realtive_to( $a_File, $b_File, $root_type, $root_ID, $rel_path ) |
3381 | - that returns an array containing the name of $a_File and $b_File relative to the Root path given as |
3382 | - param 3, 4, 5. |
3383 | - This would allow to say "Copied «users/admin/test_me.jpg» to «test_me.jpg»." rather than just |
3384 | - "Copied «test_me.jpg» to «test_me.jpg».". |
3385 | - // fp>> I don't really understand this (probably missing a verb) but I do think that extending the Fileman object is not the right direction to go on the long term |
3386 | - // blueyed>> Tried to make it clearer. If it wasn't a Filemanager method, it has to be a function or |
3387 | - // a method of the File class. IMHO it should be a method of the (to be killed) Filemanager object. |
3388 | - // fp>> Okay. It should *definitely* be a method of the File object and we should ask for ONE file at a time. Any question about 'where is the file?' (what/where/when/who, etc) should be asked to the File object itself. |
3389 | - */ |
3390 | - |
3391 | - if( ! $current_User->check_perm( 'files', 'edit' ) ) |
3392 | - { // We do not have permission to edit files |
3393 | - $Messages->add( T_('You have no permission to edit/modify files.'), 'error' ); |
3394 | - $fm_mode = NULL; |
3395 | - break; |
3396 | - } |
3397 | - |
3398 | - // Get the source list |
3399 | - if( $fm_sources = param( 'fm_sources', 'array', array(), true ) ) |
3400 | - { |
3401 | - $fm_sources_root = param( 'fm_sources_root', 'string', '', true ); |
3402 | - |
3403 | - $sources_Root = & $FileRootCache->get_by_ID( $fm_sources_root ); |
3404 | - |
3405 | - if( $sources_Root ) |
3406 | - { // instantiate the source list for the selected sources |
3407 | - $fm_source_Filelist = new Filelist( $sources_Root ); |
3408 | - } |
3409 | - else |
3410 | - { // Fallback: source files are considered to be in the current root |
3411 | - $fm_source_Filelist = new Filelist( $fm_Filelist->get_FileRoot() ); |
3412 | - $Debuglog->add( 'SourceList without explicit root!', 'error' ); |
3413 | - } |
3414 | - |
3415 | - if( $fm_source_Filelist ) |
3416 | - { |
3417 | - // TODO: should fail for non-existant sources, or sources where no read-perm |
3418 | - foreach( $fm_sources as $l_source_path ) |
3419 | - { |
3420 | - $fm_source_Filelist->add_by_subpath( urldecode($l_source_path), true ); |
3421 | - } |
3422 | - } |
3423 | - else |
3424 | - { // Without SourceList there's no mode |
3425 | - $fm_mode = false; |
3426 | - } |
3427 | - } |
3428 | - else |
3429 | - { |
3430 | - $fm_source_Filelist = false; |
3431 | - $fm_sources = NULL; |
3432 | - $fm_sources_root = NULL; |
3433 | - } |
3434 | - |
3435 | - if( ! $fm_source_Filelist || ! $fm_source_Filelist->count() ) |
3436 | - { |
3437 | - $Messages->add( T_('No source files!'), 'error' ); |
3438 | - $fm_mode = NULL; |
3439 | - break; |
3440 | - } |
3441 | - |
3442 | - param( 'confirm', 'integer', 0 ); |
3443 | - param( 'new_names', 'array', array() ); |
3444 | - param( 'overwrite', 'array', array() ); |
3445 | - |
3446 | - // Check params for each file to rename: |
3447 | + // copy/move a file |
3448 | + |
3449 | + /* |
3450 | + TODO: On error notes use prefixed names, if the roots differ. |
3451 | + Something like $fm_Filelist->get_names_realtive_to( $a_File, $b_File, $root_type, $root_ID, $rel_path ) |
3452 | + that returns an array containing the name of $a_File and $b_File relative to the Root path given as |
3453 | + param 3, 4, 5. |
3454 | + This would allow to say "Copied «users/admin/test_me.jpg» to «test_me.jpg»." rather than just |
3455 | + "Copied «test_me.jpg» to «test_me.jpg».". |
3456 | + // fp>> I don't really understand this (probably missing a verb) but I do think that extending the Fileman object is not the right direction to go on the long term |
3457 | + // blueyed>> Tried to make it clearer. If it wasn't a Filemanager method, it has to be a function or |
3458 | + // a method of the File class. IMHO it should be a method of the (to be killed) Filemanager object. |
3459 | + // fp>> Okay. It should *definitely* be a method of the File object and we should ask for ONE file at a time. Any question about 'where is the file?' (what/where/when/who, etc) should be asked to the File object itself. |
3460 | + */ |
3461 | + |
3462 | + if( ! $current_User->check_perm( 'files', 'edit' ) ) |
3463 | + { |
3464 | + // We do not have permission to edit files |
3465 | + $Messages->add( T_('You have no permission to edit/modify files.'), 'error' ); |
3466 | + $fm_mode = NULL; |
3467 | + break; |
3468 | + } |
3469 | + |
3470 | + // Get the source list |
3471 | + if( $fm_sources = param( 'fm_sources', 'array', array(), true ) ) |
3472 | + { |
3473 | + $fm_sources_root = param( 'fm_sources_root', 'string', '', true ); |
3474 | + $sources_Root = & $FileRootCache->get_by_ID( $fm_sources_root ); |
3475 | + |
3476 | + if( $sources_Root ) |
3477 | + { |
3478 | + // instantiate the source list for the selected sources |
3479 | + $fm_source_Filelist = new Filelist( $sources_Root ); |
3480 | + } |
3481 | + else |
3482 | + { |
3483 | + // Fallback: source files are considered to be in the current root |
3484 | + $fm_source_Filelist = new Filelist( $fm_Filelist->get_FileRoot() ); |
3485 | + } |
3486 | + |
3487 | + if( $fm_source_Filelist ) |
3488 | + { |
3489 | + foreach( $fm_sources as $l_source_path ) |
3490 | + { |
3491 | + $fm_source_Filelist->add_by_subpath( urldecode( $l_source_path ), true ); |
3492 | + } |
3493 | + } |
3494 | + else |
3495 | + { |
3496 | + // Without SourceList there's no mode |
3497 | + $fm_mode = false; |
3498 | + } |
3499 | + } |
3500 | + else |
3501 | + { |
3502 | + $fm_source_Filelist = false; |
3503 | + $fm_sources = NULL; |
3504 | + $fm_sources_root = NULL; |
3505 | + } |
3506 | + |
3507 | + if( ! $fm_source_Filelist || ! $fm_source_Filelist->count() ) |
3508 | + { |
3509 | + $Messages->add( T_('No source files!'), 'error' ); |
3510 | + $fm_mode = NULL; |
3511 | + break; |
3512 | + } |
3513 | + |
3514 | + param( 'confirm', 'integer', 0 ); |
3515 | + param( 'new_names', 'array', array() ); |
3516 | + param( 'overwrite', 'array', array() ); |
3517 | + |
3518 | + // Check params for each file to rename |
3519 | + while( $loop_src_File = & $fm_source_Filelist->get_next() ) |
3520 | + { |
3521 | + if( ! $loop_src_File->exists() ) |
3522 | + { |
3523 | + // this can happen on reloading the page |
3524 | + $fm_source_Filelist->remove( $loop_src_File ); |
3525 | + continue; |
3526 | + } |
3527 | + if( ! isset( $new_names[$loop_src_File->get_md5_ID()] ) ) |
3528 | + { |
3529 | + // We have not yet provided a name to rename to... |
3530 | + $confirm = 0; |
3531 | + $new_names[$loop_src_File->get_md5_ID()] = $loop_src_File->get( 'name' ); |
3532 | + continue; |
3533 | + } |
3534 | + |
3535 | + // Check if provided name is okay |
3536 | + $new_names[$loop_src_File->get_md5_ID()] = trim( strip_tags( $new_names[$loop_src_File->get_md5_ID()] ) ); |
3537 | + |
3538 | + if( !$loop_src_File->is_dir() ) |
3539 | + { |
3540 | + if( $error_filename = validate_filename( $new_names[$loop_src_File->get_md5_ID()] ) ) |
3541 | + { |
3542 | + // Not a file name or not an allowed extension |
3543 | + $confirm = 0; |
3544 | + $Messages->add( $error_filename, 'error' ); |
3545 | + continue; |
3546 | + } |
3547 | + } |
3548 | + elseif( $error_dirname = validate_dirname( $new_names[$loop_src_File->get_md5_ID()] ) ) |
3549 | + { |
3550 | + // Not a directory name |
3551 | + $confirm = 0; |
3552 | + $Messages->add( $error_dirname, 'error' ); |
3553 | + continue; |
3554 | + } |
3555 | + |
3556 | + // Check if destination file exists |
3557 | + $FileCache = & get_Cache( 'FileCache' ); |
3558 | + if( ( $dest_File = & $FileCache->get_by_root_and_path( $fm_Filelist->get_root_type(), $fm_Filelist->get_root_ID(), $fm_Filelist->get_rds_list_path().$new_names[$loop_src_File->get_md5_ID()] ) ) |
3559 | + && $dest_File->exists() ) |
3560 | + { |
3561 | + // Target exists |
3562 | + if( $dest_File === $loop_src_File ) |
3563 | + { |
3564 | + param_error( 'new_names['.$loop_src_File->get_md5_ID().']', T_('Source and target files are the same. Please choose another name or directory.') ); |
3565 | + $confirm = 0; |
3566 | + continue; |
3567 | + } |
3568 | + |
3569 | + if( ! isset( $overwrite[$loop_src_File->get_md5_ID()] ) ) |
3570 | + { |
3571 | + // We have not yet asked to overwrite |
3572 | + param_error( 'new_names['.$loop_src_File->get_md5_ID().']', sprintf( T_('The file «%s» already exists.'), $dest_File->get_rdfp_rel_path() ) ); |
3573 | + $overwrite[$loop_src_File->get_md5_ID()] = 0; |
3574 | + $confirm = 0; |
3575 | + continue; |
3576 | + } |
3577 | + |
3578 | + // We have asked to overwite... |
3579 | + if( $fm_mode == 'file_copy' ) |
3580 | + { |
3581 | + // We are making a copy: no problem, we'll recycle the file ID anyway |
3582 | + continue; |
3583 | + } |
3584 | + |
3585 | + // We are moving, we'll need to unlink the target file and drop it's meta data |
3586 | + // Check if there are delete restrictions on this file: |
3587 | + $dest_File->check_relations( 'delete_restrictions' ); |
3588 | + |
3589 | + if( $Messages->count('restrict') ) |
3590 | + { |
3591 | + // There are restrictions |
3592 | + param_error( 'new_names['.$loop_src_File->get_md5_ID().']', sprintf( T_('Cannot overwrite the file «%s» because of the following relations'), $dest_File->get_rdfp_rel_path() ) ); |
3593 | + |
3594 | + $confirm = 0; |
3595 | + break; // stop whole file list processing |
3596 | + } |
3597 | + } |
3598 | + } |
3599 | + |
3600 | + if( $confirm && $fm_source_Filelist->count() ) |
3601 | + { |
3602 | + // Copy/move is confirmed (and we still have files to copy/move), let's proceed |
3603 | + // Loop through files: |
3604 | + $fm_source_Filelist->restart(); |
3605 | while( $loop_src_File = & $fm_source_Filelist->get_next() ) |
3606 | { |
3607 | - if( ! $loop_src_File->exists() ) |
3608 | - { // this can happen on reloading the page |
3609 | - $fm_source_Filelist->remove($loop_src_File); |
3610 | - continue; |
3611 | - } |
3612 | - if( ! isset( $new_names[$loop_src_File->get_md5_ID()] ) ) |
3613 | - { // We have not yet provided a name to rename to... |
3614 | - $confirm = 0; |
3615 | - $new_names[$loop_src_File->get_md5_ID()] = $loop_src_File->get('name'); |
3616 | - continue; |
3617 | - } |
3618 | - |
3619 | - // Check if provided name is okay: |
3620 | - $new_names[$loop_src_File->get_md5_ID()] = trim(strip_tags($new_names[$loop_src_File->get_md5_ID()])); |
3621 | - |
3622 | - if( !$loop_src_File->is_dir() ) |
3623 | - { |
3624 | - if( $error_filename = validate_filename( $new_names[$loop_src_File->get_md5_ID()] ) ) |
3625 | - { // Not a file name or not an allowed extension |
3626 | - $confirm = 0; |
3627 | - $Messages->add( $error_filename , 'error' ); |
3628 | - continue; |
3629 | - } |
3630 | - } |
3631 | - elseif( $error_dirname = validate_dirname( $new_names[$loop_src_File->get_md5_ID()] ) ) |
3632 | - { // Not a directory name |
3633 | - $confirm = 0; |
3634 | - $Messages->add( $error_dirname, 'error' ); |
3635 | - continue; |
3636 | - } |
3637 | - |
3638 | - // Check if destination file exists: |
3639 | + // Get a pointer on dest file |
3640 | $FileCache = & get_Cache( 'FileCache' ); |
3641 | - if( ($dest_File = & $FileCache->get_by_root_and_path( $fm_Filelist->get_root_type(), $fm_Filelist->get_root_ID(), $fm_Filelist->get_rds_list_path().$new_names[$loop_src_File->get_md5_ID()] )) |
3642 | - && $dest_File->exists() ) |
3643 | - { // Target exists |
3644 | - if( $dest_File === $loop_src_File ) |
3645 | - { |
3646 | - param_error( 'new_names['.$loop_src_File->get_md5_ID().']', T_('Source and target files are the same. Please choose another name or directory.') ); |
3647 | - $confirm = 0; |
3648 | - continue; |
3649 | - } |
3650 | - |
3651 | - if( ! isset( $overwrite[$loop_src_File->get_md5_ID()] ) ) |
3652 | - { // We have not yet asked to overwrite: |
3653 | - param_error( 'new_names['.$loop_src_File->get_md5_ID().']', sprintf( T_('The file «%s» already exists.'), $dest_File->get_rdfp_rel_path() ) ); |
3654 | - $overwrite[$loop_src_File->get_md5_ID()] = 0; |
3655 | - $confirm = 0; |
3656 | - continue; |
3657 | - } |
3658 | - |
3659 | - // We have asked to overwite... |
3660 | - if( $fm_mode == 'file_copy' ) |
3661 | - { // We are making a copy: no problem, we'll recycle the file ID anyway. |
3662 | - continue; |
3663 | - } |
3664 | - |
3665 | - // We are moving, we'll need to unlink the target file and drop it's meta data: |
3666 | - // Check if there are delete restrictions on this file: |
3667 | - $dest_File->check_relations( 'delete_restrictions' ); |
3668 | - |
3669 | - if( $Messages->count('restrict') ) |
3670 | - { // There are restrictions: |
3671 | - // TODO: work on a better output display here... |
3672 | - param_error( 'new_names['.$loop_src_File->get_md5_ID().']', sprintf( T_('Cannot overwrite the file «%s» because of the following relations'), $dest_File->get_rdfp_rel_path() ) ); |
3673 | - |
3674 | - $confirm = 0; |
3675 | - break; // stop whole file list processing |
3676 | - } |
3677 | - } |
3678 | - } |
3679 | - |
3680 | - if( $confirm && $fm_source_Filelist->count() ) |
3681 | - { // Copy/move is confirmed (and we still have files to copy/move), let's proceed: |
3682 | - |
3683 | - // Loop through files: |
3684 | - $fm_source_Filelist->restart(); |
3685 | - while( $loop_src_File = & $fm_source_Filelist->get_next() ) |
3686 | - { |
3687 | - // Get a pointer on dest file |
3688 | - $FileCache = & get_Cache( 'FileCache' ); |
3689 | - $dest_File = & $FileCache->get_by_root_and_path( $fm_Filelist->get_root_type(), $fm_Filelist->get_root_ID(), $fm_Filelist->get_rds_list_path().$new_names[$loop_src_File->get_md5_ID()] ); |
3690 | - |
3691 | - if( $fm_mode == 'file_copy' ) |
3692 | - { // COPY |
3693 | - |
3694 | - // Do the copy |
3695 | - if( $loop_src_File->copy_to( $dest_File ) ) |
3696 | - { // Success: |
3697 | - $Messages->add( sprintf( T_('Copied «%s» to «%s».'), |
3698 | - $loop_src_File->get_rdfp_rel_path(), $dest_File->get_rdfp_rel_path() ), 'success' ); |
3699 | - |
3700 | - if( $fm_Filelist->contains( $dest_File ) === false ) |
3701 | - { |
3702 | - $fm_Filelist->add( $dest_File ); |
3703 | - } |
3704 | - } |
3705 | - else |
3706 | - { // Failure: |
3707 | - param_error( 'new_names['.$loop_src_File->get_md5_ID().']', sprintf( T_('Could not copy «%s» to «%s».'), |
3708 | - $loop_src_File->get_rdfp_rel_path(), $dest_File->get_rdfp_rel_path() ) ); |
3709 | - } |
3710 | - } |
3711 | - elseif( $fm_mode == 'file_move' ) |
3712 | - { // MOVE |
3713 | - // NOTE: DB integrity is handled by the File object itself |
3714 | - $DB->begin(); |
3715 | - |
3716 | - if( isset( $overwrite[$loop_src_File->get_md5_ID()] ) |
3717 | - && $overwrite[$loop_src_File->get_md5_ID()] ) |
3718 | - { // We want to overwrite, let's unlink the old file: |
3719 | - if( ! $dest_File->unlink() ) |
3720 | - { // Unlink failed: |
3721 | - $DB->rollback(); |
3722 | - |
3723 | - $Messages->add( sprintf( ( $dest_File->is_dir() ? T_('Could not delete the directory «%s» (not empty?).') : T_('Could not delete the file «%s».') ), $dest_File->dget('name') ), 'error' ); |
3724 | - |
3725 | - // Move on to next file: |
3726 | - continue; |
3727 | - } |
3728 | - } |
3729 | - |
3730 | - // Do the move: |
3731 | - $rdfp_oldpath = $loop_src_File->get_rdfp_rel_path(); |
3732 | - $rdfp_newpath = $fm_Filelist->get_rds_list_path().$new_names[$loop_src_File->get_md5_ID()]; |
3733 | - |
3734 | - if( $loop_src_File->move_to( $fm_Filelist->get_root_type(), $fm_Filelist->get_root_ID(), $rdfp_newpath ) ) |
3735 | - { // successfully moved |
3736 | - $Messages->add( sprintf( T_('Moved «%s» to «%s».'), $rdfp_oldpath, $rdfp_newpath ), 'success' ); |
3737 | - |
3738 | - // We may have moved in same dir, update caches: |
3739 | - $fm_Filelist->update_caches(); |
3740 | - // We remove the file from the source list, after refreshing the cache |
3741 | - $fm_source_Filelist->update_caches(); |
3742 | - $fm_source_Filelist->remove( $loop_src_File ); |
3743 | - |
3744 | - if( $fm_Filelist->contains( $loop_src_File ) === false ) |
3745 | - { // File not in filelist (expected if not same dir) |
3746 | - $fm_Filelist->add( $loop_src_File ); |
3747 | - } |
3748 | - } |
3749 | - else |
3750 | - { // move failed |
3751 | - param_error( 'new_names['.$loop_src_File->get_md5_ID().']', sprintf( T_('Could not move «%s» to «%s».'), $rdfp_oldpath, $rdfp_newpath ) ); |
3752 | - // Note: we do not rollback, since unlinking is already done on disk :'( |
3753 | - } |
3754 | - |
3755 | - $DB->commit(); |
3756 | - } |
3757 | - else debug_die( 'Unhandled file copy/move mode' ); |
3758 | - } |
3759 | - |
3760 | - // EXIT MODE: |
3761 | - $fm_mode = NULL; |
3762 | - } |
3763 | - break; |
3764 | + $dest_File = & $FileCache->get_by_root_and_path( $fm_Filelist->get_root_type(), $fm_Filelist->get_root_ID(), $fm_Filelist->get_rds_list_path().$new_names[$loop_src_File->get_md5_ID()] ); |
3765 | + |
3766 | + if( $fm_mode == 'file_copy' ) |
3767 | + { |
3768 | + // COPY |
3769 | + |
3770 | + // Do the copy |
3771 | + if( $loop_src_File->copy_to( $dest_File ) ) |
3772 | + { |
3773 | + // Success |
3774 | + $Messages->add( sprintf( T_('Copied «%s» to «%s».'), |
3775 | + $loop_src_File->get_rdfp_rel_path(), $dest_File->get_rdfp_rel_path() ), 'success' ); |
3776 | + |
3777 | + if( $fm_Filelist->contains( $dest_File ) === false ) |
3778 | + { |
3779 | + $fm_Filelist->add( $dest_File ); |
3780 | + } |
3781 | + } |
3782 | + else |
3783 | + { |
3784 | + // Failure |
3785 | + param_error( 'new_names['.$loop_src_File->get_md5_ID().']', sprintf( T_('Could not copy «%s» to «%s».'), |
3786 | + $loop_src_File->get_rdfp_rel_path(), $dest_File->get_rdfp_rel_path() ) ); |
3787 | + } |
3788 | + } |
3789 | + elseif( $fm_mode == 'file_move' ) |
3790 | + { |
3791 | + // MOVE |
3792 | + // NOTE: DB integrity is handled by the File object itself |
3793 | + $DB->begin(); |
3794 | + |
3795 | + if( isset( $overwrite[$loop_src_File->get_md5_ID()] ) |
3796 | + && $overwrite[$loop_src_File->get_md5_ID()] ) |
3797 | + { |
3798 | + // We want to overwrite, let's unlink the old file |
3799 | + if( ! $dest_File->unlink() ) |
3800 | + { |
3801 | + // Unlink failed |
3802 | + $DB->rollback(); |
3803 | + |
3804 | + $Messages->add( sprintf( ( $dest_File->is_dir() ? T_('Could not delete the directory «%s» (not empty?).') : T_('Could not delete the file «%s».') ), $dest_File->dget( 'name' ) ), 'error' ); |
3805 | + |
3806 | + // Move on to next file |
3807 | + continue; |
3808 | + } |
3809 | + } |
3810 | + |
3811 | + // Do the move |
3812 | + $rdfp_oldpath = $loop_src_File->get_rdfp_rel_path(); |
3813 | + $rdfp_newpath = $fm_Filelist->get_rds_list_path().$new_names[$loop_src_File->get_md5_ID()]; |
3814 | + |
3815 | + if( $loop_src_File->move_to( $fm_Filelist->get_root_type(), $fm_Filelist->get_root_ID(), $rdfp_newpath ) ) |
3816 | + { |
3817 | + // successfully moved |
3818 | + $Messages->add( sprintf( T_('Moved «%s» to «%s».'), $rdfp_oldpath, $rdfp_newpath ), 'success' ); |
3819 | + |
3820 | + // We may have moved in same dir, update caches |
3821 | + $fm_Filelist->update_caches(); |
3822 | + // We remove the file from the source list, after refreshing the cache |
3823 | + $fm_source_Filelist->update_caches(); |
3824 | + $fm_source_Filelist->remove( $loop_src_File ); |
3825 | + |
3826 | + if( $fm_Filelist->contains( $loop_src_File ) === false ) |
3827 | + { |
3828 | + // File not in filelist (expected if not same dir) |
3829 | + $fm_Filelist->add( $loop_src_File ); |
3830 | + } |
3831 | + } |
3832 | + else |
3833 | + { |
3834 | + // move failed |
3835 | + param_error( 'new_names['.$loop_src_File->get_md5_ID().']', sprintf( T_('Could not move «%s» to «%s».'), $rdfp_oldpath, $rdfp_newpath ) ); |
3836 | + // Note: we do not rollback, since unlinking is already done on disk :'( |
3837 | + } |
3838 | + |
3839 | + $DB->commit(); |
3840 | + } |
3841 | + else debug_die( 'Unhandled file copy/move mode' ); |
3842 | + } |
3843 | + |
3844 | + // EXIT MODE |
3845 | + $fm_mode = NULL; |
3846 | + } |
3847 | + break; |
3848 | |
3849 | case 'link_item': |
3850 | - // We want to link file(s) to an item: |
3851 | - // TODO: maybe this should not be a mode and maybe we should handle linking as soon as we have an $edited_Item ... |
3852 | - if( !isset($edited_Item) ) |
3853 | - { // No Item to link to... |
3854 | - $fm_mode = NULL; |
3855 | - break; |
3856 | - } |
3857 | - |
3858 | - // TODO: check EDIT permissions! |
3859 | + // We want to link file(s) to an item |
3860 | + if( ! isset( $edited_Item ) ) |
3861 | + { |
3862 | + // No Item to link to... |
3863 | + $fm_mode = NULL; |
3864 | break; |
3865 | + } |
3866 | + break; |
3867 | |
3868 | } |
3869 | |
3870 | -// Update sub-menu: |
3871 | +// Update sub-menu |
3872 | if( $current_User->check_perm( 'files', 'add' ) ) |
3873 | -{ // Permission to upload and we are not in a popup window (no subtabs needed otherwise) |
3874 | - $AdminUI->add_menu_entries( |
3875 | - 'files', |
3876 | - array( |
3877 | +{ |
3878 | + // Permission to upload and we are not in a popup window (no subtabs needed otherwise) |
3879 | + $AdminUI->add_menu_entries( 'files', array( |
3880 | 'browse' => array( |
3881 | 'text' => T_('Browse'), |
3882 | 'href' => regenerate_url( 'ctrl', 'ctrl=files' ) ), |
3883 | @@ -1490,10 +1464,9 @@ |
3884 | ); |
3885 | } |
3886 | |
3887 | -// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect) |
3888 | +// Display <html><head>...</head> section (should be done early if actions do not redirect) |
3889 | $AdminUI->disp_html_head(); |
3890 | - |
3891 | -// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions) |
3892 | +// Display title, menu, messages, etc... (messages MUST be displayed AFTER the actions) |
3893 | $AdminUI->disp_body_top(); |
3894 | |
3895 | // Display reload-icon in the opener window if we're a popup in the same CWD and the |
3896 | @@ -1505,7 +1478,7 @@ |
3897 | && opener.document.FilesForm |
3898 | && typeof(opener.document.FilesForm.md5_filelist.value) != 'undefined' |
3899 | && typeof(opener.document.FilesForm.md5_cwd.value) != 'undefined' |
3900 | - && opener.document.FilesForm.md5_cwd.value == '<?php echo md5($fm_Filelist->get_ads_list_path()); ?>' |
3901 | + && opener.document.FilesForm.md5_cwd.value == '<?php echo md5( $fm_Filelist->get_ads_list_path() ); ?>' |
3902 | ) |
3903 | { |
3904 | opener.document.getElementById( 'fm_reloadhint' ).style.display = |
3905 | @@ -1516,104 +1489,97 @@ |
3906 | // --> |
3907 | </script> |
3908 | <?php |
3909 | - |
3910 | +// Begin payload block |
3911 | $AdminUI->disp_payload_begin(); |
3912 | |
3913 | -// Display payload: |
3914 | -if( !empty($action ) && $action != 'list' && $action != 'nil' ) |
3915 | +// Display payload |
3916 | +if( ! empty( $action ) && $action != 'list' && $action != 'nil' ) |
3917 | { |
3918 | |
3919 | // Action displays: |
3920 | switch( $action ) |
3921 | { |
3922 | case 'rename': |
3923 | - // Rename files dialog: |
3924 | - $AdminUI->disp_view( 'files/views/_file_rename.form.php' ); |
3925 | - break; |
3926 | + // Rename files dialog: |
3927 | + $AdminUI->disp_view( 'files/views/_file_rename.form.php' ); |
3928 | + break; |
3929 | |
3930 | case 'delete': |
3931 | - // Delete file(s). We arrive here either if not confirmed or in case of error(s). |
3932 | - $AdminUI->disp_view( 'files/views/_file_delete.form.php' ); |
3933 | - break; |
3934 | + // Delete file(s). We arrive here either if not confirmed or in case of error(s). |
3935 | + $AdminUI->disp_view( 'files/views/_file_delete.form.php' ); |
3936 | + break; |
3937 | |
3938 | case 'download': |
3939 | - $AdminUI->disp_view( 'files/views/_file_download.form.php' ); |
3940 | - break; |
3941 | + $AdminUI->disp_view( 'files/views/_file_download.form.php' ); |
3942 | + break; |
3943 | |
3944 | case 'edit_perms': |
3945 | - // Filesystem permissions for specific files |
3946 | - $AdminUI->disp_view( 'files/views/_file_permissions.form.php' ); |
3947 | - break; |
3948 | + // Filesystem permissions for specific files |
3949 | + $AdminUI->disp_view( 'files/views/_file_permissions.form.php' ); |
3950 | + break; |
3951 | |
3952 | case 'edit_file': |
3953 | - // File Edit dialog: |
3954 | - $AdminUI->disp_view( 'files/views/_file_edit.form.php' ); |
3955 | - break; |
3956 | + // File Edit dialog: |
3957 | + $AdminUI->disp_view( 'files/views/_file_edit.form.php' ); |
3958 | + break; |
3959 | |
3960 | case 'edit_properties': |
3961 | - // File properties (Meta data) dialog: |
3962 | - $AdminUI->disp_view( 'files/views/_file_properties.form.php' ); |
3963 | - break; |
3964 | + // File properties (Meta data) dialog: |
3965 | + $AdminUI->disp_view( 'files/views/_file_properties.form.php' ); |
3966 | + break; |
3967 | |
3968 | case 'edit_settings': |
3969 | - // Display settings dialog: |
3970 | - $AdminUI->disp_view( 'files/views/_file_browse_set.form.php' ); |
3971 | - break; |
3972 | + // Display settings dialog: |
3973 | + $AdminUI->disp_view( 'files/views/_file_browse_set.form.php' ); |
3974 | + break; |
3975 | |
3976 | case 'download': |
3977 | - // Deferred action message: |
3978 | - if( isset($action_title) ) |
3979 | - { |
3980 | - echo "\n<h2>$action_title</h2>\n"; |
3981 | - } |
3982 | - |
3983 | - if( isset($action_msg) ) |
3984 | - { |
3985 | - echo $action_msg; |
3986 | - |
3987 | - if( isset( $js_focus ) ) |
3988 | - { // we want to auto-focus a field |
3989 | - echo ' |
3990 | - <script type="text/javascript"> |
3991 | - <!-- |
3992 | - '.$js_focus.'.focus(); |
3993 | - // --> |
3994 | - </script>'; |
3995 | - } |
3996 | - } |
3997 | + // Deferred action message: |
3998 | + if( isset( $action_title ) ) |
3999 | + { |
4000 | + echo "\n<h2>$action_title</h2>\n"; |
4001 | + } |
4002 | + |
4003 | + if( isset( $action_msg ) ) |
4004 | + { |
4005 | + echo $action_msg; |
4006 | + |
4007 | + if( isset( $js_focus ) ) |
4008 | + { |
4009 | + // we want to auto-focus a field |
4010 | + echo ' |
4011 | + <script type="text/javascript"> |
4012 | + <!-- |
4013 | + '.$js_focus.'.focus(); |
4014 | + // --> |
4015 | + </script>'; |
4016 | + } |
4017 | + } |
4018 | } |
4019 | } |
4020 | |
4021 | - |
4022 | -/* |
4023 | - * Diplay mode payload: |
4024 | - */ |
4025 | +// Diplay mode payload |
4026 | switch( $fm_mode ) |
4027 | { |
4028 | case 'file_copy': |
4029 | case 'file_move': |
4030 | - // CMR dialog: |
4031 | - $AdminUI->disp_view( 'files/views/_file_copy_move.form.php' ); |
4032 | - break; |
4033 | + // CMR dialog: |
4034 | + $AdminUI->disp_view( 'files/views/_file_copy_move.form.php' ); |
4035 | + break; |
4036 | |
4037 | case 'link_item': |
4038 | - // Links dialog: |
4039 | - $AdminUI->disp_view( 'files/views/_file_links.view.php' ); |
4040 | - break; |
4041 | + // Links dialog: |
4042 | + $AdminUI->disp_view( 'files/views/_file_links.view.php' ); |
4043 | + break; |
4044 | } |
4045 | |
4046 | - |
4047 | -// ------------------- |
4048 | -// Browsing interface: |
4049 | -// ------------------- |
4050 | -// Display VIEW: |
4051 | +// Browsing interface |
4052 | +// Display VIEW |
4053 | $AdminUI->disp_view( 'files/views/_file_browse.view.php' ); |
4054 | |
4055 | - |
4056 | -// End payload block: |
4057 | +// End payload block |
4058 | $AdminUI->disp_payload_end(); |
4059 | - |
4060 | -// Display body bottom, debug info and close </html>: |
4061 | +// Display body bottom, debug info, close </html> |
4062 | $AdminUI->disp_global_footer(); |
4063 | |
4064 | ?> |
4065 | |
4066 | === modified file 'qp_inc/plugins/_plugin.class.php' |
4067 | --- qp_inc/plugins/_plugin.class.php 2011-11-21 17:17:22 +0000 |
4068 | +++ qp_inc/plugins/_plugin.class.php 2013-03-05 23:36:23 +0000 |
4069 | @@ -1,59 +1,38 @@ |
4070 | <?php |
4071 | /** |
4072 | - * This file implements the abstract {@link Plugin} class. |
4073 | - * |
4074 | - * This file is part of Quam Plures - {@link http://quamplures.net/} |
4075 | - * See also {@link https://launchpad.net/quam-plures}. |
4076 | - * |
4077 | - * @copyright Copyright (c) 2011 by {@link http://1912webworks.com/ Ed Bennett} |
4078 | - * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/} |
4079 | - * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/} |
4080 | - * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}. |
4081 | - * |
4082 | - * {@internal License choice |
4083 | - * - If you have received this file as part of a package, please find the license.txt file in |
4084 | - * the same folder or the closest folder above for complete license terms. |
4085 | - * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) |
4086 | - * then you must choose one of the following licenses before using the file: |
4087 | - * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php |
4088 | - * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php |
4089 | - * }} |
4090 | - * |
4091 | - * {@internal Open Source relicensing agreement: |
4092 | - * Daniel HAHLER grants Francois PLANQUE the right to license |
4093 | - * Daniel HAHLER's contributions to this file and the b2evolution project |
4094 | - * under any OSI approved OSS license (http://www.opensource.org/licenses/). |
4095 | - * }} |
4096 | - * |
4097 | - * @todo Add links to pages in the manual, once they are "clean"/tiny |
4098 | - * |
4099 | - * {@internal Below is a list of authors who have contributed to design/coding of this file: }} |
4100 | + * This file implements the Plugin class |
4101 | + * |
4102 | + * Real plugins should be derived from this class. |
4103 | + * |
4104 | + * @todo (1111): var $code needs to be checked for duplicity upon installation and a note thrown |
4105 | + * to the installing user indicating a potential conflict ... if it isn't already checked ;) |
4106 | + * @todo (1111): var $group needs to be an enum with "other" as the default. There is no need |
4107 | + * for a plugin author to jack up the plugins display page with their own group name! |
4108 | + * @todo (1111): var $priority needs to not apply to "install widget". Actually, it needs to not |
4109 | + * apply to everything except rendering ... and it needs a rename to $render_priority |
4110 | * @author {@link http://wonderwinds.com/ Ed Bennett} |
4111 | - * @author fplanque: Francois PLANQUE - {@link http://fplanque.net/} |
4112 | - * @author blueyed: Daniel HAHLER |
4113 | - * |
4114 | + * @author {@link http://daniel.hahler.de/ Daniel HAHLER} |
4115 | + * @author {@link http://fplanque.net/ Francois PLANQUE} |
4116 | + * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project} |
4117 | + * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 |
4118 | * @package plugins |
4119 | */ |
4120 | -if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
4121 | - |
4122 | +if(!defined('QP_MAIN_INIT')) die('fail'); |
4123 | |
4124 | /** |
4125 | - * Plugin Class |
4126 | + * Plugin class |
4127 | * |
4128 | * Real plugins should be derived from this class. |
4129 | - * |
4130 | - * @abstract |
4131 | - * |
4132 | * @package plugins |
4133 | */ |
4134 | class Plugin |
4135 | { |
4136 | /** |
4137 | - * If this is a rendering plugin, when should rendering apply? This is the |
4138 | - * default value for the plugin and can be overriden in the Plugins |
4139 | - * administration for plugins that provide rendering events. |
4140 | + * If this is a rendering plugin, when should rendering apply? |
4141 | * |
4142 | - * The actual value for the plugin gets stored in T_plugins.plug_apply_rendering. |
4143 | + * This is the default value for the plugin and can be overriden in the Plugin's |
4144 | + * administration for plugins that provide rendering events. The actual value for |
4145 | + * the plugin gets stored in T_plugins=>plug_apply_rendering. |
4146 | * |
4147 | * Possible values: |
4148 | * - 'stealth': gets always used, but not displayed as option |
4149 | @@ -62,241 +41,191 @@ |
4150 | * - 'opt-in': disabled by default |
4151 | * - 'lazy': checkbox gets displayed, but is disabled |
4152 | * - 'never': cannot get used as a renderer |
4153 | - * |
4154 | - * @todo (legacy): blueyed>> IMHO we would need another value, which is the same as "lazy", but does not display a checkbox, which is useful for Plugins that add themselves as renderers on Item update |
4155 | - * |
4156 | - * @var string |
4157 | + * @var string ENUM( 'stealth', 'always', 'opt-out', 'opt-in', 'lazy', 'never' ) DEFAULT 'never' |
4158 | */ |
4159 | var $apply_rendering = 'never'; |
4160 | - |
4161 | /** |
4162 | - * Plugin author. |
4163 | - * |
4164 | - * This is for user info only. |
4165 | - * |
4166 | - * @var string |
4167 | + * Plugin author |
4168 | + * |
4169 | + * This is used on the plugin's "info" page, and on the application's "credits" page. |
4170 | + * @var string The author's name |
4171 | */ |
4172 | var $author = 'Dracones Incompertus'; |
4173 | - |
4174 | /** |
4175 | - * Plugin author URL. |
4176 | - * |
4177 | - * This is for user info only, not to be confused with help_url. |
4178 | - * |
4179 | - * @var string |
4180 | + * Plugin author URL |
4181 | + * |
4182 | + * This is used on the plugin's "info" page, and on the application's "credits" page, |
4183 | + * @var string The author's URL (optional) |
4184 | */ |
4185 | var $author_url = ''; |
4186 | - |
4187 | /** |
4188 | - * Globally unique code for this plugin functionality. 32 chars. |
4189 | - * |
4190 | - * A common code MIGHT be shared between different plugins providing the same functionnality. |
4191 | - * This allows to replace a given renderer with another one and keep the associations with posts. |
4192 | - * Example: replacing a GIF smiley renderer with an SWF smiley renderer... |
4193 | - * |
4194 | - * MUST BE SET BY THE PLUGIN!!! |
4195 | - * |
4196 | - * @var string |
4197 | + * Unique code for this plugin functionality |
4198 | + * |
4199 | + * THIS MUST BE SET BY YOUR PLUGIN! |
4200 | + * |
4201 | + * 32 characters max. Should be unique to each plugin, but a common code MIGHT be shared between |
4202 | + * different plugins providing the same functionnality. This allows to replace a given renderer |
4203 | + * with another one and keep the associations with posts. Example: replacing a GIF smiley renderer |
4204 | + * with an SWF smiley renderer... |
4205 | + * |
4206 | + * For multiple instances of the same plugin, core will incrementally change this. Also, |
4207 | + * the user can change this via the plugin's settings page (Plugin variables (Advanced)). |
4208 | + * @var string A 32 character string identifying this plugin specific to this plugin |
4209 | */ |
4210 | var $code = ''; |
4211 | - |
4212 | - /** |
4213 | - * Main group of the plugin. |
4214 | - * |
4215 | - * Accepts any value you want, but please pick from the following: |
4216 | - * "toolbars, widgets, renderers, antispam, pingers, tools, comments, other" |
4217 | - * |
4218 | - * @var string |
4219 | - */ |
4220 | - var $group; |
4221 | - |
4222 | - /** |
4223 | - * Sub-Group of the plugin. |
4224 | - * |
4225 | - * OBSOLETE AND UN-USED! Left here only to not cause havoc with existing plugins |
4226 | - * |
4227 | - * @var string |
4228 | - */ |
4229 | - var $sub_group; |
4230 | - |
4231 | - /** |
4232 | - * URL for more info about the plugin, author and new versions. |
4233 | - * |
4234 | - * This is for user info only. If empty, it defaults to 'something unknown right now', |
4235 | - * |
4236 | - * @var string |
4237 | + /** |
4238 | + * Main group of the plugin |
4239 | + * |
4240 | + * Accepts any value you want, but please pick from: "antispam, comments, pingers, renderers, |
4241 | + * toolbars, utilities, widgets, other". Eventually this will become a requirement so learn to |
4242 | + * love it now :) |
4243 | + * @var string 'antispam', 'comments', 'pingers', 'renderers', 'toolbars', 'utilities', |
4244 | + * 'widgets', 'other' |
4245 | + */ |
4246 | + var $group = 'other'; |
4247 | + /** |
4248 | + * URL for plugin support |
4249 | + * |
4250 | + * This is used on the Global settings => Plugins page and should point to a URL that offers |
4251 | + * support and update info about the plugin. If empty no icon is displayed. |
4252 | + * @var string A URL for support and update info about this plugin (optional) |
4253 | */ |
4254 | var $help_url = ''; |
4255 | - |
4256 | /** |
4257 | - * Number of allowed installs. |
4258 | + * Number of allowed installs |
4259 | * |
4260 | - * When installing the plugin it gets checked if the plugin is already installed this |
4261 | - * many times. If so, the installation gets aborted. |
4262 | + * When the plugin is already installed this many times the option to install again is removed. |
4263 | + * Use 0 for unlimited, and any other number you see fit. Default is 1. |
4264 | + * @var integer How many times can this plugin be installed? |
4265 | */ |
4266 | - var $number_of_installs; |
4267 | - |
4268 | + var $number_of_installs = 1; |
4269 | /** |
4270 | - * Default priority. |
4271 | - * |
4272 | - * Priority determines in which order the plugins get called. |
4273 | - * Range: 1 to 100 (the lower the number, the earlier it gets called) |
4274 | - * |
4275 | - * @var int |
4276 | + * Priority |
4277 | + * |
4278 | + * Priority determines in which order the plugins get called. Range: 1 to 100 (the lower the |
4279 | + * number, the earlier it gets called). Renderers use this to determine which renderer gets |
4280 | + * called first. Also, adding plugins to the "Install widget" screen is by priority. Also, |
4281 | + * renderer checkboxes are by priority. Possibly other places as well. |
4282 | + * |
4283 | + * The installing user can change this in "Plugin variables (Advanced)" |
4284 | + * @var integer Rendering priority (lower number is first) |
4285 | */ |
4286 | var $priority = 50; |
4287 | - |
4288 | /** |
4289 | - * Plugin version number (max 42 chars, so obscure CVS Revision keywords get handled). |
4290 | - * |
4291 | - * This must be compatible to PHP's {@link version_compare()}, |
4292 | - * e.g. '1', '2', '1.1', '2.1b' and '10-1-1a' are fine. |
4293 | - * |
4294 | - * This can be used by other plugins when requiring your plugin |
4295 | - * through {@link Plugin::GetDependencies()}. |
4296 | - * |
4297 | + * Plugin version number |
4298 | + * |
4299 | + * Max 42 chars, so obscure CVS Revision keywords get handled. This must be compatible to PHP's |
4300 | + * {@link version_compare()}, e.g. '1', '2', '1.1', '2.1b' and '10-1-1a' are fine. This can be |
4301 | + * used by other plugins when requiring your plugin through {@link Plugin::GetDependencies()}. |
4302 | * By increasing it you can request a call of {@link GetDbLayout()} upon instantiating. |
4303 | * If there are DB layout changes to be made, the plugin gets changed to status "needs_config". |
4304 | - * |
4305 | - * @var string |
4306 | + * @var string Incremental version number stored as a string |
4307 | */ |
4308 | var $version = '0'; |
4309 | - |
4310 | /** |
4311 | - * Plugin name as it will appear in lists. |
4312 | - * |
4313 | - * This should be no longer than 50 characters. To make it available for |
4314 | - * translations set it in function PluginInit() by using (for example) |
4315 | - * $this->name = $this->T_('Plugin Name'); |
4316 | - * |
4317 | - * @var string |
4318 | + * Plugin name |
4319 | + * |
4320 | + * Name as it will appear in lists, should be no longer than 50 characters so it fits nicely |
4321 | + * on the (very crowded) Global settings => Plugins page. To make it available for translations |
4322 | + * set it in function PluginInit() by using $this->name = $this->T_('A Great Plugin'); |
4323 | + * @var string Name of the plugin, used in lists |
4324 | */ |
4325 | var $name = 'foo'; |
4326 | - |
4327 | - /** |
4328 | - * Plugin short description. |
4329 | - * |
4330 | - * This should be no longer than a line and is limited to 255 chars, but |
4331 | - * "shorter is better"! To make it available for translations |
4332 | - * set it in function PluginInit() by using (for example) |
4333 | - * $this->short_desc = $this->T_('Makes blogging easier'); |
4334 | - * |
4335 | - * @var string |
4336 | - */ |
4337 | - var $short_desc; |
4338 | - |
4339 | - /** |
4340 | - * Plugin long description. |
4341 | - * |
4342 | - * This should be no longer than a line or two. If much more is needed you |
4343 | - * should put it in your readme.html file instead. To make it available for |
4344 | - * translations set it in function PluginInit() by using (for example) |
4345 | - * $this->long_desc = $this->T_('Makes blogging easier by making a toolbar that does stuff that gets rendered into stuff'); |
4346 | - * |
4347 | - * @var string |
4348 | - */ |
4349 | - var $long_desc; |
4350 | - |
4351 | - |
4352 | - /** |
4353 | - * Name of the ping service (if this is a ping plugin, see {@link Plugin::ItemSendPing()}) |
4354 | - * @var string |
4355 | + /** |
4356 | + * Plugin short description |
4357 | + * |
4358 | + * This is limited to 255 characters but should be no longer than a line because it gets used |
4359 | + * on the (very crowded) Global settings => Plugins page. To make it available for translations |
4360 | + * set it in function PluginInit() by using $this->short_desc = $this->T_('Makes blogging easier'); |
4361 | + * @var string Short (one line) description of the plugin |
4362 | + */ |
4363 | + var $short_desc = 'No desc available'; |
4364 | + /** |
4365 | + * Plugin long description |
4366 | + * |
4367 | + * This can be as long and informative as you like, but remember you also should provide a |
4368 | + * readme.html file. To make it available for translations set it in function PluginInit() |
4369 | + * by using $this->long_desc = $this->T_('Makes blogging easier by making a toolbar that does stuff that gets rendered into stuff'); |
4370 | + * |
4371 | + * This is used on the plugin's "info" page, and on the application's "credits" page. |
4372 | + * @var string Long description of the plugin, but not a replacement for a "readme" file |
4373 | + */ |
4374 | + var $long_desc = 'No long description available for this plugin'; |
4375 | + /** |
4376 | + * Name of the ping service |
4377 | + * @var string Only if this is a ping plugin |
4378 | */ |
4379 | var $ping_service_name; |
4380 | - |
4381 | /** |
4382 | - * Note about the ping service, used in the list of ping services in the blog settings |
4383 | - * (if this is a ping plugin, see {@link Plugin::ItemSendPing()}) |
4384 | - * @var string |
4385 | + * Note about the ping service |
4386 | + * @var string If this is a ping plugin, used in the list of ping services in the blog settings |
4387 | */ |
4388 | var $ping_service_note; |
4389 | - |
4390 | - /**#@+ |
4391 | - * Variables below MUST NOT be overriden or changed by you! |
4392 | - * @access private |
4393 | - */ |
4394 | - |
4395 | /** |
4396 | - * Name of the current class. (AUTOMATIC) |
4397 | - * |
4398 | - * Will be set automatically (from filename) when registering plugin. |
4399 | - * |
4400 | - * @var string |
4401 | + * Name of the current class |
4402 | + * |
4403 | + * THIS MUST BE SET BY YOUR PLUGIN! |
4404 | + * |
4405 | + * Will be set automatically (from file name) when registering plugin, but folder name and |
4406 | + * file name and the class declaration must match. "class thisismyplugin_plugin extends Plugin" |
4407 | + * appears in file name "_thisismyplugin.plugin.php" in folder name "thisismyplugin_plugin". |
4408 | + * @var string 40 characters max |
4409 | */ |
4410 | var $classname; |
4411 | - |
4412 | /** |
4413 | - * Internal (DB) ID. (AUTOMATIC) |
4414 | - * |
4415 | - * ID < 1 means 'NOT installed' |
4416 | - * |
4417 | - * @var int |
4418 | + * Internal (DB) ID |
4419 | + * |
4420 | + * You do not set this but you can access it with $this->ID inside your plugin. |
4421 | + * ID < 1 means 'NOT installed'. |
4422 | + * @var integer auto_incremented plugin ID |
4423 | */ |
4424 | var $ID = 0; |
4425 | - |
4426 | /** |
4427 | - * If the plugin provides settings, this will become the object to access them. |
4428 | - * |
4429 | - * This gets instantianted on Plugin registration for PHP4 and through |
4430 | - * overloading in PHP5+, which means on first access. |
4431 | - * |
4432 | + * The object to access the (optional) plugin settings |
4433 | * @see GetDefaultSettings() |
4434 | * @var PluginSettings |
4435 | */ |
4436 | var $Settings; |
4437 | - |
4438 | /** |
4439 | - * If the plugin provides user settings, this will become the object to access them. |
4440 | - * |
4441 | - * This gets instantianted on Plugin registration for PHP4 and through |
4442 | - * overloading in PHP5+, which means on first access. |
4443 | + * The object to access the (optional) user settings |
4444 | * |
4445 | * NOTE: its methods use {@link $current_User::$ID} by default, but you may call it |
4446 | - * if there's no {@link $current_User} instantiated (yet). |
4447 | - * |
4448 | + * if there is no {@link $current_User} instantiated (yet). |
4449 | * @see GetDefaultUserSettings() |
4450 | * @var PluginUserSettings |
4451 | */ |
4452 | var $UserSettings; |
4453 | - |
4454 | /** |
4455 | - * The status of the plugin. |
4456 | - * |
4457 | - * Use {@link set_status()} to change it, if you need to. |
4458 | - * Either 'enabled', 'disabled', 'needs_config' or 'broken'. |
4459 | - * |
4460 | - * @var string |
4461 | + * The status of the plugin |
4462 | + * |
4463 | + * Use {@link set_status()} to change it, if you need to. Either 'enabled', 'disabled', |
4464 | + * 'needs_config' or 'broken', installation of the plugin will set it appropriately. |
4465 | + * @var string 'enabled', 'disabled', 'needs_config', 'broken' |
4466 | */ |
4467 | var $status; |
4468 | - |
4469 | /** |
4470 | - * The "mother" object, where this Plugin got instantiated from. |
4471 | - * |
4472 | - * @deprecated since 2.0 |
4473 | + * The "mother" object, where this Plugin got instantiated from |
4474 | + * @deprecated since before time began (which is something of a miracle eh?) |
4475 | * @var Plugins|Plugins_admin |
4476 | */ |
4477 | var $Plugins; |
4478 | - |
4479 | /** |
4480 | - * The translations keyed by locale. They get loaded through include() of _global.php. |
4481 | - * @see Plugin::T_() |
4482 | - * @var array |
4483 | + * The translations keyed by locale |
4484 | + * |
4485 | + * They get loaded through include() of _global.php. |
4486 | + * @var array Array of string translations, English => Something else |
4487 | */ |
4488 | var $_trans = array(); |
4489 | - |
4490 | /** |
4491 | - * Has the global po/php/_global.php file (where translation for |
4492 | - * all languages can be put into) been loaded? |
4493 | + * Has _global.php been loaded? |
4494 | * |
4495 | + * Has the global po/_global.xx.php file (translation for language xx) been loaded? |
4496 | * @var boolean |
4497 | */ |
4498 | var $_trans_loaded_global = false; |
4499 | |
4500 | - /**#@-*/ |
4501 | - |
4502 | - |
4503 | /** |
4504 | - * Constructor. |
4505 | + * Constructor |
4506 | * |
4507 | * You should not use a constructor with your plugin, but the |
4508 | * {@link Plugin::PluginInit()} method instead! |
4509 | @@ -307,152 +236,229 @@ |
4510 | |
4511 | |
4512 | /** |
4513 | - * Init the Plugin after it has been registered/instantiated. |
4514 | - * |
4515 | - * Should set name, short description, and long description in a localizable fashion. |
4516 | - * |
4517 | - * This gets called on every instantiated plugin, also if it's just for |
4518 | - * discovering the list of available plugins in the backoffice. |
4519 | - * |
4520 | - * Use this to validate Settings/requirements and/or cache them into class properties. |
4521 | - * |
4522 | - * @param array Associative array of parameters. |
4523 | - * 'is_installed': true, if the plugin is installed; false if not (probably it got discovered then) |
4524 | - * 'db_row': an array with the columns of the plugin DB entry (in T_plugins). |
4525 | - * This is empty, if the plugin is not installed! |
4526 | - * E.g., 'plug_version' might be interesting to compare again "$this->version". |
4527 | - * |
4528 | - * @return boolean If this method returns false, the Plugin gets unregistered (for the current request only). |
4529 | - */ |
4530 | - function PluginInit( & $params ) |
4531 | - { |
4532 | - // NOTE: the code below is just to handle stuff that has been deprecated since |
4533 | - // b2evolution 1.9. You don't have to include this, if you override this method. |
4534 | - |
4535 | - if( is_null($this->short_desc) ) |
4536 | - { // may have been set in plugin's constructor (which is deprecated since 1.9) |
4537 | - $this->short_desc = T_('No desc available'); |
4538 | - } |
4539 | - if( is_null($this->long_desc) ) |
4540 | - { // may have been set in plugin's constructor (which is deprecated since 1.9) |
4541 | - $this->long_desc = T_('No long description available'); |
4542 | - } |
4543 | - |
4544 | - return true; |
4545 | - } |
4546 | - |
4547 | - |
4548 | - // Plugin information (settings, DB layout, ..): {{{ |
4549 | - |
4550 | - /** |
4551 | - * Define default settings here. |
4552 | - * Those can then be edited in the backoffice. |
4553 | - * |
4554 | - * You can access them in the plugin through the member object |
4555 | - * {@link Plugin::$Settings}, e.g.: |
4556 | - * <code>$this->Settings->get( 'my_param' );</code> |
4557 | - * |
4558 | - * fp> this is unclear: You probably don't need to set or change values (other than the |
4559 | - * defaultvalues), but if you know what you're doing, see |
4560 | - * {@link PluginSettings}, where {@link Plugin::$Settings} gets derived from. |
4561 | - * |
4562 | - * NOTE: this method gets called by b2evo when instantiating the plugin |
4563 | - * settings and when the settings get displayed for editing in the backoffice. |
4564 | - * In the second case, $params['for_editing'] will be true. |
4565 | - * |
4566 | - * @todo 3.0 fp> 1) This is not an event: RENAME to lowercase (in b2evo 3.0) |
4567 | - * dh> Not only events are CamelCase, but "interactions" with the Plugins(_admin) class, too! |
4568 | - * Maybe it should get prefixed with "Plugin"?! |
4569 | - * The intention is: all interfacing methods are camel-cased. That makes a lot of sense, |
4570 | - * given the provided helpers (get_plugin_url etc). |
4571 | - * This applies to the other todos below, too. |
4572 | - * @todo 3.0 fp> 2) This defines more than Default values :: confusing name |
4573 | - * @todo name tentative get_general_param_definitions() |
4574 | - * |
4575 | - * @param array Associative array of parameters (since 1.9). |
4576 | - * 'for_editing': true, if the settings get queried for editing; |
4577 | - * false, if they get queried for instantiating {@link Plugin::$Settings}. |
4578 | - * @return array |
4579 | + * Internal Event: Called after the plugin has been installed |
4580 | + */ |
4581 | + function AfterInstall() |
4582 | + { |
4583 | + } |
4584 | + |
4585 | + |
4586 | + /** |
4587 | + * Internal Event: Your plugin gets notified here just before it gets disabled |
4588 | + * |
4589 | + * You cannot prevent this, but only clean up stuff if you have to. |
4590 | + */ |
4591 | + function BeforeDisable() |
4592 | + { |
4593 | + } |
4594 | + |
4595 | + |
4596 | + /** |
4597 | + * Internal Event: Called when a plugin is not enabled |
4598 | + * |
4599 | + * Event handler: Called when a plugin is not enabled and the admin tries to enable the |
4600 | + * plugin, changes its configuration/settings, and after installation. Use this if your |
4601 | + * plugin needs configuration before it can be used. |
4602 | + * @return true|string True if the plugin can be enabled/activated, a string with an |
4603 | + * error/note otherwise. |
4604 | + */ |
4605 | + function BeforeEnable() |
4606 | + { |
4607 | + return true; |
4608 | + } |
4609 | + |
4610 | + |
4611 | + /** |
4612 | + * Internal Event: Called before the plugin is going to be installed |
4613 | + * |
4614 | + * This is the hook to create any DB tables or the like. If you just want |
4615 | + * to add a note use {@link Plugin::msg()} (and return true). |
4616 | + * @return true|string True if the plugin can be enabled/activated, a string with an |
4617 | + * error/note otherwise. |
4618 | + */ |
4619 | + function BeforeInstall() |
4620 | + { |
4621 | + return true; |
4622 | + } |
4623 | + |
4624 | + |
4625 | + /** |
4626 | + * Internal Event: Called before the plugin is going to be un-installed |
4627 | + * |
4628 | + * This is the hook to remove any files or the like - tables with canonical names (see |
4629 | + * {@link Plugin::get_sql_table()}), are handled internally. See {@link BeforeUninstallPayload()} |
4630 | + * for the corresponding payload handler, which you can request to invoke by returning |
4631 | + * NULL here. Note: this method gets called again, if the uninstallation has to be |
4632 | + * confirmed, either because you've requested a call to {@link BeforeUninstallPayload()} |
4633 | + * or there are tables to be dropped (what the admin user has to confirm). |
4634 | + * |
4635 | + * This should cleanup everything without confirmation! |
4636 | + * @param array Associative array of parameters. 'unattended': true if Uninstall is |
4637 | + * unattended (e.g., the /install action "deletedb" uses it). |
4638 | + * @return boolean|NULL true when it's ok to uninstall, false on failure (the plugin won't |
4639 | + * get uninstalled then). You should add the reason for it through {@link Plugin::msg()}. |
4640 | + * NULL requests to execute the {@link BeforeUninstallPayload()} method. |
4641 | + */ |
4642 | + function BeforeUninstall( & $params ) |
4643 | + { |
4644 | + return true; |
4645 | + } |
4646 | + |
4647 | + |
4648 | + /** |
4649 | + * Internal Event: Invoked to display the payload before uninstalling the plugin |
4650 | + * |
4651 | + * You have to request a call to this during the plugin uninstall procedure by returning |
4652 | + * NULL in {@link BeforeUninstall()}. If your plugin uses canonical table names (see |
4653 | + * {@link Plugin::get_sql_table()}), there will be already a list of those tables |
4654 | + * included in it. Do not end the form, just add own inputs or hidden keys to it. |
4655 | + * @param array Associative array of parameters. 'Form': The {@link Form} that |
4656 | + * asks the user for confirmation (by reference). |
4657 | + */ |
4658 | + function BeforeUninstallPayload( & $params ) |
4659 | + { |
4660 | + } |
4661 | + |
4662 | + |
4663 | + /** |
4664 | + * Internal Event: Display a template |
4665 | + * |
4666 | + * Use {@link Plugin::GetProvidedTemplates()} to return a list of names that you register. |
4667 | + * @param array Associative array of parameters. 'template': name of template to be |
4668 | + * displayed (from the list of {@link Plugin::GetProvidedTemplates()}). If your Plugin |
4669 | + * registers only one template you can ignore it. |
4670 | + */ |
4671 | + function DisplayTemplate( & $params ) |
4672 | + { |
4673 | + } |
4674 | + |
4675 | + |
4676 | + /** |
4677 | + * Internal Event: Execute/handle a cron job |
4678 | + * |
4679 | + * Internal Event: Execute/handle a cron job, which has been scheduled by the admin out |
4680 | + * of the list that the Plugin provides (see {@link GetCronJobs()}). |
4681 | + * @param array Associative array of parameters |
4682 | + * - 'ctrl': The "ctrl" name as defined in {@link GetCronJobs()} |
4683 | + * - 'params': The "params" value as defined in {@link GetCronJobs()}, plus "ctsk_ID" which holds the cron task ID. |
4684 | + * @return array with keys "code" (integer, 1 is ok), "message" (gets logged) |
4685 | + */ |
4686 | + function ExecCronJob( & $params ) |
4687 | + { |
4688 | + } |
4689 | + |
4690 | + |
4691 | + /** |
4692 | + * Internal Event: Define default Plugin settings |
4693 | + * |
4694 | + * This defines settings that are available on the Global settings => Plugins => {{a plugin}} |
4695 | + * page. You can access them in the plugin through the member object {@link Plugin::$Settings}, |
4696 | + * e.g.: <code>$this->Settings->get( 'my_param' );</code> |
4697 | + * |
4698 | + * NOTE: this method gets called by the application when instantiating the plugin settings |
4699 | + * and when the settings get displayed for editing in the backoffice. In the second case, |
4700 | + * $params['for_editing'] will be true. |
4701 | + * |
4702 | * The array to be returned should define the names of the settings as keys (max length is 30 chars) |
4703 | * and assign an array with the following keys to them (only 'label' is required): |
4704 | - * |
4705 | - * 'label': Name/Title of the param, gets displayed as label for the input field, or |
4706 | - * as "legend" tag with types "array" and "fieldset". |
4707 | - * 'defaultvalue': Default value for the setting, defaults to '' (empty string) |
4708 | - * 'type', which can be: |
4709 | - * 'info': not an input - just a label followed by information (text, link, image - whatever) |
4710 | - * 'info': if type is info then use info to supply the actual information |
4711 | - * 'text' (default): a simple string |
4712 | - * 'password': like text, but hidden during input |
4713 | - * 'html_input' : like text, but allows html |
4714 | - * 'checkbox': either 0 or 1 |
4715 | - * 'integer': a number (no float, can have leading "+" or "-") (like 'text' for input, but gets validated when submitting) |
4716 | - * 'float': a floating number (can have leading "+" or "-", e.g. "+1", "-0.05") (like 'text' for input, but gets validated when submitting) |
4717 | - * 'textarea': several lines of input. The following can be set for this type: |
4718 | - * 'rows': number of rows |
4719 | - * 'cols': number of columns |
4720 | - * 'html_textarea': like textarea, but allows html |
4721 | - * 'select': a drop down field; you must set 'options' for it: |
4722 | - * 'options': an array of options ('value' => 'description'), see {@link Form::select_input_array()}. |
4723 | - * 'select_blog': a drop down field, providing all existing blogs (Blog ID is the value or "" if "allow_none" is true) (WARNING: does not scale - not recommended) |
4724 | - * 'select_group': a drop down field, providing all existing groups (Group ID is the value or "" if "allow_none" is true) |
4725 | - * 'select_user': a drop down field, providing all existing groups (User ID is the value or "" if "allow_none" is true) (WARNING: does not scale - not recommended) |
4726 | - * 'array': a subset of settings. The value gets automagically (un)serialized through get() and set(). |
4727 | - * The following keys apply to this type: |
4728 | - * 'entries': an array with meta information about sub-settings |
4729 | - * (which can be everything from the top-level, except: "valid_pattern", "valid_range"). |
4730 | - * Note: currently there's no type forcing or checking |
4731 | - * for sub-entries involved (e.g., if you have an entry of type "integer", you could get |
4732 | - * a non-numeric string there). |
4733 | - * fp> TODO: !!!! very unsafe |
4734 | - * 'key': defines the key to use for each entry. This may be a text input for example |
4735 | - * (with label, note etc). (optional, default is numeric keys, which are not editable) |
4736 | - * 'max_count': maximum count of sets (optional, default is no restriction) |
4737 | - * 'min_count': minimum count of sets (optional, default is no restriction) |
4738 | - * 'note' (gets displayed as a note to the param field), |
4739 | - * 'size': Size of the HTML input field (applies to types 'text', 'password' and 'integer'; defaults to 15) |
4740 | - * 'maxlength': maxlength attribute for the input field (See 'size' above; defaults to no limit) |
4741 | - * 'disabled': if true, it adds a 'disabled="disabled"' html attribute to the element and the value cannot be changed |
4742 | - * 'no_edit': if true, the setting is not editable. This is useful for internal settings. |
4743 | - * 'allow_none': set this to true to have "None" in the options list for types 'select_group' and 'select_user'. |
4744 | - * 'valid_pattern': A regular expression pattern that the value must match. |
4745 | - * This is either just a regexp pattern as string or an array |
4746 | - * with the keys 'pattern' and 'error' to define a custom error message. |
4747 | - * 'valid_range': An array with keys 'min', 'max' and (optionally) 'error' to define |
4748 | - * a custom error message. At least "min" or "max" must be given. |
4749 | - * 'help': can be: |
4750 | - * '#anchor': anchor that gets appended to {@link $help_url} |
4751 | - * true: the settings name/key gets transformed to an html ID and gets used as anchor to {@link $help_url}. |
4752 | - * 'http://example.com/uri': a full URL (starting with http:// or https://) |
4753 | - * 'layout': Use this to visually group your settings. |
4754 | - * Either 'begin_fieldset', 'end_fieldset' or 'separator'. You can use 'label' for 'begin_fieldset'. |
4755 | - * 'multiple': This allows to select multiple values in a SELECT (including select_*) (boolean) |
4756 | - * 'id', 'onchange', 'onclick', 'onfocus', 'onkeyup', 'onkeydown', 'onreset', 'onselect', 'cols', 'rows', 'maxlength': |
4757 | - * get passed through as attributes to the form/input element. |
4758 | - * |
4759 | - * e.g.: |
4760 | + |
4761 | + * <ul> |
4762 | + * <li>'label': Name/Title of the param, gets displayed as label for the input field, or as |
4763 | + * "legend" tag with types "array" and "fieldset".</li> |
4764 | + * <li>'type', which can be:<ul> |
4765 | + * <li>'info': not an input - just a label followed by information (text, link, image - whatever)</li> |
4766 | + * <li>'text' (default): a simple string</li> |
4767 | + * <li>'password': like text, but hidden during input</li> |
4768 | + * <li>'html_input' : like text, but allows html</li> |
4769 | + * <li>'checkbox': either 0 or 1</li> |
4770 | + * <li>'integer': a number (no float, can have leading "+" or "-") (like 'text' for input, |
4771 | + * but gets validated when submitting)</li> |
4772 | + * <li>'float': a floating number (can have leading "+" or "-", e.g. "+1", "-0.05") (like |
4773 | + * 'text' for input, but gets validated when submitting)</li> |
4774 | + * <li>'textarea': several lines of input. The following can be set for this type:<ul> |
4775 | + * <li>'rows': number of rows</li> |
4776 | + * <li>'cols': number of columns</li> |
4777 | + * </ul></li> |
4778 | + * <li>'html_textarea': like textarea, but allows html</li> |
4779 | + * <li>'select': a drop down field; you must set 'options' for it:<ul> |
4780 | + * <li>'options': an array of options ('value' => 'description'), see {@link Form::select_input_array()}.</li> |
4781 | + * </ul></li> |
4782 | + * <li>'select_blog': a drop down field, providing all existing blogs (Blog ID is the value or |
4783 | + * "" if "allow_none" is true) (WARNING: does not scale - not recommended)</li> |
4784 | + * <li>'select_group': a drop down field, providing all existing groups (Group ID is the value |
4785 | + * or "" if "allow_none" is true)</li> |
4786 | + * <li>'select_user': a drop down field, providing all existing groups (User ID is the value or |
4787 | + * "" if "allow_none" is true) (WARNING: does not scale - not recommended)</li> |
4788 | + * </ul></li> |
4789 | + * <li>'array': a subset of settings. The value gets automagically (un)serialized through get() |
4790 | + * and set(). The following keys apply to this type:<ul> |
4791 | + * <li>'entries': an array with meta information about sub-settings (which can be everything from |
4792 | + * the top-level, except: "valid_pattern", "valid_range"). Note: currently there's no type |
4793 | + * forcing or checking for sub-entries involved (e.g., if you have an entry of type "integer", |
4794 | + * you could get a non-numeric string there). fp> TODO: !!!! very unsafe</li> |
4795 | + * <li>'key': defines the key to use for each entry. This may be a text input for example |
4796 | + * (with label, note etc). (optional, default is numeric keys, which are not editable)</li> |
4797 | + * <li>'max_count': maximum count of sets (optional, default is no restriction)</li> |
4798 | + * <li>'min_count': minimum count of sets (optional, default is no restriction)</li> |
4799 | + * </ul></li> |
4800 | + * <li>'size': Size of the HTML input field (applies to types 'text', 'password' and 'integer'; |
4801 | + * defaults to 15)</li> |
4802 | + * <li>'maxlength': maxlength attribute for the input field (See 'size' above; defaults to |
4803 | + * no limit)</li> |
4804 | + * <li>'disabled': if true, it adds a 'disabled="disabled"' html attribute to the element and |
4805 | + * the value cannot be changed</li> |
4806 | + * <li>'no_edit': if true, the setting is not editable. This is useful for internal settings.</li> |
4807 | + * <li>'allow_none': set this to true to have "None" in the options list for types 'select_group' |
4808 | + * and 'select_user'.</li> |
4809 | + * <li>'multiple': This allows to select multiple values in a SELECT (including select_*) (boolean)</li> |
4810 | + * <li>'valid_pattern': A regular expression pattern that the value must match. This is either |
4811 | + * just a regexp pattern as string or an array with the keys 'pattern' and 'error' to define |
4812 | + * a custom error message.</li> |
4813 | + * <li>'valid_range': An array with keys 'min', 'max' and (optionally) 'error' to define a |
4814 | + * custom error message. At least "min" or "max" must be given.</li> |
4815 | + * <li>'help': can be:<ul> |
4816 | + * <li>'#anchor': anchor that gets appended to {@link $help_url}</li> |
4817 | + * <li>true: the settings name/key gets transformed to an html ID and gets used as anchor to {@link $help_url}.</li> |
4818 | + * <li>'http://example.com/uri': a full URL (starting with http:// or https://)</li> |
4819 | + * </ul></li> |
4820 | + * <li>'defaultvalue': Default value for the setting, defaults to '' (empty string)</li> |
4821 | + * <li>'note' (gets displayed as a note to the param field).</li> |
4822 | + * <li>'layout': Use this to visually group your settings. Either 'begin_fieldset', 'end_fieldset' |
4823 | + * or 'separator'. You can use 'label' for 'begin_fieldset'.</li> |
4824 | + * <li>'id', 'onchange', 'onclick', 'onfocus', 'onkeyup', 'onkeydown', 'onreset', 'onselect', 'cols', 'rows', 'maxlength': |
4825 | + * get passed through as attributes to the form/input element.</li> |
4826 | + * </ul> |
4827 | + * |
4828 | + * Example: |
4829 | * <code> |
4830 | * return array( |
4831 | * 'my_param' => array( |
4832 | * 'label' => $this->T_('My Param'), |
4833 | * 'defaultvalue' => '10', |
4834 | + * 'valid_pattern' => array( 'pattern' => '[1-9]\d+', $this->T_('The value must be >= 10.') ), |
4835 | * 'note' => $this->T_('Quite cool, eh?'), |
4836 | - * 'valid_pattern' => array( 'pattern' => '[1-9]\d+', $this->T_('The value must be >= 10.') ), |
4837 | * ), |
4838 | * 'another_param' => array( // this one has no 'note' |
4839 | * 'label' => $this->T_('My checkbox'), |
4840 | + * 'type' => 'checkbox', |
4841 | * 'defaultvalue' => '1', |
4842 | - * 'type' => 'checkbox', |
4843 | * ), |
4844 | * array( 'layout' => 'separator' ), |
4845 | - * 'my_select' => array( |
4846 | + * 'my_select' => array( |
4847 | * 'label' => $this->T_('Selector'), |
4848 | + * 'type' => 'select', |
4849 | + * 'options' => array( |
4850 | + * 'sun' => $this->T_('Sunday') |
4851 | + * 'mon' => $this->T_('Monday') |
4852 | + * ), |
4853 | * 'defaultvalue' => 'one', |
4854 | - * 'type' => 'select', |
4855 | - * 'options' => array( 'sun' => $this->T_('Sunday'), 'mon' => $this->T_('Monday') ), |
4856 | - * ) ); |
4857 | + * ) |
4858 | + * ); |
4859 | * </code> |
4860 | - * |
4861 | + * @param array Associative array of parameters |
4862 | + * - 'for_editing': 'true' if the settings get queried for editing, 'false' if they get |
4863 | + * queried for instantiating {@link Plugin::$Settings}. |
4864 | + * @return array Array of plugin's settings |
4865 | */ |
4866 | function GetDefaultSettings( & $params ) |
4867 | { |
4868 | @@ -461,23 +467,34 @@ |
4869 | |
4870 | |
4871 | /** |
4872 | - * Define here default user settings that are then available in the backoffice. |
4873 | + * Internal Event: Define default Blog settings |
4874 | + * @see Plugin::GetDefaultSettings() |
4875 | + * @param array Associative array of parameters. 'for_editing': true if the settings get |
4876 | + * queried for editing, false if they get queried for instantiating {@link Plugin::$UserSettings}. |
4877 | + * @return array See {@link Plugin::GetDefaultSettings()}. |
4878 | + */ |
4879 | + function GetDefaultBlogSettings( & $params ) |
4880 | + { |
4881 | + return array(); |
4882 | + } |
4883 | + |
4884 | + |
4885 | + /** |
4886 | + * Internal Event: Define default User settings |
4887 | * |
4888 | - * You can access them in the plugin through the member object |
4889 | - * {@link $UserSettings}, e.g.: |
4890 | + * This method behaves exactly like {@link Plugin::GetDefaultSettings()}, except that it |
4891 | + * defines user specific settings instead of global settings. You can access them in the |
4892 | + * plugin through the member object {@link $UserSettings} e.g.: |
4893 | * <code>$this->UserSettings->get( 'my_param' );</code> |
4894 | * |
4895 | - * This method behaves exactly like {@link Plugin::GetDefaultSettings()}, |
4896 | - * except that it defines user specific settings instead of global settings. |
4897 | - * |
4898 | - * @todo 3.0 fp> 1) This is not an event: RENAME to lowercase (in b2evo 3.0) |
4899 | - * @todo 3.0 fp> 2) This defines more than Default values :: confusing name |
4900 | - * @todo name tentative get_user_param_definitions() |
4901 | - * |
4902 | + * This hook accepts special cases for a user's avatar and (brief) biography. These fields |
4903 | + * are stored in the core table, but it is up to your plugin to use them. To activate them |
4904 | + * in a user's profile add either of these to your user settings array: |
4905 | + * <code>'use_avatar' => true,</code> |
4906 | + * <code>'use_biography' => true,</code> |
4907 | * @see Plugin::GetDefaultSettings() |
4908 | - * @param array Associative array of parameters. |
4909 | - * 'for_editing': true, if the settings get queried for editing; |
4910 | - * false, if they get queried for instantiating {@link Plugin::$UserSettings}. |
4911 | + * @param array Associative array of parameters. 'for_editing': true if the settings get |
4912 | + * queried for editing, false if they get queried for instantiating {@link Plugin::$UserSettings}. |
4913 | * @return array See {@link Plugin::GetDefaultSettings()}. |
4914 | */ |
4915 | function GetDefaultUserSettings( & $params ) |
4916 | @@ -487,23 +504,7 @@ |
4917 | |
4918 | |
4919 | /** |
4920 | - * Define here default collection/blog settings that are to be made available in the backoffice. |
4921 | - * |
4922 | - * @see Plugin::GetDefaultSettings() |
4923 | - * @param array Associative array of parameters. |
4924 | - * 'for_editing': true, if the settings get queried for editing; |
4925 | - * false, if they get queried for instantiating {@link Plugin::$UserSettings}. |
4926 | - * @return array See {@link Plugin::GetDefaultSettings()}. |
4927 | - */ |
4928 | - function GetDefaultBlogSettings( & $params ) |
4929 | - { |
4930 | - return array(); |
4931 | - } |
4932 | - |
4933 | - |
4934 | - /** |
4935 | - * Get definitions for widget specific editable params |
4936 | - * |
4937 | + * Internal Event: Define default Widget settings |
4938 | * @see Plugin::GetDefaultSettings() |
4939 | * @param local params like 'for_editing' => true |
4940 | */ |
4941 | @@ -514,71 +515,20 @@ |
4942 | |
4943 | |
4944 | /** |
4945 | - * Get the list of dependencies that the plugin has. |
4946 | - * |
4947 | - * This gets checked on install or uninstall of a plugin. |
4948 | - * |
4949 | - * There are two <b>classes</b> of dependencies: |
4950 | - * - 'recommends': This is just a recommendation. If it cannot get fulfilled |
4951 | - * there will just be a note added on install. |
4952 | - * - 'requires': A plugin cannot be installed if the dependencies cannot get |
4953 | - * fulfilled. Also, a plugin cannot get uninstalled, if another |
4954 | - * plugin depends on it. |
4955 | - * |
4956 | - * Each <b>class</b> of dependency can have the following types: |
4957 | - * - 'events_by_one': A list of eventlists that have to be provided by a single plugin, |
4958 | - * e.g., <code>array( array('CaptchaPayload', 'CaptchaValidated') )</code> |
4959 | - * to look for a plugin that provides both events. |
4960 | - * - 'plugins': |
4961 | - * A list of plugins, either just the plugin's classname or an array with |
4962 | - * classname and minimum version of the plugin (see {@link Plugin::$version}). |
4963 | - * E.g.: <code>array( 'test_plugin', '1' )</code> to require at least version "1" |
4964 | - * of the test plugin. |
4965 | - * - 'app_min': Minimum application (QP) version, e.g. "1.0". |
4966 | - * This way you can make sure that the hooks you need are implemented in the core. |
4967 | - * |
4968 | - * @see test_plugin::GetDependencies() |
4969 | - * @return array |
4970 | - */ |
4971 | - function GetDependencies() |
4972 | - { |
4973 | - return array(); // no dependencies by default, of course |
4974 | - } |
4975 | - |
4976 | - |
4977 | - /** |
4978 | - * This method should return your DB schema, consisting of a list of CREATE TABLE |
4979 | - * queries. |
4980 | - * |
4981 | - * The DB gets changed accordingly on installing or enabling your Plugin. |
4982 | - * |
4983 | - * If you want to change your DB layout in a new version of your Plugin, simply |
4984 | - * adjust the queries here and increase {@link Plugin::$version}, because this will |
4985 | - * request to check the current DB layout against the one you require. |
4986 | - * |
4987 | - * For restrictions see {@link db_delta()}. |
4988 | - */ |
4989 | - function GetDbLayout() |
4990 | - { |
4991 | - return array(); |
4992 | - } |
4993 | - |
4994 | - |
4995 | - /** |
4996 | - * This method gets asked when plugins get installed and allows you to return a list |
4997 | - * of extra events, which your plugin triggers itself (e.g. through |
4998 | - * {@link $Plugins->trigger_event()}). |
4999 | - * |
5000 | - * NOTE: PLEASE use a distinct prefix for the event name, e.g. "$this->classname". |
The diff has been truncated for viewing.