--- imce/imce.module        Sun Sep 27 00:30:43 2009 +0200
+++ imce/imce.module        Sun Sep 27 01:44:36 2009 +0200
@@ -142,11 +142,20 @@
     return $profiles[1];
   }
   else {
+    $directories = array();
+    $profile_id = null;
     foreach (variable_get('imce_roles_profiles', array()) as $rid => $role) {
       if (isset($user->roles[$rid]) && isset($profiles[$role['pid']])) {
-        return $profiles[$role['pid']];
+        if(null == $profile_id) {
+          $profile_id = $role['pid'];
+        }
+        $directories = array_merge($directories, $profiles[$role['pid']]['directories']);
       }
     }
+    if(null != $role['pid']) {
+      $profiles[$profile_id]['directories'] = $directories;
+      return $profiles[$profile_id];
+    }
   }
   return FALSE;
 }
@@ -189,4 +198,4 @@
  */
 function imce_reg_dir($dirname) {
   return $dirname == '.' || (is_string($dirname) && $dirname != '' && !preg_match('@(^\s)|(^/)|(^\./)|(\s$)|(/$)|(/\.$)|(\.\.)|(//)|(\\\\)|(/\./)@', $dirname));
-}
\ No newline at end of file
+}