function honeypot_get_protected_forms in Honeypot 7
Same name and namespace in other branches
- 8 honeypot.module \honeypot_get_protected_forms()
- 6 honeypot.module \honeypot_get_protected_forms()
- 2.0.x honeypot.module \honeypot_get_protected_forms()
Build an array of all the protected forms on the site, by form_id.
@todo - Add in API call/hook to allow modules to add to this array.
1 call to honeypot_get_protected_forms()
- honeypot_form_alter in ./
honeypot.module - Implements hook_form_alter().
File
- ./
honeypot.module, line 173 - Honeypot module, for deterring spam bots from completing Drupal forms.
Code
function honeypot_get_protected_forms() {
$forms =& drupal_static(__FUNCTION__);
// If the data isn't already in memory, get from cache or look it up fresh.
if (!isset($forms)) {
if ($cache = cache_get('honeypot_protected_forms')) {
$forms = $cache->data;
}
else {
$forms = array();
// Look up all the honeypot forms in the variables table.
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'honeypot_form_%'")
->fetchCol();
// Add each form that's enabled to the $forms array.
foreach ($result as $variable) {
if (variable_get($variable, 0)) {
$forms[] = substr($variable, 14);
}
}
// Save the cached data.
cache_set('honeypot_protected_forms', $forms, 'cache');
}
}
return $forms;
}