From: hickert Date: Mon, 6 Nov 2006 11:23:49 +0000 (+0000) Subject: Added acl filter to environment printer X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0526416820578a739f29f237b7d85567c97a877a;p=gosa.git Added acl filter to environment printer git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5017 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/personal/environment/class_selectPrinterDialog.inc b/plugins/personal/environment/class_selectPrinterDialog.inc index 2400b2857..9b17dca8e 100644 --- a/plugins/personal/environment/class_selectPrinterDialog.inc +++ b/plugins/personal/environment/class_selectPrinterDialog.inc @@ -14,13 +14,45 @@ class selectPrinterDialog extends plugin var $AlreadyAssigned = array(); var $regex = "*"; var $depselect = "/"; - var $deplist = "/"; + var $deplist = array("/"); + var $module = array("printer"); + var $ui = NULL; function selectPrinterDialog ($config, $dn= NULL,$alreadyused=array() ) { $this->AlreadyAssigned = $alreadyused; plugin::plugin ($config, $dn); - $this->depselect = $this->config->current['BASE']; + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH); + + $tmp =array(); + foreach($deps as $dep){ + $tmp[$dep['dn']] = $dep; + } + $deps = $tmp; + + /* Load possible departments */ + $this->ui= get_userinfo(); + $department = array(); + foreach($this->module as $module){ + + $d = $this->ui->get_module_departments($module); + foreach($d as $department){ + $departments[$department] = $department; + } + } + $ids = $this->config->idepartments; + $this->deplist = array(); + foreach($deps as $dep){ + if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $departments)){ + $this->deplist[$dep['dn']] = $ids[$dep['dn']]; + } + } + + $this->depselect = key($this->deplist); } function execute() @@ -33,8 +65,11 @@ class selectPrinterDialog extends plugin $display= ""; if(isset($_POST['dialogissubmitted'])){ - $this->regex=$_POST['regexPrinter']; - $this->depselect = $_POST['depselectPrinter']; + foreach(array('regexPrinter' => 'regex','depselectPrinter'=>'depselect') as $attr => $name){ + if(isset($_POST[$attr])){ + $this->$name =$_POST[$attr]; + } + } } if((isset($_GET['search']))&&(!empty($_GET['search']))){ @@ -42,8 +77,6 @@ class selectPrinterDialog extends plugin $this->regex=preg_replace("/\*\*/","*",$this->regex); } - $this->deplist=$this->config->idepartments; - $smarty->assign("regexPrinter" ,$this->regex); $smarty->assign("deplistPrinter" ,$this->deplist); $smarty->assign("depselectPrinter",$this->depselect); @@ -83,10 +116,20 @@ class selectPrinterDialog extends plugin function getPrinter($detailed = false) { $a_return=array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->depselect); - $ldap->search("(&(objectClass=gotoPrinter)(cn=".$this->regex."))",array("*")); - while($printer = $ldap->fetch()){ + + + $filter = "(&(objectClass=gotoPrinter)(cn=".$this->regex."))"; + $module = $this->module; + $base = $this->depselect; + $attrs = array("cn","description"); + $res = get_list($filter,$module,$base,$attrs); + + foreach($res as $printer) { + + $acl = $this->ui->get_permissions($printer['dn'],"printer","gotoUserPrinter"); + if(!preg_match("/w/",$acl)){ + continue; + } if(isset($this->AlreadyAssigned[$printer['cn'][0]])) continue;