Code

Fixed string
[gosa.git] / gosa-plugins / ldapmanager / addons / ldapmanager / class_export.inc
index b61a9de4027fb341c92021b6f9abe3a6a58192ed..ec6448040b11832d1bcdbdc6f51e5b3c43387da1 100644 (file)
@@ -15,6 +15,8 @@ class ldifexport extends plugin
 
     function ldifexport (&$config, $dn= NULL)
     {
+
+        $this->initTime = microtime(TRUE);
         /* Include config object */
         $this->config= &$config;
         $this->ui = get_userinfo();
@@ -23,6 +25,8 @@ class ldifexport extends plugin
         $this->baseSelector->setSubmitButton(false);
         $this->baseSelector->setHeight(300);
         $this->baseSelector->update(true);
+        stats::log('plugin', $class = get_class($this), $category = array($this->acl_category),  $action = 'open',
+                $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
 
     }
 
@@ -49,24 +53,25 @@ class ldifexport extends plugin
 
         // Assign smarty values 
         $smarty= get_smarty();
+
         $smarty->assign("single","");
         $smarty->assign("base", $this->baseSelector->render());
 
         // fill in old vars in the Export form
-        if(isset($_POST['single'])) $smarty->assign("single",$_POST['single']);
+        if(isset($_POST['single'])) $smarty->assign("single",set_post(get_post('single')));
 
         // Get the LDAP link, to generate the Export
         $ldap = $this->config->get_ldap_link();
         $dn = "";
         if(isset($_POST['sfrmgetsingle']))
         {  
-            $dn   = $_POST['single'];
+            $dn   = get_post('single');
             $scope= "base";
             $acls = $this->ui->get_permissions($dn,"ldapmanager/ldif");
             $name = "entryExport.ldif";
             if(!$ldap->dn_exists($dn)){
-                msg_dialog::display(_("Ldap error"),
-                        sprintf(_("No such object '%s'!"),bold(LDAP::fix($dn))),
+                msg_dialog::display(_("LDAP error"),
+                        sprintf(_("No such object %s!"),bold(LDAP::fix($dn))),
                         ERROR_DIALOG);
                 $dn ="";
             }
@@ -79,17 +84,32 @@ class ldifexport extends plugin
         }
 
         if(!empty($dn)){
+
             // Check permissions before sending the output
             if(!preg_match("/r/",$acls)){
                 msg_dialog::display(_("Permission error"), 
-                        sprintf(_("You have no permission to export '%s'!"),LDAP::fix($dn)),
+                        sprintf(_("You have no permission to export %s!"), bold(LDAP::fix($dn))),
                         ERROR_DIALOG);
             }else{
-                $data = $ldap->generateLdif($dn, 'objectClass=*',array(),$scope);
-                send_binary_content($data,$name);
+
+                // Check permissions before sending the output
+                if(!preg_match("/r/",$acls)){
+                    msg_dialog::display(_("Permission error"),
+                            sprintf(_("You have no permission to export %s!"), bold(LDAP::fix($dn))),
+                            ERROR_DIALOG);
+                }else{
+                    $data = $ldap->generateLdif(LDAP::fix($dn), 'objectClass=*',$scope);
+                    if($data === NULL){
+                        msg_dialog::display(_("Error"),
+                                sprintf(_("Failed to generate LDAP export: %s"), $ldap->get_error()),
+                                ERROR_DIALOG);
+                    }else{
+                        send_binary_content($data,$name);
+                    }
+                }
             }
         }
-
+    
         // Show the main form
         return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
     }