diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc
index 944e1fa2d8778888dc088f5b934a094f706b56f1..7dc12f1d21b115bfb90626c4371c043d4f6f004c 100644 (file)
class gosaSupportDaemon
{
- static private $s_host = "";
- static private $i_port = 0;
- static private $s_encryption_key = "";
+ private $s_host = "";
+ private $i_port = 0;
+ private $s_encryption_key = "";
private $o_sock = NULL;
private $f_timeout = 2;
# load from config, store statically
if (isset($config->current['GOSA_SI'])){
- if (gosaSupportDaemon::$s_host == ""){
- $host= preg_replace("/^.*@([^:]+):.*$/", "$1", $config->current['GOSA_SI']);
- $port= preg_replace("/^.*@[^:]+:(.*)$/", "$1", $config->current['GOSA_SI']);
- $key = preg_replace("/^(.*)@[^:]+:.*$/", "$1", $config->current['GOSA_SI']);
-
- gosaSupportDaemon::$s_host = $host;
- gosaSupportDaemon::$i_port = $port;
- gosaSupportDaemon::$s_encryption_key = $key;
+ if ($this->s_host == ""){
+ $this->s_host= preg_replace("/^.*@([^:]+):.*$/", "$1", $config->current['GOSA_SI']);
+ $this->i_port= preg_replace("/^.*@[^:]+:(.*)$/", "$1", $config->current['GOSA_SI']);
+ $this->s_encryption_key = preg_replace("/^(.*)@[^:]+:.*$/", "$1", $config->current['GOSA_SI']);
}
$this->f_timeout = $timeout;
*/
public function connect()
{
- $this->o_sock = new Socket_Client(gosaSupportDaemon::$s_host,gosaSupportDaemon::$i_port,TRUE,$this->f_timeout);
+ $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout);
if($this->o_sock->connected()){
- $this->o_sock->setEncryptionKey(gosaSupportDaemon::$s_encryption_key);
+ $this->o_sock->setEncryptionKey($this->s_encryption_key);
$this->is_connected = TRUE;
}else{
$this->error = $this->o_sock->get_error();
$ret = $entries;
}
}
+
return($ret);
}
+
/*! \brief Checks if the given ids are used queue ids.
@param Array The ids we want to check..
@return Array An array containing all ids as index and TRUE/FALSE as value.
}
}
}
+
if(!isset($params['XML'])){
- $this->set_error(_("Could not parse XML."));
- $params = array();
+ if (!array_key_exists('XML', $params)){
+ $this->set_error(_("Could not parse XML."));
+ }
+ $params = array("COUNT" => 0);
}
+
return($params);
}
/*! \brief Returns an array containing all queued entries.
@return Array All queued entries as an array.
*/
- public function send($data, $answer_expected= FALSE)
+ public function _send($data, $answer_expected= FALSE)
{
$this->b_error = FALSE;
$this->s_error = "";
if($this->connect()){
$this->o_sock->write($data);
- if ($answer_exepcted){
- $str = trim($this->o_sock->read());
- $entries = $this->xml_to_array($str);
- if(isset($entries['XML']) && is_array($entries['XML'])){
- $ret = $entries;
- }
+ if ($answer_expected){
+ $str = trim($this->o_sock->read());
+ $entries = $this->xml_to_array($str);
+ if(isset($entries['XML']) && is_array($entries['XML'])){
+ $ret = $entries;
+ }
}
}
return($ret);
}
+
+ static function send($header, $to, $data= array())
+ {
+ $xml_message= "";
+
+ /* Get communication object */
+ $d= new gosaSupportDaemon(TRUE,10);
+
+ /* Prepare data */
+ foreach ($data as $key => $value){
+ $xml_message.= "<$key>$value</$key>";
+ }
+
+ return $d->_send("<xml><header>$header</header><source>GOSA</source><target>$to</target>".$xml_message."</xml>");
+ }
+
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: