Changeset 1057 in ExiteCMS for trunk/includes/user_functions.php


Ignore:
Timestamp:
11/04/07 13:41:50 (5 years ago)
Author:
hverton
Message:

Fixed user_groups parsing error when the user is member of no groups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/user_functions.php

    r954 r1057  
    136136 
    137137if (isset($userdata) && is_array($userdata)) { 
    138     // get the users own group memberships into an array 
    139     $groups = explode(".", substr($userdata['user_groups'], 1)); 
    140     foreach ($groups as $group) { 
    141         // check if this groups has subgroups. If so, add them to the array 
    142         getsubgroups($group); 
    143     } 
    144     // create a new user_group field with all inherited groups, and 
    145     // get the inherited group rights and add them to the user own rights 
    146     $userdata['user_groups'] = ""; 
    147     foreach ($groups as $group) { 
    148         $userdata['user_groups'] .= ".".$group; 
    149         $result = dbarray(dbquery("SELECT group_rights FROM ".$db_prefix."user_groups WHERE group_id = '".$group."'")); 
    150         if (isset($result['group_rights']) && $result['group_rights'] != "") { 
    151             $userdata['user_rights'] .= ($userdata['user_rights']==""?"":".").$result['group_rights']; 
     138    // if group memberships are defined, get the users own group memberships into an array 
     139    if (!empty($userdata['user_groups'])) { 
     140        $groups = explode(".", substr($userdata['user_groups'], 1)); 
     141        foreach ($groups as $group) { 
     142            // check if this groups has subgroups. If so, add them to the array 
     143            getsubgroups($group); 
     144        } 
     145        // create a new user_group field with all inherited groups, and 
     146        // get the inherited group rights and add them to the user own rights 
     147        $userdata['user_groups'] = ""; 
     148        foreach ($groups as $group) { 
     149            $userdata['user_groups'] .= ".".$group; 
     150            $result = dbarray(dbquery("SELECT group_rights FROM ".$db_prefix."user_groups WHERE group_id = '".$group."'")); 
     151            if (isset($result['group_rights']) && $result['group_rights'] != "") { 
     152                $userdata['user_rights'] .= ($userdata['user_rights']==""?"":".").$result['group_rights']; 
     153            } 
    152154        } 
    153155    } 
Note: See TracChangeset for help on using the changeset viewer.