Changeset 1900 in ExiteCMS
- Timestamp:
- 10/22/08 18:08:43 (3 years ago)
- File:
-
- 1 edited
-
trunk/includes/user_functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/user_functions.php
r1885 r1900 285 285 global $groups, $db_prefix; 286 286 287 // every user is a member 288 if ($group_id == "101") { return true; } 289 // get the group rights from the user record 290 $result = dbquery("SELECT user_groups, user_level FROM ".$db_prefix."users WHERE user_id = '".$user_id."'"); 291 if ($data = dbarray($result)) { 292 // check if the requested group matches a user level 293 if ($group_id == $data['user_level']) { return true; } 294 // if group memberships are defined, get the users own group memberships into an array 295 if (!empty($data['user_groups'])) { 296 $groups = explode(".", substr($data['user_groups'], 1)); 297 foreach ($groups as $group) { 298 // check if this groups has subgroups. If so, add them to the array 299 getsubgroups($group); 300 } 301 // now that we have all groups, check for a match 302 foreach ($groups as $group) { 303 if ($group == $group_id) { return true; } 304 } 305 } 306 } 307 // user not found or no group match 308 return false; 287 // result cache 288 static $resultcache; 289 if (isset($resultcache[$user_id][$group_id])) { 290 return $resultcache[$user_id][$group_id]; 291 } 292 293 $check = false; 294 if ($group_id == "101") { 295 // every user is a member 296 $check = true; 297 } else { 298 // get the group rights from the user record 299 $result = dbquery("SELECT user_groups, user_level FROM ".$db_prefix."users WHERE user_id = '".$user_id."'"); 300 if ($data = dbarray($result)) { 301 // check if the requested group matches a user level 302 if ($group_id == $data['user_level']) { 303 $check = true; 304 } else { 305 // if group memberships are defined, get the users own group memberships into an array 306 if (!empty($data['user_groups'])) { 307 $groups = explode(".", substr($data['user_groups'], 1)); 308 foreach ($groups as $group) { 309 // check if this groups has subgroups. If so, add them to the array 310 getsubgroups($group); 311 } 312 // now that we have all groups, check for a match 313 foreach ($groups as $group) { 314 if ($group == $group_id) { 315 $check = true; 316 break; 317 } 318 } 319 } 320 } 321 } 322 } 323 324 if (!isset($resultcache[$user_id])) $resultcache[$user_id] = array(); 325 $resultcache[$user_id][$group_id] = $check; 326 327 return $check; 309 328 } 310 329 … … 461 480 462 481 global $groups, $settings, $db_prefix; 482 483 // result cache 484 static $resultcache; 485 if (isset($resultcache[$group_id])) { 486 return $resultcache[$group_id]; 487 } 463 488 464 489 // gather the group and it's sub-groups into an array … … 489 514 $members[] = $data; 490 515 } 516 517 if (!isset($resultcache)) $resultcache = array(); 518 $resultcache[$group_id] = $members; 519 491 520 return $members; 492 521 }
Note: See TracChangeset
for help on using the changeset viewer.
