Code

Added Template file upload, binary
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Oct 2005 07:55:38 +0000 (07:55 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Oct 2005 07:55:38 +0000 (07:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1474 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index b33788bd56a559db4cf8a22710b97fa706e30bb7..0d1ea42a6652df1d9a77581eaf6810277d112c21 100644 (file)
@@ -66,7 +66,9 @@ class faiTemplate extends plugin
         foreach($this->sub64coded as $codeIt){
           $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]);
         }       
+
+        $this->SubObjects[$object['cn'][0]]['FAItemplateFile'] =base64_decode($this->readBinary("FAItemplateFile",$object['dn']));
+       
         $this->SubObjects[$object['cn'][0]]['status']      = "edited";
         $this->SubObjects[$object['cn'][0]]['dn']          = $object['dn'];
       }
@@ -289,6 +291,36 @@ class faiTemplate extends plugin
       show_ldap_error($ldap->get_error()); 
     }
   }
+
+  function readBinary($attr,$dn){
+    $Data  ="";
+    $ds= ldap_connect($this->config->current['SERVER']);
+    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
+    if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
+      ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
+      ldap_set_rebind_proc($ds, array(&$this, "rebind"));
+    }
+
+    if(isset($this->config->current['TLS']) &&  $this->config->current['TLS'] == "true"){
+      ldap_start_tls($ds);
+    }
+
+    $r  = ldap_bind($ds);
+    $sr = @ldap_read($ds, $dn, $attr."=*", array($attr));
+
+    if ($sr) {
+      $ei=ldap_first_entry($ds, $sr);
+      if ($ei) {
+        if ($info = ldap_get_values_len($ds, $ei, $attr)){
+          $Data= $info[0];
+        }
+      }
+    }
+
+    /* close conncetion */
+    ldap_unbind($ds);
+    return($Data);
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 4476c548505e5bede0641538d35952fff0dae1f3..c4e8dad3a3139ef49779d48df93405f1eaeca66d 100644 (file)
@@ -43,10 +43,18 @@ class faiTemplateEntry extends plugin
     $smarty     = get_smarty();
     $display = "";
 
+    if(isset($_POST['TmpFileUpload'])){
+      if($str=file_get_contents($_FILES['FAItemplateFile']['tmp_name'])){
+        $this->Object_FAItemplateFile = $str;
+      }
+    
+    }
     foreach($this->attributes as $attrs){
       $smarty->assign($attrs,stripslashes($this->$attrs));
     }
 
+    $smarty->assign("Object_FAItemplateFile","");
+  
     for($i =1 ; $i <= 100 ; $i++){
       $Object_FAIprioritys[$i]=$i;
     }
@@ -60,6 +68,7 @@ class faiTemplateEntry extends plugin
   {
     if(isset($_POST['SubObjectFormSubmitted'])){
       foreach($this->attributes as $attrs){
+        if($attrs == "Object_FAItemplateFile") continue;
         if(isset($_POST[$attrs])){
           $this->$attrs = $_POST[$attrs];
         }else{
index e7ef3a72144e9e4c8efe4175ca90f5ad3e92d8e2..57d1d9e7317721d2901af0ef2231ab9242a0c193 100644 (file)
@@ -35,7 +35,8 @@
                                                        </LABEL>
                                                </td>
                                                <td>
-                                                       <input type="text" name="Object_FAItemplateFile" value="{$Object_FAItemplateFile}" id="Object_FAItemplateFile">
+                                                       <input type="file" name="FAItemplateFile" value="{$Object_FAItemplateFile}" id="Object_FAItemplateFile">
+                                                       <input type="submit" value="{t}upload{/t}" name="TmpFileUpload">
                                                </td>
                                        </tr>
                                        <tr>