Code

Fixed Translation Strings.
[gosa.git] / plugins / admin / systems / class_goFonServer.inc
index 4d0fca755371dbb77d4f5f08509c920509a1c754..e8cd4d529b9324d574b7b959c224754d1d318653 100644 (file)
@@ -8,7 +8,7 @@ class goFonServer extends plugin{
 
   /* This plugin only writes its objectClass */
   var $objectclasses    = array("goFonServer");
-  var $attributes       = array("goFonServerStatus","goFonAdmin", "goFonPassword","goFonAreaCode", "goFonCountryCode");
+  var $attributes       = array("goFonAdmin", "goFonPassword","goFonAreaCode", "goFonCountryCode");
   var $StatusFlag       = "goFonServerStatus";
  
   /* This class can't be assigned twice so it conflicts with itsself */
@@ -16,6 +16,7 @@ class goFonServer extends plugin{
 
   var $DisplayName      = "";
   var $dn               = NULL;
+  var $cn               ="";
   var $acl;
 
   var $goFonServerStatus  = "";
@@ -45,6 +46,7 @@ class goFonServer extends plugin{
 
   function getListEntry()
   {
+    $this->updateStatusState();
     $flag = $this->StatusFlag;
     $fields['Status']     = $this->$flag;
     $fields['Message']    = _("Asterisk management");
@@ -167,6 +169,16 @@ class goFonServer 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");
@@ -179,6 +191,23 @@ class goFonServer 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];
+    }
+  }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>