function userprotect_check_bypass in User protect 6
Same name and namespace in other branches
- 5 userprotect.module \userprotect_check_bypass()
- 7 userprotect.module \userprotect_check_bypass()
Checks to see if the current user can bypass a protection.
Parameters
$protection The protection to check for bypass.:
$uid An optional user to perform the bypass check on (default is current user).:
Return value
TRUE if the user can bypass, FALSE otherwise.
4 calls to userprotect_check_bypass()
- userprotect_form_alter in ./
userprotect.module - Alters forms for user protection.
- userprotect_user_admin_account_validate in ./
userprotect.module - Custom validation function for protecting users from the user administration operations.
- userprotect_user_delete_access in ./
userprotect.module - Access callback for user delete pages.
- userprotect_user_edit_access in ./
userprotect.module - Access callback for user edit pages.
File
- ./
userprotect.module, line 1086
Code
function userprotect_check_bypass($protection, $uid = NULL) {
global $user;
static $bypass = array();
static $bypass_defaults;
// If not a user admin, no checks necessary.
if (!user_access('administer users')) {
return FALSE;
}
// Take the current user unless otherwise specified.
$uid = isset($uid) ? $uid : $user->uid;
// Set the static array for the current admin.
if (!isset($bypass[$uid])) {
$result = db_query("SELECT * FROM {userprotect} WHERE uid = %d AND up_type = 'admin'", $uid);
if ($admin_array = db_fetch_array($result)) {
$bypass[$uid] = $admin_array;
}
}
// If a per administrator bypass setting exists, return it.
if (isset($bypass[$uid][$protection])) {
return $bypass[$uid][$protection];
}
else {
if (!isset($bypass_defaults)) {
$bypass_defaults = variable_get('userprotect_administrator_bypass_defaults', userprotect_administrator_bypass_defaults());
}
return isset($bypass_defaults[$protection]) ? $bypass_defaults[$protection] : FALSE;
}
}