function drupal_is_denied in Drupal 5
Same name and namespace in other branches
- 4 includes/bootstrap.inc \drupal_is_denied()
- 6 includes/bootstrap.inc \drupal_is_denied()
- 7 includes/bootstrap.inc \drupal_is_denied()
Perform an access check for a given mask and rule type. Rules are usually created via admin/user/rules page.
If any allow rule matches, access is allowed. Otherwise, if any deny rule matches, access is denied. If no rule matches, access is allowed.
Parameters
$type string: Type of access to check: Allowed values are:
- 'host': host name or IP address
- 'mail': e-mail address
- 'user': username
$mask string: String or mask to test: '_' matches any character, '%' matches any number of characters.
Return value
bool TRUE if access is denied, FALSE if access is allowed.
7 calls to drupal_is_denied()
- user_admin_access_check_submit in modules/
user/ user.module - user_authenticate in modules/
user/ user.module - user_login_validate in modules/
user/ user.module - user_pass_reset in modules/
user/ user.module - Menu callback; process one time login link and redirects to the user page on success.
- user_pass_validate in modules/
user/ user.module
File
- includes/
bootstrap.inc, line 845 - Functions that need to be loaded on every Drupal request.
Code
function drupal_is_denied($type, $mask) {
// Because this function is called for every page request, both cached
// and non-cached pages, we tried to optimize it as much as possible.
// We deny access if the only matching records in the {access} table have
// status 0. If any have status 1, or if there are no matching records,
// we allow access. So, select matching records in decreasing order of
// 'status', returning NOT(status) for the first. If any have status 1,
// they come first, and we return NOT(status) = 0 (allowed). Otherwise,
// if we have some with status 0, we return 1 (denied). If no matching
// records, we get no return from db_result, so we return (bool)NULL = 0
// (allowed).
// The use of ORDER BY / LIMIT is more efficient than "MAX(status) = 0"
// in PostgreSQL <= 8.0.
return (bool) db_result(db_query_range("SELECT CASE WHEN status=1 THEN 0 ELSE 1 END FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE LOWER(mask) ORDER BY status DESC", $type, $mask, 0, 1));
}