=== added file 'field/flickrfield.install'
--- field/flickrfield.install	1970-01-01 00:00:00 +0000
+++ field/flickrfield.install	2008-03-23 00:02:10 +0000
@@ -0,0 +1,40 @@
+<?php
+// $Id$
+
+// Borrowed shamelessly from cck/text.install
+
+// Updates happen in random order, whether or not the module is enabled,
+// so include critical code here just to be sure.
+include_once('./'. drupal_get_path('module', 'content') .'/content.module');
+
+/**
+ * Implementation of hook_install().
+ */
+function flickrfield_install() {
+  content_notify('install', 'flickrfield');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function flickrfield_uninstall() {
+  content_notify('uninstall', 'flickrfield');
+}
+
+/**
+ * Implementation of hook_enable().
+ *
+ * Notify content module when this module is enabled.
+ */
+function flickrfield_enable() {
+  content_notify('enable', 'flickrfield');
+}
+
+/**
+ * Implementation of hook_disable().
+ *
+ * Notify content module when this module is disabled.
+ */
+function flickrfield_disable() {
+  content_notify('disable', 'flickrfield');
+}

=== added file 'flickr.admin.inc'
--- flickr.admin.inc	1970-01-01 00:00:00 +0000
+++ flickr.admin.inc	2008-03-23 00:02:10 +0000
@@ -0,0 +1,89 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_settings
+ */
+function flickr_admin_settings() {
+  $form['flickr_api_key'] = array(
+    '#type' => 'textfield',
+    '#title' => t('API Key'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_api_key', ''),
+    '#description' => t('API Key from Flickr'),
+  );
+  $form['flickr_api_secret'] = array(
+    '#type' => 'textfield',
+    '#title' => t('API Shared Secret'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_api_secret', ''),
+    '#description' => t("API key's secret from Flickr."),
+  );
+  $form['flickr_default_userid'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default Flickr User Id'),
+    '#default_value' => variable_get('flickr_default_userid', ''),
+    '#description' => t("An, optional, default Flickr username or user id. This will be used when no user is specified."),
+  );
+  $times = array(900, 1800, 2700, 3600, 7200, 10800, 14400, 18000, 21600, 43200, 86400);
+  $ageoptions = drupal_map_assoc($times, 'format_interval');
+  $form['flickr_cache_duration'] = array(
+    '#type' => 'select',
+    '#title' => t('Update interval'),
+    '#options' => $ageoptions,
+    '#default_value' => variable_get('flickr_cache_duration', 3600),
+    '#description' => t("The refresh interval indicating how often you want to check cached Flickr API calls are up to date."),
+  );
+
+  // 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(" Disabled until a valid API Key is set.");
+  }
+
+  return system_settings_form($form);
+}
+
+function flickr_admin_settings_validate($form, &$form_state) {
+  $key = trim($form_state['values']['flickr_api_key']);
+  $sec = trim($form_state['values']['flickr_api_secret']);
+  $uid = trim($form_state['values']['flickr_default_userid']);
+
+  if ($key && (preg_match('/^[A-Fa-f\d]{32}$/', $key) != 1)) {
+    form_set_error('flickr_api_key', t('This does not appear to be a Flickr API key.'));
+  }
+  if ($sec && (preg_match('/^[A-Fa-f\d]{16}$/', $sec) != 1)) {
+    form_set_error('flickr_api_secret', t('This does not appear to be a Flickr API secret.'));
+  }
+  if ($uid) {
+    if (flickr_is_nsid($uid)) {
+      // it's already a uid
+    }
+    else {
+      $user = flickr_user_find_by_username($uid);
+      if (!$user) {
+        form_set_error('flickr_default_userid', t('%uid is not a Flickr user id and it does not appear to be a valid user name.', array('%uid' => $uid)));
+      }
+    }
+  }
+}
+
+function flickr_admin_settings_submit($form, &$form_state) {
+  // clean up the data ...
+  $form_state['values']['flickr_api_key'] = trim($form_state['values']['flickr_api_key']);
+  $form_state['values']['flickr_api_secret'] = trim($form_state['values']['flickr_api_secret']);
+  $form_state['values']['flickr_default_userid'] = trim($form_state['values']['flickr_default_userid']);
+
+  // ... replace the usernames with a user id ...
+  if (!flickr_is_nsid($form_state['values']['flickr_default_userid'])) {
+    $username = $form_state['values']['flickr_default_userid'];
+    if ($user = flickr_user_find_by_username($username)) {
+      drupal_set_message(t("The Flickr username %username has been replaced with the corresponding user id %uid.", array('%username' => $form_state['values']['flickr_default_userid'], '%uid' => $user['id'])));
+      $form_state['values']['flickr_default_userid'] = $user['id'];
+    }
+  }
+
+  // ... and save the settings
+  system_settings_form_submit($form, &$form_state);
+}
+

=== modified file 'block/flickr_block.info'
--- block/flickr_block.info	2008-03-22 23:59:41 +0000
+++ block/flickr_block.info	2008-03-23 00:02:10 +0000
@@ -1,5 +1,6 @@
-; $Id: flickr_block.info,v 1.4 2008/03/20 22:33:30 drewish Exp $
+; $Id: flickr_block.info,v 1.2.2.1 2007/06/18 23:06:43 dww Exp $
 name = Flickr Block
 description = Flickr Block for inserting photos into content.
-dependencies = flickr
+dependencies[] = flickr
 package = Flickr
+core = 6.x

=== modified file 'block/flickr_block.install'
--- block/flickr_block.install	2008-03-22 23:59:41 +0000
+++ block/flickr_block.install	2008-03-23 00:02:10 +0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: flickr_block.install,v 1.4 2008/03/20 22:33:30 drewish Exp $
+// $Id: flickr_block.install,v 1.2.2.1 2007/08/27 23:08:40 drewish Exp $
 
 function flickr_block_uninstall() {
   foreach (range(0, 6) as $delta) {

=== modified file 'block/flickr_block.module'
--- block/flickr_block.module	2008-03-22 23:59:41 +0000
+++ block/flickr_block.module	2008-03-23 00:02:10 +0000
@@ -1,6 +1,6 @@
 <?php
 
-// $Id: flickr_block.module,v 1.11 2008/03/20 22:33:30 drewish Exp $
+// $Id: flickr_block.module,v 1.9.2.3 2008/02/02 23:59:19 drewish Exp $
 
 
 /**
@@ -115,11 +115,13 @@
       $settings['user_id'] = variable_get('flickr_default_userid', '');
     }
 
+    $block = array();
+
     // Get per user nsid if necessary
     if ($delta < 3) {
       if (arg(0) == 'user' && ($uid = (int) arg(1))) {
         if ($user = user_load(array('uid' => $uid))) {
-          if ($user->flickr['nsid']) {
+          if (!empty($user->flickr['nsid'])) {
             if ($delta == 0) {
               $block['subject'] = t("%username's recent Flickr photos", array('%username' => $user->name));
               $block['content'] = _flickr_block_recent($user->flickr['nsid'], $settings['show_n'], $settings['size']);
@@ -192,10 +194,24 @@
   return $output;
 }
 
+/**
+ * Implementation of hook_theme().
+ */
+function flickr_block_theme() {
+  return array(
+    'flickr_block_photo' => array(
+      'arguments' => array('p', 'size' => NULL),
+    ),
+    'flickr_block_photoset' => array(
+      'arguments' => array('ps', 'owner', 'size'),
+    ),
+  );
+}
+
 function theme_flickr_block_photo($p, $size = NULL) {
-  return theme('flickr_photo',$p, $size);
+  return theme('flickr_photo', $p, $size);
 }
 
 function theme_flickr_block_photoset($ps, $owner, $size) {
-  return theme('flickr_photoset',$ps, $owner, $size);
+  return theme('flickr_photoset', $ps, $owner, $size);
 }

=== modified file 'field/flickrfield.info'
--- field/flickrfield.info	2008-03-22 23:59:41 +0000
+++ field/flickrfield.info	2008-03-23 00:02:10 +0000
@@ -1,6 +1,7 @@
-; $Id: flickrfield.info,v 1.2 2008/03/20 22:33:30 drewish Exp $
+; $Id: flickrfield.info,v 1.1.2.1 2007/11/26 15:53:01 drewish Exp $
 name = Flickrfield
 description = Flickr CCK field to insert Flickr images into content.
-version = "$Name: HEAD $"
-dependencies = flickr content
+dependencies[] = flickr
+dependencies[] = content
 package = CCK
+core = 6.x

=== modified file 'field/flickrfield.module'
--- field/flickrfield.module	2008-03-22 23:59:41 +0000
+++ field/flickrfield.module	2008-03-23 00:02:10 +0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: flickrfield.module,v 1.2 2008/03/20 22:33:30 drewish Exp $
+// $Id: flickrfield.module,v 1.1.2.1 2007/11/14 00:21:33 drewish Exp $
 
 /**
  * @file
@@ -11,16 +11,14 @@
 /**
  * Include css unconditionally.
  */
-function flickrfield_menu($may_cache) {
-  if (!$may_cache) {
-    drupal_add_css(drupal_get_path('module', 'flickr') .'/flickr.css');
-  }
+function flickrfield_init() {
+  drupal_add_css(drupal_get_path('module', 'flickr') .'/flickr.css');
 }
 
 /**
  * Implementation of hook_help().
  */
-function flickrfield_help($section) {
+function flickrfield_help($section, $arg) {
   switch ($section) {
     case 'admin/help#flickrfield':
       return t('Flickrfields display Flickr photos or photosets. Input the user id of the photo owner and the photo or photoset id. The id is visible in the url when you view the photo or photoset on Flickr.');
@@ -32,7 +30,10 @@
  */
 function flickrfield_field_info() {
   return array(
-    'flickrfield' => array('label' => 'Flickr Photo'),
+    'flickrfield' => array(
+      'label' => 'Flickr Photo',
+      'description' => t('Blargh! Flickr photo!'),
+    ),
   );
 }
 
@@ -69,14 +70,75 @@
     'flickrfield' => array(
       'label' => 'Flickr Photo',
       'field types' => array('flickrfield'),
-    ),
+      'multiple values' => CONTENT_HANDLE_CORE,
+      'callbacks' => array(
+        'default value' => CONTENT_CALLBACK_DEFAULT,
+      ),
+    ),
+  );
+}
+
+function flickrfield_elements() {
+  return array(
+    'flickrfield' => array(
+      '#input' => TRUE,
+      //'#columns' => array('type', 'id', 'uid'),
+      //'#process' => array('flickrfield_process'),
+    ),
+  );
+}
+
+function flickrfield_widget(&$form, &$form_state, $field, $items, $delta = 0) {
+  $element = array(
+    '#type' => $field['widget']['type'],
+    '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
+  );
+  return $element;
+}
+
+/*
+function flickrfield_process($element, $edit, $form_state, $form) {
+  $field_key = $element['#columns'][0];
+  $element[$field_key] = array(
+    '#type' => 'fieldset',
+    '#title' => 'Item',
+    '#default_value' => isset($element['#value']) ? $element['#value'] : '',
+    '#element_validate' => array('flickrfield_validate'),
+
+    // The following values were set by the content module and need
+    // to be passed down to the nested element.
+    '#field_name' => $element['#field_name'],
+    '#delta' => $element['#delta'],
+    '#columns' => $element['#columns'],
+    '#title' => $element['#title'],
+    '#required' => $element['#required'],
+    '#description' => $element['#description'],
+  );
+  $element[$field_key]['type'] = array(
+    '#type' => 'select',
+    '#title' => t('Item Type'),
+    '#default_value' => 'nubba',
+    '#options' => array('photo_id' => t('Photo'), 'set_id' => t('Photoset')),
+  );
+  return $element;
+}
+ */
+
+function theme_flickrfield($element) {
+  var_dump($element);
+  return theme('form_element', array(
+      '#title' => 'Item',
+      '#description' => 'Noooooo!',
+      '#type' => 'text',
+    ),
+    $element['#value']
   );
 }
 
 /**
  * Implementation of hook_widget().
  */
-function flickrfield_widget($op, &$node, $field, &$items) {
+function flickrfield_widgeto($op, &$node, $field, &$items) {
   switch ($op) {
     case 'form':
       $form = array();
@@ -134,6 +196,13 @@
 }
 
 /**
+ * Implementation of hook_content_is_empty().
+ */
+function flickrfield_content_is_empty($item, $field) {
+  return empty($item['id']);
+}
+
+/**
  * Implementation of hook_field_formatter_info().
  */
 function flickrfield_field_formatter_info() {
@@ -168,6 +237,23 @@
 }
 
 /**
+ * Implementation of hook_theme().
+ */
+function flickrfield_theme() {
+  return array(
+    'flickrfield_photo' => array(
+      'arguments' => array('img', 'photo_url', 'formatter', 'photo_data', 'node'),
+    ),
+    'flickrfield_photoset' => array(
+      'arguments' => array('img', 'photo_url', 'formatter', 'photo_data', 'node'),
+    ),
+    'flickrfield' => array(
+      'arguments' => array('element'),
+    ),
+  );
+}
+
+/**
  * Flickrfield photo themes.
  *
  * If we are not on the node, make the photo link back to the node,
@@ -196,4 +282,4 @@
   }
   $output .= '<div class="flickr-citation"><cite>'. l(t('Source: Flickr'), $photo_url) .'</cite></div>';
   return $output;
-}
\ No newline at end of file
+}

=== modified file 'filter/flickr_filter.info'
--- filter/flickr_filter.info	2008-03-22 23:59:41 +0000
+++ filter/flickr_filter.info	2008-03-23 00:02:10 +0000
@@ -1,5 +1,6 @@
-; $Id: flickr_filter.info,v 1.5 2008/03/20 22:33:30 drewish Exp $
+; $Id: flickr_filter.info,v 1.3.2.1 2007/06/18 23:06:43 dww Exp $
 name = Flickr Filter
 description = Flickr Filter for inserting photos into content.
-dependencies = flickr
+dependencies[] = flickr
 package = Flickr
+core = 6.x

=== modified file 'filter/flickr_filter.module'
--- filter/flickr_filter.module	2008-03-22 23:59:41 +0000
+++ filter/flickr_filter.module	2008-03-23 00:02:10 +0000
@@ -1,6 +1,6 @@
 <?php
 
-// $Id: flickr_filter.module,v 1.11 2008/03/20 22:33:30 drewish Exp $
+// $Id: flickr_filter.module,v 1.9.2.3 2008/02/02 23:59:19 drewish Exp $
 
 require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
 
@@ -103,10 +103,24 @@
   return '';
 }
 
+/**
+ * Implementation of hook_theme().
+ */
+function flickr_filter_theme() {
+  return array(
+    'flickr_filter_photo' => array(
+      'arguments' => array('p', 'size', 'attribs'),
+    ),
+    'flickr_filter_photoset' => array(
+      'arguments' => array('ps', 'owner', 'size', 'attribs'),
+    ),
+  );
+}
+
 function theme_flickr_filter_photo($p, $size, $attribs) {
-  return theme('flickr_photo',$p, $size, NULL, $attribs);
+  return theme('flickr_photo', $p, $size, NULL, $attribs);
 }
 
 function theme_flickr_filter_photoset($ps, $owner, $size, $attribs) {
-  return theme('flickr_photoset',$ps, $owner, $size, $attribs);
+  return theme('flickr_photoset', $ps, $owner, $size, $attribs);
 }

=== modified file 'flickr.css'
--- flickr.css	2008-03-22 23:59:41 +0000
+++ flickr.css	2008-03-23 00:02:10 +0000
@@ -1,4 +1,4 @@
-/* $Id: flickr.css,v 1.3 2008/03/20 22:33:30 drewish Exp $ */
+/* $Id: flickr.css,v 1.1 2006/12/02 23:39:09 drewish Exp $ */
 
 .flickr-photos {}
 

=== modified file 'flickr.inc'
--- flickr.inc	2008-03-22 23:59:41 +0000
+++ flickr.inc	2008-03-23 00:02:10 +0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: flickr.inc,v 1.27 2008/03/20 22:33:30 drewish Exp $
+// $Id: flickr.inc,v 1.25.2.5 2007/07/20 18:22:22 andrewlevine Exp $
 
 define('FLICKR_REST_ENDPOINT', 'http://api.flickr.com/services/rest/');
 
@@ -127,7 +127,7 @@
 
   // Save cacheable results for future use.
   if ($cacheable) {
-    cache_set("flickr_$arg_hash", 'cache', $result->data, time() + variable_get('flickr_cache_duration', 3600));
+    cache_set("flickr_$arg_hash", $result->data, 'cache', time() + variable_get('flickr_cache_duration', 3600));
   }
 
   return $response;
@@ -159,6 +159,9 @@
   if (!isset($attributes) || !is_array($attributes)) {
     $attributes = array();
   }
+  if (empty($attributs['class'])) {
+    $attributes['class'] = NULL;
+  }
 
   // photoset's use primary instead of id to specify the image.
   if (isset($photo['primary'])) {

=== modified file 'flickr.info'
--- flickr.info	2008-03-22 23:59:41 +0000
+++ flickr.info	2008-03-23 00:02:10 +0000
@@ -1,4 +1,5 @@
-; $Id: flickr.info,v 1.6 2008/03/20 22:33:30 drewish Exp $
+; $Id: flickr.info,v 1.4.2.1 2007/06/18 23:06:43 dww Exp $
 name = Flickr
 description = Flickr and Drupal integration.
 package = Flickr
+core = 6.x

=== modified file 'flickr.install'
--- flickr.install	2008-03-22 23:59:41 +0000
+++ flickr.install	2008-03-23 00:02:10 +0000
@@ -1,60 +1,44 @@
 <?php
-// $Id: flickr.install,v 1.4 2008/03/20 22:33:30 drewish Exp $
+// $Id: flickr.install,v 1.2 2007/01/06 00:41:03 andrewlevine Exp $
 
 function flickr_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query('
-        CREATE TABLE {flickr_users} (
-          `uid` INT( 10 ) UNSIGNED NOT NULL ,
-          `nsid` VARCHAR( 64 ) NOT NULL, 
-          `identifier` VARCHAR( 64 ) NOT NULL ,
-          PRIMARY KEY ( `uid` )
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;
-      ');
-      break;
-    case 'pgsql':
-      db_query('
-        CREATE TABLE {flickr_users} (
-          uid integer NOT NULL PRIMARY KEY,
-          nsid varchar(64) NOT NULL,
-          identifier varchar(64) NOT NULL
-        );
-      ');
-      break;
-  }
+  drupal_install_schema('flickr');
 }
 
 function flickr_uninstall() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query('DROP TABLE IF EXISTS {flickr_users}');
-      break;
-    case 'pgsql':
-      db_query('DROP TABLE {flickr_users}');
-      break;
-  }
+  drupal_uninstall_schema('flickr');
+}
+
+function flickr_schema() {
+  $schema['flickr_users'] = array(
+    'description' => t('Connects Drupal users to their Flickr accounts.'),
+    'fields' => array(
+      'uid' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'description' => t('Primary Key: Drupal user ID'),
+      ),
+      'nsid' => array(
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
+        'description' => t('Flickr NSID'),
+      ),
+      'identifier' => array(
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
+        'description' => t('Flickr identifier'),
+      ),
+    ),
+    'primary key' => array('uid'),
+  );
+  return $schema;
 }
 
 /**
  * Adding a table to map Drupal users to Flickr users
  */
 function flickr_update_1() {
-  $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql('
-        CREATE TABLE IF NOT EXISTS {flickr_users} (
-          `uid` INT( 10 ) UNSIGNED NOT NULL ,
-          `nsid` VARCHAR( 64 ) NOT NULL, 
-          `identifier` VARCHAR( 64 ) NOT NULL ,
-          PRIMARY KEY ( `uid` )
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;
-      ');
-      break;
-  }
-  return $ret;
+  flickr_install();
 }

=== modified file 'flickr.module'
--- flickr.module	2008-03-22 23:59:41 +0000
+++ flickr.module	2008-03-23 00:02:10 +0000
@@ -1,16 +1,16 @@
 <?php
 
-// $Id: flickr.module,v 1.39 2008/03/20 22:33:30 drewish Exp $
+// $Id: flickr.module,v 1.37.2.4 2008/02/26 00:10:39 drewish Exp $
 
 require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
 
 /**
  * Implementation of hook_help().
  */
-function flickr_help($section) {
+function flickr_help($section, $arg) {
   switch ($section) {
     case 'admin/settings/flickr':
-     return t("You will need a Flickr API key to use this module. You can apply for one at <a href='@link'>@link</a>", array('@link' => url('http://www.flickr.com/services/api/keys/apply/')));
+      return t("You will need a Flickr API key to use this module. You can apply for one at <a href='@link'>@link</a>", array('@link' => url('http://www.flickr.com/services/api/keys/apply/')));
     case 'admin/help#flickr':
       return t('The flickr module uses XML-RPC to connect to Flickr\'s API and retreive photo information.');
   }
@@ -28,184 +28,81 @@
 }
 
 /**
+ * Implementation of hook_theme().
+ */
+function flickr_theme() {
+  return array(
+    'flickr_photo' => array(
+      'arguments' => array('size' => NULL, 'format' => NULL, 'attribs' => NULL),
+    ),
+    'flickr_photo_box' => array(
+      'arguments' => array('p', 'size' => NULL, 'format' => NULL, 'attribs' => NULL),
+    ),
+    'flickr_photos' => array(
+      'arguments' => array('uid' => NULL, 'photos' => NULL),
+    ),
+    'flickr_photoset' => array(
+      'arguments' => array('ps', 'owner', 'size', 'attribs' => NULL),
+    ),
+  );
+}
+
+/**
  * Implementation of hook_menu().
  */
-function flickr_menu($may_cache) {
-  global $user;
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/flickr', 'title' => t('Flickr'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('flickr_admin_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-      'description' => t('Change settings for the flickr module.'));
-
-    $items[] = array(
-      'path' => 'flickr',
-      'title' => t('Flickr photos'),
-      'access' => TRUE,
-      'type' => MENU_CALLBACK,
-      'callback' => 'flickr_photos',
-      'description' => t('Flickr photos of default user id.'));
-
-    $items[] = array(
-      'path' => 'flickr/auth',
-      'access' => TRUE,
-      'type' => MENU_CALLBACK,
-      'callback' => 'flickr_auth_callback');
-  }
-  else {
-    if (arg(0) == 'flickr' && is_numeric(arg(1)) && arg(1) > 0) {
-      $account = user_load(array('uid' => arg(1)));
-      if ($account !== FALSE && isset($account->flickr['nsid'])) {
-        $nsid = $account->flickr['nsid'];
-        $admin_access = user_access('administer flickr');
-        // let a user view their own account or all if they have permission
-        $view_access |= (user_access('view own flickr photos') && ($user->uid == arg(1))) ||
-          user_access('view all flickr photos');
+function flickr_menu() {
+  $items['admin/settings/flickr'] = array(
+    'title' => 'Flickr',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('flickr_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+    'description' => 'Change settings for the flickr module.',
+    'file' => 'flickr.admin.inc',
+  );
+  $items['flickr'] = array(
+    'title' => 'Flickr photos',
+    'type' => MENU_CALLBACK,
+    'page callback' => 'flickr_photos',
+    'access callback' => TRUE,
+    'description' => 'Flickr photos of default user id.',
+  );
+  $items['flickr/%user'] = array(
+    'title' => 'Flickr photos',
+    'type' => MENU_CALLBACK,
+    'page callback' => 'flickr_photos',
+    'page arguments' => array(1),
+    'access callback' => 'flickr_photos_access',
+    'access arguments' => array(1),
+    'description' => 'Flickr photos of specified user.',
+  );
+  $items['flickr/auth'] = array(
+    'type' => MENU_CALLBACK,
+    'access callback' => TRUE,
+    'page callback' => 'flickr_auth_callback',
+  );
+  return $items;
+}
+
+function flickr_photos_access($account) {
+  $view_access = FALSE;
+  if (!empty($account) && !empty($account->uid)) {
+    if (isset($account->flickr['nsid'])) {
+      $view_access = user_access('administer flickr') ||
         // Only admins can view blocked accounts
-        $view_access &= $account->status || $admin_access;
-
-        //main flickr user page(photos)
-        $items[] = array(
-          'path' => 'flickr/'. arg(1),
-          'title' => t("@user's Flickr", array('@user' => $account->name)),
-          'type' => MENU_CALLBACK,
-          'callback' => 'flickr_photos',
-          'callback arguments' => array(arg(1)),
-          'access' => $view_access,
-        );
-        $items[] = array(
-          'path' => 'flickr/'. arg(1) .'/photos',
-          'title' => t('Photos'),
-          'type' => MENU_DEFAULT_LOCAL_TASK,
-          'weight' => -10,
-          'access' => $view_access,
-        );
-      }
-      elseif ($account !== FALSE && !isset($account->flickr['nsid'])) {
-        drupal_set_message(t('%user does not have a Flickr account', array('%user' => $account->name)), 'error');
-      }
-    }
-  }
-
-  return $items;
-}
-
-/**
- * Implementation of hook_settings
- */
-function flickr_admin_settings() {
-  $form['#validate'] = array('flickr_admin_settings_validate' => array());
-  $form['flickr_api_key'] = array(
-    '#type' => 'textfield',
-    '#title' => t('API Key'),
-    '#required' => TRUE,
-    '#default_value' => variable_get('flickr_api_key', ''),
-    '#description' => t('API Key from Flickr'),
-  );
-  $form['flickr_api_secret'] = array(
-    '#type' => 'textfield',
-    '#title' => t('API Shared Secret'),
-    '#required' => TRUE,
-    '#default_value' => variable_get('flickr_api_secret', ''),
-    '#description' => t("API key's secret from Flickr."),
-  );
-  $form['flickr_default_userid'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Default Flickr User Id'),
-    '#default_value' => variable_get('flickr_default_userid', ''),
-    '#description' => t("An, optional, default Flickr username or user id. This will be used when no user is specified."),
-  );
-  $times = array(900, 1800, 2700, 3600, 7200, 10800, 14400, 18000, 21600, 43200, 86400);
-  $ageoptions = drupal_map_assoc($times, 'format_interval');
-  $form['flickr_cache_duration'] = array(
-    '#type' => 'select',
-    '#title' => t('Update interval'),
-    '#options' => $ageoptions,
-    '#default_value' => variable_get('flickr_cache_duration', 3600),
-    '#description' => t("The refresh interval indicating how often you want to check cached Flickr API calls are up to date."),
-  );
-
-  // 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(" Disabled until a valid API Key is set.");
-  }
-
-  return system_settings_form($form);
-}
-
-function flickr_admin_settings_validate($form_id, $form) {
-  $key = trim($form['flickr_api_key']);
-  $sec = trim($form['flickr_api_secret']);
-  $uid = trim($form['flickr_default_userid']);
-
-  if ($key && (preg_match('/^[A-Fa-f\d]{32}$/', $key) != 1)) {
-    form_set_error('flickr_api_key', t('This does not appear to be a Flickr API key.'));
-  }
-  if ($sec && (preg_match('/^[A-Fa-f\d]{16}$/', $sec) != 1)) {
-    form_set_error('flickr_api_secret', t('This does not appear to be a Flickr API secret.'));
-  }
-  if ($uid) {
-    if (flickr_is_nsid($uid)) {
-      // it's already a uid
+        $account->status && (
+          user_access('view all flickr photos') ||
+          user_access('view own flickr photos') && $GLOBALS['user']->uid == $account->uid
+        );
     }
     else {
-      $user = flickr_user_find_by_username($uid);
-      if (!$user) {
-        form_set_error('flickr_default_userid', t('%uid is not a Flickr user id and it does not appear to be a valid user name.', array('%uid' => $uid)));
-      }
-    }
-  }
-}
-
-function flickr_admin_settings_submit($form_id, $form) {
-  // clean up the data ...
-  $form['flickr_api_key'] = trim($form['flickr_api_key']);
-  $form['flickr_api_secret'] = trim($form['flickr_api_secret']);
-  $form['flickr_default_userid'] = trim($form['flickr_default_userid']);
-
-  // ... replace the usernames with a user id ...
-  if (!flickr_is_nsid($form['flickr_default_userid'])) {
-    $username = $form['flickr_default_userid'];
-    if ($user = flickr_user_find_by_username($username)) {
-      drupal_set_message(t("The Flickr username %username has been replaced with the corresponding user id %uid.", array('%username' => $form['flickr_default_userid'], '%uid' => $user['id'])));
-      $form['flickr_default_userid'] = $user['id'];
-    }
-  }
-
-  // ... and save the settings
-  system_settings_form_submit($form_id, $form);
-}
-
-function theme_flickr_photo($p, $size = NULL, $format = NULL, $attribs = NULL) {
-  $img = flickr_img($p, $size, $attribs);
-  $photo_url = flickr_photo_page_url($p['owner'], $p['id']);
-  $title = is_array($p['title']) ? $p['title']['_content'] : $p['title'];
-  return l($img, $photo_url, array('title' => $title), NULL, NULL, TRUE, TRUE);
-}
-
-function theme_flickr_photo_box($p, $size = NULL, $format = NULL, $attribs = NULL) {
-  $img = flickr_img($p, $size, $attribs);
-  $title = is_array($p['title']) ? $p['title']['_content'] : $p['title'];
-  $photo_url = flickr_photo_page_url($p['owner'], $p['id']);
-
-  $output .= "<div class='flickr-photo-box'>\n";
-  $output .= "<a href='$photo_url'>$img</a>";
-  $output .= "<a href='$photo_url'>";
-  $output .= '<div class="flickr-photo-title">'. $title ."</div>\n";
-  $output .= "</a>";
-  $output .= "</div>\n";
-
-  return $output;
+      drupal_set_message(t('%user does not have a Flickr account', array('%user' => $account->name)), 'error');
+    }
+  }
+  return $view_access;
 }
 
 /**
- * Implimentation of the hook_user()
+ * Implementation of the hook_user()
  * Add an extra field for the user to enter his flickr identifier.
  */
 function flickr_user($op, &$edit, &$account, $category = NULL) {
@@ -222,7 +119,7 @@
       $form['flickr']['flickr_identifier'] = array(
         '#type' => 'textfield',
         '#title' => t('Flickr identifier'),
-        '#default_value' => $user->flickr['identifier'],
+        '#default_value' => empty($user->flickr['identifier']) ? '' : $user->flickr['identifier'],
         '#description' => t('Enter either your Flickr username, the email address associated with your Flickr account, or your Flickr NSID. Leave this box empty to delete your Flickr page on this site.'),
         '#maxlength' => 64,
       );
@@ -252,8 +149,7 @@
   }
   elseif ($op == 'load') {
     $result = db_query('SELECT * FROM {flickr_users} WHERE uid=%d', $account->uid);
-    if (db_num_rows($result) > 0) {
-      $flickr_info = db_fetch_object($result);
+    if ($flickr_info = db_fetch_object($result)) {
       $account->flickr['identifier'] = $flickr_info->identifier;
       $account->flickr['nsid'] = $flickr_info->nsid;
     }
@@ -263,23 +159,24 @@
   }
 }
 
-function flickr_photos($uid = NULL) {
+function flickr_photos($user = 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] = $_GET['page'] ? $_GET['page'] : '';
+  $pager_page_array[$element] = !empty($_GET['page']) ? $_GET['page'] : '';
 
-  if ($uid === NULL) {
+  if ($user === NULL) {
     $nsid = variable_get('flickr_default_userid', '');
     if (!$nsid) {
       drupal_set_message(t('No default Flickr user id has been set.'));
       return FALSE;
     }
+    $uid = 0;
   }
   else {
-    $account = user_load(array('uid' => $uid));
+    $account = $user;
     if ($account->flickr['nsid']) {
       $nsid = $account->flickr['nsid'];
     }
@@ -287,6 +184,7 @@
       drupal_set_message(t('%user does not have a Flickr account', array('%user' => $account->name)), 'error');
       return FALSE;
     }
+    $uid = $account->uid;
   }
 
   $photos = flickr_photos_search($nsid, $pager_page_array[$element]+1);
@@ -302,6 +200,27 @@
   return theme('flickr_photos', $uid, $photos);
 }
 
+function theme_flickr_photo($p, $size = NULL, $format = NULL, $attribs = NULL) {
+  $img = flickr_img($p, $size, $attribs);
+  $photo_url = flickr_photo_page_url($p['owner'], $p['id']);
+  $title = is_array($p['title']) ? $p['title']['_content'] : $p['title'];
+  return l($img, $photo_url, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE));
+}
+
+function theme_flickr_photo_box($p, $size = NULL, $format = NULL, $attribs = NULL) {
+  $img = flickr_img($p, $size, $attribs);
+  $title = is_array($p['title']) ? $p['title']['_content'] : $p['title'];
+  $photo_url = flickr_photo_page_url($p['owner'], $p['id']);
+
+  $output = "<div class='flickr-photo-box'>\n";
+  $output .= "<a href='$photo_url'>$img</a>";
+  $output .= "<a href='$photo_url'>";
+  $output .= '<div class="flickr-photo-title">'. $title ."</div>\n";
+  $output .= "</a>";
+  $output .= "</div>\n";
+
+  return $output;
+}
 
 function theme_flickr_photos($uid, $photos) {
   $output = theme('pager', NULL, variable_get('flickr_photos_per_page', 20));
@@ -318,6 +237,6 @@
   $img = flickr_img($ps, $size, $attribs);
   $photo_url = flickr_photoset_page_url($owner, $ps['id']);
   $title = is_array($ps['title']) ? $ps['title']['_content'] : $ps['title'];
-  return l($img, $photo_url, array('title' => $title), NULL, NULL, TRUE, TRUE);
+  return l($img, $photo_url, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE));
 }
 

=== modified file 'sets/flickr_sets.info'
--- sets/flickr_sets.info	2008-03-22 23:59:41 +0000
+++ sets/flickr_sets.info	2008-03-23 00:02:10 +0000
@@ -1,5 +1,6 @@
-; $Id: flickr_sets.info,v 1.7 2008/03/20 22:33:30 drewish Exp $
+; $Id: flickr_sets.info,v 1.6.2.4 2007/08/27 23:09:00 drewish Exp $
 name = Flickr Sets
 description = Add photoset capability to Flickr module
-dependencies = flickr
+dependencies[] = flickr
 package = Flickr
+core = 6.x

=== modified file 'sets/flickr_sets.module'
--- sets/flickr_sets.module	2008-03-22 23:59:41 +0000
+++ sets/flickr_sets.module	2008-03-23 00:02:10 +0000
@@ -1,117 +1,95 @@
 <?php
-//$Id: flickr_sets.module,v 1.7 2008/03/20 22:33:30 drewish Exp $
+//$Id: flickr_sets.module,v 1.6.2.3 2007/08/27 23:08:40 drewish Exp $
 
 require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
 
 /**
  * Implementation of hook_menu().
  */
-function flickr_sets_menu($may_cache) {
-  global $user;
-  $items = array();
-  
-  if ($may_cache) {
-  }
-  else {
-    if (arg(0) == 'flickr' && is_numeric(arg(1)) && arg(1) > 0) {
-      $account = user_load(array('uid' => arg(1)));
-      if ($account !== FALSE && isset($account->flickr['nsid'])) {
-        $nsid = $account->flickr['nsid'];
-        $admin_access = user_access('administer flickr');
-        // let a user view their own account or all if they have permission
-        $view_access |= (user_access('view own flickr photos') && ($user->uid == arg(1))) ||
-          user_access('view all flickr photos');
-        // Only admins can view blocked accounts
-        $view_access &= $account->status || $admin_access;
-        
-        //flickr user set page
-        $items[] = array(
-          'path' => 'flickr/'. arg(1) .'/sets',
-          'title' => t("Sets"),
-          'type' => MENU_LOCAL_TASK, 
-          'callback' => 'flickr_sets_photosets',
-          'callback arguments' => array(arg(1), $nsid),
-          'access' => $view_access,
-        );
-        $items[] = array(
-          'path' => 'flickr/'. arg(1) .'/sets/list',
-          'title' => t("List"),
-          'type' => MENU_DEFAULT_LOCAL_TASK, 
-          'access' => $view_access,
-        );
-        if (arg(3)!=NULL && arg(2)=='sets') {
-          $set_info = flickr_photoset_get_info(arg(3));
-          if ($set_info !== FALSE) {
-            $items[] = array(
-            'path' => 'flickr/'. arg(1) .'/sets/'. arg(3),
-            // Don't check_plain because flickr does it for us.
-            'title' => t("Set: !setname", array('!setname' => $set_info['title']['_content'])),
-            'type' => MENU_LOCAL_TASK,
-            'callback' => 'flickr_sets_photoset',
-            'callback arguments' => array(arg(1), $nsid, arg(3), $set_info),
-            'access' => $view_access,
-            );
-          }
-        }
-      }
-    }
-  }
-
+function flickr_sets_menu() {
+  $items['flickr/%user/sets'] = array(
+    'title' => 'Sets',
+    'type' => MENU_LOCAL_TASK,
+    'page callback' => 'flickr_sets_photosets',
+    'page arguments' => array(1),
+  );
+  $items['flickr/%user/sets/list'] = array(
+    'title' => 'List',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['flickr/%user/sets/%flickr_set'] = array(
+    'title' => 'Flickr photo set',
+    'type' => MENU_LOCAL_TASK,
+    'page callback' => 'flickr_sets_photoset',
+    'page arguments' => array(1, 3),
+  );
   return $items;
 }
 
-function flickr_sets_photosets($uid, $nsid) {
+function flickr_set_load($sid, $page = 1) {
+  return flickr_request('flickr.photosets.getPhotos',
+    array(
+      'photoset_id' => $sid,
+      'page' => $page,
+      'per_page' => variable_get('flickr_photos_per_page', 20),
+    )
+  );
+}
+
+function flickr_sets_photosets($account, $nsid = NULL) {
   global $pager_page_array, $pager_total, $pager_total_items, $user;
 
   drupal_add_css(drupal_get_path('module', 'flickr') .'/flickr.css');
 
-  $account = user_load(array('uid' => $uid));
+  $uid = $account->uid;
+  $nsid = $account->flickr['nsid'];
   //set this to something else if you want multiple pagers
   $element = 0;
-  $pager_page_array[$element] = $_GET['page'] ? $_GET['page'] : '';
-  
+  $pager_page_array[$element] = !empty($_GET['page']) && $_GET['page'] ? $_GET['page'] : '';
+
   $set_response = flickr_photoset_get_list($nsid);
-  
+
   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)));
+      drupal_set_message(t('%user has no photosets.', array('%user' => $account->name)));
     return '';
   }
-  
+
   //set pager information we just acquired
   $pager_total[$element] = ceil(count($set_response)/variable_get('flickr_photosets_per_page', 20));
   $pager_total_items[$element] = count($set_response);
- 
+
   return theme('flickr_sets_photosets', $uid, $nsid, $set_response);
 }
 
-function flickr_sets_photoset($uid, $nsid, $set_id, $set_info) {
+function flickr_sets_photoset($account, $set) {
   global $pager_page_array, $pager_total, $pager_total_items, $user;
 
   drupal_add_css(drupal_get_path('module', 'flickr') .'/flickr.css');
-  
+
+  $uid = $user->uid;
+  $nsid = $account->flickr['nsid'];
+
+  $set_id = $set['photoset']['id'];
+  $set_info = flickr_photoset_get_info($set_id);
+
   //make sure that $nsid is the real owner of $set_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] = $_GET['page'] ? $_GET['page'] : '';
+  $pager_page_array[$element] = !empty($_GET['page']) && $_GET['page'] ? $_GET['page'] : '';
   $per_page = variable_get('flickr_photos_per_page', 20);
-  
+
   //request set photos
-  $set_response = flickr_request('flickr.photosets.getPhotos', 
-    array(
-      'photoset_id' => $set_id,
-      'page' => $pager_page_array[$element]+1,
-      'per_page' => variable_get('flickr_photos_per_page', 20),
-     ));
-  
+  $set_response = flickr_set_load($set_id, $pager_page_array[$element]+1);
+
   if (!$set_response) {
     drupal_set_message(t('Error retrieving :setid\'s photosets from Flickr'), array(':setid', $set_id));
     return '';
@@ -120,30 +98,46 @@
       drupal_set_message('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', $uid, $per_page, $set_response, $set_info);
 }
 
+/**
+ * Implementation of hook_theme().
+ */
+function flickr_sets_theme() {
+  return array(
+    'flickr_sets_photosets' => array(
+      'arguments' => array('uid', 'nsid', 'photosets'),
+    ),
+    'flickr_sets_photoset' => array(
+      'arguments' => array('uid', 'per_page', 'photo_arr', 'set_info'),
+    ),
+    'flickr_sets_photoset_box' => array(
+      'arguments' => array('ps', 'uid', 'owner', 'size' => 'NULL', 'format' => NULL),
+    ),
+  );
+}
 
 function theme_flickr_sets_photosets($uid, $nsid, $photosets) {
-  $output = 
+  $output =
     theme('pager', NULL, variable_get('flickr_photosets_per_page', 20));
   $output .= "<div class='fickr-photosets'>\n";
   foreach ((array) $photosets as $photoset) {
     $output .= theme('flickr_sets_photoset_box', $photoset, $uid, $nsid, 's');
   }
   $output .= '</div>';
-  $output .= 
+  $output .=
     theme('pager', NULL, variable_get('flickr_photosets_per_page', 20));
   return $output;
 }
 
 function theme_flickr_sets_photoset($uid, $per_page, $photo_arr, $set_info) {
-  $output = 
+  $output =
     theme('pager', NULL, variable_get('flickr_photos_per_page', 20));
   $output .= "<div class='fickr-photoset'>\n";
   foreach ((array) $photo_arr['photoset']['photo'] as $photo) {
@@ -152,7 +146,7 @@
     $output .= theme('flickr_photo_box', $photo, 'm');
   }
   $output .= '</div>';
-  $output .= 
+  $output .=
     theme('pager', NULL, variable_get('flickr_photos_per_page', 20));
   return $output;
 }
@@ -160,9 +154,9 @@
 function theme_flickr_sets_photoset_box($ps, $uid, $owner, $size = NULL, $format = NULL) {
   $title = is_array($ps['title']) ? $ps['title']['_content'] : $ps['title'];
 
-  $output .= "<div class='flickr-photoset-box'>\n";
-  $output .= l(flickr_img($ps, $size) ."\n", "flickr/{$uid}/sets/{$ps['id']}", array(), NULL, NULL, FALSE, TRUE);
-  $output .= l('<div class="flickr-photoset-title">'. $title ."</div>\n", "flickr/{$uid}/sets/{$ps['id']}", array(), NULL, NULL, FALSE, TRUE);
+  $output = "<div class='flickr-photoset-box'>\n";
+  $output .= l(flickr_img($ps, $size) ."\n", "flickr/{$uid}/sets/{$ps['id']}", array('html' => TRUE));
+  $output .= l('<div class="flickr-photoset-title">'. $title ."</div>\n", "flickr/{$uid}/sets/{$ps['id']}", array('html' => TRUE));
   $output .= '<div class="flickr-photoset-count">'. format_plural($ps['photos'], '@count photo', '@count photos') ."</div>\n";
   $output .= "</div>\n";
 

=== modified file 'tags/flickr_tags.info'
--- tags/flickr_tags.info	2008-03-22 23:59:41 +0000
+++ tags/flickr_tags.info	2008-03-23 00:02:10 +0000
@@ -1,5 +1,6 @@
-; $Id: flickr_tags.info,v 1.2 2008/03/20 22:33:31 drewish Exp $
+; $Id: flickr_tags.info,v 1.1.2.3 2007/08/27 23:09:00 drewish Exp $
 name = Flickr Tags
 description = Adds tags capability to Flickr module
-dependencies = flickr
+dependencies[] = flickr
 package = Flickr
+core = 6.x

=== modified file 'tags/flickr_tags.module'
--- tags/flickr_tags.module	2008-03-22 23:59:41 +0000
+++ tags/flickr_tags.module	2008-03-23 00:02:10 +0000
@@ -1,74 +1,50 @@
 <?php
 
-//$Id: flickr_tags.module,v 1.2 2008/03/20 22:33:31 drewish Exp $
+//$Id: flickr_tags.module,v 1.1.2.2 2007/08/27 23:08:40 drewish Exp $
 require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
 
 /**
  * Implementation of hook_menu().
  */
-function flickr_tags_menu($may_cache) {
-  global $user;
-  $items = array();
-  
-  if ($may_cache) {
-  }
-  else {
-    if (arg(0) == 'flickr' && is_numeric(arg(1)) && arg(1) > 0) {
-      $account = user_load(array('uid' => arg(1)));
-      if ($account !== FALSE && isset($account->flickr['nsid'])) {
-        $nsid = $account->flickr['nsid'];
-        $admin_access = user_access('administer flickr');
-        // let a user view their own account or all if they have permission
-        $view_access |= (user_access('view own flickr photos') && ($user->uid == arg(1))) ||
-          user_access('view all flickr photos');
-        // Only admins can view blocked accounts
-        $view_access &= $account->status || $admin_access;
-        
-        //flickr main tags page(cloud)
-        $items[] = array(
-          'path' => 'flickr/'. arg(1) .'/tags',
-          'title' => t("Tags"),
-          'type' => MENU_LOCAL_TASK, 
-          'callback' => 'flickr_tags_cloud',
-          'callback arguments' => array(arg(1), $nsid),
-          'access' => $view_access,
-        );
-        $items[] = array(
-          'path' => 'flickr/'. arg(1) .'/tags/cloud',
-          'title' => t("Cloud"),
-          'type' => MENU_DEFAULT_LOCAL_TASK, 
-          'access' => $view_access,
-        );
-        //flickr tag list page
-        $items[] = array(
-          'path' => 'flickr/'. arg(1) .'/tags/list',
-          'title' => t("List"),
-          'type' => MENU_LOCAL_TASK, 
-          'callback' => 'flickr_tags_list',
-          'callback arguments' => array(arg(1), $nsid),
-          'access' => $view_access,
-        );
-        //flickr specific tag page
-        if (arg(3) !== NULL && arg(3) != 'cloud' && arg(3) != 'list') {
-            $items[] = array(
-              'path' => 'flickr/'. arg(1) .'/tags/'. arg(3), 
-              'title' => t('Tags: @tags', array('@tags' => str_replace(',', ', ', arg(3)))),
-              'type' => MENU_LOCAL_TASK,
-              'callback' => 'flickr_tags_photos',
-              'callback arguments' => array(arg(1), $nsid, arg(3)),
-              'access' => $view_access,
-          );
-        }
-      }
-    }
-  }
-
+function flickr_tags_menu() {
+  $items['flickr/%user/tags'] = array(
+    'title' => 'Tags',
+    'description' => 'Flickr main tag cloud page',
+    'type' => MENU_LOCAL_TASK, 
+    'page callback' => 'flickr_tags_cloud',
+    'page arguments' => array(1),
+  );
+  $items['flickr/%user/tags/cloud'] = array(
+    'title' => 'Cloud',
+    'description' => 'Flickr main tag cloud page',
+    'type' => MENU_DEFAULT_LOCAL_TASK, 
+    'page callback' => 'flickr_tags_cloud',
+    'page arguments' => array(1),
+  );
+  $items['flickr/%user/tags/list'] = array(
+    'title' => 'List',
+    'description' => 'Flickr tag list page',
+    'type' => MENU_LOCAL_TASK, 
+    'page callback' => 'flickr_tags_list',
+    'page arguments' => array(1),
+  );
+  $items['flickr/%user/tags/%flickr_tag'] = array(
+    'title' => 'Photos for tag',
+    'description' => 'Show Flickr photos for a particular tag',
+    'type' => MENU_LOCAL_TASK, 
+    'page callback' => 'flickr_tags_photos',
+    'page arguments' => array(1, 3),
+  );
   return $items;
 }
 
-function flickr_tags_cloud($uid, $nsid) {
+function flickr_tag_load($tag, $page = 1) {
+  return $tag;
+}
+
+function flickr_tags_cloud($account, $nsid = NULL) {
   drupal_add_css(drupal_get_path('module', 'flickr_tags') .'/flickr_tags.css');
-  $account = user_load(array('uid' => $uid));
+  $nsid = $account->flickr['nsid'];
   //get tag info
   $poptag_response = flickr_tags_get_list_user_popular($nsid, variable_get('flickr_tags_in_cloud', 150));
   
@@ -87,12 +63,12 @@
     $tag_arr[$tag['_content']] = $tag['count'];
   }
 
-  return theme('flickr_tags_cloud', $uid, $nsid, $tag_arr);
+  return theme('flickr_tags_cloud', $account->uid, $nsid, $tag_arr);
 }
 
-function flickr_tags_list($uid, $nsid) {
+function flickr_tags_list($account, $nsid = NULL) {
   drupal_add_css(drupal_get_path('module', 'flickr_tags') .'/flickr_tags.css');
-  $account = user_load(array('uid' => $uid));
+  $nsid = $account->flickr['nsid'];
   //get all tags
   $taglist_response = flickr_tags_get_list_user($nsid);
   
@@ -113,20 +89,20 @@
   }
   
   //pass array to the theme function
-  return theme('flickr_tags_list', $uid, $nsid, $tag_arr);
+  return theme('flickr_tags_list', $account->uid, $nsid, $tag_arr);
 }
 
-function flickr_tags_photos($uid, $nsid, $tagstring) {
+function flickr_tags_photos($account, $tagstring) {
   global $pager_page_array, $pager_total, $pager_total_items;
 
   drupal_add_css(drupal_get_path('module', 'flickr') .'/flickr.css');
 
   $tag_arr = explode(',', $tagstring);
-  $account = user_load(array('uid' => $uid));
+  $nsid = $account->flickr['nsid'];
   
   //set this to something else if you want multiple pagers
   $element = 0;
-  $pager_page_array[$element] = $_GET['page'] ? $_GET['page'] : '';
+  $pager_page_array[$element] = !empty($_GET['page']) && $_GET['page'] ? $_GET['page'] : '';
   
   $photo_arr = flickr_photos_search($nsid, $pager_page_array[$element]+1, flickr_tag_request_args($tag_arr));
   
@@ -143,7 +119,21 @@
   $pager_total[$element] = $photo_arr['pages'];
   $pager_total_items[$element] = $photo_arr['total'];
   
-  return theme('flickr_photos', $uid, $photo_arr);
+  return theme('flickr_photos', $account->uid, $photo_arr);
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function flickr_tags_theme() {
+  return array(
+    'flickr_tags_list' => array(
+      'arguments' => array('uid', 'nsid', 'tag_arr'),
+    ),
+    'flickr_tags_cloud' => array(
+      'arguments' => array('uid', 'nsid', 'tag_arr'),
+    ),
+  );
 }
 
 function theme_flickr_tags_list($uid, $nsid, $tag_arr) {

