Index: trunk/admin/include/functions.php
===================================================================
--- trunk/admin/include/functions.php	(revision 29009)
+++ trunk/admin/include/functions.php	(revision 29052)
@@ -42,5 +42,5 @@
   WHERE site_id = '.$id.'
 ;';
-  $category_ids = array_from_query($query, 'id');
+  $category_ids = query2array($query, null, 'id');
   delete_categories($category_ids);
 
@@ -84,5 +84,5 @@
 '.wordwrap(implode(', ', $ids), 80, "\n").')
 ;';
-  $element_ids = array_from_query($query, 'id');
+  $element_ids = query2array($query, null, 'id');
   delete_elements($element_ids);
 
@@ -96,5 +96,5 @@
   WHERE category_id IN ('.implode(',', $ids).')
 ;';
-    $image_ids_linked = array_from_query($query, 'image_id');
+    $image_ids_linked = query2array($query, null, 'image_id');
 
     if (count($image_ids_linked) > 0)
@@ -109,5 +109,5 @@
     AND category_id NOT IN ('.implode(',', $ids).')
 ;';
-        $image_ids_not_orphans = array_from_query($query, 'image_id');
+        $image_ids_not_orphans = query2array($query, null, 'image_id');
         $image_ids_to_delete = array_diff($image_ids_linked, $image_ids_not_orphans);
       }
@@ -261,5 +261,5 @@
     }
   }
-  
+
   $ids_str = wordwrap(implode(', ', $ids), 80, "\n");
 
@@ -320,5 +320,5 @@
   WHERE representative_picture_id IN ('. $ids_str .')
 ;';
-  $category_ids = array_from_query($query, 'id');
+  $category_ids = query2array($query, null, 'id');
   if (count($category_ids) > 0)
   {
@@ -401,5 +401,5 @@
       $orphan_tag_ids[] = $tag['id'];
     }
-    
+
     delete_tags($orphan_tag_ids);
   }
@@ -419,5 +419,5 @@
   WHERE tag_id IS NULL
 ;';
-  return array_from_query($query);
+  return query2array($query);
 }
 
@@ -459,5 +459,5 @@
     AND i.id IS NULL
 ;';
-  $wrong_representant = array_from_query($query, 'id');
+  $wrong_representant = query2array($query, null, 'id');
 
   if (count($wrong_representant) > 0)
@@ -484,5 +484,5 @@
     AND '.sprintf($where_cats, 'category_id').'
 ;';
-    $to_rand = array_from_query($query, 'id');
+    $to_rand = query2array($query, null, 'id');
     if (count($to_rand) > 0)
     {
@@ -506,5 +506,5 @@
 ;';
   $result = pwg_query($query);
-  $orphan_image_ids = array_from_query($query, 'image_id');
+  $orphan_image_ids = query2array($query, null, 'image_id');
 
   if (count($orphan_image_ids) > 0)
@@ -701,10 +701,10 @@
     pwg_query($query);
   }
-  
+
   // make a category private => all its child categories become private
   if ($value == 'private')
   {
     $subcats = get_subcat_ids($categories);
-    
+
     $query = '
 UPDATE '.CATEGORIES_TABLE.'
@@ -740,5 +740,5 @@
     // A6 permission removed to U4
     // A7 no permission removed
-    // 
+    //
     // 1) we must extract "top albums": A2, A5 and A6
     // 2) for each top album, decide which album is the reference for permissions
@@ -746,8 +746,7 @@
 
     // step 1, search top albums
-    $all_categories = array();
     $top_categories = array();
     $parent_ids = array();
-    
+
     $query = '
 SELECT
@@ -760,10 +759,5 @@
   WHERE id IN ('.implode(',', $categories).')
 ;';
-    $result = pwg_query($query);
-    while ($row = pwg_db_fetch_assoc($result))
-    {
-      $all_categories[] = $row;
-    }
-    
+    $all_categories = query2array($query);
     usort($all_categories, 'global_rank_compare');
 
@@ -771,5 +765,5 @@
     {
       $is_top = true;
-      
+
       if (!empty($cat['id_uppercat']))
       {
@@ -796,5 +790,5 @@
 
     // step 2, search the reference album for permissions
-    // 
+    //
     // to find the reference of each top album, we will need the parent albums
     $parent_cats = array();
@@ -809,9 +803,5 @@
   WHERE id IN ('.implode(',', $parent_ids).')
 ;';
-      $result = pwg_query($query);
-      while ($row = pwg_db_fetch_assoc($result))
-      {
-        $parent_cats[$row['id']] = $row;
-      }
+      $parent_cats= query2array($query, 'id');
     }
 
@@ -844,5 +834,5 @@
   WHERE cat_id = '.$ref_cat_id.'
 ;';
-        $ref_access = array_from_query($query, $field);
+        $ref_access = query2array($query, null, $field);
 
         if (count($ref_access) == 0)
@@ -950,5 +940,5 @@
   WHERE dir IS NOT NULL
 ;';
-  $cat_dirs = simple_hash_from_query($query, 'id', 'dir');
+  $cat_dirs = query2array($query, 'id', 'dir');
 
   // caching galleries_url
@@ -957,5 +947,5 @@
   FROM '.SITES_TABLE.'
 ;';
-  $galleries_url = simple_hash_from_query($query, 'id', 'galleries_url');
+  $galleries_url = query2array($query, 'id', 'galleries_url');
 
   // categories : id, site_id, uppercats
@@ -967,5 +957,5 @@
 '.wordwrap(implode(', ', $cat_ids), 80, "\n").')
 ;';
-  $categories = array_from_query($query);
+  $categories = query2array($query);
 
   // filling $cat_fulldirs
@@ -1027,5 +1017,4 @@
           $extension = get_extension($node);
 
-//          if (in_array($extension, $conf['picture_ext']))
           if (isset($conf['flip_picture_ext'][$extension]))
           {
@@ -1034,5 +1023,5 @@
               $fs['thumbnails'][] = $path.'/'.$node;
             }
-            else if (basename($path) == 'pwg_representative')
+            elseif (basename($path) == 'pwg_representative')
             {
               $fs['representatives'][] = $path.'/'.$node;
@@ -1043,11 +1032,10 @@
             }
           }
-//          else if (in_array($extension, $conf['file_ext']))
-          else if (isset($conf['flip_file_ext'][$extension]))
+          elseif (isset($conf['flip_file_ext'][$extension]))
           {
             $fs['elements'][] = $path.'/'.$node;
           }
         }
-        else if (is_dir($path.'/'.$node) and $node != 'pwg_high' and $recursive)
+        elseif (is_dir($path.'/'.$node) and $node != 'pwg_high' and $recursive)
         {
           $subdirs[] = $node;
@@ -1090,5 +1078,5 @@
   FROM '.USERS_TABLE.'
 ;';
-  $base_users = array_from_query($query, 'id');
+  $base_users = query2array($query, null, 'id');
 
   $query = '
@@ -1096,5 +1084,5 @@
   FROM '.USER_INFOS_TABLE.'
 ;';
-  $infos_users = array_from_query($query, 'user_id');
+  $infos_users = query2array($query, null, 'user_id');
 
   // users present in $base_users and not in $infos_users must be added
@@ -1125,5 +1113,5 @@
 ;';
     $to_delete = array_diff(
-      array_from_query($query, 'user_id'),
+      query2array($query, null, 'user_id'),
       $base_users
       );
@@ -1150,5 +1138,5 @@
   FROM '.CATEGORIES_TABLE.'
 ;';
-  $cat_map = hash_from_query($query, 'id');
+  $cat_map = query2array($query, 'id');
 
   $datas = array();
@@ -1187,5 +1175,5 @@
   WHERE storage_category_id IS NOT NULL
 ;';
-  $cat_ids = array_from_query($query, 'storage_category_id');
+  $cat_ids = query2aray($query, null, 'storage_category_id');
   $fulldirs = get_fulldirs($cat_ids);
 
@@ -1424,5 +1412,5 @@
       WHERE cat_id = '.$insert['id_uppercat'].'
     ;';
-    $granted_grps =  array_from_query($query, 'group_id');
+    $granted_grps =  query2array($query, null, 'group_id');
     $inserts = array();
     foreach ($granted_grps as $granted_grp)
@@ -1440,8 +1428,8 @@
       WHERE cat_id = '.$insert['id_uppercat'].'
     ;';
-    $granted_users =  array_from_query($query, 'user_id');
+    $granted_users =  query2array($query, null, 'user_id');
     add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id']), $granted_users)));
   }
-  else if ('private' == $insert['status'])
+  elseif ('private' == $insert['status'])
   {
     add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id']))));
@@ -1564,5 +1552,5 @@
   WHERE name = \''.$tag_name.'\'
 ;';
-  if (count($existing_tags = array_from_query($query, 'id')) == 0)
+  if (count($existing_tags = query2array($query, null, 'id')) == 0)
   {
     // search existing by case insensitive name
@@ -1572,5 +1560,5 @@
   WHERE CONVERT(name, CHAR) = \''.$tag_name.'\'
 ;';
-    if (count($existing_tags = array_from_query($query, 'id')) == 0)
+    if (count($existing_tags = query2array($query, null, 'id')) == 0)
     {
       $url_name = trigger_change('render_tag_url', $tag_name);
@@ -1581,5 +1569,5 @@
   WHERE url_name = \''.$url_name.'\'
 ;';
-      if (count($existing_tags = array_from_query($query, 'id')) == 0)
+      if (count($existing_tags = query2array($query, null, 'id')) == 0)
       {
         mass_inserts(
@@ -1692,5 +1680,5 @@
 ;';
 
-  $current_rank_of = simple_hash_from_query(
+  $current_rank_of = query2array(
     $query,
     'category_id',
@@ -1798,5 +1786,5 @@
   WHERE category_id IN ('.implode(',', $sources).')
 ;';
-  $images = array_from_query($query, 'image_id');
+  $images = query2array($query, null, 'image_id');
 
   associate_images_to_categories($images, $destinations);
@@ -1969,5 +1957,5 @@
   WHERE name = \''.$tag_name.'\'
 ;';
-  $existing_tags = array_from_query($query, 'id');
+  $existing_tags = query2array($query, null, 'id');
 
   if (count($existing_tags) == 0)
@@ -2451,5 +2439,5 @@
     AND status = \'private\'
 ;';
-  $private_cats = array_from_query($query, 'id');
+  $private_cats = query2array($query, null, 'id');
 
   if (count($private_cats) == 0)
@@ -2457,5 +2445,5 @@
     return;
   }
-  
+
   $inserts = array();
   foreach ($private_cats as $cat_id)
@@ -2469,5 +2457,5 @@
     }
   }
-  
+
   mass_inserts(
     USER_ACCESS_TABLE,
@@ -2500,5 +2488,5 @@
 ;';
 
-  return array_from_query($query, 'user_id');
+  return query2array($query, null, 'user_id');
 }
 
@@ -2703,5 +2691,5 @@
     }
     closedir($fh);
-    
+
     if (@rmdir($path))
     {
@@ -2748,5 +2736,5 @@
     'users' => USER_INFOS_TABLE
     );
-    
+
   if (!is_array($requested))
   {
@@ -2761,9 +2749,9 @@
     $requested = array_intersect($requested, array_keys($tables));
   }
-  
+
   $keys = array(
     '_hash' => md5(get_absolute_root_url()),
     );
-  
+
   foreach ($requested as $item)
   {
@@ -2778,5 +2766,5 @@
     list($keys[$item]) = pwg_db_fetch_row(pwg_query($query));
   }
-  
+
   return $keys;
 }
