Changeset 647 for trunk/admin/include


Ignore:
Timestamp:
Dec 18, 2004, 11:05:30 PM (20 years ago)
Author:
plg
Message:
  • bug fixed : in admin/cat_list, next_rank cant' be calculted and query to count sub-categories per sub-categories became false if no sub-categories
  • virtual association come back in admin/infos_images (not only in admin/picture_modify)
  • check_favorites function in admin section becomes check_user_favorites in public section : favorites are checked when user tries to display his favorites. Function was optimized.
  • in function update_category, wrap of long queries due to many categories to update at the same time
  • typo fixed in description of paginate_pages_around configuration parameter
  • bug fixed in new navigation bar : no separation pipe was displayed between next and last when the page displayed was the last
  • sessions.expiration changed of type from int to datetime (a lot easier to read)
  • sessions.ip removed : IP address is no longer used to verify session
  • typo fixed in language/en_UK.iso-8859-1/admin.lang.php on editcat_lock_info language item
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r642 r647  
    392392}
    393393
    394 // The check_favorites function deletes all the favorites of a user if he is
    395 // not allowed to see them (the category or an upper category is restricted
    396 // 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 user
    406   if ( isset( $row['forbidden_categories'] ) )
    407     $restricted_cat = explode( ',', $row['forbidden_categories'] );
    408   else
    409     $restricted_cat = array();
    410   // retrieving all the favorites for this user and comparing their
    411   // categories to the restricted categories
    412   $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 belongs
    419     // to. Indeed if a picture belongs to category_1 and category_2 and that
    420     // category_2 is not restricted to the user, he can have the picture as
    421     // 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 
    443394/**
    444395 * updates calculated informations about a set of categories : date_last and
     
    480431    {
    481432      $query.= '
    482   WHERE id IN ('.implode(',', $ids).')';
     433  WHERE id IN ('.wordwrap(implode(', ', $ids), 80, "\n").')';
    483434    }
    484435  }
     
    503454       MAX(date_available) AS date_last
    504455  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").')
    506457  GROUP BY category_id
    507458;';
     
    543494    ON id = category_id AND representative_picture_id = image_id
    544495  WHERE representative_picture_id IS NOT NULL
    545     AND id IN ('.implode(',', $cat_ids).')
     496    AND id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").')
    546497    AND category_id IS NULL
    547498;';
Note: See TracChangeset for help on using the changeset viewer.