aboutsummaryrefslogtreecommitdiffstats
path: root/admin/picture_modify.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2006-03-05 22:44:32 +0000
committerplegall <plg@piwigo.org>2006-03-05 22:44:32 +0000
commit8615119a8088ba77819601f50393ad05b6ce0208 (patch)
treecf4cacb41aaccf7fe13fe04bdef8c370d72ea4f7 /admin/picture_modify.php
parentc08fa6f67ef5b149fdeb3bcc57045e629df8fff4 (diff)
bug fixed: table #categories_link was created with an hardcoded prefix
bug fixed: on source/destination links, if an image/category association is added to a source, destinations must be filled. If an image/category association is delete from a source, the same association must be deleted in the destinations. git-svn-id: http://piwigo.org/svn/trunk@1065 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/picture_modify.php')
-rw-r--r--admin/picture_modify.php37
1 files changed, 33 insertions, 4 deletions
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index a4d5d8ac5..0840414a6 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -121,13 +121,25 @@ if (isset($_POST['associate'])
and count($_POST['cat_dissociated']) > 0)
{
$datas = array();
+
foreach ($_POST['cat_dissociated'] as $category_id)
{
- array_push($datas, array('image_id' => $_GET['image_id'],
- 'category_id' => $category_id));
+ array_push(
+ $datas,
+ array(
+ 'image_id' => $_GET['image_id'],
+ 'category_id' => $category_id
+ )
+ );
}
- mass_inserts(IMAGE_CATEGORY_TABLE, array('image_id', 'category_id'), $datas);
+
+ mass_inserts(
+ IMAGE_CATEGORY_TABLE,
+ array('image_id', 'category_id'),
+ $datas
+ );
+ check_links();
update_category($_POST['cat_dissociated']);
}
// dissociate the element from categories (but not from its storage category)
@@ -135,12 +147,29 @@ if (isset($_POST['dissociate'])
and isset($_POST['cat_associated'])
and count($_POST['cat_associated']) > 0)
{
+ $associated_categories = $_POST['cat_associated'];
+
+ // If the same element is associated to a source and its destinations,
+ // dissociating the element with the source implies dissociating the
+ // element fwith the destination.
+ $destinations_of = get_destinations($_POST['cat_associated']);
+ foreach ($destinations_of as $source => $destinations)
+ {
+ $associated_categories = array_merge(
+ $associated_categories,
+ $destinations
+ );
+ }
+
$query = '
DELETE FROM '.IMAGE_CATEGORY_TABLE.'
WHERE image_id = '.$_GET['image_id'].'
- AND category_id IN ('.implode(',',$_POST['cat_associated'] ).')
+ AND category_id IN ('.implode(',', $associated_categories).')
+ AND is_storage = \'false\'
';
pwg_query($query);
+
+ check_links();
update_category($_POST['cat_associated']);
}
// elect the element to represent the given categories