Changeset 2303
- Timestamp:
- Apr 19, 2008, 4:59:18 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_7/admin/include/functions.php
r2094 r2303 63 63 function delete_categories($ids) 64 64 { 65 global $counts;66 67 65 if (count($ids) == 0) 68 66 { … … 125 123 pwg_query($query); 126 124 127 if (isset($counts['del_categories']))128 {129 $counts['del_categories']+= count($ids);130 }131 125 trigger_action('delete_categories', $ids); 132 126 } … … 139 133 function delete_elements($ids) 140 134 { 141 global $counts;142 143 135 if (count($ids) == 0) 144 136 { … … 202 194 pwg_query($query); 203 195 204 if (isset($counts['del_elements']))205 {206 $counts['del_elements']+= count($ids);207 }208 196 trigger_action('delete_elements', $ids); 209 197 } … … 579 567 // depending on the MySQL version, we use the multi table update or N 580 568 // update queries 581 $query = 'SELECT VERSION() AS version;'; 582 list($mysql_version) = mysql_fetch_array(pwg_query($query)); 583 if (count($datas) < 10 or version_compare($mysql_version, '4.0.4') < 0) 569 if (count($datas) < 10 or version_compare(mysql_get_server_info(), '4.0.4') < 0) 584 570 { 585 571 // MySQL is prior to version 4.0.4, multi table update feature is not … … 1188 1174 function update_uppercats() 1189 1175 { 1190 $uppercat_ids = array(); 1191 1192 $query = ' 1193 SELECT id, id_uppercat 1176 $query = ' 1177 SELECT id, id_uppercat, uppercats 1194 1178 FROM '.CATEGORIES_TABLE.' 1195 1179 ;'; 1196 $result = pwg_query($query); 1197 while ($row = mysql_fetch_array($result)) 1198 { 1199 $uppercat_ids[$row['id']] = 1200 !empty($row['id_uppercat']) ? $row['id_uppercat'] : 'NULL'; 1201 } 1202 1203 // uppercats array associates a category id to the list of uppercats id. 1204 $uppercats = array(); 1205 1206 foreach (array_keys($uppercat_ids) as $id) 1207 { 1208 $uppercats[$id] = array(); 1180 $cat_map = hash_from_query($query, 'id'); 1181 1182 $datas = array(); 1183 foreach ($cat_map as $id => $cat) 1184 { 1185 $upper_list = array(); 1209 1186 1210 1187 $uppercat = $id; 1211 1212 while ($uppercat != 'NULL') 1213 { 1214 array_push($uppercats[$id], $uppercat); 1215 $uppercat = $uppercat_ids[$uppercat]; 1216 } 1217 } 1218 1219 $datas = array(); 1220 1221 foreach ($uppercats as $id => $list) 1222 { 1223 array_push( 1224 $datas, 1225 array( 1226 'id' => $id, 1227 'uppercats' => implode(',', array_reverse($list)) 1228 ) 1229 ); 1230 } 1231 1188 while ($uppercat) 1189 { 1190 array_push($upper_list, $uppercat); 1191 $uppercat = $cat_map[$uppercat]['id_uppercat']; 1192 } 1193 1194 $new_uppercats = implode(',', array_reverse($upper_list)); 1195 if ($new_uppercats != $cat['uppercats']) 1196 { 1197 array_push( 1198 $datas, 1199 array( 1200 'id' => $id, 1201 'uppercats' => $new_uppercats 1202 ) 1203 ); 1204 } 1205 } 1232 1206 $fields = array('primary' => array('id'), 'update' => array('uppercats')); 1233 1207 mass_updates(CATEGORIES_TABLE, $fields, $datas);
Note: See TracChangeset
for help on using the changeset viewer.