diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc
index 98b568701a99f042a045e1ee26312fa40146d59d..a657419d6303eee9825965a2763d44630f13bd5a 100644 (file)
$this->o_sock->setEncryptionKey($this->s_encryption_key);
$this->is_connected = TRUE;
}else{
- $this->error = $this->o_sock->get_error();
+ $this->s_error = $this->o_sock->get_error();
+ $this->b_error = TRUE;
$this->disconnect();
}
return($this->is_connected);
/*! \brief Returns an array containing all queued entries.
@return Array All queued entries as an array.
*/
- public function get_queued_entries($from=0,$to=10,$sort="timestamp DESC")
+ public function get_queued_entries($from=-1,$to=-1,$sort="timestamp DESC")
{
$this->b_error = FALSE;
$this->s_error = "";
</phrase>
</clause>
</where>
- <orderby>".$sort."</orderby>
+ <orderby>".$sort."</orderby>";
+if($from != -1 && $to != -1){
+$xml_msg.= "
<limit>
- <from>".$from."</from>
- <to>".$to."</to>
- </limit>
+ <from>".$from."</from>
+ <to>".$to."</to>
+ </limit>";
+}
+$xml_msg.= "
</xml>";
if($this->connect()){
$str = trim($this->o_sock->read());
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) && is_array($entries['XML'])){
- $ret = $entries;
+
+ /* Check if returned values represent a valid answer */
+ if($entries['XML']['HEADER'] == "answer"){
+
+ /* Unset header tags */
+ foreach(array("HEADER","SOURCE","TARGET") as $type){
+ unset($entries['XML'][$type]);
+ }
+ $ret = $entries['XML'];
+ }
}
}
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) && is_array($entries['XML'])){
foreach($entries['XML'] as $entry){
- $ret[] = $entry['ID'];
+ if(isset($entry['ID'])){
+ $ret[] = $entry['ID'];
+ }
}
}
}
<operator>eq</operator>
<id>".$id."</id>
</phrase>";
- $ret[$id] = FALSE;
}
$xml_msg .= "</clause>
</where>
$str = trim($this->o_sock->read());
$entries = $this->xml_to_array($str);
if(isset($entries['XML'])){
- $ret = $entries['XML'];
+ foreach($entries['XML'] as $name => $entry){
+ if(preg_match("/^ANSWER[0-9]*$/",$name)){
+ $ret[$name] = $entry;
+ }
+ }
}
}
return($ret);
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
$entries = $this->xml_to_array($str);
- if(isset($entries['XML']['ANSWER1'])){
+ if( isset($entries['XML']['HEADER']) &&
+ $entries['XML']['HEADER']=="answer" &&
+ isset($entries['XML']['ANSWER1'])){
return(TRUE);
}
}
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
$entries = $this->xml_to_array($str);
- if(isset($entries['XML']['ANSWER1'])){
+ if( isset($entries['XML']['HEADER']) &&
+ $entries['XML']['HEADER']=="answer" &&
+ isset($entries['XML']['ANSWER1'])){
$ret = $entries['XML']['ANSWER1'];
}
}
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())
+ static function send($header, $to, $data= array(), $answer_expected = FALSE)
{
$xml_message= "";
$xml_message.= "<$key>$value</$key>";
}
- return $d->_send("<xml><header>$header</header><target>$to</target>".$xml_message."</xml>");
+ return $d->_send("<xml><header>$header</header><source>GOSA</source><target>$to</target>".$xml_message."</xml>",$answer_expected);
}
+ static function ping($target)
+ {
+ if (tests::is_mac($target)){
+ /* Get communication object */
+ $d= new gosaSupportDaemon(TRUE,0.5);
+ $answer= $d->_send("<xml><header>gosa_ping</header><source>GOSA</source><target>$target</target></xml>", TRUE);
+ return (count($answer) ? TRUE:FALSE);
+ }
+
+ return (FALSE);
+ }
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: