You are here

function gallery_assist_access in Gallery Assist 6

Implementation of hook_access().

1 call to gallery_assist_access()
_gallery_assist_check_access in ./gallery_assist.module
Check if user have edit or access permitions and if positiv check the gallery public status.

File

./gallery_assist.module, line 187
Drupal content type with gallery functionality.

Code

function gallery_assist_access($op, $node, $account) {
  global $user;

  // Manage permissions for the gallery assist content type.
  if ($op == 'view' && $node->uid == $user->uid) {
    return user_access('view gallery_assist content', $account);
  }
  if ($op == 'create') {
    return user_access('create gallery_assist content', $account);
  }
  if ($op == 'update') {
    if (user_access('edit any gallery_assist content', $account) || user_access('edit own gallery_assist content', $account) && $account->uid == $node->uid) {
      return TRUE;
    }
  }
  if ($op == 'delete') {
    if (user_access('delete any gallery_assist content', $account) || user_access('delete own gallery_assist content', $account) && $account->uid == $node->uid) {
      return TRUE;
    }
  }

  // Manage permissions for conten types with gallery assist assignment.
  $types = node_get_types();
  foreach ($types as $v) {
    if ($op == 'view' && $node->uid == $user->uid) {
      return user_access('view gallery_assist_' . $v->type . ' content', $account);
    }
    if ($op == 'create') {
      return user_access('create gallery_assist_' . $v->type . ' content', $account);
    }
    if ($op == 'update') {
      if (user_access('edit any gallery_assist_' . $v->type . ' content', $account) || user_access('edit own gallery_assist_' . $v->type . ' content', $account) && $account->uid == $node->uid) {
        return TRUE;
      }
    }
    if ($op == 'delete') {
      if (user_access('delete any gallery_assist_' . $v->type . ' content', $account) || user_access('delete own gallery_assist_' . $v->type . ' content', $account) && $account->uid == $node->uid) {
        return TRUE;
      }
    }
  }
}