From 96060816c2fe2063844415dcf0b23e144037112b Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 29 Feb 2008 09:07:18 +0000 Subject: [PATCH] Updated support daemon git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9201 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_gosaSupportDaemon.inc | 72 ++++++++++++++++--- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc index 80b214451..6fcfe0c07 100644 --- a/gosa-core/include/class_gosaSupportDaemon.inc +++ b/gosa-core/include/class_gosaSupportDaemon.inc @@ -598,7 +598,59 @@ $xml_msg.= " } - /*! \brief Returns an array containing all queued entries. + /* Allows simply appending a new DaemonEvent + */ + public function append($event) + { + if(!($event instanceof DaemonEvent)){ + return(FALSE); + } + + $this->reset_error(); + + /* Add to queue if new + */ + if($event->is_new()){ + + if($event->get_type() == SCHEDULED_EVENT){ + $action = $event->get_schedule_action(); + }elseif($event->get_type() == TRIGGERED_EVENT){ + $action = $event->get_schedule_action(); + }else{ + trigger_error("Unknown type of queue event given."); + return(FALSE); + } + + /* Get event informations, like targets.. + */ + $targets = $event->get_targets(); + $data = $event->save(); + + /* Append an entry for each target + */ + foreach($targets as $target){ + $data['macaddress'] = $target; + $this->send_data($action,$target,$data,TRUE); + + if($this->is_error()){ + return(FALSE); + } + } + return(TRUE); + }else{ + + /* Updated edited entry. + */ + $id = $event->get_id(); + $data = $event->save(); + return($this->update_entries(array($id),$data)); + } + + return(FALSE); + } + + +/*! \brief Returns an array containing all queued entries. @return Array All queued entries as an array. */ public function _send($data, $answer_expected= FALSE) @@ -652,18 +704,18 @@ $xml_msg.= " } - static function ping($target) - { - if (tests::is_mac($target)){ +static function ping($target) +{ + if (tests::is_mac($target)){ /* Get communication object */ - $d= new gosaSupportDaemon(TRUE,0.5); - $answer= $d->_send("
gosa_ping
GOSA$target
", TRUE); - return (count($answer) ? TRUE:FALSE); - } - - return (FALSE); + $d= new gosaSupportDaemon(TRUE,0.5); + $answer= $d->_send("
gosa_ping
GOSA$target
", TRUE); + return (count($answer) ? TRUE:FALSE); } + return (FALSE); +} + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -- 2.30.2