You are here

function node_gallery_user_access in Node Gallery 6.2

Same name and namespace in other branches
  1. 6.3 node_gallery.module \node_gallery_user_access()
  2. 6 node_gallery.module \node_gallery_user_access()
2 calls to node_gallery_user_access()
node_gallery_operations in ./node_gallery.module
template_preprocess_gallery_images_list in theme/theme.inc
1 string reference to 'node_gallery_user_access'
node_gallery_menu in ./node_gallery.module
Implementation of hook_menu().

File

./node_gallery.module, line 542
Node gallery module file

Code

function node_gallery_user_access($op, $gallery = NULL, $account = NULL) {
  global $user;

  //$gallery_config = $gallery->config;
  $image_type = $gallery->config['image_type'];
  $gallery_type = $gallery->type;
  switch ($op) {
    case 'view':
      return user_access('administer nodes') || user_access(NODE_GALLERY_PERM_VIEW_GALLERY);
      break;
    case 'view My Galleries':
      if (isset($user->status) || $user->uid == 0 && $user->uid != $account->uid) {
        return user_access('administer nodes') || user_access(NODE_GALLERY_PERM_VIEW_GALLERY);
      }
      break;
    case 'upload':
      if ($user->uid == $gallery->uid) {
        return user_access('administer nodes') || user_access('create ' . $image_type . ' content');
      }
      else {
        return user_access('administer nodes') || user_access('edit any ' . $gallery_type . ' content');
      }
      break;
    case 'edit':
      if ($user->uid == $gallery->uid) {
        return user_access('administer nodes') || user_access('edit own ' . $gallery_type . ' content') || user_access('edit any ' . $gallery_type . ' content');
      }
      else {
        return user_access('administer nodes') || user_access('edit any ' . $gallery_type . ' content');
      }
      break;
    case 'edit image':
      if ($user->uid == $gallery->uid) {
        return user_access('administer nodes') || user_access('edit own ' . $image_type . ' content') || user_access('edit any ' . $image_type . ' content');
      }
      else {
        return user_access('administer nodes') || user_access('edit any ' . $image_type . ' content');
      }
      break;
    case 'delete':
      if ($user->uid == $gallery->uid) {
        return user_access('administer nodes') || user_access('delete own ' . $image_type . ' content') || user_access('delete any ' . $image_type . ' content');
      }
      else {
        return user_access('administer nodes') || user_access('delete any ' . $image_type . ' content');
      }
      break;
    case 'create':
      return user_access('administer nodes') || user_access('create ' . $gallery_type . ' content');
      break;
  }
}