Changeset 16512


Ignore:
Timestamp:
Jul 8, 2012, 9:14:12 PM (12 years ago)
Author:
grum
Message:

bug:2371

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMenuManager/amm_root.class.inc.php

    r16006 r16512  
    527527    $registeredBlocks = $menu->get_registered_blocks();
    528528
     529    $nbExistingGroups=0;
     530    $sql="SELECT COUNT(id) AS nbGroup
     531          FROM ".GROUPS_TABLE.";";
     532    $result=pwg_query($sql);
     533    if($result)
     534    {
     535      while($row=pwg_db_fetch_assoc($result))
     536      {
     537        $nbExistingGroups=$row['nbGroup'];
     538      }
     539    }
     540
     541
    529542    $userGroups=array();
    530543    $sql="SELECT group_id
     
    556569          if($userFiltered)
    557570          {
     571            // filter access enabled
     572
    558573            $users->setAlloweds($row['users'], false);
    559574            if($users->isAllowed($user['status']))
    560575            {
     576              // user is authorized, check group
    561577              if(count($userGroups))
    562578              {
     579                // users is attached to one group or more, check access for each group
     580                // at least, one group must have right access
     581                $nbOk=count($userGroups);
     582
    563583                $groups->setAlloweds($row['groups'], false);
    564584                foreach($row['groups'] as $val)
    565585                {
    566                   if(isset($userGroups[$val]) and !$groups->isAllowed($val)) $ok=false;
     586                  if(isset($userGroups[$val]) and !$groups->isAllowed($val)) $nbOk--;
    567587                }
     588
     589                // no group is authorized to access the menu
     590                if($nbOk==0) $ok=false;
    568591              }
    569               else
     592              elseif($nbExistingGroups>0 and count($row['groups'])>0)
    570593              {
    571                 if(count($row['groups'])==0) $ok=false;
     594                // if user is not attached to any group and if at least there 1
     595                // existing group, no authorization to access to the menu
     596                $ok=false;
    572597              }
    573598            }
    574599            else
    575600            {
     601              // user not authorized
    576602              $ok=false;
    577603            }
Note: See TracChangeset for help on using the changeset viewer.