You are here

function _publishcontent_unpublish_access in Publish Content 6

Same name and namespace in other branches
  1. 5.2 publishcontent.module \_publishcontent_unpublish_access()
  2. 7 publishcontent.module \_publishcontent_unpublish_access()

Access callback for unpublish action. Only allow access based on permissions and current node status = published

2 calls to _publishcontent_unpublish_access()
publishcontent_form_alter in ./publishcontent.module
Implements of hook_form_alter().
publishcontent_views_handler_field_node_link::render in ./publishcontent_views_handler_field_node_link.inc
1 string reference to '_publishcontent_unpublish_access'
publishcontent_menu in ./publishcontent.module
Implements of hook_menu().

File

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

Code

function _publishcontent_unpublish_access($node, $token = FALSE) {
  if ($token && !drupal_valid_token($token)) {
    return FALSE;
  }
  if (!variable_get('publishcontent_' . $node->type, TRUE)) {
    return FALSE;
  }
  global $user;
  return $node->status && (user_access('unpublish any content') || user_access('unpublish own content') && $user->uid == $node->uid || user_access('unpublish editable content') && node_access('update', $node) || user_access('unpublish own ' . check_plain($node->type) . ' content', $user) && $user->uid == $node->uid || user_access('unpublish any ' . check_plain($node->type) . ' content') || user_access('unpublish editable ' . check_plain($node->type) . ' content') && node_access('update', $node));
}