function enforce_revlog_js in Enforce revision log message 6
Same name and namespace in other branches
- 8 enforce_revlog.module \enforce_revlog_js()
- 7 enforce_revlog.module \enforce_revlog_js()
Helper AHAH function to change the required state of the log message textarea. Allows visual feedback by the user. This function is only triggered when the right conditions are met.
1 string reference to 'enforce_revlog_js'
- enforce_revlog_menu in ./
enforce_revlog.module - Implementation of hook_menu().
File
- ./
enforce_revlog.module, line 213 - Allows enforcing unpriviledged users to enter a log message every time a node revision is created or reverted
Code
function enforce_revlog_js() {
$form_state = array(
'submitted' => FALSE,
);
$form_build_id = $_POST['form_build_id'];
// Add the new element to the stored form. Without adding the element to the
// form, Drupal is not aware of this new element's existence and will not
// process it. We retreive the cached form, add the element, and resave.
$form = form_get_cache($form_build_id, $form_state);
// Switching theme function used to render the log message textarea. Will switch the "required" state.
// We cannot use the #required property due to validation issues otherwise
$form['revision_information']['log']['#theme'] = empty($form['revision_information']['log']['#theme']) ? 'enforce_revlog_log_message' : NULL;
form_set_cache($form_build_id, $form, $form_state);
$form += array(
'#post' => $_POST,
'#programmed' => FALSE,
);
// Rebuild the form.
$form = form_builder($_POST['form_id'], $form, $form_state);
// Render the new output.
$new_form = $form['revision_information']['log'];
return drupal_json(array(
'status' => TRUE,
'data' => drupal_render($new_form),
));
}