Code

Removed Object_ from Templates
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Oct 2005 08:18:05 +0000 (08:18 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Oct 2005 08:18:05 +0000 (08:18 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1632 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiTemplate.inc
plugins/admin/fai/class_faiTemplateEntry.inc
plugins/admin/fai/faiTemplate.tpl
plugins/admin/fai/faiTemplateEntry.tpl

index bdd177d57e47693f024ea180600a3444d6773e3c..1ee396e1963496809da340dc198c74d3d42bae0b 100644 (file)
@@ -194,10 +194,12 @@ class faiTemplate extends plugin
    */
   function save_object()
   {
-    plugin::save_object();
-    foreach($this->attributes as $attrs){
-      if(isset($_POST[$attrs])){
-        $this->$attrs = $_POST[$attrs];
+    if(isset($_POST['FAItemplate_posted'])){
+      plugin::save_object();
+      foreach($this->attributes as $attrs){
+        if(isset($_POST[$attrs])){
+          $this->$attrs = $_POST[$attrs];
+        } 
       }
     }
   }
index d25a2dbedceb7e161d726496f18343ba4c3a3e0a..160047b5dd2efd42b8c1cfaa3f947e1cadae0c1a 100644 (file)
@@ -9,22 +9,22 @@ class faiTemplateEntry extends plugin
 
   /* attribute list for save action */
   var $ignore_account= TRUE;
-  var $attributes   = array("Object_cn","Object_description","Object_FAItemplateFile","Object_FAItemplatePath","Object_FAImode","Object_user","Object_group","Object_binary","Object_FAIowner");
+  var $attributes   = array("cn","description","FAItemplateFile","FAItemplatePath","FAImode","user","group","binary","FAIowner");
   var $objectclasses= array();
 
   var $orig_cn              = "";
 
-  var $Object_dn            = "";
-  var $Object_cn            = "";
-  var $Object_FAItemplateFile   = "";
-  var $Object_FAItemplatePath   = "";
-  var $Object_description   = "";
-  var $Object_status        = "new";
-  var $Object_FAImode       = "0640";
-  var $Object_FAIowner      = "root.root";
-  var $Object_user          = "root";
-  var $Object_group         = "root";
-  var $Object_binary        = false;
+  var $dn            = "";
+  var $cn            = "";
+  var $FAItemplateFile   = "";
+  var $FAItemplatePath   = "";
+  var $description   = "";
+  var $status        = "new";
+  var $FAImode       = "0640";
+  var $FAIowner      = "root.root";
+  var $user          = "root";
+  var $group         = "root";
+  var $binary        = false;
   
   function faiTemplateEntry ($config, $dn= NULL,$object=false)
   {
@@ -33,21 +33,21 @@ class faiTemplateEntry extends plugin
       $this->orig_cn= $object['cn'];
       $this->dn=$object['dn'];
       foreach($object as $name=>$value){
-        $oname = "Object_".$name;
+        $oname = $name;
         $this->$oname=$value;
       }
     }else{
-      $this->Object_status = "new";
+      $this->status = "new";
       $this->orig_cn       = false;
     }
-    $this->Object_user = explode( '.', $this->Object_FAIowner );
-    $this->Object_group = $this->Object_user[1];
-    $this->Object_user = $this->Object_user[0];
-    $_SESSION['binary'] = $this->Object_FAItemplateFile;
+    $this->user = explode( '.', $this->FAIowner );
+    $this->group = $this->user[1];
+    $this->user = $this->user[0];
+    $_SESSION['binary'] = $this->FAItemplateFile;
     $_SESSION['binarytype'] = 'octet-stream';
-    $_SESSION['binaryfile'] = basename( $this->Object_FAItemplatePath );
+    $_SESSION['binaryfile'] = basename( $this->FAItemplatePath );
     
-    $this->Object_FAImode= sprintf("%0.4s", $this->Object_FAImode)." ";
+    $this->FAImode= sprintf("%0.4s", $this->FAImode)." ";
   }
 
   function execute()
@@ -59,18 +59,18 @@ class faiTemplateEntry extends plugin
 
     if(isset($_POST['TmpFileUpload'])){
       if($str=file_get_contents($_FILES['FAItemplateFile']['tmp_name'])){
-        $this->Object_FAItemplateFile = $str;
+        $this->FAItemplateFile = $str;
 
         /* If we don't have a filename set it from upload filename. */
-        if( 0 == strlen( $this->Object_FAItemplatePath ) )
-          $this->Object_FAItemplatePath = $_FILES['FAItemplateFile']['name'];
+        if( 0 == strlen( $this->FAItemplatePath ) )
+          $this->FAItemplatePath = $_FILES['FAItemplateFile']['name'];
       }
     
     }
     
     $status= _("no file uploaded yet");
-    if(strlen($this->Object_FAItemplateFile)){
-      $status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->Object_FAItemplateFile));
+    if(strlen($this->FAItemplateFile)){
+      $status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->FAItemplateFile));
     }
     $smarty->assign("status",$status);
 
@@ -86,7 +86,7 @@ class faiTemplateEntry extends plugin
     }
 
     /* Assign file modes */
-    $tmode= "$this->Object_FAImode ";
+    $tmode= "$this->FAImode ";
     foreach (array("s", "u", "g", "o") as $type){
       $current= substr($tmode, 0, 1);
       $tmode=   preg_replace("/^./", "", $tmode);
@@ -101,7 +101,7 @@ class faiTemplateEntry extends plugin
       }
     }
 
-    $smarty->assign("Object_FAItemplateFile","");
+    $smarty->assign("FAItemplateFile","");
 
     $display.= $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE));
     return($display);
@@ -110,15 +110,15 @@ class faiTemplateEntry extends plugin
   /* Save data to object */
   function save_object()
   {
-    if (!isset($_POST['Object_FAItemplatePath'])){
+    if (!isset($_POST['FAItemplatePath'])){
       return;
     }
     if(isset($_POST['SubObjectFormSubmitted'])){
       foreach($this->attributes as $attrs){
-        if($attrs == "Object_FAItemplateFile") 
+        if($attrs == "FAItemplateFile") 
           continue;
-        if($attrs == "Object_FAIowner") {
-          $this->$attrs = $_POST["Object_user"] . '.' . $_POST["Object_group"];
+        if($attrs == "FAIowner") {
+          $this->$attrs = $_POST["user"] . '.' . $_POST["group"];
           continue;
         }
         if(isset($_POST[$attrs])){
@@ -142,36 +142,36 @@ class faiTemplateEntry extends plugin
       }
       $tmode= $tmode.$dest;
     }
-    $this->Object_FAImode= $tmode;
+    $this->FAImode= $tmode;
   }
 
   /* Check supplied data */
   function check()
   {
     $message= array();
-    if(empty($this->Object_FAItemplateFile)){
+    if(empty($this->FAItemplateFile)){
       $message[]=_("Please specify a value for attribute 'file'.");
     } 
 
-    if(empty($this->Object_FAItemplatePath)){
+    if(empty($this->FAItemplatePath)){
       $message[]=_("Please specify a value for attribute 'path'.");
     } 
   
-    if(empty($this->Object_cn)){
+    if(empty($this->cn)){
       $message[] = _("Please enter a name.");
     }
 
-    if(empty($this->Object_user)){
+    if(empty($this->user)){
       $message[] = _("Please enter a user.");
     }
-    elseif(preg_match("/[^0-9a-z]/i",$this->Object_user)){
+    elseif(preg_match("/[^0-9a-z]/i",$this->user)){
       $message[] = _("Please enter a valid user. Only a-Z 0-9 are allowed.");
     }
 
-    if(empty($this->Object_group)){
+    if(empty($this->group)){
       $message[] = _("Please enter a group.");
     }
-    elseif(preg_match("/[^0-9a-z]/i",$this->Object_group)){
+    elseif(preg_match("/[^0-9a-z]/i",$this->group)){
       $message[] = _("Please enter a valid group. Only a-Z 0-9 are allowed.");
     }
 
@@ -182,8 +182,7 @@ class faiTemplateEntry extends plugin
   {
     $tmp=array();
     foreach($this->attributes as $attrs){ 
-      $attr = preg_replace("/^Object_/","",$attrs);
-      $tmp[$attr] = $this->$attrs;
+      $tmp[$attrs] = $this->$attrs;
     }
 
     if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
@@ -192,7 +191,7 @@ class faiTemplateEntry extends plugin
     }
   
     $tmp['dn']      = $this->dn;  
-    $tmp['status']  = $this->Object_status;  
+    $tmp['status']  = $this->status;  
 
     return($tmp);
   }
index ed3d004cd258a50e5747cb7af69d25397997ea47..e7e2a8fbe4e551bd55c670b1a62b8c1512915685 100644 (file)
@@ -49,3 +49,4 @@
                </td>
        </tr>
 </table>
+<input type="hidden" value="1" name="FAItemplate_posted">
index aafae0ec4c5ea05a65a715a20e6247f7a8632c53..1599ce9242a84b7a4520a9481ea879714cc6940b 100644 (file)
@@ -5,11 +5,11 @@
 <tr>
        <td width="50%">
                {t}Name{/t}{$must}&nbsp;
-               <input value="{$Object_cn}" name="Object_cn" size="13">&nbsp;&nbsp;
+               <input value="{$cn}" name="cn" size="13">&nbsp;&nbsp;
        </td>
        <td>
                {t}Description{/t}&nbsp;
-               <input size="35" value="{$Object_description}" name="Object_description">
+               <input size="35" value="{$description}" name="description">
        </td>
 </tr>
 </table>
    <table>
     <tr>
                <td style="vertical-align:top">
-                       <LABEL for="Object_FAItemplateFile">
+                       <LABEL for="FAItemplateFile">
                                {t}File{/t}{$must}&nbsp;
                        </LABEL>
                        </td>
                <td style="vertical-align:top">
                        {$status}
-                       {if $Object_FAItemplatePath}
+                       {if $FAItemplatePath}
                          <a href="getbin.php?rand={$rand}"><img alt="{t}Save template{/t}..." title="{t}Save template{/t}..." src="images/save.png" border="0" align="center" /></a>
                        {/if}
                        <br>
                        <br>
-                       <input type="file" name="FAItemplateFile" value="{$Object_FAItemplateFile}" id="Object_FAItemplateFile">
+                       <input type="file" name="FAItemplateFile" value="{$FAItemplateFile}" id="FAItemplateFile">
                        &nbsp;<input type="submit" value="{t}Upload{/t}" name="TmpFileUpload">
                        <br>
                        <br>
                        </td>
        </tr><tr>
                        <td>
-                               <LABEL for="Object_FAItemplatePath">
+                               <LABEL for="FAItemplatePath">
                                        {t}Destination path{/t}{$must}&nbsp;
                                </LABEL>
                                </td>
                        <td>
-                               <input type="text" name="Object_FAItemplatePath" value="{$Object_FAItemplatePath}" id="Object_FAItemplatePath" size="45">
+                               <input type="text" name="FAItemplatePath" value="{$FAItemplatePath}" id="FAItemplatePath" size="45">
                                </td>
                </tr>
                </table>
                <tr>
        
                <td>
-                       <LABEL for="Object_user">
+                       <LABEL for="user">
                                {t}Owner{/t}{$must}&nbsp;
                        </LABEL>
                        </td>
                <td>
-                       <input type="text" name="Object_user" value="{$Object_user}" id="Object_user" size="15">
+                       <input type="text" name="user" value="{$user}" id="user" size="15">
                        </td>
        </tr><tr>
                <td style="vertical-align:top">
-                       <LABEL for="Object_group">
+                       <LABEL for="group">
                                {t}Group{/t}{$must}&nbsp;
                        </LABEL>
                        </td>
                <td>
-                       <input type="text" name="Object_group" value="{$Object_group}" id="Object_group" size="15">
+                       <input type="text" name="group" value="{$group}" id="group" size="15">
                        <br>
                        <br>
                        </td>