Code

Fixed Translation Strings.
[gosa.git] / plugins / admin / systems / class_goNtpServer.inc
index 3f423dea7a7b84b892ccd4581c34957f7b7252f5..f7a9ea42ea0f881685aab9fed452154794fdd9c3 100644 (file)
@@ -8,7 +8,7 @@ class goNtpServer extends plugin{
 
   /* This plugin only writes its objectClass */
   var $objectclasses    = array("goNtpServer");
-  var $attributes       = array("goTimeSource","goNtpServerStatus");
+  var $attributes       = array("goTimeSource");
   var $StatusFlag       = "goNtpServerStatus";
 
   /* This class can't be assigned twice so it conflicts with itsself */
@@ -19,7 +19,7 @@ class goNtpServer extends plugin{
   var $goTimeSource     = array();
   var $goNtpServerStatus= "";
   var $acl;
-
+  var $cn               = "";
 
   function goNtpServer($config,$dn)
   {
@@ -64,6 +64,7 @@ class goNtpServer extends plugin{
 
   function getListEntry()
   {
+    $this->updateStatusState();
     $flag = $this->StatusFlag;
     $fields['Status']      = $this->$flag;
     $fields['Message']    = _("NTP service");
@@ -90,6 +91,7 @@ class goNtpServer extends plugin{
       $ldap->add($this->attrs);
     }
     show_ldap_error($ldap->get_error());
+    $this->handle_post_events("remove");
   }
 
 
@@ -111,6 +113,11 @@ class goNtpServer extends plugin{
       $ldap->add($this->attrs);
     }
     show_ldap_error($ldap->get_error());
+    if($this->initially_was_account){
+      $this->handle_post_events("modify");
+    }else{
+      $this->handle_post_events("add");
+    }
   }
 
 
@@ -156,6 +163,16 @@ class goNtpServer extends plugin{
       foreach ($add_attrs as $name => $value){
         $command= preg_replace("/%$name/", $value, $command);
       }
+
+      /* If there are still some %.. in our command, try to fill these with some other class vars */
+      if(preg_match("/%/",$command)){
+        $attrs = get_object_vars($this);
+        foreach($attrs as $name => $value){
+          if(!is_string($value)) continue;
+          $command= preg_replace("/%$name/", $value, $command);
+        }
+      }
+
       if (check_command($command)){
         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
             $command, "Execute");
@@ -168,6 +185,26 @@ class goNtpServer extends plugin{
     }
   }
 
+
+  /* Get updates for status flag */
+  function updateStatusState()
+  {
+    if(empty($this->StatusFlag)) return;
+
+    $attrs = array();
+    $flag = $this->StatusFlag;
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->cn);
+    $ldap->cat($this->dn,array($flag));
+    if($ldap->count()){
+      $attrs = $ldap->fetch();
+    }
+    if(isset($attrs[$flag][0])){
+      $this->$flag = $attrs[$flag][0];
+    }
+  }
+
+
   function check(){ return array();}
 
   function save_object(){;}