Changeset 25244


Ignore:
Timestamp:
Oct 30, 2013, 9:14:32 PM (7 years ago)
Author:
mistic100
Message:

mistakenly removed status check in previous commit + same thing for users

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_perm.php

    r25243 r25244  
    100100      }
    101101     
     102      $query = '
     103SELECT id
     104  FROM '.CATEGORIES_TABLE.'
     105  WHERE id IN ('.implode(',', $cat_ids).')
     106    AND status = \'private\'
     107;';
     108      $private_cats = array_from_query($query, 'id');
     109     
    102110      $inserts = array();
    103       foreach ($cat_ids as $cat_id)
     111      foreach ($private_cats as $cat_id)
    104112      {
    105113        foreach ($grant_groups as $group_id)
  • trunk/admin/include/functions.php

    r25019 r25244  
    22562256
    22572257  // make sure categories are private and select uppercats or subcats
    2258   $cat_ids = (isset($_POST['apply_on_sub'])) ? implode(',', get_subcat_ids($category_ids)).",".implode(',', get_uppercat_ids($category_ids)) : implode(',', get_uppercat_ids($category_ids));
    2259   $query = '
    2260 SELECT
    2261     id
     2258  $cat_ids = get_uppercat_ids($category_ids);
     2259  if (isset($_POST['apply_on_sub']))
     2260  {
     2261    $cat_ids = array_merge($cat_ids, get_subcat_ids($category_ids));
     2262  }
     2263
     2264  $query = '
     2265SELECT id
    22622266  FROM '.CATEGORIES_TABLE.'
    2263   WHERE id IN ('.$cat_ids.')
     2267  WHERE id IN ('.implode(',', $cat_ids).')
    22642268    AND status = \'private\'
    22652269;';
     
    22702274    return;
    22712275  }
    2272 
    2273   // We must not reinsert already existing lines in user_access table
    2274   $granteds = array();
     2276 
     2277  $inserts = array();
    22752278  foreach ($private_cats as $cat_id)
    22762279  {
    2277     $granteds[$cat_id] = array();
    2278   }
    2279 
    2280   $query = '
    2281 SELECT
    2282     user_id,
    2283     cat_id
    2284   FROM '.USER_ACCESS_TABLE.'
    2285   WHERE cat_id IN ('.implode(',', $private_cats).')
    2286     AND user_id IN ('.implode(',', $user_ids).')
    2287 ;';
    2288   $result = pwg_query($query);
    2289   while ($row = pwg_db_fetch_assoc($result))
    2290   {
    2291     $granteds[ $row['cat_id'] ][] = $row['user_id'];
    2292   }
    2293 
    2294   $inserts = array();
    2295 
    2296   foreach ($private_cats as $cat_id)
    2297   {
    2298     $grant_to_users = array_diff($user_ids, $granteds[$cat_id]);
    2299 
    2300     foreach ($grant_to_users as $user_id)
     2280    foreach ($user_ids as $user_id)
    23012281    {
    23022282      $inserts[] = array(
     
    23062286    }
    23072287  }
    2308 
    2309   if (count($inserts) > 0)
    2310   {
    2311     mass_inserts(USER_ACCESS_TABLE, array_keys($inserts[0]), $inserts);
    2312   }
     2288 
     2289  mass_inserts(
     2290    USER_ACCESS_TABLE,
     2291    array('user_id','cat_id'),
     2292    $inserts,
     2293    array('ignore'=>true)
     2294    );
    23132295}
    23142296
Note: See TracChangeset for help on using the changeset viewer.