Changeset 29052


Ignore:
Timestamp:
Jul 17, 2014, 8:47:07 PM (10 years ago)
Author:
rvelices
Message:

more query2array on admin side

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r28587 r29052  
    4242  WHERE site_id = '.$id.'
    4343;';
    44   $category_ids = array_from_query($query, 'id');
     44  $category_ids = query2array($query, null, 'id');
    4545  delete_categories($category_ids);
    4646
     
    8484'.wordwrap(implode(', ', $ids), 80, "\n").')
    8585;';
    86   $element_ids = array_from_query($query, 'id');
     86  $element_ids = query2array($query, null, 'id');
    8787  delete_elements($element_ids);
    8888
     
    9696  WHERE category_id IN ('.implode(',', $ids).')
    9797;';
    98     $image_ids_linked = array_from_query($query, 'image_id');
     98    $image_ids_linked = query2array($query, null, 'image_id');
    9999
    100100    if (count($image_ids_linked) > 0)
     
    109109    AND category_id NOT IN ('.implode(',', $ids).')
    110110;';
    111         $image_ids_not_orphans = array_from_query($query, 'image_id');
     111        $image_ids_not_orphans = query2array($query, null, 'image_id');
    112112        $image_ids_to_delete = array_diff($image_ids_linked, $image_ids_not_orphans);
    113113      }
     
    261261    }
    262262  }
    263  
     263
    264264  $ids_str = wordwrap(implode(', ', $ids), 80, "\n");
    265265
     
    320320  WHERE representative_picture_id IN ('. $ids_str .')
    321321;';
    322   $category_ids = array_from_query($query, 'id');
     322  $category_ids = query2array($query, null, 'id');
    323323  if (count($category_ids) > 0)
    324324  {
     
    401401      $orphan_tag_ids[] = $tag['id'];
    402402    }
    403    
     403
    404404    delete_tags($orphan_tag_ids);
    405405  }
     
    419419  WHERE tag_id IS NULL
    420420;';
    421   return array_from_query($query);
     421  return query2array($query);
    422422}
    423423
     
    459459    AND i.id IS NULL
    460460;';
    461   $wrong_representant = array_from_query($query, 'id');
     461  $wrong_representant = query2array($query, null, 'id');
    462462
    463463  if (count($wrong_representant) > 0)
     
    484484    AND '.sprintf($where_cats, 'category_id').'
    485485;';
    486     $to_rand = array_from_query($query, 'id');
     486    $to_rand = query2array($query, null, 'id');
    487487    if (count($to_rand) > 0)
    488488    {
     
    506506;';
    507507  $result = pwg_query($query);
    508   $orphan_image_ids = array_from_query($query, 'image_id');
     508  $orphan_image_ids = query2array($query, null, 'image_id');
    509509
    510510  if (count($orphan_image_ids) > 0)
     
    701701    pwg_query($query);
    702702  }
    703  
     703
    704704  // make a category private => all its child categories become private
    705705  if ($value == 'private')
    706706  {
    707707    $subcats = get_subcat_ids($categories);
    708    
     708
    709709    $query = '
    710710UPDATE '.CATEGORIES_TABLE.'
     
    740740    // A6 permission removed to U4
    741741    // A7 no permission removed
    742     // 
     742    //
    743743    // 1) we must extract "top albums": A2, A5 and A6
    744744    // 2) for each top album, decide which album is the reference for permissions
     
    746746
    747747    // step 1, search top albums
    748     $all_categories = array();
    749748    $top_categories = array();
    750749    $parent_ids = array();
    751    
     750
    752751    $query = '
    753752SELECT
     
    760759  WHERE id IN ('.implode(',', $categories).')
    761760;';
    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);
    768762    usort($all_categories, 'global_rank_compare');
    769763
     
    771765    {
    772766      $is_top = true;
    773      
     767
    774768      if (!empty($cat['id_uppercat']))
    775769      {
     
    796790
    797791    // step 2, search the reference album for permissions
    798     // 
     792    //
    799793    // to find the reference of each top album, we will need the parent albums
    800794    $parent_cats = array();
     
    809803  WHERE id IN ('.implode(',', $parent_ids).')
    810804;';
    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');
    816806    }
    817807
     
    844834  WHERE cat_id = '.$ref_cat_id.'
    845835;';
    846         $ref_access = array_from_query($query, $field);
     836        $ref_access = query2array($query, null, $field);
    847837
    848838        if (count($ref_access) == 0)
     
    950940  WHERE dir IS NOT NULL
    951941;';
    952   $cat_dirs = simple_hash_from_query($query, 'id', 'dir');
     942  $cat_dirs = query2array($query, 'id', 'dir');
    953943
    954944  // caching galleries_url
     
    957947  FROM '.SITES_TABLE.'
    958948;';
    959   $galleries_url = simple_hash_from_query($query, 'id', 'galleries_url');
     949  $galleries_url = query2array($query, 'id', 'galleries_url');
    960950
    961951  // categories : id, site_id, uppercats
     
    967957'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
    968958;';
    969   $categories = array_from_query($query);
     959  $categories = query2array($query);
    970960
    971961  // filling $cat_fulldirs
     
    10271017          $extension = get_extension($node);
    10281018
    1029 //          if (in_array($extension, $conf['picture_ext']))
    10301019          if (isset($conf['flip_picture_ext'][$extension]))
    10311020          {
     
    10341023              $fs['thumbnails'][] = $path.'/'.$node;
    10351024            }
    1036             else if (basename($path) == 'pwg_representative')
     1025            elseif (basename($path) == 'pwg_representative')
    10371026            {
    10381027              $fs['representatives'][] = $path.'/'.$node;
     
    10431032            }
    10441033          }
    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]))
    10471035          {
    10481036            $fs['elements'][] = $path.'/'.$node;
    10491037          }
    10501038        }
    1051         else if (is_dir($path.'/'.$node) and $node != 'pwg_high' and $recursive)
     1039        elseif (is_dir($path.'/'.$node) and $node != 'pwg_high' and $recursive)
    10521040        {
    10531041          $subdirs[] = $node;
     
    10901078  FROM '.USERS_TABLE.'
    10911079;';
    1092   $base_users = array_from_query($query, 'id');
     1080  $base_users = query2array($query, null, 'id');
    10931081
    10941082  $query = '
     
    10961084  FROM '.USER_INFOS_TABLE.'
    10971085;';
    1098   $infos_users = array_from_query($query, 'user_id');
     1086  $infos_users = query2array($query, null, 'user_id');
    10991087
    11001088  // users present in $base_users and not in $infos_users must be added
     
    11251113;';
    11261114    $to_delete = array_diff(
    1127       array_from_query($query, 'user_id'),
     1115      query2array($query, null, 'user_id'),
    11281116      $base_users
    11291117      );
     
    11501138  FROM '.CATEGORIES_TABLE.'
    11511139;';
    1152   $cat_map = hash_from_query($query, 'id');
     1140  $cat_map = query2array($query, 'id');
    11531141
    11541142  $datas = array();
     
    11871175  WHERE storage_category_id IS NOT NULL
    11881176;';
    1189   $cat_ids = array_from_query($query, 'storage_category_id');
     1177  $cat_ids = query2aray($query, null, 'storage_category_id');
    11901178  $fulldirs = get_fulldirs($cat_ids);
    11911179
     
    14241412      WHERE cat_id = '.$insert['id_uppercat'].'
    14251413    ;';
    1426     $granted_grps =  array_from_query($query, 'group_id');
     1414    $granted_grps =  query2array($query, null, 'group_id');
    14271415    $inserts = array();
    14281416    foreach ($granted_grps as $granted_grp)
     
    14401428      WHERE cat_id = '.$insert['id_uppercat'].'
    14411429    ;';
    1442     $granted_users =  array_from_query($query, 'user_id');
     1430    $granted_users =  query2array($query, null, 'user_id');
    14431431    add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id']), $granted_users)));
    14441432  }
    1445   else if ('private' == $insert['status'])
     1433  elseif ('private' == $insert['status'])
    14461434  {
    14471435    add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id']))));
     
    15641552  WHERE name = \''.$tag_name.'\'
    15651553;';
    1566   if (count($existing_tags = array_from_query($query, 'id')) == 0)
     1554  if (count($existing_tags = query2array($query, null, 'id')) == 0)
    15671555  {
    15681556    // search existing by case insensitive name
     
    15721560  WHERE CONVERT(name, CHAR) = \''.$tag_name.'\'
    15731561;';
    1574     if (count($existing_tags = array_from_query($query, 'id')) == 0)
     1562    if (count($existing_tags = query2array($query, null, 'id')) == 0)
    15751563    {
    15761564      $url_name = trigger_change('render_tag_url', $tag_name);
     
    15811569  WHERE url_name = \''.$url_name.'\'
    15821570;';
    1583       if (count($existing_tags = array_from_query($query, 'id')) == 0)
     1571      if (count($existing_tags = query2array($query, null, 'id')) == 0)
    15841572      {
    15851573        mass_inserts(
     
    16921680;';
    16931681
    1694   $current_rank_of = simple_hash_from_query(
     1682  $current_rank_of = query2array(
    16951683    $query,
    16961684    'category_id',
     
    17981786  WHERE category_id IN ('.implode(',', $sources).')
    17991787;';
    1800   $images = array_from_query($query, 'image_id');
     1788  $images = query2array($query, null, 'image_id');
    18011789
    18021790  associate_images_to_categories($images, $destinations);
     
    19691957  WHERE name = \''.$tag_name.'\'
    19701958;';
    1971   $existing_tags = array_from_query($query, 'id');
     1959  $existing_tags = query2array($query, null, 'id');
    19721960
    19731961  if (count($existing_tags) == 0)
     
    24512439    AND status = \'private\'
    24522440;';
    2453   $private_cats = array_from_query($query, 'id');
     2441  $private_cats = query2array($query, null, 'id');
    24542442
    24552443  if (count($private_cats) == 0)
     
    24572445    return;
    24582446  }
    2459  
     2447
    24602448  $inserts = array();
    24612449  foreach ($private_cats as $cat_id)
     
    24692457    }
    24702458  }
    2471  
     2459
    24722460  mass_inserts(
    24732461    USER_ACCESS_TABLE,
     
    25002488;';
    25012489
    2502   return array_from_query($query, 'user_id');
     2490  return query2array($query, null, 'user_id');
    25032491}
    25042492
     
    27032691    }
    27042692    closedir($fh);
    2705    
     2693
    27062694    if (@rmdir($path))
    27072695    {
     
    27482736    'users' => USER_INFOS_TABLE
    27492737    );
    2750    
     2738
    27512739  if (!is_array($requested))
    27522740  {
     
    27612749    $requested = array_intersect($requested, array_keys($tables));
    27622750  }
    2763  
     2751
    27642752  $keys = array(
    27652753    '_hash' => md5(get_absolute_root_url()),
    27662754    );
    2767  
     2755
    27682756  foreach ($requested as $item)
    27692757  {
     
    27782766    list($keys[$item]) = pwg_db_fetch_row(pwg_query($query));
    27792767  }
    2780  
     2768
    27812769  return $keys;
    27822770}
Note: See TracChangeset for help on using the changeset viewer.