Code

Added sorting to FAIscripts
[gosa.git] / plugins / admin / fai / class_faiTemplateEntry.inc
index 24bab5d1311f3d4239325e13b4e5de9c06ffd68d..203c789baa6769a8a6b7eb2894faffa903cc7a70 100644 (file)
@@ -25,7 +25,7 @@ class faiTemplateEntry extends plugin
   var $user          = "root";
   var $group         = "root";
   var $binary        = false;
-
+  var $parent        = NULL;
   var $FAIstate      = "";
   
   function faiTemplateEntry ($config, $dn= NULL,$object=false)
@@ -137,53 +137,57 @@ class faiTemplateEntry extends plugin
       $smarty->assign($attr."ACL",$this->getacl($attr,preg_match("/freeze/",$this->FAIstate)));
     }
 
-    $display.= "<h2><font color='red'>Fix / problen and ensure that size and content are correct if you download this template. Revision > 4582 (gosa-2.5 is already patched)</font></h2>".$smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE));
+    $display.=  $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE));
     return($display);
   }
 
   /* Save data to object */
   function save_object()
   {
-    if (!isset($_POST['FAItemplatePath'])){
-      return;
-    }
+    /* Check if form is posted and we are not freezed */
     if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){
-      foreach($this->attributes as $attrs){
-        if($attrs == "FAItemplateFile") 
-          continue;
-        if($attrs == "FAIowner") {
-          $this->$attrs = $_POST["user"] . '.' . $_POST["group"];
-          continue;
-        }
-        if(isset($_POST[$attrs])){
-          $this->$attrs = $_POST[$attrs];
-        }else{
-          $this->$attrs = "";
-        }
+
+      plugin::save_object();
+
+      /* Set user.group (FAIowner) attribute */  
+      if(isset($_POST['group']) && isset($_POST["user"]) && $this->acl_is_writeable("FAIowner")){
+        $this->FAIowner = $_POST["user"].'.'.$_POST["group"];
+        $this->user = $_POST['user'];
+        $this->group= $_POST['group'];
       }
-      /* Save mode */
-      $tmode= "";
-      foreach (array("s", "u", "g", "o") as $type){
-        $nr= 1;
-        $dest= 0;
-        while ($nr < 5){
-          if (isset($_POST["$type$nr"])){
-            $dest+= $nr;
+
+      /* Check if permissions have changed */
+      if($this->acl_is_writeable("FAImode")){
+
+        /* Save mode */
+        $tmode= "";
+        foreach (array("s", "u", "g", "o") as $type){
+          $nr= 1;
+          $dest= 0;
+          while ($nr < 5){
+            if (isset($_POST["$type$nr"])){
+              $dest+= $nr;
+            }
+            $nr+= $nr;
           }
-          $nr+= $nr;
+          $tmode= $tmode.$dest;
         }
-        $tmode= $tmode.$dest;
+        $this->FAImode= $tmode;
       }
-      $this->FAImode= $tmode;
     }
   }
 
+
   /* Check supplied data */
   function check()
   {
     /* Call common method to give check the hook */
     $message= plugin::check();
 
+    if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){
+      $message[] =_("There is already a template with the given name.");
+    }
+
     if(empty($this->FAItemplateFile)){
       $message[]=_("Please specify a value for attribute 'file'.");
     }