Same name and namespace in other branches
- 4.7.x includes/bootstrap.inc \drupal_is_denied()
- 5.x includes/bootstrap.inc \drupal_is_denied()
- 7.x 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.
File
- includes/
bootstrap.inc, line 1078 - 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 (deny). If any have status 1 (allow), or if there are no
// matching records, we allow access.
$sql = "SELECT 1 FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE LOWER(mask) AND status = %d";
return db_result(db_query_range($sql, $type, $mask, 0, 0, 1)) && !db_result(db_query_range($sql, $type, $mask, 1, 0, 1));
}