You are here

function _publishcontent_publish_access in Publish Content 6

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

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

2 calls to _publishcontent_publish_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_publish_access'
publishcontent_menu in ./publishcontent.module
Implements of hook_menu().

File

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

Code

function _publishcontent_publish_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('publish any content') || user_access('publish own content') && $user->uid == $node->uid || user_access('publish editable content') && node_access('update', $node) || user_access('publish own ' . check_plain($node->type) . ' content', $user) && $user->uid == $node->uid || user_access('publish any ' . check_plain($node->type) . ' content') || user_access('publish editable ' . check_plain($node->type) . ' content') && node_access('update', $node));
}