Changeset 647 for trunk/admin
- Timestamp:
- Dec 18, 2004, 11:05:30 PM (19 years ago)
- Location:
- trunk/admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/cat_list.php
r642 r647 328 328 } 329 329 330 if (count($categories) > 0) 331 { 332 $next_rank = max(array_keys($categories)) + 1; 333 } 334 else 335 { 336 $next_rank = 1; 337 } 338 330 339 $template->assign_vars(array( 331 340 'CATEGORIES_NAV'=>$navigation, 332 'NEXT_RANK'=> max(array_keys($categories))+1,341 'NEXT_RANK'=>$next_rank, 333 342 'F_ACTION'=>$form_action, 334 343 … … 368 377 // +-----------------------------------------------------------------------+ 369 378 $ranks = array(); 370 foreach ($categories as $category) 371 { 372 $ranks[$category['id']] = $category['rank']; 373 } 374 375 $query = ' 379 380 if (count($categories) > 0) 381 { 382 foreach ($categories as $category) 383 { 384 $ranks[$category['id']] = $category['rank']; 385 } 386 387 $query = ' 376 388 SELECT id_uppercat, COUNT(*) AS nb_subcats 377 389 FROM '. CATEGORIES_TABLE.' … … 379 391 GROUP BY id_uppercat 380 392 ;'; 381 $result = pwg_query($query); 382 while ($row = mysql_fetch_array($result)) 383 { 384 $categories[$ranks[$row['id_uppercat']]]['nb_subcats'] = $row['nb_subcats']; 393 $result = pwg_query($query); 394 while ($row = mysql_fetch_array($result)) 395 { 396 $categories[$ranks[$row['id_uppercat']]]['nb_subcats'] 397 = $row['nb_subcats']; 398 } 385 399 } 386 400 -
trunk/admin/include/functions.php
r642 r647 392 392 } 393 393 394 // The check_favorites function deletes all the favorites of a user if he is395 // not allowed to see them (the category or an upper category is restricted396 // or invisible)397 function check_favorites( $user_id )398 {399 $query = 'SELECT status,forbidden_categories';400 $query.= ' FROM '.USERS_TABLE;401 $query.= ' WHERE id = '.$user_id;402 $query.= ';';403 $row = mysql_fetch_array( pwg_query( $query ) );404 $status = $row['status'];405 // retrieving all the restricted categories for this user406 if ( isset( $row['forbidden_categories'] ) )407 $restricted_cat = explode( ',', $row['forbidden_categories'] );408 else409 $restricted_cat = array();410 // retrieving all the favorites for this user and comparing their411 // categories to the restricted categories412 $query = 'SELECT image_id FROM '.FAVORITES_TABLE;413 $query.= ' WHERE user_id = '.$user_id;414 $query.= ';';415 $result = pwg_query ( $query );416 while ( $row = mysql_fetch_array( $result ) )417 {418 // for each picture, we have to check all the categories it belongs419 // to. Indeed if a picture belongs to category_1 and category_2 and that420 // category_2 is not restricted to the user, he can have the picture as421 // favorite.422 $query = 'SELECT DISTINCT(category_id) as category_id';423 $query.= ' FROM '.PREFIX_TABLE.'image_category';424 $query.= ' WHERE image_id = '.$row['image_id'];425 $query.= ';';426 $picture_result = pwg_query( $query );427 $picture_cat = array();428 while ( $picture_row = mysql_fetch_array( $picture_result ) )429 {430 array_push( $picture_cat, $picture_row['category_id'] );431 }432 if ( count( array_diff( $picture_cat, $restricted_cat ) ) == 0 )433 {434 $query = 'DELETE FROM '.FAVORITES_TABLE;435 $query.= ' WHERE image_id = '.$row['image_id'];436 $query.= ' AND user_id = '.$user_id;437 $query.= ';';438 pwg_query( $query );439 }440 }441 }442 443 394 /** 444 395 * updates calculated informations about a set of categories : date_last and … … 480 431 { 481 432 $query.= ' 482 WHERE id IN ('. implode(',', $ids).')';433 WHERE id IN ('.wordwrap(implode(', ', $ids), 80, "\n").')'; 483 434 } 484 435 } … … 503 454 MAX(date_available) AS date_last 504 455 FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id 505 WHERE category_id IN ('. implode(',', $cat_ids).')456 WHERE category_id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') 506 457 GROUP BY category_id 507 458 ;'; … … 543 494 ON id = category_id AND representative_picture_id = image_id 544 495 WHERE representative_picture_id IS NOT NULL 545 AND id IN ('. implode(',', $cat_ids).')496 AND id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') 546 497 AND category_id IS NULL 547 498 ;'; -
trunk/admin/infos_images.php
r642 r647 61 61 } 62 62 63 $associate = false;64 65 63 $query = 'SELECT id,file FROM '.IMAGES_TABLE; 66 64 $query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; … … 112 110 } 113 111 // add link to another category 114 if (isset($_POST['check-'.$row['id']]) and count($errors) == 0) 112 if (isset($_POST['check-'.$row['id']]) 113 and isset($_POST['associate']) 114 and $_POST['associate'] != '') 115 115 { 116 116 $query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE; … … 119 119 $query.= ';'; 120 120 pwg_query($query); 121 $associate = true; 122 } 123 } 124 if (isset($_POST['associate'])) update_category($_POST['associate']); 125 if ($associate) synchronize_all_users(); 121 } 122 } 123 if (isset($_POST['associate']) and $_POST['associate'] != '') 124 { 125 update_category(array($_POST['associate'])); 126 } 126 127 // +-----------------------------------------------------------------------+ 127 128 // | update general options | … … 337 338 338 339 // Virtualy associate a picture to a category 339 // 340 // We only show a List Of Values if the number of categories is less than 341 // $conf['max_LOV_categories'] 342 $query = 'SELECT COUNT(id) AS nb_total_categories'; 343 $query.= ' FROM '.CATEGORIES_TABLE.';'; 344 $row = mysql_fetch_array(pwg_query($query)); 345 if ($row['nb_total_categories'] < $conf['max_LOV_categories']) 346 { 347 /*$vtp->addSession($sub, 'associate_LOV'); 348 $page['plain_structure'] = get_plain_structure(true); 349 $structure = create_structure('', array()); 350 display_categories($structure, ' '); 351 $vtp->closeSession($sub, 'associate_LOV');*/ 352 } 353 // else, we only display a small text field, we suppose the administrator 354 // knows the id of its category 355 else 356 { 357 //$vtp->addSession($sub, 'associate_text'); 358 //$vtp->closeSession($sub, 'associate_text'); 359 } 340 $query = ' 341 SELECT id,name,uppercats,global_rank 342 FROM '.CATEGORIES_TABLE.' 343 ;'; 344 display_select_cat_wrapper($query, 345 array(), 346 'associate_option', 347 true); 360 348 } 361 349 //----------------------------------------------------------- sending html code
Note: See TracChangeset
for help on using the changeset viewer.