mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-05-07 08:35:53 +03:00
- 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). git-svn-id: http://piwigo.org/svn/trunk@832 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
5834354491
commit
c8bf225cd4
2 changed files with 33 additions and 8 deletions
|
@ -1,6 +1,14 @@
|
||||||
2005-08-18 Pierrick LE GALL
|
2005-08-18 Pierrick LE GALL
|
||||||
|
|
||||||
* bug 133 fixed : "Nb of images incorectly rendered in "tool tip"
|
* 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 deleted
|
||||||
|
if it belongs to no authorized category (which was the expected
|
||||||
|
behaviour).
|
||||||
|
|
||||||
|
2005-08-18 Pierrick LE GALL
|
||||||
|
|
||||||
|
* bug 134 fixed : "Nb of images incorectly rendered in "tool tip"
|
||||||
near category in category menu". Correction reported (and
|
near category in category menu". Correction reported (and
|
||||||
improved) from branch 1.4
|
improved) from branch 1.4
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// | last update : $Date$
|
// | last update : $Date$
|
||||||
// | last modifier : $Author$
|
// | last modifier : $Author$
|
||||||
// | revision : $Revision$
|
// | revision : $Revision$
|
||||||
|
// | revision : $Revision$
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | This program is free software; you can redistribute it and/or modify |
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
// | it under the terms of the GNU General Public License as published by |
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
@ -235,26 +236,42 @@ function check_user_favorites()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// retrieving images allowed : belonging to at least one authorized
|
||||||
|
// category
|
||||||
$query = '
|
$query = '
|
||||||
SELECT f.image_id
|
SELECT DISTINCT f.image_id
|
||||||
FROM '.FAVORITES_TABLE.' AS f INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
|
FROM '.FAVORITES_TABLE.' AS f INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
|
||||||
ON f.image_id = ic.image_id
|
ON f.image_id = ic.image_id
|
||||||
WHERE f.user_id = '.$user['id'].'
|
WHERE f.user_id = '.$user['id'].'
|
||||||
AND ic.category_id IN ('.$user['forbidden_categories'].')
|
AND ic.category_id NOT IN ('.$user['forbidden_categories'].')
|
||||||
;';
|
;';
|
||||||
$result = pwg_query($query);
|
$result = pwg_query($query);
|
||||||
$elements = array();
|
$authorizeds = array();
|
||||||
while ($row = mysql_fetch_array($result))
|
while ($row = mysql_fetch_array($result))
|
||||||
{
|
{
|
||||||
array_push($elements, $row['image_id']);
|
array_push($authorizeds, $row['image_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($elements) > 0)
|
$query = '
|
||||||
|
SELECT image_id
|
||||||
|
FROM '.FAVORITES_TABLE.'
|
||||||
|
WHERE user_id = '.$user['id'].'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
$favorites = array();
|
||||||
|
while ($row = mysql_fetch_array($result))
|
||||||
|
{
|
||||||
|
array_push($favorites, $row['image_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$to_deletes = array_diff($favorites, $authorizeds);
|
||||||
|
|
||||||
|
if (count($to_deletes) > 0)
|
||||||
{
|
{
|
||||||
$query = '
|
$query = '
|
||||||
DELETE FROM '.FAVORITES_TABLE.'
|
DELETE FROM '.FAVORITES_TABLE.'
|
||||||
WHERE image_id IN ('.implode(',', $elements).')
|
WHERE image_id IN ('.implode(',', $to_deletes).')
|
||||||
AND user_id = '.$user['id'].'
|
AND user_id = '.$user['id'].'
|
||||||
;';
|
;';
|
||||||
pwg_query($query);
|
pwg_query($query);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue