Ignore:
Timestamp:
Jun 21, 2013, 4:09:02 PM (11 years ago)
Author:
flop25
Message:

bug:2855
take care if no parent album, and propagate the permissions
ToDo: check "Apply to sub" checkbox if $conf inheritance_by_default is true, optimizations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/site_update.php

    r23376 r23428  
    267267        array(
    268268          'id' => $insert['id'],
    269           'parent' => $parent,
     269          'parent' => (isset($parent)) ? $parent : Null,
    270270          'status' => $insert['status'],
    271271          'visible' => $insert['visible'],
     
    304304      {
    305305        $category_ids[] = $category['id'];
    306         $category_up[] = $category['id_uppercat'];
     306        if (!empty($category['id_uppercat']))
     307        {
     308          $category_up[] = $category['id_uppercat'];
     309        }
    307310      }
    308311      $category_up=implode(',',array_unique($category_up));
     
    315318        ;';
    316319        $result = pwg_query($query);
    317         $granted_grps = array();
    318         while ($row = pwg_db_fetch_assoc($result))
     320        if (!empty($result))
    319321        {
    320           if (is_null($granted_grps[$row['cat_id']]))
     322          $granted_grps = array();
     323          while ($row = pwg_db_fetch_assoc($result))
    321324          {
    322             $granted_grps[$row['cat_id']]=array();
    323           }
    324           array_push(
    325             $granted_grps,
    326             array(
    327               $row['cat_id'] => array_push($granted_grps[$row['cat_id']],$row['group_id'])
    328             )
    329           );
    330         }
    331         $insert_granted_grps=array();
    332         foreach ($category_ids as $ids)
    333         {
    334           $parent=$db_categories[$ids]['parent'];
    335           foreach ($granted_grps[$parent] as $granted_grp)
    336           {
     325            if (!is_array ($granted_grps[$row['cat_id']]))
     326            {
     327              $granted_grps[$row['cat_id']]=array();
     328            }
    337329            array_push(
    338               $insert_granted_grps,
     330              $granted_grps,
    339331              array(
    340                 'group_id' => $granted_grp,
    341                 'cat_id' => $ids
     332                $row['cat_id'] => array_push($granted_grps[$row['cat_id']],$row['group_id'])
    342333              )
    343334            );
    344            
    345335          }
     336          $insert_granted_grps=array();
     337          foreach ($category_ids as $ids)
     338          {
     339            $parent_id=$db_categories[$ids]['parent'];
     340            while (in_array($parent_id, $category_ids))
     341            {
     342              $parent_id= $db_categories[$parent_id]['parent'];
     343            }
     344            if ($db_categories[$ids]['status']=='private' and !is_null($parent_id))
     345            {
     346              foreach ($granted_grps[$parent_id] as $granted_grp)
     347              {
     348                array_push(
     349                  $insert_granted_grps,
     350                  array(
     351                    'group_id' => $granted_grp,
     352                    'cat_id' => $ids
     353                  )
     354                );
     355               
     356              }
     357            }
     358          }
     359 
     360          mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $insert_granted_grps);
    346361        }
    347 
    348         mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $insert_granted_grps);
    349362
    350363        $query = '
     
    354367        ;';
    355368        $result = pwg_query($query);
    356         $granted_users = array();
    357         while ($row = pwg_db_fetch_assoc($result))
     369        if (!empty($result))
    358370        {
    359           if (is_null($granted_users[$row['cat_id']]))
     371
     372          $granted_users = array();
     373          while ($row = pwg_db_fetch_assoc($result))
    360374          {
    361             $granted_users[$row['cat_id']]=array();
    362           }
    363           array_push(
    364             $granted_users,
    365             array(
    366               $row['cat_id'] => array_push($granted_users[$row['cat_id']],$row['user_id'])
    367             )
    368           );
    369         }
    370         $insert_granted_users=array();
    371         foreach ($category_ids as $ids)
    372         {
    373           $parent=$db_categories[$ids]['parent'];
    374           foreach ($granted_users[$parent] as $granted_user)
    375           {
     375            if (!is_array ($granted_users[$row['cat_id']]))
     376            {
     377              $granted_users[$row['cat_id']]=array();
     378            }
    376379            array_push(
    377               $insert_granted_users,
     380              $granted_users,
    378381              array(
    379                 'user_id' => $granted_user,
    380                 'cat_id' => $ids
     382                $row['cat_id'] => array_push($granted_users[$row['cat_id']],$row['user_id'])
    381383              )
    382384            );
    383            
    384385          }
     386          $insert_granted_users=array();
     387          foreach ($category_ids as $ids)
     388          {
     389            $parent_id=$db_categories[$ids]['parent'];
     390             while (in_array($parent_id, $category_ids))
     391            {
     392              $parent_id= $db_categories[$parent_id]['parent'];
     393            }
     394            if ($db_categories[$ids]['status']=='private' and !is_null($parent_id))
     395            {
     396              foreach ($granted_users[$parent_id] as $granted_user)
     397              {
     398                array_push(
     399                  $insert_granted_users,
     400                  array(
     401                    'user_id' => $granted_user,
     402                    'cat_id' => $ids
     403                  )
     404                );
     405              }
     406            }
     407          }
     408          mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert_granted_users);
    385409        }
    386         mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert_granted_users);
    387 
    388410      }     
    389411      else
Note: See TracChangeset for help on using the changeset viewer.