Code

Added toggling of remove flag for packages
[gosa.git] / plugins / admin / fai / class_faiTemplate.inc
index 9ba26c6496b89a5464ce9b30ffd237f0d199d7fa..56e7f613d02bc6e22742f3a701988cdbedd87d77 100644 (file)
@@ -210,7 +210,7 @@ class faiTemplate extends plugin
   
         $dn = $this->SubObjects[$key]['dn'];       
  
-        $down = "<a href='getFAIscript.php?is_template&id=".base64_encode($dn)."' target='_blank'>
+        $down = "<a href='getFAIscript.php?is_template&id=".base64_encode($dn)."'>
           <img src='images/save.png' alt='"._("Download")."' title='"._("Download")."' border=0>
           </a>";
       }
@@ -308,7 +308,7 @@ class faiTemplate extends plugin
 
     $ldap = $this->config->get_ldap_link();
 
-    $ldap->cat($this->dn);
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()!=0){
       /* Write FAIscript to ldap*/
       $ldap->cd($this->dn);
@@ -322,11 +322,10 @@ class faiTemplate extends plugin
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
     }
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Saving FAI template base failed"));
 
     /* Do object tagging */
     $this->handle_object_tagging();
-    show_ldap_error($ldap->get_error());
 
     /* Prepare FAIscriptEntry to write it to ldap
      * First sort array.
@@ -363,9 +362,20 @@ class faiTemplate extends plugin
       $sub_dn = "cn=".$obj['cn'].",".$this->dn;
 
       if($obj['status']=="new"){
-        $ldap->cat($sub_dn);
+        $ldap->cat($sub_dn,array("objectClass"));
         if($ldap->count()){
-          $obj['status']="modify";
+          $obj['status']="edited";
+        }
+      }
+
+       /* Check if gosaAdministrativeUnitTag is required as object class */
+      if($obj['status'] == "edited"){
+        $ldap->cat($sub_dn,array("objectClass"));
+        $attrs = $ldap->fetch();
+        if(isset($attrs['objectClass'])){
+          if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
+            $tmp['objectClass'][] = "gosaAdministrativeUnitTag";
+          }
         }
       }
 
@@ -373,10 +383,12 @@ class faiTemplate extends plugin
         $ldap->cd($sub_dn);
         $ldap->rmdir_recursive($sub_dn);
         $this->handle_post_events("remove");
+        show_ldap_error($ldap->get_error(), _("Removing FAI template base failed")); 
       }elseif($obj['status'] == "edited"){
         $ldap->cd($sub_dn);
         $this->cleanup();
         $ldap->modify ($tmp); 
+        show_ldap_error($ldap->get_error(), _("Saving FAI template failed")); 
 
         $this->handle_post_events("modify");
       }elseif($obj['status']=="new"){
@@ -389,11 +401,10 @@ class faiTemplate extends plugin
         $ldap->cd($sub_dn);
         $ldap->add($tmp); 
         $this->handle_post_events("add");
+        show_ldap_error($ldap->get_error(), _("Saving FAI template failed")); 
       }
-      show_ldap_error($ldap->get_error()); 
 
       $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
-      show_ldap_error($ldap->get_error()); 
     }
   }
 }