You are here

function flickr_sets_photoset in Flickr 7

Same name and namespace in other branches
  1. 5 sets/flickr_sets.module \flickr_sets_photoset()
  2. 6 sets/flickr_sets.module \flickr_sets_photoset()

Return a user's photos from a given set.

1 string reference to 'flickr_sets_photoset'
flickr_sets_menu in sets/flickr_sets.module
Implements hook_menu().

File

sets/flickr_sets.module, line 113
The Flickr sets module.

Code

function flickr_sets_photoset($account, $set) {
  global $pager_page_array, $pager_total, $pager_total_items, $user;
  $uid = $account->uid;
  $nsid = $account->flickr['nsid'];
  $id = $set['photoset']['id'];
  $set_info = flickr_photosets_getinfo($id);

  // Make sure that $nsid is the real owner of $id.
  if ($nsid != $set_info['owner']) {
    drupal_goto('flickr/' . $uid . '/sets');
  }

  // Display photos.
  // Set this to something else if you want multiple pagers.
  $element = 0;
  $pager_page_array[$element] = empty($_GET['page']) ? 0 : (int) $_GET['page'];
  $per_page = variable_get('flickr_sets_photos_per_set', 6);

  // Request set of photos.
  $set_response = flickr_set_load($id, $pager_page_array[$element] + 1);
  if (!$set_response) {
    drupal_set_message(t("Error retrieving :setid's photosets from Flickr"), array(
      ':setid',
      $id,
    ));
    return '';
  }
  elseif (!isset($set_response['photoset']['photo']) || empty($set_response['photoset']['photo'])) {
    drupal_set_message(t('This photoset is empty'));
    return '';
  }

  // Set pager information we just acquired.
  $pager_total_items[$element] = $set_response['photoset']['total'];
  $pager_total[$element] = $set_response['photoset']['pages'];
  return theme('flickr_sets_photoset', array(
    'uid' => $uid,
    'per_page' => $per_page,
    'photo_arr' => $set_response,
    'set_info' => $set_info,
  ));
}