You are here

function og_publishcontent_unpublish_access in Publish Content 7

Implements hook_publishcontent_unpublish_access().

Implement on behalf of organic groups.

File

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

Code

function og_publishcontent_unpublish_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, 'unpublish any content', $account) || og_user_access($entity_type, $entity_id, 'unpublish own content', $account) && $account->uid == $node->uid || og_user_access($entity_type, $entity_id, 'unpublish editable content') && node_access('update', $node) || og_user_access($entity_type, $entity_id, 'unpublish own ' . check_plain($node->type) . ' content', $account) && $account->uid == $node->uid || og_user_access($entity_type, $entity_id, 'unpublish any ' . check_plain($node->type) . ' content', $account) || og_user_access($entity_type, $entity_id, 'unpublish editable ' . check_plain($node->type) . ' content', $account) && node_access('update', $node));
      if ($group_access) {
        $access = TRUE;
      }
    }
  }
  return $access ? PUBLISHCONTENT_ACCESS_ALLOW : PUBLISHCONTENT_ACCESS_IGNORE;
}