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