Index: flickr.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/flickr/flickr.module,v retrieving revision 1.29 diff -u -r1.29 flickr.module --- flickr.module 15 Feb 2007 02:54:46 -0000 1.29 +++ flickr.module 15 Feb 2007 03:50:57 -0000 @@ -45,6 +45,14 @@ 'access' => TRUE, 'type' => MENU_CALLBACK, 'callback' => 'flickr_auth_callback'); + + $items[] = array( + 'path' => 'flickr', + 'title' => t('Flickr photos'), + 'access' => TRUE, + 'type' => MENU_CALLBACK, + 'callback' => 'flickr_photos', + 'description' => t('Flickr photos of default user id.')); } else { if (arg(0) == 'flickr' && is_numeric(arg(1)) && arg(1) > 0) { @@ -114,6 +122,7 @@ // we need an api key before we can verify usernames if (!$form['flickr_api_key']['#default_value']) { $form['flickr_default_userid']['#disabled'] = TRUE; + $form['flickr_default_userid']['#description'] = t("An, optional, default Flickr username or user id. Disabled until a valid API Key is set."); } return system_settings_form($form); @@ -242,7 +251,7 @@ } } -function flickr_photos($uid) { +function flickr_photos($uid=NULL) { drupal_add_css(drupal_get_path('module', 'flickr') .'/flickr.css'); global $pager_page_array, $pager_total,$pager_total_items; @@ -250,10 +259,30 @@ $element = 0; $pager_page_array[$element] = $_GET['page'] ? $_GET['page'] : ''; - $photo_arr = flickr_photos_get($uid, array(), $pager_page_array[$element]+1); + if($uid === NULL) { + $nsid = variable_get('flickr_default_userid', ''); + if(!$nsid) { + drupal_set_message(t('No default user id is setup.')); + 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; + } + } + + $photo_arr = flickr_photos_get($nsid, array(), $pager_page_array[$element]+1); - if ($photo_arr == FALSE) { - return ''; + + if (!isset($photo_arr['photos']) || empty($photo_arr['photos']) ) { + drupal_set_message(t('No accessible photos found for Flickr %userid', array('%userid'=> $nsid))); + return FALSE; } //set pager information we just acquired @@ -264,16 +293,7 @@ } -function flickr_photos_get($uid, $tags=array(), $page=1, $other_args=array()){ - $account = user_load(array('uid' => $uid)); - if (isset($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; - } - +function flickr_photos_get($nsid, $tags=array(), $page=1, $other_args=array()){ $args = array ( 'user_id' => $nsid, 'page' => $page, @@ -299,12 +319,8 @@ if (flickr_error($search_response)) { flickr_set_error($search_response); return FALSE; - } - if (!isset($search_response['photos']) || empty($search_response['photos']) ) { - drupal_set_message(t('%user has no accessible photos on Flickr', array('%user'=>$account->name))); - return FALSE; } - + return $search_response; }