Changeset 24986


Ignore:
Timestamp:
Oct 18, 2013, 10:56:05 PM (7 years ago)
Author:
plg
Message:

bug 2977 fixed: when moving an album, whatever the previous status
private/public we must remove irrelevant permissions (a public album
can have hidden permission, ie list of groups/users permitted). I've
also found a bug in the algorithm that selects users/groups to delete
(reverse parameters in array_diff).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/admin/include/functions.php

    r21566 r24986  
    11401140    foreach ($categories as $cat_id => $category)
    11411141    {
    1142       switch ($category['status'])
     1142      if ('public' == $category['status'])
    11431143      {
    1144         case 'public' :
    1145         {
    1146           set_cat_status(array($cat_id), 'private');
    1147           break;
    1148         }
    1149         case 'private' :
    1150         {
    1151           $subcats = get_subcat_ids(array($cat_id));
    1152 
    1153           foreach ($tables as $table => $field)
    1154           {
    1155             $query = '
     1144        set_cat_status(array($cat_id), 'private');
     1145      }
     1146     
     1147      $subcats = get_subcat_ids(array($cat_id));
     1148
     1149      foreach ($tables as $table => $field)
     1150      {
     1151        $query = '
    11561152SELECT '.$field.'
    11571153  FROM '.$table.'
    11581154  WHERE cat_id = '.$cat_id.'
    11591155;';
    1160             $category_access = array_from_query($query, $field);
    1161 
    1162             $query = '
     1156        $category_access = array_from_query($query, $field);
     1157
     1158        $query = '
    11631159SELECT '.$field.'
    11641160  FROM '.$table.'
    11651161  WHERE cat_id = '.$new_parent.'
    11661162;';
    1167             $parent_access = array_from_query($query, $field);
    1168 
    1169             $to_delete = array_diff($parent_access, $category_access);
    1170 
    1171             if (count($to_delete) > 0)
    1172             {
    1173               $query = '
     1163        $parent_access = array_from_query($query, $field);
     1164
     1165        $to_delete = array_diff($category_access, $parent_access);
     1166
     1167        if (count($to_delete) > 0)
     1168        {
     1169          $query = '
    11741170DELETE FROM '.$table.'
    11751171  WHERE '.$field.' IN ('.implode(',', $to_delete).')
    11761172    AND cat_id IN ('.implode(',', $subcats).')
    11771173;';
    1178               pwg_query($query);
    1179             }
    1180           }
    1181           break;
     1174          pwg_query($query);
    11821175        }
    11831176      }
Note: See TracChangeset for help on using the changeset viewer.