Changeset 832


Ignore:
Timestamp:
Aug 18, 2005, 11:40:59 PM (19 years ago)
Author:
plg
Message:
  • bug 133 fixed : (report from branch 1.4) Deleting user favorites is too restrictive. Instead of deleting a favorite because it belongs to at least one forbidden category, a favorite is deletedif it belongs to no authorized category (which was the expected behaviour).
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/ChangeLog

    r831 r832  
    112005-08-18 Pierrick LE GALL
    22
    3         * bug 133 fixed : "Nb of images incorectly rendered in "tool tip"
     3        * bug 133 fixed : (report from branch 1.4) Deleting user favorites
     4        is too restrictive. Instead of deleting a favorite because it
     5        belongs to at least one forbidden category, a favorite is deleted
     6        if it belongs to no authorized category (which was the expected
     7        behaviour).
     8
     92005-08-18 Pierrick LE GALL
     10
     11        * bug 134 fixed : "Nb of images incorectly rendered in "tool tip"
    412        near category in category menu". Correction reported (and
    513        improved) from branch 1.4
  • trunk/include/functions_user.inc.php

    r817 r832  
    99// | last update   : $Date$
    1010// | last modifier : $Author$
     11// | revision      : $Revision$
    1112// | revision      : $Revision$
    1213// +-----------------------------------------------------------------------+
     
    236237    return;
    237238  }
    238  
    239   $query = '
    240 SELECT f.image_id
     239
     240  // retrieving images allowed : belonging to at least one authorized
     241  // category
     242  $query = '
     243SELECT DISTINCT f.image_id
    241244  FROM '.FAVORITES_TABLE.' AS f INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
    242245    ON f.image_id = ic.image_id
    243246  WHERE f.user_id = '.$user['id'].'
    244     AND ic.category_id IN ('.$user['forbidden_categories'].')
     247    AND ic.category_id NOT IN ('.$user['forbidden_categories'].')
    245248;';
    246249  $result = pwg_query($query);
    247   $elements = array();
     250  $authorizeds = array();
    248251  while ($row = mysql_fetch_array($result))
    249252  {
    250     array_push($elements, $row['image_id']);
    251   }
    252 
    253   if (count($elements) > 0)
     253    array_push($authorizeds, $row['image_id']);
     254  }
     255
     256  $query = '
     257SELECT image_id
     258  FROM '.FAVORITES_TABLE.'
     259  WHERE user_id = '.$user['id'].'
     260;';
     261  $result = pwg_query($query);
     262  $favorites = array();
     263  while ($row = mysql_fetch_array($result))
     264  {
     265    array_push($favorites, $row['image_id']);
     266  }
     267
     268  $to_deletes = array_diff($favorites, $authorizeds);
     269
     270  if (count($to_deletes) > 0)
    254271  {
    255272    $query = '
    256273DELETE FROM '.FAVORITES_TABLE.'
    257   WHERE image_id IN ('.implode(',', $elements).')
     274  WHERE image_id IN ('.implode(',', $to_deletes).')
    258275    AND user_id = '.$user['id'].'
    259276;';
Note: See TracChangeset for help on using the changeset viewer.