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