You are here

function view_unpublished_menu in view_unpublished 5

File

./view_unpublished.module, line 24

Code

function view_unpublished_menu($may_cache) {
  $items = array();
  if (!$may_cache) {
    if (is_numeric(arg(1)) && arg(0) == 'node' && user_access('use view_unpublished module') && !user_access('administer nodes')) {
      $node = node_load(arg(1));
      if ($node->status == 0 && (user_access('view unpublished ' . $node->type . ' content') || user_access('view all unpublished content'))) {

        //print_r($node);

        //die();
        $items[] = array(
          'path' => 'node/' . arg(1),
          'title' => t('View'),
          'callback' => 'node_page_view',
          'callback arguments' => array(
            $node,
          ),
          'type' => MENU_CALLBACK,
          'access' => true,
        );
      }
      if ($node->status == 0 && (user_access('edit unpublished ' . $node->type . ' content') || user_access('edit all unpublished content'))) {
        $items[] = array(
          'path' => 'node/' . arg(1) . '/edit',
          'title' => t('Edit'),
          'callback' => 'node_page_edit',
          'callback arguments' => array(
            $node,
          ),
          'access' => true,
          'weight' => 1,
          'type' => MENU_LOCAL_TASK,
        );
      }
    }
  }
  return $items;
}