function workbench_moderation_moderate_form in Workbench Moderation 7
Same name and namespace in other branches
- 7.3 workbench_moderation.module \workbench_moderation_moderate_form()
Generates a moderation form for a node.
The caller of this form needs to check whether the node is in moderation.
Parameters
$node: The node being acted upon.
Return value
$form A Drupal Forms API array.
3 string references to 'workbench_moderation_moderate_form'
- workbench_moderation_iib_entity_item in ./
workbench_moderation.iib.inc - Implements hook_iib_entity_item().
- workbench_moderation_messages in ./
workbench_moderation.module - Sets status messages for a node.
- workbench_moderation_node_history_view in ./
workbench_moderation.node.inc - Display a node's moderation history.
File
- ./
workbench_moderation.module, line 1858 - Content moderation for Workbench.
Code
function workbench_moderation_moderate_form($form, &$form_state, $node, $destination = NULL) {
global $user;
$form = array();
// Build links to available moderation states.
$links = array();
$my_revision = $node->workbench_moderation['my_revision'];
if ($my_revision->vid == $node->workbench_moderation['current']->vid && ($next_states = workbench_moderation_states_next($my_revision->state, $user, $node))) {
$form['#destination'] = $destination;
$form['node'] = array(
'#type' => 'value',
'#value' => $node,
);
$form['#attributes']['class'][] = 'workbench-moderation-moderate-form';
$form['#attached']['css'][] = drupal_get_path('module', 'workbench_moderation') . '/css/workbench_moderation.css';
$form['state'] = array(
'#type' => 'select',
'#title' => t('Moderation state'),
'#title_display' => 'invisible',
'#options' => $next_states,
'#default_value' => _workbench_moderation_default_next_state($my_revision->state, $next_states),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Apply'),
);
// Cache the form on first load to preserve the node for validation.
// Otherwise, the node would be reloaded on submit, and there would be no
// way to detect if the current revision has been changed.
$form_state['cache'] = TRUE;
}
else {
$form['#access'] = FALSE;
}
return $form;
}