function autoban_get_rules in Automatic IP ban (Autoban) 7
Retrieves autoban rules from the database.
Parameters
int $rid: (optional) Autoban rule id.
array $header: (optional) Autoban rule table header.
Return value
array|object An array of rules objects or rule object.
6 calls to autoban_get_rules()
- autoban_ban_all in ./
autoban.module - Ban all IP's for rules.
- autoban_ban_all_form_submit in ./
autoban.admin.inc - Form submission for autoban_ban_all_form().
- autoban_export_form in ./
autoban.admin.inc - Export autoban rules.
- autoban_form in ./
autoban.admin.inc - Defines the form for autoban rules.
- autoban_page in ./
autoban.admin.inc - Menu callback. Displays autoban rules list.
3 string references to 'autoban_get_rules'
- autoban_clear_tables_form_submit in ./
autoban.admin.inc - Form submission for autoban_clear_tables_form().
- autoban_delete_submit in ./
autoban.admin.inc - Processes autoban_delete form submissions.
- autoban_form_submit in ./
autoban.admin.inc - Form submission for autoban_form().
File
- ./
autoban.module, line 356 - Main file for autoban module.
Code
function autoban_get_rules($rid = NULL, $header = array()) {
// Skip the cache for TableSort list.
if (empty($header)) {
$stored_rules =& drupal_static(__FUNCTION__);
}
// The cache was reset, we passed in headers, or $res hasn't been built.
if (empty($stored_rules)) {
$query = db_select('autoban', 'list')
->fields('list');
if (!empty($header)) {
$query
->extend('TableSort')
->orderByHeader($header);
}
$stored_rules = $query
->execute()
->fetchAllAssoc('rid');
}
// Return rule object.
if ($rid !== NULL && empty($header)) {
if (!empty($stored_rules[$rid])) {
return $stored_rules[$rid];
}
else {
drupal_set_message(t('autoban_get_rules: Missing index @rid.', array(
'@rid' => $rid,
)), 'error');
return NULL;
}
}
return $stored_rules;
}