function readonlymode_form_alter in Read only mode 7
Same name and namespace in other branches
- 8 readonlymode.module \readonlymode_form_alter()
- 6 readonlymode.module \readonlymode_form_alter()
Implements hook_form_alter().
Permit posting of content.
File
- ./
readonlymode.module, line 63 - The Read Ony Mode main module file.
Code
function readonlymode_form_alter(&$form, $form_state, $form_id) {
$mode = _readonlymode_form_check($form_id);
if ($mode != READONLYMODE_FORM_ALLOWED) {
// Check whether the form is a fresh form being served to the user.
if (!isset($form_state['input']['form_token'])) {
// If a redirect URL is set, then we redirect to it.
if ($url = variable_get('site_readonly_url', '')) {
drupal_goto($url);
}
else {
// Replace FAPI #after_build handlers with our block form.
$form['#after_build'] = array(
'readonlymode_block_form',
);
}
}
}
$path = current_path();
if (user_access('readonlymode access forms') && variable_get('site_readonly', FALSE) && $path != 'admin/config/development/maintenance') {
drupal_set_message(t('The site is currently set to read-only, content moderation is disabled for all users without the "Access all forms while in maintenance" permission. <a href="@link">Go online</a>.', array(
'@link' => url('admin/config/development/maintenance'),
)), 'warning', FALSE);
}
$form['#validate'][] = 'readonlymode_check_form_validate';
}