Changeset 1060
- Timestamp:
- Mar 1, 2006, 1:48:29 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r1048 r1060 64 64 65 65 $prefix_length = strlen($conf['prefix_thumbnail']); 66 66 67 67 $thumbnails = array(); 68 68 if ($opendir = @opendir($dir.'/thumbnail')) … … 122 122 } 123 123 delete_categories($category_ids); 124 124 125 125 // destruction of the site 126 126 $query = ' … … 130 130 pwg_query($query); 131 131 } 132 132 133 133 134 134 // The function delete_categories deletes the categories identified by the … … 150 150 // sub-categories must be so 151 151 $ids = get_subcat_ids($ids); 152 152 153 153 // destruction of all the related elements 154 154 $query = ' … … 215 215 return; 216 216 } 217 217 218 218 // destruction of the comments on the image 219 219 $query = ' … … 255 255 ;'; 256 256 pwg_query($query); 257 257 258 258 // destruction of the image 259 259 $query = ' … … 280 280 { 281 281 global $conf; 282 282 283 283 // destruction of the access linked to the user 284 284 $query = ' … … 350 350 { 351 351 global $conf; 352 352 353 353 // retrieving all categories to update 354 354 $cat_ids = array(); 355 355 356 356 $query = ' 357 357 SELECT id … … 390 390 return false; 391 391 } 392 392 393 393 // calculate informations about categories retrieved 394 394 $query = ' … … 416 416 array_push($datas, array('id' => $id, 'nb_images' => 0)); 417 417 } 418 418 419 419 $fields = array('primary' => array('id'), 420 420 'update' => array('date_last', 'nb_images')); … … 468 468 $to_rand = array_diff($wrong_representant, $to_null); 469 469 } 470 470 471 471 if (count($to_null) > 0) 472 472 { … … 478 478 pwg_query($query); 479 479 } 480 480 481 481 // If the random representant is not allowed, we need to find 482 482 // categories with elements and with no representant. Those categories … … 497 497 ) 498 498 ); 499 499 500 500 if (count($to_rand) > 0) 501 501 { … … 553 553 { 554 554 $dirs = array(); 555 555 556 556 if (is_dir($path)) 557 557 { … … 611 611 $query.= ','; 612 612 } 613 613 614 614 if (!isset($insert[$dbfield]) or $insert[$dbfield] == '') 615 615 { … … 710 710 } 711 711 } 712 712 713 713 $temporary_tablename = $tablename.'_'.micro_seconds(); 714 714 715 715 $query = ' 716 716 CREATE TABLE '.$temporary_tablename.' … … 781 781 $uppercats_array[$row['id']] = $row['uppercats']; 782 782 } 783 783 784 784 $datas = array(); 785 785 foreach ($uppercats_array as $id => $uppercats) … … 886 886 return array(); 887 887 } 888 888 889 889 $uppercats = array(); 890 890 … … 947 947 $current_rank = 0; 948 948 $current_uppercat = ''; 949 949 950 950 $query = ' 951 951 SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat … … 982 982 return array(); 983 983 } 984 984 985 985 // caching directories of existing categories 986 986 $query = ' … … 1010 1010 // categories : id, site_id, uppercats 1011 1011 $categories = array(); 1012 1012 1013 1013 $query = ' 1014 1014 SELECT id, uppercats, site_id … … 1022 1022 array_push($categories, $row); 1023 1023 } 1024 1024 1025 1025 // filling $cat_fulldirs 1026 1026 $cat_fulldirs = array(); … … 1073 1073 { 1074 1074 $extension = get_extension($node); 1075 1075 1076 1076 // if (in_array($extension, $conf['picture_ext'])) 1077 1077 if (isset($conf['flip_picture_ext'][$extension])) … … 1114 1114 $fs['elements'] = array_merge($fs['elements'], 1115 1115 $tmp_fs['elements']); 1116 1116 1117 1117 $fs['thumbnails'] = array_merge($fs['thumbnails'], 1118 1118 $tmp_fs['thumbnails']); 1119 1119 1120 1120 $fs['representatives'] = array_merge($fs['representatives'], 1121 1121 $tmp_fs['representatives']); … … 1149 1149 { 1150 1150 global $conf; 1151 1151 1152 1152 $query = ' 1153 1153 SELECT '.$conf['user_fields']['id'].' AS id … … 1218 1218 $base_users 1219 1219 ); 1220 1220 1221 1221 if (count($to_delete) > 0) 1222 1222 { … … 1240 1240 { 1241 1241 $uppercat_ids = array(); 1242 1242 1243 1243 $query = ' 1244 1244 SELECT id, id_uppercat … … 1251 1251 !empty($row['id_uppercat']) ? $row['id_uppercat'] : 'NULL'; 1252 1252 } 1253 1253 1254 1254 // uppercats array associates a category id to the list of uppercats id. 1255 1255 $uppercats = array(); 1256 1256 1257 1257 foreach (array_keys($uppercat_ids) as $id) 1258 1258 { … … 1298 1298 $cat_ids = array_from_query($query, 'storage_category_id'); 1299 1299 $fulldirs = get_fulldirs($cat_ids); 1300 1300 1301 1301 foreach ($cat_ids as $cat_id) 1302 1302 { … … 1326 1326 } 1327 1327 $query .= ' GROUP BY element_id;'; 1328 1328 1329 1329 $result = pwg_query($query); 1330 1330 1331 1331 $datas = array(); 1332 1332 1333 1333 while ($row = mysql_fetch_array($result)) 1334 1334 { … … 1341 1341 ); 1342 1342 } 1343 1343 1344 1344 mass_updates( 1345 1345 IMAGES_TABLE, … … 1352 1352 1353 1353 $query=' 1354 UPDATE '.IMAGES_TABLE .' 1354 SELECT id FROM '.IMAGES_TABLE .' 1355 1355 LEFT JOIN '.RATE_TABLE.' ON id=element_id 1356 WHERE element_id IS NULL AND average_rate IS NOT NULL'; 1357 if ( $element_id != -1 ) 1358 { 1359 $query .= ' AND id=' . $element_id; 1360 } 1361 $to_update = array_from_query( $query, 'id'); 1362 1363 if ( !empty($to_update) ) 1364 { 1365 $query=' 1366 UPDATE '.IMAGES_TABLE .' 1356 1367 SET average_rate=NULL 1357 WHERE element_id IS NULL'; 1358 if ( $element_id != -1 ) 1359 { 1360 $query .= ' AND id=' . $element_id; 1361 } 1362 pwg_query($query); 1368 WHERE id IN (' . implode(',',$to_update) . ')'; 1369 pwg_query($query); 1370 } 1363 1371 } 1364 1372 … … 1383 1391 1384 1392 $categories = array(); 1385 1393 1386 1394 $query = ' 1387 1395 SELECT id, id_uppercat, status, uppercats … … 1399 1407 ); 1400 1408 } 1401 1409 1402 1410 // is the movement possible? The movement is impossible if you try to move 1403 1411 // a category in a sub-category or itself … … 1425 1433 } 1426 1434 } 1427 1435 1428 1436 $tables = 1429 1437 array( … … 1431 1439 GROUP_ACCESS_TABLE => 'group_id' 1432 1440 ); 1433 1441 1434 1442 $query = ' 1435 1443 UPDATE '.CATEGORIES_TABLE.' … … 1472 1480 { 1473 1481 $subcats = get_subcat_ids(array($cat_id)); 1474 1482 1475 1483 foreach ($tables as $table => $field) 1476 1484 { … … 1488 1496 ;'; 1489 1497 $parent_access = array_from_query($query, $field); 1490 1498 1491 1499 $to_delete = array_diff($parent_access, $category_access); 1492 1500 1493 1501 if (count($to_delete) > 0) 1494 1502 {
Note: See TracChangeset
for help on using the changeset viewer.