You are here

function flickr_sets_photosets in Flickr 7

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

Return a user's photosets (one thumb per set).

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

File

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

Code

function flickr_sets_photosets($account, $nsid = NULL) {
  global $pager_page_array, $pager_total, $pager_total_items, $user;
  drupal_set_title(flickr_sets_page_title($user));
  $uid = $account->uid;
  $nsid = $account->flickr['nsid'];

  // 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_per_page', 8);

  // First we need the complete list of sets just for the pager info.
  $set_response = flickr_photosets_getlist($nsid);
  $pager_total[$element] = ceil(count($set_response) / variable_get('flickr_sets_per_page', 8));
  $pager_total_items[$element] = count($set_response);

  // Now we only get the sets for the corresponding page.
  $set_response = flickr_photosets_getlist($nsid, $pager_page_array[$element] + 1);
  if ($set_response === FALSE) {
    drupal_set_message(t("Error retrieving %user's photosets from Flickr", array(
      '%user' => $account->name,
    )));
    return '';
  }
  if (!$set_response || empty($set_response)) {
    drupal_set_message(t('%user has no photosets', array(
      '%user' => $account->name,
    )));
    return '';
  }
  return theme('flickr_sets_photosets', array(
    'uid' => $uid,
    'per_page' => $per_page,
    'nsid' => $nsid,
    'photosets' => $set_response,
  ));
}