--- join_role_with_password.module	Thu Feb 05 14:17:00 2009
+++ join_role_with_password.module	Wed Sep 09 14:00:11 2009
@@ -1,4 +1,3 @@
 <?php
-// $Id: join_role_with_password.module,v 1.2 2009/02/05 13:17:00 francoud Exp $
-
+// $Id: join_role_with_password.module,v 1.2-1 2009/09/09 14:30:00 francoud Exp $
 /**
@@ -58,3 +57,3 @@
 
-   $items['user/%user/join_role'] = array(
+   $items['user/%only_current_user/join_role'] = array(
    'title' => 'Join or leave a role',
@@ -64,4 +63,5 @@
    'access arguments' => array('May join new role'),
-   'type' => MENU_LOCAL_TASK,
+   'type' => MENU_NORMAL_ITEM,
   );
+  
 
@@ -71,2 +71,12 @@
 /**
+ * Implementation of _to_arg():    no matter what the user are we watching, the link to
+ *                                 join or leave a role should always go to current user!
+ *                                 patch 2009-09-09.
+ */
+function only_current_user_to_arg($arg) {
+   global $user;
+   return $user->uid;
+   }
+
+/**
  * Implementation of hook_form():  form to ADD a password for one role;
@@ -553,2 +563,14 @@
   
+/* Only rule /user/{current user}/join_role  should be present; but due to menu system way to work,
+      acctually we can have a valid url for each user: /user/{any user}/join_role . But the module only
+	  works on the current user! so better to inform user of this. Maybe I can find a better way to redirect
+	  to the proper unique url? PATCH 2009-09-09
+   */
+  
+  if ((arg(0) == "user") && (arg(1) != $user->uid)) {
+    $form['join_roles'] = array(
+    '#value' => t("Please note: you will now change roles for yourself, user: %user (uid: %uid)", array('%user' => $user->name,'%uid' => $user->uid)),
+  );
+  }  
+
   $form['join_roles']['role_to_join'] = array(
