From 4133433328b317372898e0d521d76775b291df30 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 5 Oct 2005 07:55:38 +0000 Subject: [PATCH] Added Template file upload, binary git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1474 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/fai/class_faiTemplate.inc | 34 +++++++++++++++++++- plugins/admin/fai/class_faiTemplateEntry.inc | 9 ++++++ plugins/admin/fai/faiTemplateEntry.tpl | 3 +- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/plugins/admin/fai/class_faiTemplate.inc b/plugins/admin/fai/class_faiTemplate.inc index b33788bd5..0d1ea42a6 100644 --- a/plugins/admin/fai/class_faiTemplate.inc +++ b/plugins/admin/fai/class_faiTemplate.inc @@ -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: diff --git a/plugins/admin/fai/class_faiTemplateEntry.inc b/plugins/admin/fai/class_faiTemplateEntry.inc index 4476c5485..c4e8dad3a 100644 --- a/plugins/admin/fai/class_faiTemplateEntry.inc +++ b/plugins/admin/fai/class_faiTemplateEntry.inc @@ -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{ diff --git a/plugins/admin/fai/faiTemplateEntry.tpl b/plugins/admin/fai/faiTemplateEntry.tpl index e7ef3a721..57d1d9e73 100644 --- a/plugins/admin/fai/faiTemplateEntry.tpl +++ b/plugins/admin/fai/faiTemplateEntry.tpl @@ -35,7 +35,8 @@ - + + -- 2.30.2