You are here

function flickr_photos in Flickr 5

Same name and namespace in other branches
  1. 6 flickr.module \flickr_photos()
  2. 7 flickr.module \flickr_photos()
1 string reference to 'flickr_photos'
flickr_menu in ./flickr.module
Implementation of hook_menu().

File

./flickr.module, line 265

Code

function flickr_photos($uid = NULL) {
  drupal_add_css(drupal_get_path('module', 'flickr') . '/flickr.css');
  global $pager_page_array, $pager_total, $pager_total_items;

  //set this to something else if you want multiple pagers
  $element = 0;
  $pager_page_array[$element] = empty($_GET['page']) ? 0 : (int) $_GET['page'];
  if ($uid === NULL) {
    $nsid = variable_get('flickr_default_userid', '');
    if (!$nsid) {
      drupal_set_message(t('No default Flickr user id has been set.'));
      return FALSE;
    }
  }
  else {
    $account = user_load(array(
      'uid' => $uid,
    ));
    if ($account->flickr['nsid']) {
      $nsid = $account->flickr['nsid'];
    }
    else {
      drupal_set_message(t('%user does not have a Flickr account', array(
        '%user' => $account->name,
      )), 'error');
      return FALSE;
    }
  }
  $photos = flickr_photos_search($nsid, $pager_page_array[$element] + 1);
  if (!$photos) {
    drupal_set_message(t('No accessible photos found for Flickr %userid', array(
      '%userid' => $nsid,
    )));
    return FALSE;
  }

  //set pager information we just acquired
  $pager_total[$element] = $photos['pages'];
  $pager_total_items[$element] = $photos['total'];
  return theme('flickr_photos', $uid, $photos);
}