Ignore:
Timestamp:
Mar 5, 2006, 11:44:32 PM (18 years ago)
Author:
plg
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/picture_modify.php

    r1064 r1065  
    122122{
    123123  $datas = array();
     124 
    124125  foreach ($_POST['cat_dissociated'] as $category_id)
    125126  {
    126     array_push($datas, array('image_id' => $_GET['image_id'],
    127                              'category_id' => $category_id));
    128   }
    129   mass_inserts(IMAGE_CATEGORY_TABLE, array('image_id', 'category_id'), $datas);
    130 
     127    array_push(
     128      $datas,
     129      array(
     130        'image_id' => $_GET['image_id'],
     131        'category_id' => $category_id
     132        )
     133      );
     134  }
     135 
     136  mass_inserts(
     137    IMAGE_CATEGORY_TABLE,
     138    array('image_id', 'category_id'),
     139    $datas
     140    );
     141
     142  check_links();
    131143  update_category($_POST['cat_dissociated']);
    132144}
     
    136148    and count($_POST['cat_associated']) > 0)
    137149{
     150  $associated_categories = $_POST['cat_associated'];
     151
     152  // If the same element is associated to a source and its destinations,
     153  // dissociating the element with the source implies dissociating the
     154  // element fwith the destination.
     155  $destinations_of = get_destinations($_POST['cat_associated']);
     156  foreach ($destinations_of as $source => $destinations)
     157  {
     158    $associated_categories = array_merge(
     159      $associated_categories,
     160      $destinations
     161      );
     162  }
     163 
    138164  $query = '
    139165DELETE FROM '.IMAGE_CATEGORY_TABLE.'
    140166  WHERE image_id = '.$_GET['image_id'].'
    141     AND category_id IN ('.implode(',',$_POST['cat_associated'] ).')
     167    AND category_id IN ('.implode(',', $associated_categories).')
     168    AND is_storage = \'false\'
    142169';
    143170  pwg_query($query);
     171
     172  check_links();
    144173  update_category($_POST['cat_associated']);
    145174}
Note: See TracChangeset for help on using the changeset viewer.