Changeset 2304 for trunk/admin/include/functions.php
- Timestamp:
- Apr 19, 2008, 5:00:11 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r2299 r2304 60 60 function delete_categories($ids) 61 61 { 62 global $counts;63 64 62 if (count($ids) == 0) 65 63 { … … 122 120 pwg_query($query); 123 121 124 if (isset($counts['del_categories']))125 {126 $counts['del_categories']+= count($ids);127 }128 122 trigger_action('delete_categories', $ids); 129 123 } … … 136 130 function delete_elements($ids) 137 131 { 138 global $counts;139 140 132 if (count($ids) == 0) 141 133 { … … 199 191 pwg_query($query); 200 192 201 if (isset($counts['del_elements']))202 {203 $counts['del_elements']+= count($ids);204 }205 193 trigger_action('delete_elements', $ids); 206 194 } … … 437 425 } 438 426 439 function date_convert_back( $date )440 {441 // date arrives at this format : YYYY-MM-DD442 // It must be transformed in DD/MM/YYYY443 if ( $date != '' )444 {445 list($year,$month,$day) = explode( '-', $date );446 return $day.'/'.$month.'/'.$year;447 }448 else449 {450 return '';451 }452 }453 454 427 /** 455 428 * returns an array containing sub-directories which can be a category, … … 576 549 // depending on the MySQL version, we use the multi table update or N 577 550 // update queries 578 $query = 'SELECT VERSION() AS version;'; 579 list($mysql_version) = mysql_fetch_array(pwg_query($query)); 580 if (count($datas) < 10 or version_compare($mysql_version, '4.0.4') < 0) 551 if (count($datas) < 10 or version_compare(mysql_get_server_info(), '4.0.4') < 0) 581 552 { 582 553 // MySQL is prior to version 4.0.4, multi table update feature is not … … 1185 1156 function update_uppercats() 1186 1157 { 1187 $uppercat_ids = array(); 1188 1189 $query = ' 1190 SELECT id, id_uppercat 1158 $query = ' 1159 SELECT id, id_uppercat, uppercats 1191 1160 FROM '.CATEGORIES_TABLE.' 1192 1161 ;'; 1193 $result = pwg_query($query); 1194 while ($row = mysql_fetch_array($result)) 1195 { 1196 $uppercat_ids[$row['id']] = 1197 !empty($row['id_uppercat']) ? $row['id_uppercat'] : 'NULL'; 1198 } 1199 1200 // uppercats array associates a category id to the list of uppercats id. 1201 $uppercats = array(); 1202 1203 foreach (array_keys($uppercat_ids) as $id) 1204 { 1205 $uppercats[$id] = array(); 1162 $cat_map = hash_from_query($query, 'id'); 1163 1164 $datas = array(); 1165 foreach ($cat_map as $id => $cat) 1166 { 1167 $upper_list = array(); 1206 1168 1207 1169 $uppercat = $id; 1208 1209 while ($uppercat != 'NULL') 1210 { 1211 array_push($uppercats[$id], $uppercat); 1212 $uppercat = $uppercat_ids[$uppercat]; 1213 } 1214 } 1215 1216 $datas = array(); 1217 1218 foreach ($uppercats as $id => $list) 1219 { 1220 array_push( 1221 $datas, 1222 array( 1223 'id' => $id, 1224 'uppercats' => implode(',', array_reverse($list)) 1225 ) 1226 ); 1227 } 1228 1170 while ($uppercat) 1171 { 1172 array_push($upper_list, $uppercat); 1173 $uppercat = $cat_map[$uppercat]['id_uppercat']; 1174 } 1175 1176 $new_uppercats = implode(',', array_reverse($upper_list)); 1177 if ($new_uppercats != $cat['uppercats']) 1178 { 1179 array_push( 1180 $datas, 1181 array( 1182 'id' => $id, 1183 'uppercats' => $new_uppercats 1184 ) 1185 ); 1186 } 1187 } 1229 1188 $fields = array('primary' => array('id'), 'update' => array('uppercats')); 1230 1189 mass_updates(CATEGORIES_TABLE, $fields, $datas);
Note: See TracChangeset
for help on using the changeset viewer.