Code

Removed show_ldap_error() calls
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiTemplate.inc
index 54bd8326728984c69c5e1cc89dc396f02a1301cd..9015ba8789f9e1f853ef3ff95c591cd0a0a77501 100644 (file)
@@ -2,11 +2,6 @@
 
 class faiTemplate extends plugin
 {
-  /* CLI vars */
-  var $cli_summary      = "Manage server basic objects";
-  var $cli_description  = "Some longer text\nfor help";
-  var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* attribute list for save action */
   var $ignore_account   = TRUE;
 
@@ -66,7 +61,11 @@ class faiTemplate extends plugin
       $attrs_to_search[] = "FAIstate";
       $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search);
 
+      $data = array();
       while($object = $ldap->fetch()){
+        $data[] = $object;
+      }
+      foreach($data as $object){
 
         /* Skip objects, that are tagged as removed */
         if(isset($object['FAIstate'][0])){
@@ -176,6 +175,15 @@ class faiTemplate extends plugin
       }
     }
 
+    /* File download requested */
+    if(isset($_GET['getFAItemplate'])){
+      if(isset($this->SubObjects[$_GET['getFAItemplate']])){
+        $obj = $this->SubObjects[$_GET['getFAItemplate']];
+        $obj  = $this->get_object_attributes($obj,$this->sub_Load_Later);
+        send_binary_content($obj['FAItemplateFile'],$obj['cn'].".FAItemplate");
+      }
+    }
+
     /* Edit entries via GET */
     if(isset($_GET['act']) && isset($_GET['id'])){
       if($_GET['act'] == "edit" && isset($this->SubObjects[$_GET['id']])){
@@ -215,7 +223,7 @@ class faiTemplate extends plugin
       $msgs = $this->dialog->check();
       if(count($msgs)>0){
         foreach($msgs as $msg){
-          print_red($msg);
+          msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
         }
       }else{
         /* Get return object */
@@ -302,7 +310,7 @@ class faiTemplate extends plugin
       if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){
         $down = "";
       }else{
-        $down = "<a href='getFAIscript.php?is_template&amp;id=".base64_encode($dn)."'>
+        $down = "<a href='?plug=".$_GET['plug']."&getFAItemplate=".$key."'>
           <img src='images/save.png' alt='"._("Download")."' title='"._("Download")."' border=0>
           </a>";
       }
@@ -435,7 +443,9 @@ class faiTemplate extends plugin
     $ldap = $this->config->get_ldap_link();
 
     FAI::prepare_to_save_FAI_object($this->dn,$this->attrs);
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/template with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+    }
 
     if($this->initially_was_account){
       new log("modify","fai/".get_class($this),$this->dn,$this->attributes);
@@ -492,7 +502,7 @@ class faiTemplate extends plugin
       }
 
       /* Tag object */
-      $this->tag_attrs(&$tmp, $sub_dn, $this->gosaUnitTag);
+      $this->tag_attrs($tmp, $sub_dn, $this->gosaUnitTag);
 
       if($obj['status'] == "delete"){
         FAI::prepare_to_save_FAI_object($sub_dn,array(),true);