--- orig	2008-10-09 17:15:49.000000000 +0200
+++ new	2008-10-09 17:15:49.000000000 +0200
@@ -1,47 +1,53 @@
 <?php
-// $id
 
-function administerusersbyrole_perm()
-{
+// $Id$
+
+/**
+ * @file
+ * Allows users with 'administer users' permission and a role (specified in 'Access control') to edit and/or delete other users with a specified role.
+ */
+
+
+
+function administerusersbyrole_perm() {
   $roles = db_query('SELECT name FROM {role} WHERE rid > 1 ORDER BY name');
   $perms = array();
   $perms[] = 'create users';
-  while( $role=db_fetch_array($roles) ) {
-    $perms[] = 'edit users with role '.$role['name'];
-    $perms[] = 'delete users with role '.$role['name'];
+  while ( $role = db_fetch_array($roles) ) {
+    $perms[] = 'edit users with role '. $role['name'];
+    $perms[] = 'delete users with role '. $role['name'];
   }
   return $perms;
 }
 
-function administerusersbyrole_menu($may_cache)
-{
+function administerusersbyrole_menu($may_cache) {
   $items = array();
-  if( !$may_cache ) {
-    if( arg(0)==='admin' && arg(1)==='user' && arg(2)==='user' && arg(3)==='create' ) {
-      if( !user_access('create users') ) {
+  if ( !$may_cache ) {
+    if ( arg(0)==='admin' && arg(1)==='user' && arg(2)==='user' && arg(3)==='create' ) {
+      if ( !user_access('create users') ) {
         drupal_set_message(t('You do not have permission to create users.'), 'error');
         drupal_goto("");
       }
     }
-    else if( arg(0)==='user' ) {
-      switch( arg(2) ) {
+    else if ( arg(0)==='user' ) {
+      switch ( arg(2) ) {
         case 'edit':
           $uid = arg(1);
 
           // allow user to edit self.
           global $user;
-          if( $uid === $user->uid )
+          if ( $uid === $user->uid )
             break;
 
-          $account = user_load( array('uid'=>$uid) );
+          $account = user_load(array('uid' => $uid));
 
           // otherwise check permissions.
-          $allowed=true;
-          foreach( $account->roles as $role )
-            if( !user_access('edit users with role '.$role) )
-              $allowed=false;
+          $allowed=TRUE;
+          foreach ( $account->roles as $role )
+            if ( !user_access('edit users with role '. $role) )
+              $allowed=FALSE;
 
-          if( !$allowed ) {
+          if ( !$allowed ) {
             drupal_set_message(t('You do not have permission to edit %user.', array('%user' => $account->name)), 'error');
             drupal_goto("user/$uid");
           }
@@ -51,12 +57,12 @@ function administerusersbyrole_menu($may
         case 'delete':
           $uid = arg(1);
           $account = user_load( array('uid' => $uid) );
-          $allowed=true;
-          foreach( $account->roles as $role )
-            if( !user_access('delete users with role '.$role) )
-              $allowed=false;
+          $allowed=TRUE;
+          foreach ( $account->roles as $role )
+            if ( !user_access('delete users with role '. $role) )
+              $allowed=FALSE;
 
-          if( !$allowed ) {
+          if ( !$allowed ) {
             drupal_set_message(t('You do not have permission to delete %user.', array('%user' => $account->name)), 'error');
             drupal_goto("user/$uid");
           }