Code

Upps
[gosa.git] / plugins / admin / fai / class_faiTemplate.inc
index bcaabc0ec0478ce801d1a2bddc3060ca3bed5e07..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,7 +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();
 
     /* Prepare FAIscriptEntry to write it to ldap
      * First sort array.
@@ -359,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";
+          }
         }
       }
 
@@ -369,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); 
+        $ldap->modify ($tmp); 
+        show_ldap_error($ldap->get_error(), _("Saving FAI template failed")); 
 
         $this->handle_post_events("modify");
       }elseif($obj['status']=="new"){
@@ -385,8 +401,10 @@ $ldap->modify ($tmp);
         $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);
     }
   }
 }