From 221cd124c5e538587205d61f1cfb111cf65b658a Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 6 Sep 2006 04:40:34 +0000 Subject: [PATCH] Updated function that returns all available bases (Allowed to move to) git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4600 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/personal/generic/class_user.inc | 51 ++++++++----------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 17c92f0a4..3b4e20374 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -1228,43 +1228,24 @@ class user extends plugin */ function allowedBasesToMoveTo() { - $allowed = array(); - $ret_all = false; - if($this->uid == $_SESSION['ui']->username){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=posixGroup)(memberUid=".$_SESSION['ui']->username."))",array("gosaSubtreeACL")); - - while($attrs = $ldap->fetch()){ - - if(isset($attrs['gosaSubtreeACL'])){ - - foreach($attrs['gosaSubtreeACL'] as $attr){ - if((preg_match("/:user#/",$attr))||(preg_match("/:all/",$attr))){ - $s = preg_replace("/^.*ou=groups,/","",$attrs['dn']); - - foreach($this->config->idepartments as $key => $dep) { - if(preg_match("/".$s."/i",$key)){ - $allowed[$key] = $dep; - } - } - } - } - } + /* Get bases */ + $ui = get_userinfo(); + $check = $ui->get_module_departments("ogroups"); + $bases = array(); + + foreach($check as $dn_allowed){ + $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed]; + } + + foreach($bases as $key => $base ){ + $acl = $ui->get_permissions($key,"users/user"); + + /* Remove those bases, which are not allowed to move to, but keep current base ... */ + if(!preg_match("/m/",$acl) && $key != $this->base){ + unset($bases[$key]); } - if(count($allowed) == 0){ - foreach($this->config->idepartments as $key => $dep) { - if($this->base==$key){ - $allowed[$key] = $dep; - } - } - } - - return($allowed); - - }else{ - return($this->config->idepartments); } + return($bases); } -- 2.30.2