Code

Prepared ldapmanager for acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 31 Oct 2006 07:04:11 +0000 (07:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 31 Oct 2006 07:04:11 +0000 (07:04 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4966 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/addons/ldapmanager/class_csvimport.inc
plugins/addons/ldapmanager/class_export.inc
plugins/addons/ldapmanager/class_exportxls.inc
plugins/addons/ldapmanager/class_import.inc
plugins/addons/ldapmanager/main.inc

index 86fee5fc4d16573451760383b7f13ba69e040f6c..c1bc331e49fd3be14aa7585d76d89baeab7ac66a 100644 (file)
@@ -18,13 +18,6 @@ class csvimport extends plugin
   {
     /* 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);
-
-
   }
 
   function execute()
@@ -496,6 +489,26 @@ class csvimport extends plugin
     /* Show main page */
     return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE)));
   }
+
+
+  /* Return plugin informations for acl handling
+     #FIXME You can only read attributes within this report plugin */
+  function plInfo()
+  {
+    return (array(
+        "plShortName"   => _("CSV import"),
+        "plDescription" => _("CSV import"),
+        "plSelfModify"  => FALSE,
+        "plDepends"     => array(),
+        "plPriority"    => 4,
+        "plSection"     => array("addon"),
+        "plCategory"    => array("ldapmanager"),
+
+        "plProvidedAcls" => array()
+        ));
+  }
+
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 8f7dd4d394785ebdf6dec732dfe7a53b26b4cbab..82984e6e87438e69d5c4868059345f8e40e3cc66 100644 (file)
@@ -14,12 +14,7 @@ class ldifexport extends plugin
   {
     /* 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()
@@ -33,34 +28,36 @@ class ldifexport extends plugin
     $smarty->assign("type",FALSE);
     $smarty->assign("depselectivbb","");
 
-    /* Check permissions for export */
-    if (chkacl($this->acl,"export")!=""){
-      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'];
-      } 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);
+    $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);
 
     // Get the LDAP link, to generate the Export
     $ldap = $this->config->get_ldap_link();
@@ -75,33 +72,63 @@ 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&amp;dn=".base64_encode($_POST['single']));
-    }
-    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/ldifexport");
     }
+    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&amp;dn=".base64_encode($_POST['single']));
+      }
+      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('contentexport.tpl', TRUE)));
   }
+
+  /* Return plugin informations for acl handling
+     #FIXME You can only read attributes within this report plugin */
+  function plInfo()
+  {
+    return (array(
+        "plShortName"   => _("Export"),
+        "plDescription" => _("Export"),
+        "plSelfModify"  => FALSE,
+        "plDepends"     => array(),
+        "plPriority"    => 1,
+        "plSection"     => array("addon"),
+        "plCategory"    => array("ldapmanager" => array("objectClass" => "none", "description" => _("Ldap manager addon"))),
+
+        "plProvidedAcls" => array()
+        ));
+  }
+
 }
 
 
index ea03de074160914cb75db43b669ecf92e254c541..69fb99c3b0a228c99f78933e4165e1af401bf17d 100644 (file)
@@ -108,6 +108,23 @@ class xlsexport extends plugin
     /* Show main page */
     return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
   }
+
+  /* Return plugin informations for acl handling
+     #FIXME You can only read attributes within this report plugin */
+  function plInfo()
+  {
+    return (array(
+        "plShortName"   => _("Export XLS"),
+        "plDescription" => _("Export XLS"),
+        "plSelfModify"  => FALSE,
+        "plDepends"     => array(),
+        "plPriority"    => 2,
+        "plSection"     => array("addon"),
+        "plCategory"    => array("ldapmanager"),
+
+        "plProvidedAcls" => array()
+        ));
+  }
 }
 
 
index ec5662c8a2dfa7ccc56c6580d188225f74a87241..5421ec364c7d1164fc42e14ef6334321a9df9221 100644 (file)
@@ -114,6 +114,22 @@ class ldifimport extends plugin
 
   }
 
+  /* Return plugin informations for acl handling
+     #FIXME You can only read attributes within this report plugin */
+  function plInfo()
+  {
+    return (array(
+        "plShortName"   => _("Import"),
+        "plDescription" => _("Import"),
+        "plSelfModify"  => FALSE,
+        "plDepends"     => array(),
+        "plPriority"    => 3,
+        "plSection"     => array("addon"),
+        "plCategory"    => array("ldapmanager"),
+
+        "plProvidedAcls" => array()
+        ));
+  }
 }
 
 
index 9c529f2a286dab711dd6e0f20e12786d77eac9a8..696c14add98996662b90b6368c40cb02a6de1fe7 100644 (file)
@@ -22,18 +22,12 @@ if (!$remove_lock){
        /* Create phonelist object on demand */
        if (!isset($_SESSION['ldif']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
                $_SESSION['ldif']= new ldif ($config);
+               $_SESSION['ldif']->set_acl_category("logview");
        }
        $ldif= $_SESSION['ldif'];
 
-       #print_red(_("Warning: Please check the SIZELIMIT option set on your LDAP server. You may not get all entries, if this value is to low!"));
-
-    /* set permissions */
-    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
-    $ldif->acl= get_module_permission($acl, "ldapmanager", $ui->dn);
-       
        /* Execute formular */
        $display= $ldif->execute ();
-
        $display.= "<input type=\"hidden\" name=\"ignore\">\n";
 
        /* Page header*/