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


Ignore:
Timestamp:
05/30/08 21:41:54 (4 years ago)
Author:
hverton
Message:

added a new module to define forum ranking

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/user_functions.php

    r1401 r1420  
    250250} 
    251251 
    252 // Check if user is assigned to the specified user group 
     252// Check if the current user is assigned to the specified user group 
    253253function checkgroup($group) { 
    254254    if (iSUPERADMIN && ($group != "100")) { return true; } 
     
    262262        return false; 
    263263    } 
     264} 
     265 
     266// Check if a user is assigned to the specified user group 
     267function checkusergroup($user_id, $group_id) { 
     268    global $db_prefix; 
     269 
     270    // every user is a member 
     271    if ($group_id == "101") { return true; } 
     272    // get the group rights from the user record 
     273    $result = dbquery("SELECT user_groups, user_level FROM ".$db_prefix."users WHERE user_id = '".$user_id."'"); 
     274    if ($data = dbarray($result)) { 
     275        // check if the requested group matches a user level 
     276        if ($group_id == $data['user_level']) { return true; } 
     277        // if group memberships are defined, get the users own group memberships into an array 
     278        if (!empty($data['user_groups'])) { 
     279            $groups = explode(".", substr($data['user_groups'], 1)); 
     280            foreach ($groups as $group) { 
     281                // check if this groups has subgroups. If so, add them to the array 
     282                getsubgroups($group); 
     283            } 
     284            // now that we have all groups, check for a match 
     285            foreach ($groups as $group) { 
     286                if ($group == $group_id) { return true; } 
     287            } 
     288        } 
     289    } 
     290    // user not found or no group match 
     291    return false; 
    264292} 
    265293 
Note: See TracChangeset for help on using the changeset viewer.