You are here

function _readonlymode_form_check in Read only mode 6

Same name and namespace in other branches
  1. 8 readonlymode.module \_readonlymode_form_check()
  2. 7 readonlymode.module \_readonlymode_form_check()

Internal handler to check whether this form is to be restricted. Returns TRUE if the form is allowed, FALSE otherwise.

2 calls to _readonlymode_form_check()
readonlymode_check_form_validate in ./readonlymode.module
Our validate handler for checking whether the form submission is occurring while read-only mode is enabled.
readonlymode_form_alter in ./readonlymode.module
Implementation of hook_form_alter(). Permit posting of content

File

./readonlymode.module, line 167
Read Only Mode provides an alternate to the built in 'Maintenance Mode' in Drupal. Instead of displaying a static text file to users while the site is in maintenance mode, Read Only Mode will allow access (reading) of new content while…

Code

function _readonlymode_form_check(&$form, $form_id, $submitted = TRUE) {

  // If not in read-only mode, allow the form.
  if (!variable_get('site_readonly', FALSE)) {
    return TRUE;
  }

  // Admins can access all forms.
  if (user_access('readonlymode access forms')) {
    return TRUE;
  }

  // Is the form in the list of default forms? Then allow access.
  if (in_array($form_id, _readonlymode_default_forms_allowed())) {
    return TRUE;
  }

  // Is the form in the list of read-only forms? Then allow access.
  if (!$submitted && in_array($form_id, _readonlymode_default_forms_viewonly())) {
    return TRUE;
  }

  // Check if the form is in the custom list of allowed forms. If so, allow.
  if (_readonlymode_form_list_check($form_id, variable_get('site_readonly_forms_allowed', ''))) {
    return TRUE;
  }

  // Check if the form is in the custom list of allowed read-only forms.
  if (!$submitted && _readonlymode_form_list_check($form_id, variable_get('site_readonly_forms_viewonly', ''))) {
    return TRUE;
  }
  return FALSE;
}