1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | file : $Id: cat_modify.php 2202 2008-01-30 22:16:01Z rub $ |
---|
8 | // | last update : $Date: 2008-01-30 22:16:01 +0000 (Wed, 30 Jan 2008) $ |
---|
9 | // | last modifier : $Author: rub $ |
---|
10 | // | revision : $Revision: 2202 $ |
---|
11 | // +-----------------------------------------------------------------------+ |
---|
12 | // | This program is free software; you can redistribute it and/or modify | |
---|
13 | // | it under the terms of the GNU General Public License as published by | |
---|
14 | // | the Free Software Foundation | |
---|
15 | // | | |
---|
16 | // | This program is distributed in the hope that it will be useful, but | |
---|
17 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
18 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
19 | // | General Public License for more details. | |
---|
20 | // | | |
---|
21 | // | You should have received a copy of the GNU General Public License | |
---|
22 | // | along with this program; if not, write to the Free Software | |
---|
23 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
24 | // | USA. | |
---|
25 | // +-----------------------------------------------------------------------+ |
---|
26 | |
---|
27 | if (!defined('PHPWG_ROOT_PATH')) |
---|
28 | { |
---|
29 | die('Hacking attempt!'); |
---|
30 | } |
---|
31 | |
---|
32 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
33 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
34 | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | // | Check Access and exit when user status is not ok | |
---|
37 | // +-----------------------------------------------------------------------+ |
---|
38 | check_status(ACCESS_ADMINISTRATOR); |
---|
39 | |
---|
40 | //---------------------------------------------------------------- verification |
---|
41 | if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) ) |
---|
42 | { |
---|
43 | $_GET['cat_id'] = '-1'; |
---|
44 | } |
---|
45 | |
---|
46 | $template->set_filenames( array('categories'=>'admin/cat_modify.tpl') ); |
---|
47 | |
---|
48 | //--------------------------------------------------------- form criteria check |
---|
49 | if (isset($_POST['submit'])) |
---|
50 | { |
---|
51 | $data = |
---|
52 | array( |
---|
53 | 'id' => $_GET['cat_id'], |
---|
54 | 'name' => @$_POST['name'], |
---|
55 | 'commentable' => $_POST['commentable'], |
---|
56 | 'uploadable' => |
---|
57 | isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false', |
---|
58 | 'comment' => |
---|
59 | $conf['allow_html_descriptions'] ? |
---|
60 | @$_POST['comment'] : strip_tags(@$_POST['comment']) |
---|
61 | ); |
---|
62 | |
---|
63 | mass_updates( |
---|
64 | CATEGORIES_TABLE, |
---|
65 | array( |
---|
66 | 'primary' => array('id'), |
---|
67 | 'update' => array_diff(array_keys($data), array('id')) |
---|
68 | ), |
---|
69 | array($data) |
---|
70 | ); |
---|
71 | |
---|
72 | set_cat_visible(array($_GET['cat_id']), $_POST['visible']); |
---|
73 | set_cat_status(array($_GET['cat_id']), $_POST['status']); |
---|
74 | |
---|
75 | if (isset($_POST['parent'])) |
---|
76 | { |
---|
77 | move_categories( |
---|
78 | array($_GET['cat_id']), |
---|
79 | $_POST['parent'] |
---|
80 | ); |
---|
81 | } |
---|
82 | |
---|
83 | $image_order = ''; |
---|
84 | if ( !isset($_POST['image_order_default']) ) |
---|
85 | { |
---|
86 | for ($i=1; $i<=3; $i++) |
---|
87 | { |
---|
88 | if ( !empty($_POST['order_field_'.$i]) ) |
---|
89 | { |
---|
90 | if (! empty($image_order) ) |
---|
91 | { |
---|
92 | $image_order .= ','; |
---|
93 | } |
---|
94 | $image_order .= $_POST['order_field_'.$i]; |
---|
95 | if ($_POST['order_direction_'.$i]=='DESC') |
---|
96 | { |
---|
97 | $image_order .= ' DESC'; |
---|
98 | } |
---|
99 | } |
---|
100 | } |
---|
101 | } |
---|
102 | $image_order = empty($image_order) ? 'null' : "'$image_order'"; |
---|
103 | $query = ' |
---|
104 | UPDATE '.CATEGORIES_TABLE.' SET image_order='.$image_order.' |
---|
105 | WHERE '; |
---|
106 | if (isset($_POST['image_order_subcats'])) |
---|
107 | { |
---|
108 | $query .= 'uppercats REGEXP \'(^|,)'.$_GET['cat_id'].'(,|$)\''; |
---|
109 | } |
---|
110 | else |
---|
111 | { |
---|
112 | $query .= 'id='.$_GET['cat_id'].';'; |
---|
113 | } |
---|
114 | pwg_query($query); |
---|
115 | |
---|
116 | array_push($page['infos'], l10n('editcat_confirm')); |
---|
117 | } |
---|
118 | else if (isset($_POST['set_random_representant'])) |
---|
119 | { |
---|
120 | set_random_representant(array($_GET['cat_id'])); |
---|
121 | } |
---|
122 | else if (isset($_POST['delete_representant'])) |
---|
123 | { |
---|
124 | $query = ' |
---|
125 | UPDATE '.CATEGORIES_TABLE.' |
---|
126 | SET representative_picture_id = NULL |
---|
127 | WHERE id = '.$_GET['cat_id'].' |
---|
128 | ;'; |
---|
129 | pwg_query($query); |
---|
130 | } |
---|
131 | else if (isset($_POST['submitAdd'])) |
---|
132 | { |
---|
133 | $output_create = create_virtual_category( |
---|
134 | $_POST['virtual_name'], |
---|
135 | (0 == $_POST['parent'] ? null : $_POST['parent']) |
---|
136 | ); |
---|
137 | |
---|
138 | if (isset($output_create['error'])) |
---|
139 | { |
---|
140 | array_push($page['errors'], $output_create['error']); |
---|
141 | } |
---|
142 | else |
---|
143 | { |
---|
144 | // Virtual category creation succeeded |
---|
145 | // |
---|
146 | // Add the information in the information list |
---|
147 | array_push($page['infos'], $output_create['info']); |
---|
148 | |
---|
149 | // Link the new category to the current category |
---|
150 | associate_categories_to_categories( |
---|
151 | array($_GET['cat_id']), |
---|
152 | array($output_create['id']) |
---|
153 | ); |
---|
154 | |
---|
155 | // information |
---|
156 | array_push( |
---|
157 | $page['infos'], |
---|
158 | sprintf( |
---|
159 | l10n('Category elements associated to the following categories: %s'), |
---|
160 | '<ul><li>' |
---|
161 | .get_cat_display_name_from_id($output_create['id']) |
---|
162 | .'</li></ul>' |
---|
163 | ) |
---|
164 | ); |
---|
165 | } |
---|
166 | } |
---|
167 | else if (isset($_POST['submitDestinations']) |
---|
168 | and isset($_POST['destinations']) |
---|
169 | and count($_POST['destinations']) > 0) |
---|
170 | { |
---|
171 | associate_categories_to_categories( |
---|
172 | array($_GET['cat_id']), |
---|
173 | $_POST['destinations'] |
---|
174 | ); |
---|
175 | |
---|
176 | $category_names = array(); |
---|
177 | foreach ($_POST['destinations'] as $category_id) |
---|
178 | { |
---|
179 | array_push( |
---|
180 | $category_names, |
---|
181 | get_cat_display_name_from_id($category_id) |
---|
182 | ); |
---|
183 | } |
---|
184 | |
---|
185 | array_push( |
---|
186 | $page['infos'], |
---|
187 | sprintf( |
---|
188 | l10n('Category elements associated to the following categories: %s'), |
---|
189 | '<ul><li>'.implode('</li><li>', $category_names).'</li></ul>' |
---|
190 | ) |
---|
191 | ); |
---|
192 | } |
---|
193 | |
---|
194 | $query = ' |
---|
195 | SELECT * |
---|
196 | FROM '.CATEGORIES_TABLE.' |
---|
197 | WHERE id = '.$_GET['cat_id'].' |
---|
198 | ;'; |
---|
199 | $category = mysql_fetch_array( pwg_query( $query ) ); |
---|
200 | // nullable fields |
---|
201 | foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable) |
---|
202 | { |
---|
203 | if (!isset($category[$nullable])) |
---|
204 | { |
---|
205 | $category[$nullable] = ''; |
---|
206 | } |
---|
207 | } |
---|
208 | |
---|
209 | $category['is_virtual'] = empty($category['dir']) ? true : false; |
---|
210 | |
---|
211 | // Navigation path |
---|
212 | $url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='; |
---|
213 | |
---|
214 | $navigation = get_cat_display_name_cache( |
---|
215 | $category['uppercats'], |
---|
216 | PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id=' |
---|
217 | ); |
---|
218 | |
---|
219 | $form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$_GET['cat_id']; |
---|
220 | $status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; |
---|
221 | $lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED'; |
---|
222 | |
---|
223 | if ($category['commentable'] == 'true') |
---|
224 | { |
---|
225 | $commentable = 'COMMENTABLE_TRUE'; |
---|
226 | } |
---|
227 | else |
---|
228 | { |
---|
229 | $commentable = 'COMMENTABLE_FALSE'; |
---|
230 | } |
---|
231 | if ($category['uploadable'] == 'true') |
---|
232 | { |
---|
233 | $uploadable = 'UPLOADABLE_TRUE'; |
---|
234 | } |
---|
235 | else |
---|
236 | { |
---|
237 | $uploadable = 'UPLOADABLE_FALSE'; |
---|
238 | } |
---|
239 | |
---|
240 | //----------------------------------------------------- template initialization |
---|
241 | |
---|
242 | $base_url = PHPWG_ROOT_PATH.'admin.php?page='; |
---|
243 | $cat_list_url = $base_url.'cat_list'; |
---|
244 | |
---|
245 | $self_url = $cat_list_url; |
---|
246 | if (!empty($category['id_uppercat'])) |
---|
247 | { |
---|
248 | $self_url.= '&parent_id='.$category['id_uppercat']; |
---|
249 | } |
---|
250 | |
---|
251 | $template->assign_vars( |
---|
252 | array( |
---|
253 | 'CATEGORIES_NAV' => $navigation, |
---|
254 | 'CAT_NAME' => $category['name'], |
---|
255 | 'CAT_COMMENT' => $category['comment'], |
---|
256 | |
---|
257 | $status => 'checked="checked"', |
---|
258 | $lock => 'checked="checked"', |
---|
259 | $commentable => 'checked="checked"', |
---|
260 | $uploadable => 'checked="checked"', |
---|
261 | |
---|
262 | 'IMG_ORDER_DEFAULT' => empty($category['image_order']) ? |
---|
263 | 'checked="checked"' : '', |
---|
264 | |
---|
265 | 'L_EDIT_NAME' => l10n('name'), |
---|
266 | 'L_STORAGE' => l10n('storage'), |
---|
267 | 'L_REMOTE_SITE' => l10n('remote_site'), |
---|
268 | 'L_EDIT_COMMENT' => l10n('description'), |
---|
269 | 'L_EDIT_STATUS' => l10n('conf_access'), |
---|
270 | 'L_STATUS_PUBLIC' => l10n('public'), |
---|
271 | 'L_STATUS_PRIVATE' => l10n('private'), |
---|
272 | 'L_EDIT_LOCK' => l10n('lock'), |
---|
273 | 'L_EDIT_UPLOADABLE' => l10n('editcat_uploadable'), |
---|
274 | 'L_EDIT_COMMENTABLE' => l10n('comments'), |
---|
275 | 'L_YES' => l10n('yes'), |
---|
276 | 'L_NO' => l10n('no'), |
---|
277 | 'L_SUBMIT' => l10n('submit'), |
---|
278 | 'L_SET_RANDOM_REPRESENTANT'=>l10n('cat_representant'), |
---|
279 | |
---|
280 | 'U_JUMPTO' => make_index_url( |
---|
281 | array( |
---|
282 | 'category' => $category |
---|
283 | ) |
---|
284 | ), |
---|
285 | |
---|
286 | 'MAIL_CONTENT' => empty($_POST['mail_content']) |
---|
287 | ? '' : stripslashes($_POST['mail_content']), |
---|
288 | 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], |
---|
289 | 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=cat_modify', |
---|
290 | |
---|
291 | 'F_ACTION' => $form_action, |
---|
292 | ) |
---|
293 | ); |
---|
294 | |
---|
295 | |
---|
296 | if ('private' == $category['status']) |
---|
297 | { |
---|
298 | $template->assign_block_vars( |
---|
299 | 'permissions', |
---|
300 | array( |
---|
301 | 'URL'=>$base_url.'cat_perm&cat='.$category['id'] |
---|
302 | ) |
---|
303 | ); |
---|
304 | } |
---|
305 | |
---|
306 | // manage category elements link |
---|
307 | if ($category['nb_images'] > 0) |
---|
308 | { |
---|
309 | $template->assign_block_vars( |
---|
310 | 'elements', |
---|
311 | array( |
---|
312 | 'URL'=>$base_url.'element_set&cat='.$category['id'] |
---|
313 | ) |
---|
314 | ); |
---|
315 | } |
---|
316 | |
---|
317 | // image order management |
---|
318 | $matches = array(); |
---|
319 | if ( !empty( $category['image_order'] ) ) |
---|
320 | { |
---|
321 | preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i', |
---|
322 | $category['image_order'], $matches); |
---|
323 | } |
---|
324 | |
---|
325 | $sort_fields = array( |
---|
326 | '' => '', |
---|
327 | 'date_creation' => l10n('Creation date'), |
---|
328 | 'date_available' => l10n('Post date'), |
---|
329 | 'average_rate' => l10n('Average rate'), |
---|
330 | 'hit' => l10n('most_visited_cat'), |
---|
331 | 'file' => l10n('File name'), |
---|
332 | 'id' => 'Id', |
---|
333 | ); |
---|
334 | |
---|
335 | for ($i=0; $i<3; $i++) // 3 fields |
---|
336 | { |
---|
337 | $template->assign_block_vars('image_order', array('NUMBER'=>$i+1) ); |
---|
338 | foreach ($sort_fields as $sort_field => $name) |
---|
339 | { |
---|
340 | $selected=''; |
---|
341 | if ( isset($matches[1][$i]) and $matches[1][$i]==$sort_field ) |
---|
342 | { |
---|
343 | $selected='selected="selected"'; |
---|
344 | } |
---|
345 | elseif ( empty($sort_field) ) |
---|
346 | { |
---|
347 | $selected='selected="selected"'; |
---|
348 | } |
---|
349 | |
---|
350 | $template->assign_block_vars('image_order.field', |
---|
351 | array( |
---|
352 | 'SELECTED' => $selected, |
---|
353 | 'VALUE' => $sort_field, |
---|
354 | 'OPTION' => $name |
---|
355 | ) |
---|
356 | ); |
---|
357 | } |
---|
358 | |
---|
359 | $template->assign_block_vars('image_order.order', |
---|
360 | array( |
---|
361 | 'SELECTED' => |
---|
362 | ( empty($matches[2][$i]) or strcasecmp($matches[2][$i],'ASC')==0 ) |
---|
363 | ? 'selected="selected"' : '', |
---|
364 | 'VALUE' => 'ASC', |
---|
365 | 'OPTION' => 'Ascending' |
---|
366 | ) |
---|
367 | ); |
---|
368 | |
---|
369 | $template->assign_block_vars('image_order.order', |
---|
370 | array( |
---|
371 | 'SELECTED' => |
---|
372 | ( isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0 ) |
---|
373 | ? 'selected="selected"' : '', |
---|
374 | 'VALUE' => 'DESC', |
---|
375 | 'OPTION' => 'Descending' |
---|
376 | ) |
---|
377 | ); |
---|
378 | } |
---|
379 | |
---|
380 | |
---|
381 | // representant management |
---|
382 | if ($category['nb_images'] > 0 |
---|
383 | or !empty($category['representative_picture_id'])) |
---|
384 | { |
---|
385 | $template->assign_block_vars('representant', array()); |
---|
386 | |
---|
387 | // picture to display : the identified representant or the generic random |
---|
388 | // representant ? |
---|
389 | if (!empty($category['representative_picture_id'])) |
---|
390 | { |
---|
391 | $query = ' |
---|
392 | SELECT id,tn_ext,path |
---|
393 | FROM '.IMAGES_TABLE.' |
---|
394 | WHERE id = '.$category['representative_picture_id'].' |
---|
395 | ;'; |
---|
396 | $row = mysql_fetch_array(pwg_query($query)); |
---|
397 | $src = get_thumbnail_url($row); |
---|
398 | $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; |
---|
399 | $url.= '&image_id='.$category['representative_picture_id']; |
---|
400 | |
---|
401 | $template->assign_block_vars( |
---|
402 | 'representant.picture', |
---|
403 | array( |
---|
404 | 'SRC' => $src, |
---|
405 | 'URL' => $url |
---|
406 | ) |
---|
407 | ); |
---|
408 | } |
---|
409 | else // $category['nb_images'] > 0 |
---|
410 | { |
---|
411 | $template->assign_block_vars('representant.random', array()); |
---|
412 | } |
---|
413 | |
---|
414 | // can the admin choose to set a new random representant ? |
---|
415 | if ($category['nb_images'] > 0) |
---|
416 | { |
---|
417 | $template->assign_block_vars('representant.set_random', array()); |
---|
418 | } |
---|
419 | |
---|
420 | // can the admin delete the current representant ? |
---|
421 | if ( |
---|
422 | ($category['nb_images'] > 0 |
---|
423 | and $conf['allow_random_representative']) |
---|
424 | or |
---|
425 | ($category['nb_images'] == 0 |
---|
426 | and !empty($category['representative_picture_id']))) |
---|
427 | { |
---|
428 | $template->assign_block_vars('representant.delete_representant', array()); |
---|
429 | } |
---|
430 | } |
---|
431 | |
---|
432 | if (!$category['is_virtual']) |
---|
433 | { |
---|
434 | $template->assign_block_vars( |
---|
435 | 'storage', |
---|
436 | array('CATEGORY_DIR'=>preg_replace('/\/$/', |
---|
437 | '', |
---|
438 | get_complete_dir($category['id'])))); |
---|
439 | } |
---|
440 | else |
---|
441 | { |
---|
442 | $template->assign_block_vars( |
---|
443 | 'delete', |
---|
444 | array( |
---|
445 | 'URL'=>$self_url.'&delete='.$category['id'] |
---|
446 | ) |
---|
447 | ); |
---|
448 | |
---|
449 | $template->assign_block_vars('move', array()); |
---|
450 | |
---|
451 | // the category can be moved in any category but in itself, in any |
---|
452 | // sub-category |
---|
453 | $unmovables = get_subcat_ids(array($category['id'])); |
---|
454 | |
---|
455 | $blockname = 'move.parent_option'; |
---|
456 | |
---|
457 | $template->assign_block_vars( |
---|
458 | $blockname, |
---|
459 | array( |
---|
460 | 'SELECTED' |
---|
461 | => empty($category['id_uppercat']) ? 'selected="selected"' : '', |
---|
462 | 'VALUE'=> 0, |
---|
463 | 'OPTION' => '------------' |
---|
464 | ) |
---|
465 | ); |
---|
466 | |
---|
467 | $query = ' |
---|
468 | SELECT id,name,uppercats,global_rank |
---|
469 | FROM '.CATEGORIES_TABLE.' |
---|
470 | WHERE id NOT IN ('.implode(',', $unmovables).') |
---|
471 | ;'; |
---|
472 | |
---|
473 | display_select_cat_wrapper( |
---|
474 | $query, |
---|
475 | empty($category['id_uppercat']) ? array() : array($category['id_uppercat']), |
---|
476 | $blockname |
---|
477 | ); |
---|
478 | } |
---|
479 | |
---|
480 | $category['cat_dir'] = get_complete_dir($_GET['cat_id']); |
---|
481 | if (is_numeric($category['site_id']) and url_is_remote($category['cat_dir']) ) |
---|
482 | { |
---|
483 | $query = ' |
---|
484 | SELECT galleries_url |
---|
485 | FROM '.SITES_TABLE.' |
---|
486 | WHERE id = '.$category['site_id'].' |
---|
487 | ;'; |
---|
488 | list($galleries_url) = mysql_fetch_array(pwg_query($query)); |
---|
489 | $template->assign_block_vars('server', array('SITE_URL' => $galleries_url)); |
---|
490 | } |
---|
491 | |
---|
492 | if (!$category['is_virtual'] and !url_is_remote($category['cat_dir']) ) |
---|
493 | { |
---|
494 | $template->assign_block_vars('upload' ,array()); |
---|
495 | } |
---|
496 | |
---|
497 | $blockname = 'category_option_parent'; |
---|
498 | |
---|
499 | $template->assign_block_vars( |
---|
500 | $blockname, |
---|
501 | array( |
---|
502 | 'VALUE'=> 0, |
---|
503 | 'OPTION' => '------------' |
---|
504 | ) |
---|
505 | ); |
---|
506 | |
---|
507 | $query = ' |
---|
508 | SELECT id,name,uppercats,global_rank |
---|
509 | FROM '.CATEGORIES_TABLE.' |
---|
510 | ;'; |
---|
511 | |
---|
512 | display_select_cat_wrapper( |
---|
513 | $query, |
---|
514 | array(), |
---|
515 | $blockname |
---|
516 | ); |
---|
517 | |
---|
518 | // destination categories |
---|
519 | $query = ' |
---|
520 | SELECT id,name,uppercats,global_rank |
---|
521 | FROM '.CATEGORIES_TABLE.' |
---|
522 | WHERE id != '.$category['id'].' |
---|
523 | ;'; |
---|
524 | |
---|
525 | display_select_cat_wrapper( |
---|
526 | $query, |
---|
527 | array(), |
---|
528 | 'category_option_destination' |
---|
529 | ); |
---|
530 | |
---|
531 | // info by email to an access granted group of category informations |
---|
532 | if (isset($_POST['submitEmail']) and !empty($_POST['group'])) |
---|
533 | { |
---|
534 | set_make_full_url(); |
---|
535 | |
---|
536 | /* TODO: if $category['representative_picture_id'] |
---|
537 | is empty find child representative_picture_id */ |
---|
538 | if (!empty($category['representative_picture_id'])) |
---|
539 | { |
---|
540 | $query = ' |
---|
541 | SELECT id, file, path, tn_ext |
---|
542 | FROM '.IMAGES_TABLE.' |
---|
543 | WHERE id = '.$category['representative_picture_id'].' |
---|
544 | ;'; |
---|
545 | |
---|
546 | $result = pwg_query($query); |
---|
547 | if (mysql_num_rows($result) > 0) |
---|
548 | { |
---|
549 | $element = mysql_fetch_assoc($result); |
---|
550 | |
---|
551 | $img_url = '<a href="'. |
---|
552 | make_picture_url(array( |
---|
553 | 'image_id' => $element['id'], |
---|
554 | 'image_file' => $element['file'], |
---|
555 | 'category' => $category |
---|
556 | )) |
---|
557 | .'"><img src="'.get_thumbnail_url($element).'"/></a>'; |
---|
558 | } |
---|
559 | } |
---|
560 | |
---|
561 | if (!isset($img_url)) |
---|
562 | { |
---|
563 | $img_url = ''; |
---|
564 | } |
---|
565 | |
---|
566 | // TODO Mettre un array pour traduction subjet |
---|
567 | pwg_mail_group( |
---|
568 | $_POST['group'], |
---|
569 | get_str_email_format(true), /* TODO add a checkbox in order to choose format*/ |
---|
570 | get_l10n_args('[%s] Come to visit the category %s', |
---|
571 | array($conf['gallery_title'], $category['name'])), |
---|
572 | 'admin', |
---|
573 | 'cat_group_info', |
---|
574 | array |
---|
575 | ( |
---|
576 | 'IMG_URL' => $img_url, |
---|
577 | 'CAT_NAME' => $category['name'], |
---|
578 | 'LINK' => make_index_url( |
---|
579 | array( |
---|
580 | 'category' => array( |
---|
581 | 'id' => $category['id'], |
---|
582 | 'name' => $category['name'], |
---|
583 | 'permalink' => $category['permalink'] |
---|
584 | ))), |
---|
585 | 'CPL_CONTENT' => empty($_POST['mail_content']) |
---|
586 | ? '' : stripslashes($_POST['mail_content']) |
---|
587 | ), |
---|
588 | '' /* TODO Add listbox in order to choose Language selected */); |
---|
589 | |
---|
590 | unset_make_full_url(); |
---|
591 | |
---|
592 | $query = ' |
---|
593 | SELECT |
---|
594 | name |
---|
595 | FROM '.GROUPS_TABLE.' |
---|
596 | WHERE id = '.$_POST['group'].' |
---|
597 | ;'; |
---|
598 | list($group_name) = mysql_fetch_row(pwg_query($query)); |
---|
599 | |
---|
600 | array_push( |
---|
601 | $page['infos'], |
---|
602 | sprintf( |
---|
603 | l10n('An information email was sent to group "%s"'), |
---|
604 | $group_name |
---|
605 | ) |
---|
606 | ); |
---|
607 | } |
---|
608 | |
---|
609 | if ('private' == $category['status']) |
---|
610 | { |
---|
611 | $query = ' |
---|
612 | SELECT |
---|
613 | group_id |
---|
614 | FROM '.GROUP_ACCESS_TABLE.' |
---|
615 | WHERE cat_id = '.$category['id'].' |
---|
616 | ;'; |
---|
617 | } |
---|
618 | else |
---|
619 | { |
---|
620 | $query = ' |
---|
621 | SELECT |
---|
622 | id AS group_id |
---|
623 | FROM '.GROUPS_TABLE.' |
---|
624 | ;'; |
---|
625 | } |
---|
626 | $group_ids = array_from_query($query, 'group_id'); |
---|
627 | |
---|
628 | if (count($group_ids) > 0) |
---|
629 | { |
---|
630 | $query = ' |
---|
631 | SELECT |
---|
632 | id, |
---|
633 | name |
---|
634 | FROM '.GROUPS_TABLE.' |
---|
635 | WHERE id IN ('.implode(',', $group_ids).') |
---|
636 | ORDER BY name ASC |
---|
637 | ;'; |
---|
638 | $result = pwg_query($query); |
---|
639 | |
---|
640 | while ($row = mysql_fetch_array($result)) |
---|
641 | { |
---|
642 | $template->assign_block_vars( |
---|
643 | 'group_mail.group_option', |
---|
644 | array( |
---|
645 | 'VALUE' => $row['id'], |
---|
646 | 'OPTION' => $row['name'], |
---|
647 | ) |
---|
648 | ); |
---|
649 | } |
---|
650 | } |
---|
651 | |
---|
652 | //----------------------------------------------------------- sending html code |
---|
653 | $template->assign_var_from_handle('ADMIN_CONTENT', 'categories'); |
---|
654 | ?> |
---|