Changeset 23430


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

bug:2855
check "Apply to sub" checkbox if $conf inheritance_by_default is true
add admins to the users granted
optimizations

Location:
trunk/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_perm.php

    r19703 r23430  
    320320// |                           sending html code                           |
    321321// +-----------------------------------------------------------------------+
    322 $template->assign(array('PWG_TOKEN' => get_pwg_token()));
     322$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'INHERIT' => $conf['inheritance_by_default']));
    323323
    324324$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_perm');
  • trunk/admin/site_update.php

    r23428 r23430  
    323323          while ($row = pwg_db_fetch_assoc($result))
    324324          {
    325             if (!is_array ($granted_grps[$row['cat_id']]))
     325            if (!isset($granted_grps[$row['cat_id']]))
    326326            {
    327327              $granted_grps[$row['cat_id']]=array();
     
    334334            );
    335335          }
    336           $insert_granted_grps=array();
    337           foreach ($category_ids as $ids)
     336        }
     337        $query = '
     338          SELECT *
     339          FROM '.USER_ACCESS_TABLE.'
     340          WHERE cat_id IN ('.$category_up.')
     341        ;';
     342        $result = pwg_query($query);
     343        if (!empty($result))
     344        {
     345          $granted_users = array();
     346          while ($row = pwg_db_fetch_assoc($result))
    338347          {
    339             $parent_id=$db_categories[$ids]['parent'];
    340             while (in_array($parent_id, $category_ids))
     348            if (!isset($granted_users[$row['cat_id']]))
    341349            {
    342               $parent_id= $db_categories[$parent_id]['parent'];
     350              $granted_users[$row['cat_id']]=array();
    343351            }
    344             if ($db_categories[$ids]['status']=='private' and !is_null($parent_id))
     352            array_push(
     353              $granted_users,
     354              array(
     355                $row['cat_id'] => array_push($granted_users[$row['cat_id']],$row['user_id'])
     356              )
     357            );
     358          }
     359        }
     360        $insert_granted_users=array();
     361        $insert_granted_grps=array();
     362        foreach ($category_ids as $ids)
     363        {
     364          $parent_id=$db_categories[$ids]['parent'];
     365          while (in_array($parent_id, $category_ids))
     366          {
     367            $parent_id= $db_categories[$parent_id]['parent'];
     368          }
     369          if ($db_categories[$ids]['status']=='private' and !is_null($parent_id))
     370          {
     371            if (isset($granted_grps[$parent_id]))
    345372            {
    346373              foreach ($granted_grps[$parent_id] as $granted_grp)
     
    353380                  )
    354381                );
    355                
    356382              }
    357383            }
    358           }
    359  
    360           mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $insert_granted_grps);
    361         }
    362 
    363         $query = '
    364           SELECT *
    365           FROM '.USER_ACCESS_TABLE.'
    366           WHERE cat_id IN ('.$category_up.')
    367         ;';
    368         $result = pwg_query($query);
    369         if (!empty($result))
    370         {
    371 
    372           $granted_users = array();
    373           while ($row = pwg_db_fetch_assoc($result))
    374           {
    375             if (!is_array ($granted_users[$row['cat_id']]))
    376             {
    377               $granted_users[$row['cat_id']]=array();
    378             }
    379             array_push(
    380               $granted_users,
    381               array(
    382                 $row['cat_id'] => array_push($granted_users[$row['cat_id']],$row['user_id'])
    383               )
    384             );
    385           }
    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))
     384            if (isset($granted_users[$parent_id]))
    395385            {
    396386              foreach ($granted_users[$parent_id] as $granted_user)
     
    405395              }
    406396            }
     397            foreach (get_admins() as $granted_user)
     398            {
     399              array_push(
     400                $insert_granted_users,
     401                array(
     402                  'user_id' => $granted_user,
     403                  'cat_id' => $ids
     404                )
     405              );
     406            }
    407407          }
    408           mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert_granted_users);
    409408        }
    410       }     
     409        mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $insert_granted_grps);
     410        $insert_granted_users=array_unique($insert_granted_users, SORT_REGULAR);
     411        mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert_granted_users);
     412      }
    411413      else
    412414      {
  • trunk/admin/themes/default/template/cat_perm.tpl

    r13593 r23430  
    151151  <p style="margin:12px;text-align:left;">
    152152    <input class="submit" type="submit" value="{'Save Settings'|@translate}" name="submit">
    153     <label id="applytoSubAction" style="display:none;"><input type="checkbox" name="apply_on_sub">{'Apply to sub-albums'|@translate}</label>
     153    <label id="applytoSubAction" style="display:none;"><input type="checkbox" name="apply_on_sub" {if $INHERIT}checked="checked"{/if}>{'Apply to sub-albums'|@translate}</label>
    154154  </p>
    155155
Note: See TracChangeset for help on using the changeset viewer.