X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Faddons%2Fldapmanager%2Fclass_export.inc;h=d64dc79d49de817efad65abcbd1e755c10982f49;hb=1b4f65c17a53fbda492f4eb8015336d2006c4a45;hp=ad9c0754d2f5e89aec9a0fe70f702ca281ef263b;hpb=e299f0ca47a924516f2afbe4e922f2418b75315c;p=gosa.git diff --git a/plugins/addons/ldapmanager/class_export.inc b/plugins/addons/ldapmanager/class_export.inc index ad9c0754d..d64dc79d4 100644 --- a/plugins/addons/ldapmanager/class_export.inc +++ b/plugins/addons/ldapmanager/class_export.inc @@ -1,59 +1,70 @@ config= $config; - - $ui= get_userinfo(); - $acl= get_permissions ($config->current['BASE'], $ui->subtreeACL); - $acl= get_module_permission($acl, "ldifexport", $config->current['BASE']); - $this->access= $acl; + $this->ui = get_userinfo(); } function execute() { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + @log::log("view","all/".get_class($this),$this->dn); + } + /* Set government mode */ $smarty= get_smarty(); $smarty->assign("type",FALSE); + $smarty->assign("depselectivbb",""); - /* Check permissions for export */ - if ($this->access != '#all#'){ - print_red(_("You've no permission to do LDAP exports.")); + // fill in old vars in the Export form + if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){ + $smarty->assign("single",$_POST['single']); + $smarty->assign("type","single"); + $dn = $_POST['single']; + } + if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){ + $smarty->assign("depselectfull",$_POST['selfull']); + $smarty->assign("type","full"); + $dn = $_POST['selfull']; } else { - // fill in old vars in the Export form - if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){ - $smarty->assign("single",$_POST['single']); - $smarty->assign("type","single"); - $dn = $_POST['single']; - } - if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){ - $smarty->assign("depselectfull",$_POST['selfull']); - $smarty->assign("type","full"); - $dn = $_POST['selfull']; - } - if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){ - $smarty->assign("depselectivbb",$_POST['selivbb']); - $smarty->assign("type","ivbb"); - $dn = $_POST['selivbb']; - } + $smarty->assign("depselectfull", ""); + } + if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){ + $smarty->assign("depselectivbb",$_POST['selivbb']); + $smarty->assign("type","ivbb"); + $dn = $_POST['selivbb']; + } else { + $smarty->assign("depselectivbb", ""); } // Set values for optionlist in form - $smarty->assign("deplist", $this->config->idepartments); + $bases = array(); + $acl_bases = $this->ui->get_module_departments("all"); + foreach($this->config->idepartments as $base_dn => $name){ + if(in_array_ics($base_dn,$acl_bases)){ + $bases[$base_dn] = $name; + } + } + $smarty->assign("deplist", $bases); // Get the LDAP link, to generate the Export $ldap = $this->config->get_ldap_link(); @@ -68,29 +79,41 @@ class ldifexport extends plugin if(isset($dn)) { - if($ldap->dn_exists($dn) && $dn != ""){ - ; - } - else { + if(!($ldap->dn_exists($dn) && $dn != "")){ $smarty->assign("LDIFError",TRUE); print_red (_("Error while exporting the requested entries!")); } } - // Export a single LDAP entry - if(isset($_POST['sfrmgetsingle'])) - { - $smarty->assign("para","?ivbb=2&dn=".base64_encode($_POST['single'])); - } - elseif(isset($_POST['sfrmgetfull'])) - { - $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull'])); - } - elseif(isset($_POST['sfrmgetivbb'])) - { - $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb'])); + /* check alcs for given dn */ + $acls =""; + if(isset($dn)){ + $acls = $this->ui->get_permissions($dn,"all/all"); } + if((!preg_match("/r/",$acls)) && (isset($dn))){ + /* Show error msg */ + print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn))); + + /* Show main page */ + $smarty->assign("LDIFError",TRUE); + $smarty->assign("para",""); + }else{ + + // Export a single LDAP entry + if(isset($_POST['sfrmgetsingle'])) + { + $smarty->assign("para","?ivbb=2&dn=".base64_encode($_POST['single'])); + } + elseif(isset($_POST['sfrmgetfull'])) + { + $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull'])); + } + elseif(isset($_POST['sfrmgetivbb'])) + { + $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb'])); + } + } /* Show main page */ return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));