From: hickert Date: Tue, 5 Sep 2006 05:57:56 +0000 (+0000) Subject: Fixed printer acls X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6ef801139942c1488ba801857cea57b72d4508a2;p=gosa.git Fixed printer acls git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4588 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index 803ea881e..ee40925c0 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -840,7 +840,7 @@ class printgeneric extends plugin return(FALSE); } - if(!$this->acl_is_writeable($type)){ + if(!$this->acl_is_writeable("gotoUserPrinter")){ print_red(sprintf(_("You are not allowed to add the given object '%s' to the list of members of '%s'."),$dn,$this->dn)); return(FALSE); } @@ -854,22 +854,38 @@ class printgeneric extends plugin $ldap = $this->config->get_ldap_link(); $ldap->cd($dn); - $ldap->cat($dn,array("cn","uid")); + $ldap->cat($dn,array($var)); if($ldap->count()){ $attrs = $ldap->fetch(); - $name = $attrs[$var][0]; - - /* Check if this uid/cn is already assigned to any permission */ - foreach($types as $ctype){ - if(isset( $this->member[$ctype][$name])){ - print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0])); - return(FALSE); + + if(isset($attrs[$var][0])){ + $name = $attrs[$var][0]; + + /* Check if this uid/cn is already assigned to any permission */ + foreach($types as $ctype){ + + /* If we want to add a user, only check user/userAdmin members */ + if((preg_match("/user/i",$type)) && (!preg_match("/user/i",$ctype))){ + continue; + } + + /* If we want to add a group, only check groups/adminGroups .. */ + if((preg_match("/group/i",$type)) && (!preg_match("/group/i",$ctype))){ + continue; + } + + if(isset( $this->member[$ctype][$name])){ + print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0])); + return(FALSE); + } } - } - /* Everything is fine. So add the given object to members */ - $this->member[$type][$attrs[$var][0]] = $attrs ; + /* Everything is fine. So add the given object to members */ + $this->member[$type][$attrs[$var][0]] = $attrs ; + }else{ + print_a($attrs); + } }else{ print_red(sprintf(_("Can't add '%s' to list of members, it is not reachable."),$dn)); return(FALSE); diff --git a/plugins/admin/systems/tabs_printers.inc b/plugins/admin/systems/tabs_printers.inc index cf1360ecf..2c264234e 100644 --- a/plugins/admin/systems/tabs_printers.inc +++ b/plugins/admin/systems/tabs_printers.inc @@ -3,7 +3,7 @@ class printtabs extends tabs { - function printtabs($config, $data, $dn) + function printtabs($config, $data, $dn,$category) { /* Save dn */ $this->dn= $dn; @@ -14,10 +14,12 @@ class printtabs extends tabs $this->by_name[$tab['CLASS']]= $tab['NAME']; $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn,$this); $this->by_object[$tab['CLASS']]->parent= &$this; + $this->by_object[$tab['CLASS']]->set_acl_category($category); }else{ $this->by_name[$tab['CLASS']]= $tab['NAME']; $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn); $this->by_object[$tab['CLASS']]->parent= &$this; + $this->by_object[$tab['CLASS']]->set_acl_category($category); } /* Initialize current */ if ($this->current == ""){ diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc index 79bc8679a..f0cee0e46 100644 --- a/plugins/personal/environment/class_environment.inc +++ b/plugins/personal/environment/class_environment.inc @@ -749,7 +749,16 @@ class environment extends plugin $tmp2= $this->dialog->getPrinter(true); foreach($tmp as $pname){ - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn']); + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn'],"printer"); + $printerObj->set_acl_base($tmp2[$pname]['dn']); + + if($this->is_group){ + if($printerObj->by_object['printgeneric']->AddMember("AddGroup",$this->dn)){ + $this->gotoPrinter[$pname]=$tmp2[$pname]; + $this->gotoPrinter[$pname]['mode']="user"; + $this->add_del_printer_member_was_called = true; + } + }else{ if($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){ $this->gotoPrinter[$pname]=$tmp2[$pname]; $this->gotoPrinter[$pname]['mode']="user"; @@ -757,6 +766,8 @@ class environment extends plugin } } + } + $this->is_dialog=false; unset($this->dialog); $this->dialog =NULL;