Changeset 12019


Ignore:
Timestamp:
Aug 31, 2011, 5:12:14 PM (9 years ago)
Author:
flop25
Message:

feature:2418
adding an option to apply permission of users to sub-albums
changing the name of vars $private_uppercats->$private_cats

Location:
trunk/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_perm.php

    r12017 r12019  
    9797  AND status = \'private\'
    9898;';
    99   $private_uppercats = array_from_query($query, 'id');
     99  $private_cats = array_from_query($query, 'id');
    100100
    101101  // We must not reinsert already existing lines in group_access table
    102102  $granteds = array();
    103   foreach ($private_uppercats as $cat_id)
     103  foreach ($private_cats as $cat_id)
    104104  {
    105105    $granteds[$cat_id] = array();
     
    109109SELECT group_id, cat_id
    110110  FROM '.GROUP_ACCESS_TABLE.'
    111   WHERE cat_id IN ('.implode(',', $private_uppercats).')
     111  WHERE cat_id IN ('.implode(',', $private_cats).')
    112112    AND group_id IN ('.implode(',', $_POST['grant_groups']).')
    113113;';
     
    120120  $inserts = array();
    121121 
    122   foreach ($private_uppercats as $cat_id)
     122  foreach ($private_cats as $cat_id)
    123123  {
    124124    $group_ids = array_diff($_POST['grant_groups'], $granteds[$cat_id]);
  • trunk/admin/include/functions.php

    r11853 r12019  
    21442144  }
    21452145 
    2146   // make sure categories are private and select uppercats
     2146  // make sure categories are private and select uppercats or subcats
     2147  $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));
    21472148  $query = '
    21482149SELECT
    21492150    id
    21502151  FROM '.CATEGORIES_TABLE.'
    2151   WHERE id IN ('.implode(',', get_uppercat_ids($category_ids)).')
     2152  WHERE id IN ('.$cat_ids.')
    21522153    AND status = \'private\'
    21532154;';
    2154   $private_uppercats = array_from_query($query, 'id');
    2155 
    2156   if (count($private_uppercats) == 0)
     2155  $private_cats = array_from_query($query, 'id');
     2156
     2157  if (count($private_cats) == 0)
    21572158  {
    21582159    return;
     
    21612162  // We must not reinsert already existing lines in user_access table
    21622163  $granteds = array();
    2163   foreach ($private_uppercats as $cat_id)
     2164  foreach ($private_cats as $cat_id)
    21642165  {
    21652166    $granteds[$cat_id] = array();
     
    21712172    cat_id
    21722173  FROM '.USER_ACCESS_TABLE.'
    2173   WHERE cat_id IN ('.implode(',', $private_uppercats).')
     2174  WHERE cat_id IN ('.implode(',', $private_cats).')
    21742175    AND user_id IN ('.implode(',', $user_ids).')
    21752176;';
     
    21822183  $inserts = array();
    21832184 
    2184   foreach ($private_uppercats as $cat_id)
     2185  foreach ($private_cats as $cat_id)
    21852186  {
    21862187    $grant_to_users = array_diff($user_ids, $granteds[$cat_id]);
  • trunk/admin/themes/default/template/cat_perm.tpl

    r12018 r12019  
    6060      {/foreach}
    6161    </ul>
     62    <label><input type="checkbox" name="apply_on_sub">{'Apply to sub-albums'|@translate}</label>
    6263    <input class="submit" type="submit" name="grant_users_submit" value="{'Grant selected users'|@translate}">
    6364  </fieldset>
Note: See TracChangeset for help on using the changeset viewer.