You are here

function hook_publishcontent_publish_access in Publish Content 7

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

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

Parameters

node $node: A node object being checked

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

Return value

bool|NULL PUBLISHCONTENT_ACCESS_ALLOW - if the account can publish the node PUBLISHCONTENT_ACCESS_DENY - if the user definitely can not publish 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 account will be denied publish access. If one module returns DENY then the user will denied even if another module returns ALLOW.

2 functions implement hook_publishcontent_publish_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_publish_access in ./publishcontent.module
Implements hook_publishcontent_publish_access().
publishcontent_publishcontent_publish_access in ./publishcontent.module
Implements hook_publishcontent_publish_access().
1 invocation of hook_publishcontent_publish_access()
publishcontent_publish_access in ./publishcontent.module
Determine if a user has publish permission to a given node.

File

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

Code

function hook_publishcontent_publish_access($node, $account) {
  $access = !$node->status && (user_access('administer nodes') || user_access('publish any content') || user_access('publish own content') && $account->uid == $node->uid || user_access('publish editable content') && node_access('update', $node) || user_access('publish own ' . check_plain($node->type) . ' content', $account) && $account->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));
  if ($access) {

    // The user can publish 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;
}