function _readonlymode_form_check in Read only mode 7
Same name and namespace in other branches
- 8 readonlymode.module \_readonlymode_form_check()
- 6 readonlymode.module \_readonlymode_form_check()
Internal handler to check whether this form is to be restricted.
Parameters
int $form_id: The ID of the form we want to check.
Return value
int
- READONLYMODE_FORM_DENIED: The form has been blocked.
- READONLYMODE_FORM_VIEWONLY: The form should be view only.
- READONLYMODE_FORM_ALLOWED: The form has been allowed.
2 calls to _readonlymode_form_check()
- readonlymode_check_form_validate in ./
readonlymode.module - Validate handler for checking whether the form submission is occurring.
- readonlymode_form_alter in ./
readonlymode.module - Implements hook_form_alter().
File
- ./
readonlymode.module, line 252 - The Read Ony Mode main module file.
Code
function _readonlymode_form_check($form_id) {
// Get hold of our cache.
$cache =& drupal_static(__FUNCTION__, NULL);
// If NULL, we need to check the non-form specific options.
if (!isset($cache)) {
// If not in read-only mode, allow the form.
if (!variable_get('site_readonly', FALSE)) {
$cache = READONLYMODE_FORM_ALLOWED;
}
elseif (user_access('readonlymode access forms')) {
$cache = READONLYMODE_FORM_ALLOWED;
}
else {
$cache = array();
}
}
// If we have a scalar value, we don't need to check specific forms.
if (!is_array($cache)) {
return $cache;
}
// Look at form specific level if required.
if (!isset($cache[$form_id])) {
// Is the form in the list of default forms? Then allow access.
if (in_array($form_id, _readonlymode_default_forms_allowed())) {
$cache[$form_id] = READONLYMODE_FORM_ALLOWED;
}
elseif (in_array($form_id, _readonlymode_default_forms_viewonly())) {
$cache[$form_id] = READONLYMODE_FORM_VIEWONLY;
}
elseif (_readonlymode_form_list_check($form_id, variable_get('site_readonly_forms_allowed', ''))) {
$cache[$form_id] = READONLYMODE_FORM_ALLOWED;
}
elseif (_readonlymode_form_list_check($form_id, variable_get('site_readonly_forms_viewonly', ''))) {
$cache[$form_id] = READONLYMODE_FORM_VIEWONLY;
}
else {
$cache[$form_id] = READONLYMODE_FORM_DENIED;
}
}
return $cache[$form_id];
}