You are here

function node_gallery_user_access in Node Gallery 6

Same name and namespace in other branches
  1. 6.3 node_gallery.module \node_gallery_user_access()
  2. 6.2 node_gallery.module \node_gallery_user_access()
2 calls to node_gallery_user_access()
node_gallery_operations in ./node_gallery.module
theme_gallery_images_list in ./node_gallery.themes.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 300
Node gallery module file.

Code

function node_gallery_user_access($op, $gallery = NULL) {
  global $user;
  $gallery_config = gallery_config_gateway::get_by($gallery->type);
  switch ($op) {
    case 'view':
      return user_access(NODE_GALLERY_PERM_VIEW_GALLERY);
      break;
    case 'upload':
      if ($user->uid == $gallery->uid || $user->uid == 1) {
        return user_access('create ' . $gallery_config->image_type . ' content');
      }
      else {
        return user_access('edit any ' . $gallery->type . ' content');
      }
      break;
    case 'edit':
      if ($user->uid == $gallery->uid) {
        return user_access('edit own ' . $gallery->type . ' content') || user_access('edit any ' . $gallery->type . ' content');
      }
      else {
        return user_access('edit any ' . $gallery->type . ' content');
      }
      break;
    case 'edit image':
      if ($user->uid == $gallery->uid) {
        return user_access('edit own ' . $gallery_config->image_type . ' content') || user_access('edit any ' . $gallery_config->image_type . ' content');
      }
      else {
        return user_access('edit any ' . $gallery_config->image_type . ' content');
      }
      break;
    case 'delete':
      if ($user->uid == $gallery->uid) {
        return user_access('delete own ' . $gallery_config->image_type . ' content') || user_access('delete any ' . $gallery_config->image_type . ' content');
      }
      else {
        return user_access('delete any ' . $gallery_config->image_type . ' content');
      }
      break;
    case 'create':
      return user_access('create ' . $gallery->type . ' content');
      break;
  }
}