function workbench_moderation_node_unpublish_form in Workbench Moderation 7.3
Same name and namespace in other branches
- 7 workbench_moderation.node.inc \workbench_moderation_node_unpublish_form()
Form to unpublish the live revision.
Parameters
$node: The node being acted upon.
Return value
A Drupal confirmation form to unpublish the live revision.
1 string reference to 'workbench_moderation_node_unpublish_form'
- workbench_moderation_menu in ./
workbench_moderation.module - Implements hook_menu().
File
- ./
workbench_moderation.node.inc, line 302 - Provides node functions for Workbench Moderation.
Code
function workbench_moderation_node_unpublish_form($form, &$form_state, $node) {
global $user;
// Ensure that this is the live revision.
if (isset($node->workbench_moderation['published']->vid) && $node->vid != $node->workbench_moderation['published']->vid) {
drupal_set_message(t('This is not the live revision of this node.'), 'error');
drupal_goto("node/{$node->nid}/moderation");
}
$form = array();
$form['node'] = array(
'#value' => $node,
'#type' => 'value',
);
$form['message'] = array(
'#markup' => '<p>' . t('Are you sure that you want to unpublish the live revision of this content?') . '</p>',
);
$current_state = $node->workbench_moderation['my_revision']->state;
if ($next_states = workbench_moderation_states_next($current_state, $user, $node)) {
$form['state'] = array(
'#title' => t('Set moderation state'),
'#type' => 'select',
'#options' => $next_states,
'#default_value' => _workbench_moderation_default_next_state($current_state, $next_states),
);
}
else {
$form['message']['#markup'] .= '<p>' . t('The current live revision will be set to moderation state %state.', array(
'%state' => workbench_moderation_state_label(workbench_moderation_state_none()),
)) . '</p>';
$form['state'] = array(
'#type' => 'value',
'#value' => workbench_moderation_state_none(),
);
}
return confirm_form($form, t('Unpublish %title?', array(
'%title' => $node->title,
)), "node/{$node->nid}/moderation", '', t('Unpublish'));
}