--- 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 @@ '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(