? .DS_Store
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tokenauth/Attic/README.txt,v
retrieving revision 1.3.4.5
diff -u -p -r1.3.4.5 README.txt
--- README.txt	19 Aug 2010 21:19:32 -0000	1.3.4.5
+++ README.txt	25 Jan 2011 09:51:58 -0000
@@ -1,24 +1,24 @@
 # Token Authentication
 
-Enable feed readers and other simple clients to see certain private pages by 
+Enable feed readers and other simple clients to see certain private pages by
 providing an authentication token.
 
 ## Usage
 
-If you put token=x on the querystring and x is a valid token, then an anonymous 
-user will be authenticated as the user who owns the token. You may learn a user's 
+If you put token=x on the querystring and x is a valid token, then an anonymous
+user will be authenticated as the user who owns the token. You may learn a user's
 token by clicking on the tab on the user's profile page.
 
 ## Administration
 
-Go to admin/settings/tokenauth to configure this module.
+Go to admin/config/services/tokenauth to configure this module.
 
 ### Security
 
-In configuring Token Authentication, be sure to use it with 'low security' 
-content only. Tokenauth transmits what amounts to a password in the clear via URL, 
-you should assume anyone interested can get ahold of it and use it. Tokenauth 
-should be used for functionality requiring user identification more than user 
+In configuring Token Authentication, be sure to use it with 'low security'
+content only. Tokenauth transmits what amounts to a password in the clear via URL,
+you should assume anyone interested can get ahold of it and use it. Tokenauth
+should be used for functionality requiring user identification more than user
 authentication.
 
 ## Developers
@@ -28,5 +28,12 @@ Use tokenauth_reset_user_form() to get a
 
 ## Todo
 * use the token in other contexts like inbound email (see mailhandler.module)
-  
+
+## D7 todo [DGL]
+* Display text and token in user profile properly (text format issues).
+* Finish integration of issue #990468 changes. Current implementation always adds token to RSS feed URLs (which
+  is handy since is obviates the need to display the user profile text).
+* Fix problem with disable/enable (tries to init tokens on re-enable).
+* Finish integration with other moduels.
+
 $Id: README.txt,v 1.3.4.5 2010/08/19 21:19:32 grayside Exp $
Index: tokenauth.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tokenauth/Attic/tokenauth.inc,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 tokenauth.inc
--- tokenauth.inc	23 Jan 2011 07:42:42 -0000	1.1.2.2
+++ tokenauth.inc	25 Jan 2011 09:51:58 -0000
@@ -24,9 +24,8 @@ function tokenauth_reset($uid = NULL, $t
     return tokenauth_reset_user($uid, $token, $update);
   }
   else {
-    $sql = 'SELECT uid FROM {users} WHERE uid > 0';
-    $result = db_query($sql);
-    while ($row = db_fetch_object($result)) {
+    $sql = 'SELECT uid FROM {users} WHERE uid > 1';
+    foreach (db_query($sql) as $row) {
       tokenauth_reset_user($row->uid, $token, $update);
     }
     return TRUE;
@@ -55,8 +54,7 @@ function tokenauth_reset_user($uid = NUL
     'token' => isset($token) ? $token : user_password(variable_get('tokenauth_length', 10)),
   );
   if (!$update) {
-    // drupal_write_record mysteriously failing from tokenauth_enable().
-    $return = db_query("INSERT INTO {tokenauth_tokens} (uid,token) VALUES (%d,'%s')", $entry['uid'], $entry['token']);
+    $return = drupal_write_record('tokenauth_tokens', $entry);
   }
   else {
     $return = drupal_write_record('tokenauth_tokens', $entry, 'uid');
@@ -65,33 +63,34 @@ function tokenauth_reset_user($uid = NUL
 }
 
 /**
- * API function to reset a user's token.
+ * API Function to insert a new user token.
  *
  * @param $uid
- *  User ID of the user whose token to reset.
- *
- * @deprecated Use tokenauth_reset_user() instead.
+ *  UID of a specific user for whom to add a token.
+ *  A token must not already exist for this user.
+ * @param $token
+ *  [optional] A specific string to use as the token.
+ *  If not supplied, a token will be generated.
  */
-function tokenauth_user_reset($uid = NULL) {
-  return tokenauth_reset_user($uid);
+function tokenauth_insert($uid, $token = NULL) {
+  return tokenauth_reset($uid, $token, FALSE);
 }
 
 /**
- * API Function to insert new user tokens.
+ * API Function to delete a user token.
  *
  * @param $uid
- *  [optional] UID of a specific user for whom to add a token.
- * @param $token
- *  [optional] A specific string to use as the token.
+ *  UID of the user whose token to delete.
  */
-function tokenauth_insert($uid = NULL, $token = NULL) {
-  return tokenauth_reset($uid, $token, FALSE);
+function tokenauth_delete($uid) {
+  $sql = 'DELETE FROM {tokenauth_tokens} WHERE uid = :uid';
+  db_query($sql, array(":uid" => $account->uid));
 }
 
 /**
  * API function for retrieving the token for a given user.
  *
- * @param string $uid 
+ * @param string $uid
  *  Assumes current user if no user is provided.
  * @return string
  *  A token, or NULL if user has no token.
@@ -100,7 +99,10 @@ function tokenauth_get_token($uid = NULL
   if (is_null($uid)) {
     $uid = $GLOBALS['user']->uid;
   }
-  return db_result(db_query("SELECT tt.token FROM {tokenauth_tokens} tt WHERE tt.uid = %d", $uid));
+  return db_query("SELECT tt.token FROM {tokenauth_tokens} tt WHERE tt.uid = :uid",
+      array(
+        ':uid'=>$uid
+      ))->fetchField();
 }
 
 /**
@@ -112,8 +114,10 @@ function tokenauth_get_token($uid = NULL
  *  An alphanumeric string.
  */
 function tokenauth_get_user($token) {
-  $sql = "SELECT tt.uid FROM {tokenauth_tokens} tt INNER JOIN {users} u ON tt.uid = u.uid WHERE token = '%s' AND u.status != 0";
-  return db_result(db_query($sql, $token));
+  $sql = "SELECT tt.uid FROM {tokenauth_tokens} tt INNER JOIN {users} u ON tt.uid = u.uid WHERE token = :token AND u.status != 0";
+  return db_query($sql, array(
+      ':token'=>$token
+    ))->fetchField();
 }
 
 /**
@@ -176,7 +180,7 @@ EOT;
       $tokenauth_text['body'] .= "\n\n<strong>Your token:</strong> ?token=<code>[tokenauth-token]</code>";
     }
 
-    $tokenauth_text['format'] = FILTER_FORMAT_DEFAULT;
+    $tokenauth_text['format'] = NULL;
   }
   if (!$render) {
     return $tokenauth_text;
@@ -185,7 +189,7 @@ EOT;
     if (empty($account)) {
       $account = $GLOBALS['user'];
     }
-    $tokenauth_text['body'] = token_replace($tokenauth_text['body'], 'user', $account);
+    $tokenauth_text['body'] = token_replace($tokenauth_text['body'], array('user'=>$account));
   }
-  return check_markup($tokenauth_text['body'], $tokenauth_text['format']);
+  return check_markup($tokenauth_text['body']);
 }
Index: tokenauth.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tokenauth/Attic/tokenauth.info,v
retrieving revision 1.3.4.1
diff -u -p -r1.3.4.1 tokenauth.info
--- tokenauth.info	28 May 2008 04:55:54 -0000	1.3.4.1
+++ tokenauth.info	25 Jan 2011 09:51:58 -0000
@@ -1,4 +1,6 @@
 ; $Id: tokenauth.info,v 1.3.4.1 2008/05/28 04:55:54 weitzman Exp $
-name = Token authentication
+name = Token Authentication
 description = Enable aggregators, feed readers and other simple clients to see private pages by providing an authentication token.
-core = 6.x
+core = 7.x
+dependencies[] = user
+configure = admin/config/services/tokenauth
Index: tokenauth.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tokenauth/Attic/tokenauth.install,v
retrieving revision 1.3.4.12
diff -u -p -r1.3.4.12 tokenauth.install
--- tokenauth.install	2 Nov 2010 06:14:46 -0000	1.3.4.12
+++ tokenauth.install	25 Jan 2011 09:51:58 -0000
@@ -38,7 +38,6 @@ function tokenauth_schema() {
  * Implementation of hook_install().
  */
 function tokenauth_install() {
-  drupal_install_schema('tokenauth');
   // Tokenauth must authenticate the user before other modules can deny anonymous access.
   db_query("UPDATE {system} SET weight='-1000' WHERE name='tokenauth'");
 }
@@ -47,32 +46,17 @@ function tokenauth_install() {
  * Implementation of hook_enable().
  */
 function tokenauth_enable() {
-  // Assign tokens for each user.
-  $result = db_query("SELECT u.uid FROM {users} u LEFT JOIN {tokenauth_tokens} tt ON u.uid = tt.uid WHERE tt.token IS NULL AND u.uid > 0");
-  while ($row = db_fetch_object($result)) {
-    tokenauth_insert($row->uid);
-  }
+  tokenauth_reset(NULL, NULL, FALSE);
   // Clean up orphaned tokens from users removed while module disabled
-  db_query("DELETE tt.* FROM {tokenauth_tokens} tt WHERE NOT EXISTS (SELECT * FROM {users} u WHERE u.uid=tt.uid)");
+  db_query("DELETE tt.* FROM {tokenauth_tokens} tt WHERE NOT EXISTS (SELECT * FROM {users} u WHERE u.uid = tt.uid)");
 }
 
 /**
  * Implementation of hook_uninstall().
  */
 function tokenauth_uninstall() {
-  drupal_uninstall_schema('tokenauth');
   variable_del('tokenauth_length');
   variable_del('tokenauth_pages');
   variable_del('tokenauth_reset');
   variable_del('tokenauth_text');
 }
-
-/**
- * Make sure tokenauth has a low module weight.
- */
-function tokenauth_update_6106() {
-  $ret = array();
-  // Make sure existing tokenauth installations operate at the proper weight.
-  db_query("UPDATE {system} SET weight='-1000' WHERE name='tokenauth'");
-  return $ret;
-}
\ No newline at end of file
Index: tokenauth.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tokenauth/Attic/tokenauth.module,v
retrieving revision 1.11.4.32
diff -u -p -r1.11.4.32 tokenauth.module
--- tokenauth.module	23 Jan 2011 06:56:23 -0000	1.11.4.32
+++ tokenauth.module	25 Jan 2011 09:51:59 -0000
@@ -11,24 +11,34 @@ include_once('tokenauth.inc');
 /**
  * Implementation of hook_perm().
  */
-function tokenauth_perm() {
-  return array('access tokenauth', 'administer tokenauth');
+function tokenauth_permission() {
+  return array(
+      'administer tokenauth'=>array(
+          'title'=>t('Administer tokenauth'),
+          'description'=>t('User can administer site-wide tokenauth settings.')
+      ),
+      'access tokenauth'=>array(
+          'title'=>t('Access tokenauth'),
+          'description'=>t('User can access feeds using auth tokens.')
+      )
+  );
 }
 
 /**
  * Implementation of hook_menu().
  */
 function tokenauth_menu() {
-  $items['admin/settings/tokenauth'] = array(
+  $items['admin/config/services/tokenauth'] = array(
     'title' => t('Token authentication'),
-    'description' => t('Configure token behavior to allow users to authenticate per page-load via URL.'),
+    'description' => t('Configure authorisation token behavior to allow users to authenticate per page-load via URL.'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tokenauth_admin_settings'),
     'access arguments' => array('administer tokenauth'),
     'file' => 'tokenauth.pages.inc',
+    'type' => MENU_NORMAL_ITEM
   );
-  $items['admin/settings/tokenauth/reset'] = array(
-    'title' => t('Reset tokens'),
+  $items['admin/config/services/tokenauth/reset'] = array(
+    'title' => t('Reset authorisation tokens'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tokenauth_reset_confirm'),
     'access arguments' => array('administer tokenauth'),
@@ -45,7 +55,7 @@ function tokenauth_menu() {
     'type' => MENU_LOCAL_TASK,
   );
   $items['user/%user/tokenauth/reset'] = array(
-    'title' => t('Reset token'),
+    'title' => t('Reset authorisation token'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tokenauth_user_reset_confirm'),
     'access callback' => 'tokenauth_profile_access',
@@ -58,6 +68,19 @@ function tokenauth_menu() {
 }
 
 /**
+ * Implementation of hook_admin_paths().
+ */
+function tokenauth_admin_paths() {
+  $paths = array(
+    'admin/config/services/tokenauth' => TRUE,
+    'admin/config/services/tokenauth/reset' => TRUE,
+    'user/*/tokenauth' => TRUE,
+    'user/*/edit/*' => TRUE,
+  );
+  return $paths;
+}
+
+/**
  * Implementation of hook_help().
  */
 function tokenauth_help($path, $arg) {
@@ -69,10 +92,13 @@ function tokenauth_help($path, $arg) {
 }
 
 /**
- * Access callback for tokenauth view/edit.
+ * Form access callback for tokenauth view/edit.
  */
 function tokenauth_profile_access($account) {
-  return (user_access('administer users') || ($GLOBALS['user']->uid == $account->uid)) && user_access('access tokenauth') && $account->uid > 0;
+  return (user_access('administer users')  // Current user can admin users.
+        || ($GLOBALS['user']->uid == $account->uid)) // Current user is editing own profile.
+      && user_access('access tokenauth')  // Current user can use tokenauth. TODO: Should this be target user rather than current user?
+      && ($account->uid > 1);  // Don't allow anon or admin to use tokenauth under any circumstances.
 }
 
 /**
@@ -81,19 +107,31 @@ function tokenauth_profile_access($accou
 function tokenauth_init() {
   global $user;
   // Process any provided token and log in user
-  if (user_is_anonymous() && isset($_REQUEST['token']) && tokenauth_allowed_pages($_GET['q'])) {
+  if (user_is_anonymous()
+      && isset($_REQUEST['token'])
+      && tokenauth_allowed_pages($_GET['q'])) {
     if ($uid = tokenauth_get_user($_REQUEST['token'])) {
       $account = user_load($uid);
       if (user_access('access tokenauth', $account)) {
         $user = $account;
-        // Store the fact that this user authenticated via token. Needed for logout.
+        // Store the fact that this user authenticated via token. Needed for tokenauth_exit.
         $_SESSION['tokenauth_auth'] = TRUE;
         if (function_exists('drupal_save_session')) {
           drupal_save_session(FALSE);
         }
-        watchdog('user', 'Page @page loaded for %name via token authentication.', array('@page' => $_GET['q'], '%name' => $account->name));
+        watchdog('user', 'Page @page loaded for %name via token authentication.', array(
+          '@page' => $_GET['q'],
+          '%name' => $account->name
+        ));
+
+        // Warning! Danger!
+        // Kill the static data stored by menu_get_item, which will force it to re-create it
+        // and more importantly, recalculate the access field. This works, but might not be
+        // strictly conformant to the Drupal API.
+        drupal_static_reset('menu_get_item');
       }
     }
+
     // Supplied an invalid token
     if (empty($_SESSION['tokenauth_auth'])) {
       drupal_access_denied();
@@ -102,14 +140,15 @@ function tokenauth_init() {
   }
 
   // Trigger tokenauth context condition.
-  if (module_exists('context') && $plugin = context_get_plugin('condition', 'tokenauth_auth')) {
+  if (module_exists('context')
+      && ($plugin = context_get_plugin('condition', 'tokenauth_auth'))) {
     $plugin->execute((int)$_SESSION['tokenauth_auth']);
   }
 }
 
 /**
  * Implementation of hook_exit().
- * Deliberately insure that this session will not be saved by sess_write(). Safety.
+ * Deliberately ensure that this session will not be saved by sess_write(). Safety.
  * @see user_logout
  */
 function tokenauth_exit() {
@@ -128,17 +167,24 @@ function tokenauth_exit() {
  * that also passes tokenauth's allowed pages filter.
  */
 function tokenauth_url_outbound_alter(&$path, &$options, $original_path) {
-  if (isset($_SESSION['tokenauth_auth']) && $_REQUEST['token'] == ($token = tokenauth_get_token())
-    && tokenauth_allowed_pages($original_path)) {
-
+  if (isset($_SESSION['tokenauth_auth'])
+      && ($_REQUEST['token'] == ($token = tokenauth_get_token()))
+      && tokenauth_allowed_pages($original_path)) {
     if (is_array($options['query'])) {
       $options['query']['token'] = $token;
     }
-    elseif (!$options['query']) {
-      $options['query'] = 'token=' . $token;
-    }
     else {
-      $options['query'] .= '&token=' . $token;
+      $options['query'] .= 'token=' . $token;
+    }
+  }
+  else if (!isset($_SESSION['tokenauth_auth'])
+      && user_access('access tokenauth')
+      && tokenauth_allowed_pages($original_path)) {
+    // We are rendering a link to an RSS file, so append the token.
+    $token = tokenauth_get_token();
+    if ($token != NULL) {
+      // From D6 on, the query element is an array (it previously was a string).
+      $options['query']['token'] = $token;
     }
   }
 }
@@ -157,8 +203,7 @@ function tokenauth_user($op, &$edit, &$a
       tokenauth_insert($account->uid);
       break;
     case 'delete':
-      $sql = 'DELETE FROM {tokenauth_tokens} WHERE uid = %d';
-      db_query($sql, $account->uid);
+      tokenauth_delete($account->uid);
   }
 }
 
Index: tokenauth.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tokenauth/Attic/tokenauth.pages.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 tokenauth.pages.inc
--- tokenauth.pages.inc	2 Sep 2010 21:10:57 -0000	1.1.2.6
+++ tokenauth.pages.inc	25 Jan 2011 09:51:59 -0000
@@ -29,7 +29,12 @@ function tokenauth_admin_settings() {
     '#type' => 'textarea',
     '#title' => t('Activate tokens on specific pages'),
     '#default_value' => variable_get('tokenauth_pages', "rss.xml\n*/feed\n*/opml"),
-    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page. Read <a href=\"http://api.drupal.org/api/function/drupal_match_path/6\">drupal_match_path()</a> for the details.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
+    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page. Read <a href=\"http://api.drupal.org/api/function/drupal_match_path/6\">drupal_match_path()</a> for the details.",
+        array(
+          '%blog' => 'blog',
+          '%blog-wildcard' => 'blog/*',
+          '%front' => '<front>'
+    )),
   );
 
   $form['tokenauth_text'] = array(
@@ -40,14 +45,14 @@ function tokenauth_admin_settings() {
     '#collapsed' => TRUE,
     '#tree' => TRUE,
   );
-  $tokenauth_text = tokenauth_text_load(); 
+  $tokenauth_text = tokenauth_text_load();
   $form['tokenauth_text']['body'] = array(
     '#type' => 'textarea',
     '#title' => t('Body'),
     '#default_value' => $tokenauth_text['body'],
     '#rows' => 5,
   );
-  $form['tokenauth_text']['format'] = filter_form(FILTER_FORMAT_DEFAULT);
+  $form['tokenauth_text']['format'] = NULL;
 
   if (module_exists('token')) {
     $form['tokenauth_text']['view']['token_help'] = array(
@@ -79,7 +84,7 @@ function tokenauth_admin_settings() {
  */
 function tokenauth_admin_settings_validate($form, &$form_state) {
   if ($form_state['values']['op'] == t('Reset tokens')) {
-    drupal_goto('admin/settings/tokenauth/reset');
+    drupal_goto('admin/config/services/tokenauth/reset');
   }
   if ($form_state['values']['tokenauth_length'] > 33) {
     form_set_error('tokenauth_length', t('The maximum token length is 32.'));
@@ -89,24 +94,30 @@ function tokenauth_admin_settings_valida
 /**
  * Menu callback: confirm reset tokens.
  */
-function tokenauth_reset_confirm() {
-  return confirm_form(array(), t('Are you sure you want to reset all tokens?'),
-           'admin/settings/tokenauth', t('After the tokens have been reset, all users who use tokenised URLs will have to update them. This action cannot be undone.'), t('Reset tokens'), t('Cancel'));
+function tokenauth_reset_confirm($form, &$form_state) {
+  return confirm_form(
+      array(),
+      t('Are you sure you want to reset all tokens?'),
+      'admin/config/services/tokenauth',
+      t('After the tokens have been reset, all users who use tokenised URLs will have to update them. This action cannot be undone.'),
+      t('Reset tokens'),
+      t('Cancel')
+    );
 }
 
 /**
  * Handler for reset tokens confirmation
  */
-function tokenauth_reset_confirm_submit(&$form_state) {
+function tokenauth_reset_confirm_submit($form, &$form_state) {
   tokenauth_reset();
   drupal_set_message(t('All tokens have been reset.'));
-  $form_state['#redirect']  = 'admin/settings/tokenauth';
+  $form_state['redirect']  = 'admin/config/services/tokenauth';
 }
 
 /**
  * Menu callback: confirm reset users token.
  */
-function tokenauth_user_reset_confirm() {
+function tokenauth_user_reset_confirm($form, &$form_state) {
   if (arg(0) == 'user' && is_numeric(arg(1))) {
     $uid = arg(1);
   }
@@ -132,12 +143,12 @@ function tokenauth_user_reset_confirm_su
 /**
  * Menu callback. Prints the token and instructions.
  */
-function tokenauth_user_profile_form(&$form_state, $account) {
+function tokenauth_user_profile_form($form, &$form_state, $account) {
   drupal_set_title(check_plain($account->name));
   $token = tokenauth_get_token($account->uid);
-  $form['preamble'] = array('#value' => tokenauth_text_load($account, TRUE));
+  $form['#prefix'] = tokenauth_text_load($account, TRUE);
   if (!module_exists('token')) {
-    $form['preamble']['#value'] .= "<p><strong>" . t('Your token:') . "</strong> ?token=<code>$token</code></p>";
+    $form['#prefix'] .= "<p><strong>" . t('Your token:') . "</strong> ?token=<code>$token</code></p>";
   }
   $form = array_merge($form, tokenauth_reset_user_form($account->uid, NULL, $token));
   return $form;
