X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Faddons%2Fldapmanager%2Fclass_exportxls.inc;h=6a3302a8175cc1baab82eef13c74de52a183390c;hb=1b4f65c17a53fbda492f4eb8015336d2006c4a45;hp=47a7870643d90a042bb5f280c7a5e82533fb3eee;hpb=c58023bcd8e2250dad63c3779ec4f657eb8d2d36;p=gosa.git diff --git a/plugins/addons/ldapmanager/class_exportxls.inc b/plugins/addons/ldapmanager/class_exportxls.inc index 47a787064..6a3302a81 100644 --- a/plugins/addons/ldapmanager/class_exportxls.inc +++ b/plugins/addons/ldapmanager/class_exportxls.inc @@ -11,16 +11,15 @@ class xlsexport extends plugin /* attribute list for save action */ var $attributes= array(); var $objectclasses= array(); + var $ui; + var $view_logged = FALSE; function xlsexport ($config, $dn= NULL) { /* Include config object */ $this->config= $config; - /* set permissions */ - $ui= get_userinfo(); - $acl= get_permissions ($ui->dn, $ui->subtreeACL); - $this->acl= get_module_permission($acl, "ldapmanager", $ui->dn); + $this->ui = get_userinfo(); } function execute() @@ -28,48 +27,61 @@ class xlsexport extends plugin /* 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",""); + if(!isset($_POST['selfull'])) $_POST['selfull'] = "Somehow not posted"; + /* Check permissions for export */ - if (chkacl($this->acl,"xlsexport")!=""){ - 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"); + $a=$_POST['single']; + $b=$_POST['selfull']; + + } + 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"); - $a=$_POST['single']; - $b=$_POST['selfull']; -// $dn=$a.$b; - - } - if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){ - $smarty->assign("depselectfull",$_POST['selfull']); - $smarty->assign("type","full"); - $dn = $_POST['selfull']; - } else { - $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", ""); - } + $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); - $smarty->assign("choicelist",array("ou=people,"=>"users" ,"ou=groups,"=>"groups" ,"ou=computers,ou=systems,"=>"computers","ou=servers,ou=systems,"=>"servers","dc=addressbook,"=>"addressbook")); + $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); + $smarty->assign("choicelist",array( get_people_ou() =>"users" , + "ou=groups," =>"groups" , + "ou=systems," =>"computers", + "ou=servers,ou=systems," =>"servers", + "dc=addressbook," =>"addressbook")); // Get the LDAP link, to generate the Export $ldap = $this->config->get_ldap_link(); - if ($this->config->current['GOVERNMENTMODE'] == 'true'){ $smarty->assign ("govmode", "true"); @@ -81,33 +93,47 @@ class xlsexport 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!")); + print_red (_("Error while exporting the requested entries!")); } } -// print_r($_POST); - // Export a single LDAP entry - if(isset($_POST['sfrmgetsingle'])) - { - $smarty->assign("para","?ivbb=2&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull'])); - } - 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)){ + + /* 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&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull'])); + } + 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('contentexportxls.tpl', TRUE))); } + }