Code

Small improvement (4%) in mergeACL
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 29 Oct 2008 15:39:12 +0000 (15:39 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 29 Oct 2008 15:39:12 +0000 (15:39 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12808 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_userinfo.inc

index b2e27116169ef3bcbf36034ef31d6bfb880f37c6..0483ef2e61438ea7e7aea9b7a54a32fbad579545 100644 (file)
@@ -520,41 +520,27 @@ class userinfo
 
   function mergeACL($acl, $type, $newACL)
   {
+               $at= array("psub" => "p", "sub" => "s", "one" => "1");
+
     if (strpos($newACL, 'w') !== FALSE && strpos($newACL, 'r') === FALSE){
       $newACL .= "r";
     }
 
-    foreach(str_split($newACL) as $char){
+               /* Ignore invalid characters */
+               $newACL= preg_replace('/^[rwcdm]/', '', $newACL);
 
-      /* Ignore invalid characters */
-      if (!preg_match('/[rwcdm]/', $char)){
-        continue;
-      }
+    foreach(str_split($newACL) as $char){
 
       /* Skip permanent and subtree entries */
       if (preg_match('/[sp]/', $acl[$char])){
         continue;
       }
 
-      switch ($type){
-        case 'psub':
-          $acl[$char]= 'p';
-          break;
-
-        case 'sub':
-          $acl[$char]= 's';
-          break;
-
-        case 'one':
-          $acl[$char]= 1;
-          break;
-
-        case 'base':
-          if ($acl[$char] != 1){
-            $acl[$char]= 0;
-          }
-          break;
-      }
+                       if ($type == "base" && $acl[$char] != 1) {
+                               $acl[$char]= 0;
+                       } else {
+        $acl[$char]= $at[$type];
+                       }
     }
 
     return ($acl);