summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4572062)
raw | patch | inline | side by side (parent: 4572062)
author | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 27 Apr 2010 13:53:30 +0000 (13:53 +0000) | ||
committer | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 27 Apr 2010 13:53:30 +0000 (13:53 +0000) |
- Move code for saving events to a static function in the DaemonEvent
class so it can be called from different places in the code without
making it redundant. Use this new function in gotomasses and the
system plugin so that both places can benefit from the new time offset
feature.
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@17888 594d385d-05f5-0310-b6e9-bd551577e9d8
class so it can be called from different places in the code without
making it redundant. Use this new function in gotomasses and the
system plugin so that both places can benefit from the new time offset
feature.
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@17888 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/trunk/gosa-plugins/goto/addons/goto/class_gotomasses.inc b/trunk/gosa-plugins/goto/addons/goto/class_gotomasses.inc
index 0338582703545101d99b2cf198b6e39cd3f34c94..b7200f3444bbcdaeace8b9fd37a07668d881f877 100644 (file)
/* Close dialog */
if(isset($_POST['save_event_dialog'])){
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- if($this->dialog->multiple_events) {
- $event_type = get_class($this->dialog);
- $targets = $this->dialog->get_targets();
- $timestamp = $this->dialog->timestamp;
-
- $i = 1;
- $count = count($targets);
- while($i <= $count) {
- $operations = $this->dialog->concurrent_operations;
- $event = new $event_type($this->config);
- $event->set_timestamp($timestamp);
- $event->set_type(SCHEDULED_EVENT);
-
- while($operations > 0) {
- $i++;
- $target = array_shift($targets);
- $event->add_targets(array($target));
- $operations--;
- }
-
- $event->save_object();
- $event->get_targets();
- if(!$this->o_queue->append($event)){
- msg_dialog::display(_("Service infrastructure"),msgPool::siError($this->o_queue->get_error()),ERROR_DIALOG);
- }
-
- # Calculate start time for the next run
- $timestamp = $timestamp + ($this->dialog->time_offset*60);
- }
-
- $this->dialog = FALSE;
- $this->current = -1;
- }
- else {
- $this->dialog->save_object();
- if(!$this->o_queue->append($this->dialog)){
- msg_dialog::display(_("Service infrastructure"),msgPool::siError($this->o_queue->get_error()),ERROR_DIALOG);
- }else{
- $this->dialog = FALSE;
- $this->current = -1;
- }
- }
- }
+ list($this->dialog, $this->current) = DaemonEvent::save_event_dialog($this->dialog, $this->current, $this->o_queue, $this->config);
}
diff --git a/trunk/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc b/trunk/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc
index 6268d9c0eb24fd1fffe0f5a875b0ecbeb58da89a..e46fd57e5b002ebf0dc45237afc3d421a93c87e6 100644 (file)
}
+ /*! \brief Save an event dialog and check if multiple events needs to be created */
+ static function save_event_dialog($dialog, $current, $o_queue, $config)
+ {
+ if(is_object($dialog)){
+ $dialog->save_object();
+ if($dialog->multiple_events) {
+ $event_type = get_class($dialog);
+ $targets = $dialog->get_targets();
+ $timestamp = $dialog->timestamp;
+
+ $i = 1;
+ $count = count($targets);
+ while($i <= $count) {
+ $operations = $dialog->concurrent_operations;
+ $event = new $event_type($config);
+ $event->set_timestamp($timestamp);
+ $event->set_type(SCHEDULED_EVENT);
+
+ while($operations > 0) {
+ $i++;
+ $target = array_shift($targets);
+ $event->add_targets(array($target));
+ $operations--;
+ }
+
+ $event->save_object();
+ $event->get_targets();
+ if(!$o_queue->append($event)){
+ msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+ }
+
+ # Calculate start time for the next run
+ $timestamp = $timestamp + ($dialog->time_offset*60);
+ }
+
+ return(array(FALSE, -1));
+ } else {
+ $dialog->save_object();
+ if(!$o_queue->append($dialog)){
+ msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+ return(array($dialog, $current));
+ }else{
+ return(array(FALSE, -1));
+ }
+ }
+ }
+}
+
/*! \brief Returns a complete list of all available events.
@return Array Containing $this->get_event_info() for all available events.
*/
diff --git a/trunk/gosa-plugins/systems/admin/systems/class_systemManagement.inc b/trunk/gosa-plugins/systems/admin/systems/class_systemManagement.inc
index f07b78ae1842da5b466abb8e4baaed76f1886cbf..3d9fa94b5dddbd667ceaa34a196c9d2fb2f9f8c5 100644 (file)
*/
if(isset($_POST['save_event_dialog']) || $this->systab->get_type() == TRIGGERED_EVENT){
$o_queue = new gosaSupportDaemon();
- $o_queue->append($this->systab);
- if($o_queue->is_error()){
- msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
- }else{
- $this->systab = FALSE;
- }
+ $this->systab = DaemonEvent::save_event_dialog($this->systab, NULL, $o_queue, $this->config);
+
}
if(isset($_POST['abort_event_dialog'])){
$this->systab = FALSE;