You are here

function og_publishcontent_publish_access in Publish Content 7

Implements hook_publishcontent_publish_access().

Implement on behalf of organic groups.

File

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

Code

function og_publishcontent_publish_access($node, $account) {
  $access = FALSE;
  foreach (og_get_entity_groups('node', $node) as $entity_type => $og_memberships) {
    foreach ($og_memberships as $entity_id) {
      $group_access = !$node->status && (og_user_access($entity_type, $entity_id, 'administer nodes', $account) || og_user_access($entity_type, $entity_id, 'publish any content', $account) || og_user_access($entity_type, $entity_id, 'publish own content', $account) && $account->uid == $node->uid || og_user_access($entity_type, $entity_id, 'publish editable content', $account) && node_access('update', $node) || og_user_access($entity_type, $entity_id, 'publish own ' . check_plain($node->type) . ' content', $account) && $account->uid == $node->uid || og_user_access($entity_type, $entity_id, 'publish any ' . check_plain($node->type) . ' content', $account) || og_user_access($entity_type, $entity_id, 'publish editable ' . check_plain($node->type) . ' content', $account) && node_access('update', $node));
      if ($group_access) {
        $access = TRUE;
      }
    }
  }
  return $access ? PUBLISHCONTENT_ACCESS_ALLOW : PUBLISHCONTENT_ACCESS_IGNORE;
}