From 2062edb7a1d1b368c6df0da9285984391099aafc Mon Sep 17 00:00:00 2001 From: cajus Date: Wed, 29 Oct 2008 15:39:12 +0000 Subject: [PATCH] Small improvement (4%) in mergeACL git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12808 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_userinfo.inc | 34 ++++++++-------------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/gosa-core/include/class_userinfo.inc b/gosa-core/include/class_userinfo.inc index b2e271161..0483ef2e6 100644 --- a/gosa-core/include/class_userinfo.inc +++ b/gosa-core/include/class_userinfo.inc @@ -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); -- 2.30.2