- Timestamp:
- Mar 5, 2006, 11:44:32 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/element_set_global.php
r916 r1065 137 137 $datas 138 138 ); 139 139 140 check_links(); 140 141 update_category(array($_POST['associate'])); 141 142 } … … 144 145 if ($_POST['dissociate'] != 0 and count($collection) > 0) 145 146 { 146 // physical links must not be broken, so we must first retrieve image_id147 // which create virtual links with the category to "dissociate from".147 // First, we must identify which elements in the collection are really 148 // virtually associated with the category 148 149 $query = ' 149 SELECT i d150 FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id = id150 SELECT image_id 151 FROM '.IMAGE_CATEGORY_TABLE.' 151 152 WHERE category_id = '.$_POST['dissociate'].' 152 AND category_id != storage_category_id 153 AND id IN ('.implode(',', $collection).') 154 ;'; 155 $dissociables = array_from_query($query, 'id'); 156 153 AND image_id IN ('.implode(',', $collection).') 154 AND is_storage = \'false\' 155 ;'; 156 $associated_images = array_from_query($query, 'image_id'); 157 158 // If the same element is associated to a source and its destinations, 159 // dissociating the element with the source implies dissociating the 160 // element fwith the destination. 161 $destinations_of = get_destinations($_POST['dissociate']); 162 163 $associated_categories = array_merge( 164 array($_POST['dissociate']), 165 $destinations_of[ $_POST['dissociate'] ] 166 ); 167 168 // Eventually, deletion of associations 157 169 $query = ' 158 DELETE FROM '.IMAGE_CATEGORY_TABLE.' 159 WHERE category_id = '.$_POST['dissociate'].' 160 AND image_id IN ('.implode(',', $dissociables).') 170 DELETE 171 FROM '.IMAGE_CATEGORY_TABLE.' 172 WHERE category_id IN ('.implode(',', $associated_categories).' 173 AND image_id IN ('.implode(',', $associated_images).') 161 174 '; 162 175 pwg_query($query); 163 176 164 update_category(array($_POST['dissociate'])); 177 // check source/destination links. If category C has for sources A and 178 // B, if picture 1 was associated to A and B, the previous code lines 179 // have deleted the link between C and 1, while it should be kept due to 180 // B. Who said "complicated"? 181 check_links(); 182 183 update_category($associated_categories); 165 184 } 166 185 -
trunk/admin/picture_modify.php
r1064 r1065 122 122 { 123 123 $datas = array(); 124 124 125 foreach ($_POST['cat_dissociated'] as $category_id) 125 126 { 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(); 131 143 update_category($_POST['cat_dissociated']); 132 144 } … … 136 148 and count($_POST['cat_associated']) > 0) 137 149 { 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 138 164 $query = ' 139 165 DELETE FROM '.IMAGE_CATEGORY_TABLE.' 140 166 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\' 142 169 '; 143 170 pwg_query($query); 171 172 check_links(); 144 173 update_category($_POST['cat_associated']); 145 174 }
Note: See TracChangeset
for help on using the changeset viewer.