You are here

function hook_publishcontent_unpublish_access in Publish Content 7

Allow other modules the ability to modify access to the unpublish controls.

Modules may implement this hook if they want to have a say in whether or not a given user has access to perform unpublish action on a node.

Parameters

node $node: A node object being checked

user $account: The user wanting to unpublish the node.

Return value

bool|NULL PUBLISHCONTENT_ACCESS_ALLOW - if the user can unpublish the node. PUBLISHCONTENT_ACCESS_DENY - if the user definetley cannot unpublish. PUBLISHCONTENT_ACCESS_IGNORE - This module wan't change the outcome. It is typically better to return IGNORE than DENY. If no module returns ALLOW then the user will be denied access. If one module returns DENY then the user will denied even if another module returns ALLOW.

2 functions implement hook_publishcontent_unpublish_access()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

og_publishcontent_unpublish_access in ./publishcontent.module
Implements hook_publishcontent_unpublish_access().
publishcontent_publishcontent_unpublish_access in ./publishcontent.module
Implements hook_publishcontent_unpublish_access().
1 invocation of hook_publishcontent_unpublish_access()
publishcontent_unpublish_access in ./publishcontent.module
Determine if a user has unpublish rights on a node.

File

./publishcontent.api.php, line 71
Describe hooks provided by the publishcontent module.

Code

function hook_publishcontent_unpublish_access($node, $account) {
  $access = $node->status && (user_access('administer nodes') || 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));
  if ($access) {

    // The user is allowed to unpublish the node according to this hook.
    // If another hook denys access they will be denied.
    return PUBLISHCONTENT_ACCESS_ALLOW;
  }

  // This function does not believe they can publish but is
  // not explicitly denying access to publish. If no other hooks
  // allow it then the user will be denied.
  return PUBLISHCONTENT_ACCESS_IGNORE;
}