Code

Fixed Already exists errormsg, for fai objects
[gosa.git] / plugins / admin / fai / class_faiHookEntry.inc
index 3621552b0f9648d3eb09ec710e4f89f6197cf6e9..5dd08ab682531b8668f298f82871cbdfc38ad789 100644 (file)
@@ -35,6 +35,34 @@ class faiHookEntry extends plugin
       $this->Object_status = "new";
       $this->orig_cn       = false;
     }
+
+    if(isset($this->Object_FAIscript)){
+      $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, $this->dn, "FAIscript=*", array("FAIscript"));
+      if ($sr) {
+        $ei=ldap_first_entry($ds, $sr);
+        if ($ei) {
+          if ($info = ldap_get_values_len($ds, $ei, "FAIscript")){
+            $this->Object_FAIscript = base64_decode($info[0]);
+          }
+        }
+      }
+
+      /* close conncetion */
+      ldap_unbind($ds);
+    }
+
   }
 
   function execute()
@@ -42,6 +70,18 @@ class faiHookEntry extends plugin
     /* Fill templating stuff */
     $smarty     = get_smarty();
     $display = "";
+        
+    if(isset($_POST['ImportUpload'])){
+      if(($_FILES['ImportFile']['error']!=0)){
+        print_red(_("Please select a valid file."));
+      }else
+      if(($_FILES['ImportFile']['size']==0)){
+        print_red(_("Selected file is empty."));
+      }else{
+        $str = utf8_encode(file_get_contents($_FILES['ImportFile']['tmp_name']));
+        $this->Object_FAIscript = $str;
+      }
+    }
 
     foreach($this->attributes as $attrs){
       $smarty->assign($attrs,stripslashes($this->$attrs));