Code

Upps
[gosa.git] / plugins / admin / fai / class_faiTemplate.inc
index 0b57d6c578e99b0cf4a8c6cf283e3fb75d3ab5cb..56e7f613d02bc6e22742f3a701988cdbedd87d77 100644 (file)
@@ -191,10 +191,9 @@ class faiTemplate extends plugin
       return($display);
     }
 
-     /* Divlist            added 28.02.2006
-       Containing FAIscripts
-     */
+     /* Divlist Containing FAItemplates */
     $divlist = new divSelectBox("FAItemplates");
+    $divlist->setHeight(400);
     if((chkacl($this->acl,"cn")!="") || ($this->FAIstate == "freeze")){
       $img_edit = "<input type='image' src='images/edit.png'      name='editscript_%s'    title='"._("edit")."' alt='"._("edit")."'>";
       $img_remo = "";
@@ -211,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>";
       }
@@ -309,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);
@@ -323,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.
@@ -360,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";
+          }
         }
       }
 
@@ -370,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"){
@@ -386,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);
     }
   }
 }