[21] | 1 | <?php |
---|
[362] | 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[5196] | 5 | // | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[21] | 23 | |
---|
[632] | 24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
[403] | 25 | { |
---|
[632] | 26 | die('Hacking attempt!'); |
---|
[403] | 27 | } |
---|
[1072] | 28 | |
---|
[1895] | 29 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
[1072] | 30 | |
---|
| 31 | // +-----------------------------------------------------------------------+ |
---|
| 32 | // | Check Access and exit when user status is not ok | |
---|
| 33 | // +-----------------------------------------------------------------------+ |
---|
| 34 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 35 | |
---|
[5933] | 36 | trigger_action('loc_begin_cat_modify'); |
---|
| 37 | |
---|
[21] | 38 | //---------------------------------------------------------------- verification |
---|
[403] | 39 | if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) ) |
---|
[21] | 40 | { |
---|
[2490] | 41 | trigger_error( 'missing cat_id param', E_USER_ERROR); |
---|
[21] | 42 | } |
---|
[403] | 43 | |
---|
[21] | 44 | //--------------------------------------------------------- form criteria check |
---|
[825] | 45 | if (isset($_POST['submit'])) |
---|
[21] | 46 | { |
---|
[2490] | 47 | $image_order = null; |
---|
| 48 | if ( !isset($_POST['image_order_default']) ) |
---|
| 49 | { |
---|
| 50 | for ($i=1; $i<=3; $i++) |
---|
| 51 | { |
---|
| 52 | if ( !empty($_POST['order_field_'.$i]) ) |
---|
| 53 | { |
---|
| 54 | if (! empty($image_order) ) |
---|
| 55 | { |
---|
| 56 | $image_order .= ','; |
---|
| 57 | } |
---|
| 58 | $image_order .= $_POST['order_field_'.$i]; |
---|
| 59 | if ($_POST['order_direction_'.$i]=='DESC') |
---|
| 60 | { |
---|
| 61 | $image_order .= ' DESC'; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
[825] | 67 | $data = |
---|
| 68 | array( |
---|
| 69 | 'id' => $_GET['cat_id'], |
---|
| 70 | 'name' => @$_POST['name'], |
---|
[4367] | 71 | 'commentable' => isset($_POST['commentable'])?$_POST['commentable']:'false', |
---|
[825] | 72 | 'uploadable' => |
---|
| 73 | isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false', |
---|
| 74 | 'comment' => |
---|
| 75 | $conf['allow_html_descriptions'] ? |
---|
[2490] | 76 | @$_POST['comment'] : strip_tags(@$_POST['comment']), |
---|
| 77 | 'image_order' => $image_order, |
---|
[825] | 78 | ); |
---|
[38] | 79 | |
---|
[825] | 80 | mass_updates( |
---|
| 81 | CATEGORIES_TABLE, |
---|
| 82 | array( |
---|
| 83 | 'primary' => array('id'), |
---|
| 84 | 'update' => array_diff(array_keys($data), array('id')) |
---|
| 85 | ), |
---|
| 86 | array($data) |
---|
| 87 | ); |
---|
[1131] | 88 | |
---|
[2490] | 89 | // retrieve cat infos before continuing (following updates are expensive) |
---|
| 90 | $cat_info = get_cat_info($_GET['cat_id']); |
---|
[345] | 91 | |
---|
[2490] | 92 | if (isset($_POST['image_order_subcats'])) |
---|
[809] | 93 | { |
---|
[2490] | 94 | $query = ' |
---|
[6551] | 95 | UPDATE '.CATEGORIES_TABLE.' SET image_order='.(isset($image_order) ? 'NULL':'\''.$image_order.'\'').' |
---|
| 96 | WHERE uppercats LIKE \''.$cat_info['uppercats'].',%\''; |
---|
[2490] | 97 | pwg_query($query); |
---|
[809] | 98 | } |
---|
| 99 | |
---|
[2490] | 100 | if ($cat_info['visible'] != get_boolean( $_POST['visible'] ) ) |
---|
[1500] | 101 | { |
---|
[2490] | 102 | set_cat_visible(array($_GET['cat_id']), $_POST['visible']); |
---|
[1500] | 103 | } |
---|
[2653] | 104 | if ($cat_info['status'] != $_POST['status'] ) |
---|
[1500] | 105 | { |
---|
[2490] | 106 | set_cat_status(array($_GET['cat_id']), $_POST['status']); |
---|
[1500] | 107 | } |
---|
[2490] | 108 | |
---|
| 109 | if (isset($_POST['parent']) and $cat_info['id_uppercat'] != $_POST['parent']) |
---|
[1500] | 110 | { |
---|
[2490] | 111 | move_categories( array($_GET['cat_id']), $_POST['parent'] ); |
---|
[1500] | 112 | } |
---|
| 113 | |
---|
[5021] | 114 | array_push($page['infos'], l10n('Category informations updated successfully.')); |
---|
[21] | 115 | } |
---|
[2490] | 116 | elseif (isset($_POST['set_random_representant'])) |
---|
[633] | 117 | { |
---|
| 118 | set_random_representant(array($_GET['cat_id'])); |
---|
| 119 | } |
---|
[2490] | 120 | elseif (isset($_POST['delete_representant'])) |
---|
[809] | 121 | { |
---|
| 122 | $query = ' |
---|
| 123 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 124 | SET representative_picture_id = NULL |
---|
| 125 | WHERE id = '.$_GET['cat_id'].' |
---|
| 126 | ;'; |
---|
| 127 | pwg_query($query); |
---|
| 128 | } |
---|
[2490] | 129 | elseif (isset($_POST['submitAdd'])) |
---|
[1064] | 130 | { |
---|
| 131 | $output_create = create_virtual_category( |
---|
| 132 | $_POST['virtual_name'], |
---|
| 133 | (0 == $_POST['parent'] ? null : $_POST['parent']) |
---|
| 134 | ); |
---|
[1131] | 135 | |
---|
[1064] | 136 | if (isset($output_create['error'])) |
---|
| 137 | { |
---|
| 138 | array_push($page['errors'], $output_create['error']); |
---|
| 139 | } |
---|
| 140 | else |
---|
| 141 | { |
---|
| 142 | // Virtual category creation succeeded |
---|
| 143 | // |
---|
| 144 | // Add the information in the information list |
---|
| 145 | array_push($page['infos'], $output_create['info']); |
---|
[1131] | 146 | |
---|
[1064] | 147 | // Link the new category to the current category |
---|
[1121] | 148 | associate_categories_to_categories( |
---|
| 149 | array($_GET['cat_id']), |
---|
| 150 | array($output_create['id']) |
---|
| 151 | ); |
---|
[21] | 152 | |
---|
[1121] | 153 | // information |
---|
[1064] | 154 | array_push( |
---|
[1121] | 155 | $page['infos'], |
---|
| 156 | sprintf( |
---|
| 157 | l10n('Category elements associated to the following categories: %s'), |
---|
| 158 | '<ul><li>' |
---|
| 159 | .get_cat_display_name_from_id($output_create['id']) |
---|
| 160 | .'</li></ul>' |
---|
[1064] | 161 | ) |
---|
| 162 | ); |
---|
| 163 | } |
---|
| 164 | } |
---|
[2490] | 165 | elseif (isset($_POST['submitDestinations']) |
---|
[1121] | 166 | and isset($_POST['destinations']) |
---|
| 167 | and count($_POST['destinations']) > 0) |
---|
[1064] | 168 | { |
---|
[1121] | 169 | associate_categories_to_categories( |
---|
| 170 | array($_GET['cat_id']), |
---|
| 171 | $_POST['destinations'] |
---|
| 172 | ); |
---|
[1064] | 173 | |
---|
[1121] | 174 | $category_names = array(); |
---|
| 175 | foreach ($_POST['destinations'] as $category_id) |
---|
[1064] | 176 | { |
---|
| 177 | array_push( |
---|
[1121] | 178 | $category_names, |
---|
| 179 | get_cat_display_name_from_id($category_id) |
---|
[1064] | 180 | ); |
---|
| 181 | } |
---|
| 182 | |
---|
[1121] | 183 | array_push( |
---|
| 184 | $page['infos'], |
---|
| 185 | sprintf( |
---|
| 186 | l10n('Category elements associated to the following categories: %s'), |
---|
| 187 | '<ul><li>'.implode('</li><li>', $category_names).'</li></ul>' |
---|
| 188 | ) |
---|
[1064] | 189 | ); |
---|
| 190 | } |
---|
| 191 | |
---|
[632] | 192 | $query = ' |
---|
| 193 | SELECT * |
---|
| 194 | FROM '.CATEGORIES_TABLE.' |
---|
| 195 | WHERE id = '.$_GET['cat_id'].' |
---|
| 196 | ;'; |
---|
[4325] | 197 | $category = pwg_db_fetch_assoc( pwg_query( $query ) ); |
---|
[530] | 198 | // nullable fields |
---|
[809] | 199 | foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable) |
---|
[530] | 200 | { |
---|
| 201 | if (!isset($category[$nullable])) |
---|
| 202 | { |
---|
| 203 | $category[$nullable] = ''; |
---|
| 204 | } |
---|
| 205 | } |
---|
[345] | 206 | |
---|
[809] | 207 | $category['is_virtual'] = empty($category['dir']) ? true : false; |
---|
| 208 | |
---|
[2324] | 209 | $query = 'SELECT DISTINCT category_id |
---|
| 210 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
| 211 | WHERE category_id = '.$_GET['cat_id'].' |
---|
| 212 | LIMIT 1'; |
---|
| 213 | $result = pwg_query($query); |
---|
[4325] | 214 | $category['has_images'] = pwg_db_num_rows($result)>0 ? true : false; |
---|
[2223] | 215 | |
---|
[403] | 216 | // Navigation path |
---|
[834] | 217 | $navigation = get_cat_display_name_cache( |
---|
[635] | 218 | $category['uppercats'], |
---|
[2286] | 219 | get_root_url().'admin.php?page=cat_modify&cat_id=' |
---|
[834] | 220 | ); |
---|
[345] | 221 | |
---|
[2286] | 222 | $form_action = get_root_url().'admin.php?page=cat_modify&cat_id='.$_GET['cat_id']; |
---|
[403] | 223 | |
---|
| 224 | //----------------------------------------------------- template initialization |
---|
[2530] | 225 | $template->set_filename( 'categories', 'cat_modify.tpl'); |
---|
[809] | 226 | |
---|
[2286] | 227 | $base_url = get_root_url().'admin.php?page='; |
---|
[809] | 228 | $cat_list_url = $base_url.'cat_list'; |
---|
[1131] | 229 | |
---|
[809] | 230 | $self_url = $cat_list_url; |
---|
| 231 | if (!empty($category['id_uppercat'])) |
---|
| 232 | { |
---|
| 233 | $self_url.= '&parent_id='.$category['id_uppercat']; |
---|
| 234 | } |
---|
| 235 | |
---|
[2223] | 236 | $template->assign( |
---|
[1131] | 237 | array( |
---|
[1082] | 238 | 'CATEGORIES_NAV' => $navigation, |
---|
[2777] | 239 | 'CAT_ID' => $category['id'], |
---|
[2223] | 240 | 'CAT_NAME' => @htmlspecialchars($category['name']), |
---|
| 241 | 'CAT_COMMENT' => @htmlspecialchars($category['comment']), |
---|
[1131] | 242 | |
---|
[2223] | 243 | 'status_values' => array('public','private'), |
---|
[1131] | 244 | |
---|
[2223] | 245 | 'CAT_STATUS' => $category['status'], |
---|
[4385] | 246 | 'CAT_VISIBLE' => boolean_to_string($category['visible']), |
---|
| 247 | 'CAT_COMMENTABLE' => boolean_to_string($category['commentable']), |
---|
| 248 | 'CAT_UPLOADABLE' => boolean_to_string($category['uploadable']), |
---|
[2223] | 249 | |
---|
[1500] | 250 | 'IMG_ORDER_DEFAULT' => empty($category['image_order']) ? |
---|
| 251 | 'checked="checked"' : '', |
---|
| 252 | |
---|
[1082] | 253 | 'U_JUMPTO' => make_index_url( |
---|
| 254 | array( |
---|
[1861] | 255 | 'category' => $category |
---|
[1082] | 256 | ) |
---|
| 257 | ), |
---|
[1131] | 258 | |
---|
[1916] | 259 | 'MAIL_CONTENT' => empty($_POST['mail_content']) |
---|
| 260 | ? '' : stripslashes($_POST['mail_content']), |
---|
[1082] | 261 | 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], |
---|
[5920] | 262 | 'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_modify', |
---|
[1131] | 263 | |
---|
[1082] | 264 | 'F_ACTION' => $form_action, |
---|
| 265 | ) |
---|
| 266 | ); |
---|
[633] | 267 | |
---|
[809] | 268 | |
---|
| 269 | if ('private' == $category['status']) |
---|
| 270 | { |
---|
[2223] | 271 | $template->assign( 'U_MANAGE_PERMISSIONS', |
---|
| 272 | $base_url.'cat_perm&cat='.$category['id'] |
---|
[809] | 273 | ); |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | // manage category elements link |
---|
[2324] | 277 | if ($category['has_images']) |
---|
[633] | 278 | { |
---|
[2517] | 279 | $template->assign( |
---|
| 280 | 'U_MANAGE_ELEMENTS', |
---|
| 281 | $base_url.'element_set&cat='.$category['id'] |
---|
[2223] | 282 | ); |
---|
[2517] | 283 | $template->assign( |
---|
| 284 | 'U_MANAGE_RANKS', |
---|
| 285 | $base_url.'element_set_ranks&cat_id='.$category['id'] |
---|
| 286 | ); |
---|
[2223] | 287 | } |
---|
| 288 | |
---|
| 289 | if ($category['is_virtual']) |
---|
| 290 | { |
---|
| 291 | $template->assign( |
---|
[809] | 292 | array( |
---|
[5335] | 293 | 'U_DELETE' => $self_url.'&delete='.$category['id'].'&pwg_token='.get_pwg_token(), |
---|
[809] | 294 | ) |
---|
| 295 | ); |
---|
| 296 | } |
---|
[2223] | 297 | else |
---|
[1500] | 298 | { |
---|
[2223] | 299 | $category['cat_full_dir'] = get_complete_dir($_GET['cat_id']); |
---|
| 300 | $template->assign( |
---|
| 301 | array( |
---|
| 302 | 'CAT_FULL_DIR' => preg_replace('/\/$/', |
---|
| 303 | '', |
---|
| 304 | $category['cat_full_dir'] ) |
---|
| 305 | ) |
---|
| 306 | ); |
---|
| 307 | if (!url_is_remote($category['cat_full_dir']) ) |
---|
| 308 | { |
---|
| 309 | $template->assign('SHOW_UPLOADABLE', true); |
---|
| 310 | } |
---|
[1500] | 311 | } |
---|
| 312 | |
---|
[2223] | 313 | // image order management |
---|
| 314 | |
---|
[1500] | 315 | $sort_fields = array( |
---|
| 316 | '' => '', |
---|
| 317 | 'date_creation' => l10n('Creation date'), |
---|
| 318 | 'date_available' => l10n('Post date'), |
---|
| 319 | 'average_rate' => l10n('Average rate'), |
---|
[5021] | 320 | 'hit' => l10n('Most visited'), |
---|
[1500] | 321 | 'file' => l10n('File name'), |
---|
| 322 | 'id' => 'Id', |
---|
[2517] | 323 | 'rank' => l10n('Rank'), |
---|
[1500] | 324 | ); |
---|
| 325 | |
---|
[2223] | 326 | $sort_directions = array( |
---|
| 327 | 'ASC' => l10n('ascending'), |
---|
| 328 | 'DESC' => l10n('descending'), |
---|
| 329 | ); |
---|
| 330 | |
---|
| 331 | $template->assign( 'image_order_field_options', $sort_fields); |
---|
| 332 | $template->assign( 'image_order_direction_options', $sort_directions); |
---|
| 333 | |
---|
| 334 | $matches = array(); |
---|
| 335 | if ( !empty( $category['image_order'] ) ) |
---|
| 336 | { |
---|
| 337 | preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i', |
---|
| 338 | $category['image_order'], $matches); |
---|
| 339 | } |
---|
| 340 | |
---|
[1500] | 341 | for ($i=0; $i<3; $i++) // 3 fields |
---|
| 342 | { |
---|
[2223] | 343 | $tpl_image_order_select = array( |
---|
| 344 | 'ID' => $i+1, |
---|
| 345 | 'FIELD' => array(''), |
---|
| 346 | 'DIRECTION' => array('ASC'), |
---|
| 347 | ); |
---|
[5335] | 348 | |
---|
[2223] | 349 | if ( isset($matches[1][$i]) ) |
---|
[1500] | 350 | { |
---|
[2223] | 351 | $tpl_image_order_select['FIELD'] = array($matches[1][$i]); |
---|
[1500] | 352 | } |
---|
[5335] | 353 | |
---|
[2223] | 354 | if (isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0) |
---|
| 355 | { |
---|
| 356 | $tpl_image_order_select['DIRECTION'] = array('DESC'); |
---|
| 357 | } |
---|
| 358 | $template->append( 'image_orders', $tpl_image_order_select); |
---|
[1500] | 359 | } |
---|
| 360 | |
---|
| 361 | |
---|
[809] | 362 | // representant management |
---|
[2324] | 363 | if ($category['has_images'] |
---|
[809] | 364 | or !empty($category['representative_picture_id'])) |
---|
| 365 | { |
---|
[2223] | 366 | $tpl_representant = array(); |
---|
[809] | 367 | |
---|
| 368 | // picture to display : the identified representant or the generic random |
---|
| 369 | // representant ? |
---|
| 370 | if (!empty($category['representative_picture_id'])) |
---|
| 371 | { |
---|
| 372 | $query = ' |
---|
[1609] | 373 | SELECT id,tn_ext,path |
---|
[633] | 374 | FROM '.IMAGES_TABLE.' |
---|
| 375 | WHERE id = '.$category['representative_picture_id'].' |
---|
| 376 | ;'; |
---|
[4325] | 377 | $row = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[1609] | 378 | $src = get_thumbnail_url($row); |
---|
[2286] | 379 | $url = get_root_url().'admin.php?page=picture_modify'; |
---|
[809] | 380 | $url.= '&image_id='.$category['representative_picture_id']; |
---|
[1131] | 381 | |
---|
[2223] | 382 | $tpl_representant['picture'] = |
---|
[809] | 383 | array( |
---|
| 384 | 'SRC' => $src, |
---|
| 385 | 'URL' => $url |
---|
| 386 | ); |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | // can the admin choose to set a new random representant ? |
---|
[2324] | 390 | $tpl_representant['ALLOW_SET_RANDOM'] = ($category['has_images']) ? true : false; |
---|
[809] | 391 | |
---|
| 392 | // can the admin delete the current representant ? |
---|
| 393 | if ( |
---|
[2324] | 394 | ($category['has_images'] |
---|
[809] | 395 | and $conf['allow_random_representative']) |
---|
| 396 | or |
---|
[2324] | 397 | (!$category['has_images'] |
---|
[809] | 398 | and !empty($category['representative_picture_id']))) |
---|
| 399 | { |
---|
[2223] | 400 | $tpl_representant['ALLOW_DELETE'] = true; |
---|
[809] | 401 | } |
---|
[2223] | 402 | $template->assign('representant', $tpl_representant); |
---|
[633] | 403 | } |
---|
| 404 | |
---|
[2223] | 405 | if ($category['is_virtual']) |
---|
[68] | 406 | { |
---|
[809] | 407 | // the category can be moved in any category but in itself, in any |
---|
| 408 | // sub-category |
---|
| 409 | $unmovables = get_subcat_ids(array($category['id'])); |
---|
[1131] | 410 | |
---|
[809] | 411 | $query = ' |
---|
| 412 | SELECT id,name,uppercats,global_rank |
---|
| 413 | FROM '.CATEGORIES_TABLE.' |
---|
| 414 | WHERE id NOT IN ('.implode(',', $unmovables).') |
---|
| 415 | ;'; |
---|
[1131] | 416 | |
---|
[809] | 417 | display_select_cat_wrapper( |
---|
| 418 | $query, |
---|
| 419 | empty($category['id_uppercat']) ? array() : array($category['id_uppercat']), |
---|
[2223] | 420 | 'move_cat_options' |
---|
[809] | 421 | ); |
---|
| 422 | } |
---|
| 423 | |
---|
[403] | 424 | |
---|
[2223] | 425 | // create virtual in parent and link |
---|
[1064] | 426 | $query = ' |
---|
| 427 | SELECT id,name,uppercats,global_rank |
---|
| 428 | FROM '.CATEGORIES_TABLE.' |
---|
| 429 | ;'; |
---|
| 430 | display_select_cat_wrapper( |
---|
| 431 | $query, |
---|
| 432 | array(), |
---|
[2223] | 433 | 'create_new_parent_options' |
---|
[1064] | 434 | ); |
---|
| 435 | |
---|
[2223] | 436 | |
---|
[1064] | 437 | // destination categories |
---|
| 438 | $query = ' |
---|
[1121] | 439 | SELECT id,name,uppercats,global_rank |
---|
[1064] | 440 | FROM '.CATEGORIES_TABLE.' |
---|
[1121] | 441 | WHERE id != '.$category['id'].' |
---|
[1064] | 442 | ;'; |
---|
[1121] | 443 | display_select_cat_wrapper( |
---|
| 444 | $query, |
---|
| 445 | array(), |
---|
[2223] | 446 | 'category_destination_options' |
---|
[1064] | 447 | ); |
---|
| 448 | |
---|
[1895] | 449 | // info by email to an access granted group of category informations |
---|
[2140] | 450 | if (isset($_POST['submitEmail']) and !empty($_POST['group'])) |
---|
[1895] | 451 | { |
---|
[1904] | 452 | set_make_full_url(); |
---|
| 453 | |
---|
[5335] | 454 | /* TODO: if $category['representative_picture_id'] |
---|
[1904] | 455 | is empty find child representative_picture_id */ |
---|
| 456 | if (!empty($category['representative_picture_id'])) |
---|
| 457 | { |
---|
| 458 | $query = ' |
---|
| 459 | SELECT id, file, path, tn_ext |
---|
| 460 | FROM '.IMAGES_TABLE.' |
---|
| 461 | WHERE id = '.$category['representative_picture_id'].' |
---|
[1895] | 462 | ;'; |
---|
[1064] | 463 | |
---|
[1904] | 464 | $result = pwg_query($query); |
---|
[4325] | 465 | if (pwg_db_num_rows($result) > 0) |
---|
[1904] | 466 | { |
---|
[4325] | 467 | $element = pwg_db_fetch_assoc($result); |
---|
[1904] | 468 | |
---|
| 469 | $img_url = '<a href="'. |
---|
| 470 | make_picture_url(array( |
---|
| 471 | 'image_id' => $element['id'], |
---|
| 472 | 'image_file' => $element['file'], |
---|
| 473 | 'category' => $category |
---|
| 474 | )) |
---|
[3185] | 475 | .'" class="thumblnk"><img src="'.get_thumbnail_url($element).'"></a>'; |
---|
[1904] | 476 | } |
---|
| 477 | } |
---|
[5335] | 478 | |
---|
[1904] | 479 | if (!isset($img_url)) |
---|
[1895] | 480 | { |
---|
[1904] | 481 | $img_url = ''; |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | // TODO Mettre un array pour traduction subjet |
---|
| 485 | pwg_mail_group( |
---|
| 486 | $_POST['group'], |
---|
| 487 | get_str_email_format(true), /* TODO add a checkbox in order to choose format*/ |
---|
[1916] | 488 | get_l10n_args('[%s] Come to visit the category %s', |
---|
| 489 | array($conf['gallery_title'], $category['name'])), |
---|
[1904] | 490 | 'cat_group_info', |
---|
| 491 | array |
---|
| 492 | ( |
---|
| 493 | 'IMG_URL' => $img_url, |
---|
[1916] | 494 | 'CAT_NAME' => $category['name'], |
---|
[1904] | 495 | 'LINK' => make_index_url( |
---|
[1895] | 496 | array( |
---|
| 497 | 'category' => array( |
---|
| 498 | 'id' => $category['id'], |
---|
| 499 | 'name' => $category['name'], |
---|
[1904] | 500 | 'permalink' => $category['permalink'] |
---|
| 501 | ))), |
---|
[1916] | 502 | 'CPL_CONTENT' => empty($_POST['mail_content']) |
---|
| 503 | ? '' : stripslashes($_POST['mail_content']) |
---|
[1904] | 504 | ), |
---|
| 505 | '' /* TODO Add listbox in order to choose Language selected */); |
---|
[1895] | 506 | |
---|
[1904] | 507 | unset_make_full_url(); |
---|
| 508 | |
---|
[1895] | 509 | $query = ' |
---|
| 510 | SELECT |
---|
| 511 | name |
---|
| 512 | FROM '.GROUPS_TABLE.' |
---|
| 513 | WHERE id = '.$_POST['group'].' |
---|
| 514 | ;'; |
---|
[4325] | 515 | list($group_name) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5335] | 516 | |
---|
[1895] | 517 | array_push( |
---|
| 518 | $page['infos'], |
---|
| 519 | sprintf( |
---|
[5207] | 520 | l10n('An information email was sent to group "%s"'), |
---|
[1895] | 521 | $group_name |
---|
| 522 | ) |
---|
| 523 | ); |
---|
| 524 | } |
---|
| 525 | |
---|
| 526 | if ('private' == $category['status']) |
---|
| 527 | { |
---|
| 528 | $query = ' |
---|
| 529 | SELECT |
---|
| 530 | group_id |
---|
| 531 | FROM '.GROUP_ACCESS_TABLE.' |
---|
| 532 | WHERE cat_id = '.$category['id'].' |
---|
| 533 | ;'; |
---|
| 534 | } |
---|
| 535 | else |
---|
| 536 | { |
---|
| 537 | $query = ' |
---|
| 538 | SELECT |
---|
| 539 | id AS group_id |
---|
| 540 | FROM '.GROUPS_TABLE.' |
---|
| 541 | ;'; |
---|
| 542 | } |
---|
| 543 | $group_ids = array_from_query($query, 'group_id'); |
---|
| 544 | |
---|
| 545 | if (count($group_ids) > 0) |
---|
| 546 | { |
---|
| 547 | $query = ' |
---|
| 548 | SELECT |
---|
| 549 | id, |
---|
| 550 | name |
---|
| 551 | FROM '.GROUPS_TABLE.' |
---|
| 552 | WHERE id IN ('.implode(',', $group_ids).') |
---|
| 553 | ORDER BY name ASC |
---|
| 554 | ;'; |
---|
[2223] | 555 | $template->assign('group_mail_options', |
---|
| 556 | simple_hash_from_query($query, 'id', 'name') |
---|
| 557 | ); |
---|
[1895] | 558 | } |
---|
| 559 | |
---|
[5933] | 560 | trigger_action('loc_end_cat_modify'); |
---|
| 561 | |
---|
[21] | 562 | //----------------------------------------------------------- sending html code |
---|
[403] | 563 | $template->assign_var_from_handle('ADMIN_CONTENT', 'categories'); |
---|
[5933] | 564 | ?> |
---|