You are here

function node_gallery_operations in Node Gallery 6

Same name and namespace in other branches
  1. 6.2 node_gallery.module \node_gallery_operations()
4 calls to node_gallery_operations()
node_gallery_preprocess_node in ./node_gallery.module
template_preprocess_gallery_cover_view in ./node_gallery.themes.inc
theme_gallery_image_navigator in ./node_gallery.themes.inc
theme_gallery_list in ./node_gallery.themes.inc
@file Node gallery themes.

File

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

Code

function node_gallery_operations($type, $a2 = NULL) {
  global $user;
  $items = array();
  switch ($type) {
    case 'list':
      $account = $a2;

      //all gallery list or current user's gallery list;
      if ($account->uid == $user->uid) {
        $node_types = node_get_types();
        $types = gallery_config_gateway::get_types();
        foreach (array_keys($types) as $type) {
          if (user_access("create {$type} content", $user)) {
            $items[] = array(
              'title' => t('Create !type', array(
                '!type' => $node_types[$type]->name,
              )),
              'href' => 'node/add/' . $type,
            );
          }
        }
      }
      break;
    case 'cover':
      $gallery = $a2;
      if (node_gallery_user_access('edit', $gallery)) {
        $items[] = array(
          'title' => t('Edit gallery'),
          'href' => "node/{$gallery->nid}/edit",
          'query' => array(
            'destination' => "galleries/{$gallery->uid}",
          ),
        );
      }
      if (node_gallery_user_access('upload', $gallery)) {
        $items[] = array(
          'title' => t('Upload images'),
          'href' => "node/{$gallery->nid}/upload",
        );
      }
      if (node_gallery_user_access('delete', $gallery)) {
        $items[] = array(
          'title' => t('Delete gallery'),
          'href' => "node/{$gallery->nid}/delete",
          'query' => array(
            'destination' => "galleries/{$gallery->uid}",
          ),
        );
      }
      break;
    case 'gallery':
      $gallery = $a2;
      if (node_gallery_user_access('edit', $gallery)) {
        $items[] = array(
          'title' => t('Edit gallery'),
          'href' => "node/{$gallery->nid}/edit",
          'query' => array(
            'destination' => "node/{$gallery->nid}",
          ),
        );
      }
      if (node_gallery_user_access('upload', $gallery)) {
        $items[] = array(
          'title' => t('Upload images'),
          'href' => "node/{$gallery->nid}/upload",
          'query' => array(
            'destination' => "node/{$gallery->nid}",
          ),
        );
      }
      if (node_gallery_user_access('edit image', $gallery) && $gallery->image_count) {
        $items[] = array(
          'title' => t('Edit images'),
          'href' => "node/{$gallery->nid}/edit/images",
          'query' => array(
            'destination' => "node/{$gallery->nid}",
          ),
        );
      }
      if (node_gallery_user_access('delete', $gallery)) {
        $items[] = array(
          'title' => t('Delete gallery'),
          'href' => "node/{$gallery->nid}/delete",
          'query' => array(
            'destination' => "galleries/{$gallery->uid}",
          ),
        );
      }
      $items[] = array(
        'title' => t('Back to !name\'s gallery list', array(
          '!name' => $gallery->name,
        )),
        'href' => 'galleries/' . $gallery->uid,
      );
      break;
    case 'image':
      $image = $a2;
      if (node_gallery_image_user_access('edit', $image)) {
        $items[] = array(
          'title' => t('Edit image'),
          'href' => 'node/' . $image->nid . "/edit",
        );
      }
      $items[] = array(
        'title' => t('Back to gallery'),
        'href' => 'node/' . $image->gid,
      );
      break;
  }
  return theme('links', $items, array(
    'class' => 'gallery-operations',
  ));
}