From 1a4c446503f8e027bb20b5495c87a986d90e76a2 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 21 May 2008 05:18:40 +0000 Subject: [PATCH] Updated DaemonEvent to allow sending additional attributes by using $this->attributes = array("var.."); git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10971 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../addons/goto/events/class_DaemonEvent.inc | 22 +++++++++++++++++-- .../goto/events/class_DaemonEvent_notify.inc | 11 +++++----- .../events/class_DaemonEvent_reinstall.inc | 6 ----- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc index 3bfd30e8f..3732d034f 100644 --- a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc +++ b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc @@ -68,6 +68,8 @@ class DaemonEvent protected $server_list = array(); // Used as cache in the target list. protected $visible_for = HIDDEN_EVENT; + + protected $attributes = array(); function set_type($type) { @@ -409,7 +411,7 @@ class DaemonEvent return($this->s_Schedule_Action); } - // + /*! \brief Returns the event tag to schedule a new action @param Returns the event e.g. 'trigger_action_wake' */ @@ -418,13 +420,19 @@ class DaemonEvent return($this->s_Trigger_Action); } + /*! brief Returns an array containig all attributes \ That should be written. @return Array e.g. 'status' => 'bla blub' */ public function save() { - return(array("timestamp" => $this->_timestamp_to_event($this->timestamp))); + $ret = array(); + foreach($this->attributes as $attr){ + $ret[$attr] = $this->$attr; + } + $ret['timestamp'] = $this->_timestamp_to_event($this->timestamp); + return($ret); } @@ -486,6 +494,16 @@ class DaemonEvent { return(array()); } + + + /*! \brief Update a class variable from outside + */ + public function set_value($name,$value) + { + if(isset($this->$name) && in_array($name,$this->attributes)){ + $this->$name = $value; + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent_notify.inc b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent_notify.inc index 734e928c5..533723c30 100644 --- a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent_notify.inc +++ b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent_notify.inc @@ -31,6 +31,8 @@ class DaemonEvent_notify extends DaemonEvent var $subject = ""; var $from = ""; + var $attributes = array("from","users","groups","message","subject"); + public function __construct($config,$data = array()) { DaemonEvent::__construct($config,$data); @@ -197,11 +199,10 @@ class DaemonEvent_notify extends DaemonEvent public function save() { $ret = DaemonEvent::save(); - $ret['users'] = array_values($this->users); - $ret['groups'] = array_values($this->groups); - $ret['subject'] = base64_encode($this->subject); - $ret['from'] = $this->from; - $ret['message'] = base64_encode($this->message); + $ret['users'] = array_values( $ret['users']); + $ret['groups'] = array_values( $ret['groups']); + $ret['subject'] = base64_encode($ret['subject']); + $ret['message'] = base64_encode($ret['message']); return($ret); } } diff --git a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent_reinstall.inc b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent_reinstall.inc index 70c4d60df..8b596c192 100644 --- a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent_reinstall.inc +++ b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent_reinstall.inc @@ -71,12 +71,6 @@ class DaemonEvent_reinstall extends DaemonEvent $display.= $this->get_footer(); return($display); } - - public function save() - { - $ret = DaemonEvent::save(); - return($ret); - } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> -- 2.30.2