? .cvsignore
? clean_up_my_access_checks.patch
? d6_blocked.patch
? d6_clean_up_my_access_checks.patch
? d7_fix.patch
? fix_tests.patch
? fix_unapproved.patch
? php53_fix.patch
Index: userpoints.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/userpoints/userpoints.module,v
retrieving revision 1.67.2.61
diff -u -p -r1.67.2.61 userpoints.module
--- userpoints.module	15 Jul 2010 21:52:34 -0000	1.67.2.61
+++ userpoints.module	10 Sep 2010 10:49:51 -0000
@@ -159,10 +159,20 @@ function userpoints_menu() {
   );
 
   $items['myuserpoints'] = array(
-    'title'           => 'My !points',
+    'title' => 'My !points',
     'title arguments' => userpoints_translation(),
-    'page callback'   => 'userpoints_list_my_userpoints',
+    'page callback' => 'userpoints_list_my_userpoints_forward',
+    'access callback' => TRUE,
+    'type'            => MENU_CALLBACK,
+  );
+
+  $items['myuserpoints/%user_uid_optional'] = array(
+    'title' => 'My !points',
+    'title arguments' => userpoints_translation(),
+    'page callback' => 'userpoints_list_my_userpoints',
+    'page arguments' => array(1),
     'access callback' => 'userpoints_access_my_points',
+    'access arguments' => array(1),
     'type'            => MENU_NORMAL_ITEM
   );
   return $items;
@@ -171,16 +181,24 @@ function userpoints_menu() {
 /**
  * Checks if user can access their points - used via hook_menu().
  *
- * @return TRUE if user has permissions to view userpoints and if the user is logged in
+ * @return
+ *   TRUE if user has permissions to view userpoints and if the user is logged
+ *   in.
  */
-function userpoints_access_my_points() {
+function userpoints_access_my_points($account = NULL) {
   global $user;
-  if ($user->uid === 1 || user_access(USERPOINTS_PERM_ADMIN)) {
-    return TRUE;
+  if ($account && $user->uid != $account->uid) {
+    return user_access(USERPOINTS_PERM_ADMIN);
   }
-  return ( _userpoints_user_exists($user->uid) &&
-          ((user_access(USERPOINTS_PERM_VIEW) && user_is_logged_in()) || user_access(USERPOINTS_PERM_VIEW_OWN))
-         );
+  return (user_access(USERPOINTS_PERM_VIEW) && user_is_logged_in()) || user_access(USERPOINTS_PERM_VIEW_OWN);
+}
+
+/**
+ * Forward to the myuserpoints page of the current user.
+ */
+function userpoints_list_my_userpoints_forward() {
+  global $user;
+  drupal_goto('myuserpoints/' . $user->uid);
 }
 
 /**
@@ -879,17 +897,13 @@ function userpoints_user($op, &$edit, &$
       break;
 
     case 'view':
-      if (user_access(USERPOINTS_PERM_VIEW) || (user_access(USERPOINTS_PERM_VIEW_OWN) && $user->uid == $account->uid )) {
-        $details = NULL;
-        if (userpoints_access_my_points()) {
-          $details .= l(t('View'), 'myuserpoints/'. $account->uid, array('attributes' => array('title' => t('View detailed transactions'))));
-        }
+      if (userpoints_access_my_points($account)) {
+        $details = array();
+          $details[] = l(t('View'), 'myuserpoints/'. $account->uid, array('attributes' => array('title' => t('View detailed transactions'))));
         if (user_access(USERPOINTS_PERM_ADMIN)) {
-          if (!is_null($details)) {
-            $details .= ', ';
-          }
-          $details .= l(t('Adjust'), 'admin/user/userpoints/add/'. $account->uid, array('attributes' => array('title' => t('Add/substract !points from this user', userpoints_translation()))));
+          $details[] = l(t('Adjust'), 'admin/user/userpoints/add/'. $account->uid, array('attributes' => array('title' => t('Add/substract !points from this user', userpoints_translation()))));
         }
+        $details = implode(', ', $details);
 
         //Which points are we display?
         $points = userpoints_get_current_points($account->uid, variable_get(USERPOINTS_CATEGORY_PROFILE_DISPLAY_TID, 0));
@@ -1658,35 +1672,11 @@ function userpoints_cron() {
  * Purpose: Displays a detailed transaction report for an individual user
  * no URL argument returns current user otherwise accepts uid.
  */
-function userpoints_list_my_userpoints() {
+function userpoints_list_my_userpoints($points_user) {
   $overall_total = 0;
   $unapproved_total = 0;
   $approved_total = 0;
 
-  global $user;
-
-  // User which are displaying points for
-  $uid = (int)arg(1);
-  if ($uid) {
-    if ($uid != $user->uid && !user_access(USERPOINTS_PERM_ADMIN)) {
-      // If not the same as logged in user
-      drupal_access_denied();
-      return;
-    }
-  }
-  else {
-    // Default to currently logged in user
-    $uid = $user->uid;
-  }
-  $point_user = user_load(array('uid' => $uid));
-
-  // Check permissions
-  if (!user_access(USERPOINTS_PERM_VIEW) && !user_access(USERPOINTS_PERM_VIEW_OWN)) {
-    // User has no access to view points
-    drupal_access_denied();
-    return;
-  }
-
   $title = t('!Points for ', userpoints_translation()) . check_plain($point_user->name);
   drupal_set_title($title);
 
