Changeset 29052
- Timestamp:
- Jul 17, 2014, 8:47:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r28587 r29052 42 42 WHERE site_id = '.$id.' 43 43 ;'; 44 $category_ids = array_from_query($query, 'id');44 $category_ids = query2array($query, null, 'id'); 45 45 delete_categories($category_ids); 46 46 … … 84 84 '.wordwrap(implode(', ', $ids), 80, "\n").') 85 85 ;'; 86 $element_ids = array_from_query($query, 'id');86 $element_ids = query2array($query, null, 'id'); 87 87 delete_elements($element_ids); 88 88 … … 96 96 WHERE category_id IN ('.implode(',', $ids).') 97 97 ;'; 98 $image_ids_linked = array_from_query($query, 'image_id');98 $image_ids_linked = query2array($query, null, 'image_id'); 99 99 100 100 if (count($image_ids_linked) > 0) … … 109 109 AND category_id NOT IN ('.implode(',', $ids).') 110 110 ;'; 111 $image_ids_not_orphans = array_from_query($query, 'image_id');111 $image_ids_not_orphans = query2array($query, null, 'image_id'); 112 112 $image_ids_to_delete = array_diff($image_ids_linked, $image_ids_not_orphans); 113 113 } … … 261 261 } 262 262 } 263 263 264 264 $ids_str = wordwrap(implode(', ', $ids), 80, "\n"); 265 265 … … 320 320 WHERE representative_picture_id IN ('. $ids_str .') 321 321 ;'; 322 $category_ids = array_from_query($query, 'id');322 $category_ids = query2array($query, null, 'id'); 323 323 if (count($category_ids) > 0) 324 324 { … … 401 401 $orphan_tag_ids[] = $tag['id']; 402 402 } 403 403 404 404 delete_tags($orphan_tag_ids); 405 405 } … … 419 419 WHERE tag_id IS NULL 420 420 ;'; 421 return array_from_query($query);421 return query2array($query); 422 422 } 423 423 … … 459 459 AND i.id IS NULL 460 460 ;'; 461 $wrong_representant = array_from_query($query, 'id');461 $wrong_representant = query2array($query, null, 'id'); 462 462 463 463 if (count($wrong_representant) > 0) … … 484 484 AND '.sprintf($where_cats, 'category_id').' 485 485 ;'; 486 $to_rand = array_from_query($query, 'id');486 $to_rand = query2array($query, null, 'id'); 487 487 if (count($to_rand) > 0) 488 488 { … … 506 506 ;'; 507 507 $result = pwg_query($query); 508 $orphan_image_ids = array_from_query($query, 'image_id');508 $orphan_image_ids = query2array($query, null, 'image_id'); 509 509 510 510 if (count($orphan_image_ids) > 0) … … 701 701 pwg_query($query); 702 702 } 703 703 704 704 // make a category private => all its child categories become private 705 705 if ($value == 'private') 706 706 { 707 707 $subcats = get_subcat_ids($categories); 708 708 709 709 $query = ' 710 710 UPDATE '.CATEGORIES_TABLE.' … … 740 740 // A6 permission removed to U4 741 741 // A7 no permission removed 742 // 742 // 743 743 // 1) we must extract "top albums": A2, A5 and A6 744 744 // 2) for each top album, decide which album is the reference for permissions … … 746 746 747 747 // step 1, search top albums 748 $all_categories = array();749 748 $top_categories = array(); 750 749 $parent_ids = array(); 751 750 752 751 $query = ' 753 752 SELECT … … 760 759 WHERE id IN ('.implode(',', $categories).') 761 760 ;'; 762 $result = pwg_query($query); 763 while ($row = pwg_db_fetch_assoc($result)) 764 { 765 $all_categories[] = $row; 766 } 767 761 $all_categories = query2array($query); 768 762 usort($all_categories, 'global_rank_compare'); 769 763 … … 771 765 { 772 766 $is_top = true; 773 767 774 768 if (!empty($cat['id_uppercat'])) 775 769 { … … 796 790 797 791 // step 2, search the reference album for permissions 798 // 792 // 799 793 // to find the reference of each top album, we will need the parent albums 800 794 $parent_cats = array(); … … 809 803 WHERE id IN ('.implode(',', $parent_ids).') 810 804 ;'; 811 $result = pwg_query($query); 812 while ($row = pwg_db_fetch_assoc($result)) 813 { 814 $parent_cats[$row['id']] = $row; 815 } 805 $parent_cats= query2array($query, 'id'); 816 806 } 817 807 … … 844 834 WHERE cat_id = '.$ref_cat_id.' 845 835 ;'; 846 $ref_access = array_from_query($query, $field);836 $ref_access = query2array($query, null, $field); 847 837 848 838 if (count($ref_access) == 0) … … 950 940 WHERE dir IS NOT NULL 951 941 ;'; 952 $cat_dirs = simple_hash_from_query($query, 'id', 'dir');942 $cat_dirs = query2array($query, 'id', 'dir'); 953 943 954 944 // caching galleries_url … … 957 947 FROM '.SITES_TABLE.' 958 948 ;'; 959 $galleries_url = simple_hash_from_query($query, 'id', 'galleries_url');949 $galleries_url = query2array($query, 'id', 'galleries_url'); 960 950 961 951 // categories : id, site_id, uppercats … … 967 957 '.wordwrap(implode(', ', $cat_ids), 80, "\n").') 968 958 ;'; 969 $categories = array_from_query($query);959 $categories = query2array($query); 970 960 971 961 // filling $cat_fulldirs … … 1027 1017 $extension = get_extension($node); 1028 1018 1029 // if (in_array($extension, $conf['picture_ext']))1030 1019 if (isset($conf['flip_picture_ext'][$extension])) 1031 1020 { … … 1034 1023 $fs['thumbnails'][] = $path.'/'.$node; 1035 1024 } 1036 else 1025 elseif (basename($path) == 'pwg_representative') 1037 1026 { 1038 1027 $fs['representatives'][] = $path.'/'.$node; … … 1043 1032 } 1044 1033 } 1045 // else if (in_array($extension, $conf['file_ext'])) 1046 else if (isset($conf['flip_file_ext'][$extension])) 1034 elseif (isset($conf['flip_file_ext'][$extension])) 1047 1035 { 1048 1036 $fs['elements'][] = $path.'/'.$node; 1049 1037 } 1050 1038 } 1051 else 1039 elseif (is_dir($path.'/'.$node) and $node != 'pwg_high' and $recursive) 1052 1040 { 1053 1041 $subdirs[] = $node; … … 1090 1078 FROM '.USERS_TABLE.' 1091 1079 ;'; 1092 $base_users = array_from_query($query, 'id');1080 $base_users = query2array($query, null, 'id'); 1093 1081 1094 1082 $query = ' … … 1096 1084 FROM '.USER_INFOS_TABLE.' 1097 1085 ;'; 1098 $infos_users = array_from_query($query, 'user_id');1086 $infos_users = query2array($query, null, 'user_id'); 1099 1087 1100 1088 // users present in $base_users and not in $infos_users must be added … … 1125 1113 ;'; 1126 1114 $to_delete = array_diff( 1127 array_from_query($query, 'user_id'),1115 query2array($query, null, 'user_id'), 1128 1116 $base_users 1129 1117 ); … … 1150 1138 FROM '.CATEGORIES_TABLE.' 1151 1139 ;'; 1152 $cat_map = hash_from_query($query, 'id');1140 $cat_map = query2array($query, 'id'); 1153 1141 1154 1142 $datas = array(); … … 1187 1175 WHERE storage_category_id IS NOT NULL 1188 1176 ;'; 1189 $cat_ids = array_from_query($query, 'storage_category_id');1177 $cat_ids = query2aray($query, null, 'storage_category_id'); 1190 1178 $fulldirs = get_fulldirs($cat_ids); 1191 1179 … … 1424 1412 WHERE cat_id = '.$insert['id_uppercat'].' 1425 1413 ;'; 1426 $granted_grps = array_from_query($query, 'group_id');1414 $granted_grps = query2array($query, null, 'group_id'); 1427 1415 $inserts = array(); 1428 1416 foreach ($granted_grps as $granted_grp) … … 1440 1428 WHERE cat_id = '.$insert['id_uppercat'].' 1441 1429 ;'; 1442 $granted_users = array_from_query($query, 'user_id');1430 $granted_users = query2array($query, null, 'user_id'); 1443 1431 add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id']), $granted_users))); 1444 1432 } 1445 else 1433 elseif ('private' == $insert['status']) 1446 1434 { 1447 1435 add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id'])))); … … 1564 1552 WHERE name = \''.$tag_name.'\' 1565 1553 ;'; 1566 if (count($existing_tags = array_from_query($query, 'id')) == 0)1554 if (count($existing_tags = query2array($query, null, 'id')) == 0) 1567 1555 { 1568 1556 // search existing by case insensitive name … … 1572 1560 WHERE CONVERT(name, CHAR) = \''.$tag_name.'\' 1573 1561 ;'; 1574 if (count($existing_tags = array_from_query($query, 'id')) == 0)1562 if (count($existing_tags = query2array($query, null, 'id')) == 0) 1575 1563 { 1576 1564 $url_name = trigger_change('render_tag_url', $tag_name); … … 1581 1569 WHERE url_name = \''.$url_name.'\' 1582 1570 ;'; 1583 if (count($existing_tags = array_from_query($query, 'id')) == 0)1571 if (count($existing_tags = query2array($query, null, 'id')) == 0) 1584 1572 { 1585 1573 mass_inserts( … … 1692 1680 ;'; 1693 1681 1694 $current_rank_of = simple_hash_from_query(1682 $current_rank_of = query2array( 1695 1683 $query, 1696 1684 'category_id', … … 1798 1786 WHERE category_id IN ('.implode(',', $sources).') 1799 1787 ;'; 1800 $images = array_from_query($query, 'image_id');1788 $images = query2array($query, null, 'image_id'); 1801 1789 1802 1790 associate_images_to_categories($images, $destinations); … … 1969 1957 WHERE name = \''.$tag_name.'\' 1970 1958 ;'; 1971 $existing_tags = array_from_query($query, 'id');1959 $existing_tags = query2array($query, null, 'id'); 1972 1960 1973 1961 if (count($existing_tags) == 0) … … 2451 2439 AND status = \'private\' 2452 2440 ;'; 2453 $private_cats = array_from_query($query, 'id');2441 $private_cats = query2array($query, null, 'id'); 2454 2442 2455 2443 if (count($private_cats) == 0) … … 2457 2445 return; 2458 2446 } 2459 2447 2460 2448 $inserts = array(); 2461 2449 foreach ($private_cats as $cat_id) … … 2469 2457 } 2470 2458 } 2471 2459 2472 2460 mass_inserts( 2473 2461 USER_ACCESS_TABLE, … … 2500 2488 ;'; 2501 2489 2502 return array_from_query($query, 'user_id');2490 return query2array($query, null, 'user_id'); 2503 2491 } 2504 2492 … … 2703 2691 } 2704 2692 closedir($fh); 2705 2693 2706 2694 if (@rmdir($path)) 2707 2695 { … … 2748 2736 'users' => USER_INFOS_TABLE 2749 2737 ); 2750 2738 2751 2739 if (!is_array($requested)) 2752 2740 { … … 2761 2749 $requested = array_intersect($requested, array_keys($tables)); 2762 2750 } 2763 2751 2764 2752 $keys = array( 2765 2753 '_hash' => md5(get_absolute_root_url()), 2766 2754 ); 2767 2755 2768 2756 foreach ($requested as $item) 2769 2757 { … … 2778 2766 list($keys[$item]) = pwg_db_fetch_row(pwg_query($query)); 2779 2767 } 2780 2768 2781 2769 return $keys; 2782 2770 }
Note: See TracChangeset
for help on using the changeset viewer.