Code

Added acls for export xls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 31 Oct 2006 07:28:08 +0000 (07:28 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 31 Oct 2006 07:28:08 +0000 (07:28 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4968 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/addons/ldapmanager/class_export.inc
plugins/addons/ldapmanager/class_exportxls.inc

index 82984e6e87438e69d5c4868059345f8e40e3cc66..7669b7f97eaaa083393d9aec775641b64ccd7ff7 100644 (file)
@@ -83,7 +83,7 @@ class ldifexport extends plugin
     if(isset($dn)){
       $acls = $this->ui->get_permissions($dn,"ldapmanager/ldifexport");
     }
-    if(!preg_match("/r/",$acls)){
+    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)));
index 69fb99c3b0a228c99f78933e4165e1af401bf17d..78e77cbb7d3b352314a145a4dbfc8fba62bc7b04 100644 (file)
@@ -11,16 +11,14 @@ class xlsexport extends plugin
   /* attribute list for save action */
   var $attributes= array();
   var $objectclasses= array();
+  var $ui;
 
   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()
@@ -35,41 +33,46 @@ class xlsexport extends plugin
     $smarty->assign("depselectivbb","");
     
     /* 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(get_people_ou()=>"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("ldapmanager");
+    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=computers,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,29 +84,42 @@ 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&amp;d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull'])); 
-    }
-    elseif(isset($_POST['sfrmgetfull']))
-    {
-      $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
-    }
-    elseif(isset($_POST['sfrmgetivbb']))
-    {
-      $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
+   
+    /* check alcs for given dn */
+    $acls ="";
+    if(isset($dn)){
+      $acls = $this->ui->get_permissions($dn,"ldapmanager/xlsexport");
     }
+    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&amp;d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));       
+      }
+      elseif(isset($_POST['sfrmgetfull']))
+      {
+        $smarty->assign("para","?ivbb=3&amp;dn=".base64_encode($_POST['selfull']));
+      }
+      elseif(isset($_POST['sfrmgetivbb']))
+      {
+        $smarty->assign("para","?ivbb=4&amp;dn=".base64_encode($_POST['selivbb']));
+      }
+    }
 
     /* Show main page */
     return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));