You are here

function publishcontent_toggle_status_form in Publish Content 7

Form to get confirmation for publish/unpublish content

_state

Parameters

array $form:

$node:

string $toggle_title: Title of the button e.g. Publish or Unpublish

Return value

array

1 string reference to 'publishcontent_toggle_status_form'
publishcontent_menu in ./publishcontent.module
Implements hook_menu().

File

./publishcontent.module, line 284
Add link to publish or unpublish a node, with access control based on the node type

Code

function publishcontent_toggle_status_form($form, &$form_state, $node, $toggle_title) {
  $form['id'] = array(
    '#type' => 'value',
    '#value' => $node->nid,
  );

  // Set confirm form question.
  if ($toggle_title) {
    $question = t('Are you sure you want to %publish_state this content?', array(
      '%publish_state' => ucfirst($toggle_title),
    ));
  }
  else {
    $question = t('Are you sure?');
  }
  $description = t('Click confirm if you want to continue.');

  // Set return path if clicked on Cancel button.
  $path = 'node/' . $node->nid;
  return confirm_form($form, $question, $path, $description);
}