diff --git a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc
index 3bfd30e8fd4becf5f4b250236c0d57787d9c6023..5dc1d254d956f6c082a76d3cc77fe95bc5699a87 100644 (file)
protected $server_list = array(); // Used as cache in the target list.
protected $visible_for = HIDDEN_EVENT;
+
+ protected $periodType = "days";
+ protected $periodValue = 7;
+ protected $activate_periodical_job = FALSE;
+
+ protected $attributes = array("timestamp");
function set_type($type)
{
$this->timestamp = $this->_event_to_timestamp($data['TIMESTAMP']);
}
}
+
+ if(isset($data['PERIODIC']) && !preg_match("/none/i",$data['PERIODIC'])){
+ $tmp = explode("_",$data['PERIODIC']);
+ if(count($tmp) == 2){
+ $this->activate_periodical_job = TRUE;
+ $this->periodValue = $tmp[0];
+ $this->periodType = $tmp[1];
+ }
+ }
}
$this->time_select_used = FALSE;
$this->target_list_used = FALSE;
- $str = "<h2>"._("This job has no template.")."</h2>";
+ $str = "<h2>"._("This job has no template!")."</h2>";
$str.= "<p class='seperator'></p>";
$str.= "<div style='text-align:right;width:100%;padding:3px;'>
<input type='submit' name='abort_event_dialog' value='".msgPool::cancelButton()."'>
$seconds[$e] = $e;
}
+ $periodTypes = array(
+ "minutes" => _("Minutes"),
+ "hours" => _("Hours"),
+ "days" => _("Days"),
+ "weeks" => _("Weeks"),
+ "months" => _("Months"));
+
+
+ $smarty->assign("periodTypes", $periodTypes);
+ $smarty->assign("periodType", $this->periodType);
+ $smarty->assign("periodValue", $this->periodValue);
+ $smarty->assign("activate_periodical_job", $this-> activate_periodical_job);
+
$smarty->assign("years", $years);
$smarty->assign("months", $months);
$smarty->assign("days", $days);
/*! \brief Returns HTML content, displaying a dialog which allows to add new targets.
- @return String HTML content. (EventTargetAddList)
+ @return String HTML content. (EventAddSystemDialog)
*/
public function get_target_add_list()
{
$this->target_add_list_used = TRUE;
if($this->target_divlist == NULL){
- $this->target_divlist = new EventTargetAddList($this->config,$this);
+ $this->target_divlist = new EventAddSystemDialog($this->config,$this);
}
- $this->target_divlist->execute();
$smarty = get_smarty();
- $smarty->assign("divlist",$this->target_divlist->Draw());
+ $smarty->assign("divlist",$this->target_divlist->execute());
return($smarty->fetch(get_template_path('target_list.tpl', TRUE, dirname(__FILE__))));
}
$_POST['time_month'],
$_POST['time_day'],
$_POST['time_year']);
+
+ if(isset($_POST['periodValue'])) $this->periodValue = get_post('periodValue');
+ if(isset($_POST['periodType'])) $this->periodType = get_post('periodType');
+
+ if(isset($_POST['activate_periodical_job'])){
+ $this->activate_periodical_job = TRUE;
+ }else{
+ $this->activate_periodical_job = FALSE;
+ }
}
}
}
+ /*! \brief Returns a complete list of all available events.
+ @return Array Containing $this->get_event_info() for all available events.
+ */
+ static function get_event_types_by_category($categories)
+ {
+ $types= array();
+
+ foreach ($categories as $category) {
+ if (preg_match('/^users$/', $category)) {
+ $types= array_merge($types, DaemonEvent::get_event_types(USER_EVENT));
+ }
+ if (preg_match('/^systems$/', $category)) {
+ $types= array_merge($types, DaemonEvent::get_event_types(SYSTEM_EVENT));
+ }
+ }
+
+ return $types;
+ }
+
+
/*! \brief Returns a complete list of all available events.
@return Array Containing $this->get_event_info() for all available events.
*/
return($this->s_Schedule_Action);
}
- //
+
/*! \brief Returns the event tag to schedule a new action
@param Returns the event e.g. 'trigger_action_wake'
*/
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;
+ }
+ if($this->mode == SCHEDULED_EVENT){
+ $ret['timestamp'] = $this->_timestamp_to_event($this->timestamp);
+ }elseif(isset($ret['timestamp'])){
+ unset($ret['timestamp']);
+ }
+
+ if(isset($ret['periodic'])){
+ unset($ret['periodic']);
+ }
+ if($this->activate_periodical_job){
+ $ret['periodic']= $this->periodValue."_".$this->periodType;
+ }
+
+ return($ret);
}
{
return(array());
}
+
+
+ /*! \brief Update a class variable from outside
+ */
+ public function set_value($name,$value)
+ {
+ $name = strtolower($name);
+ if(isset($this->$name) && in_array_strict($name,$this->attributes)){
+ $this->$name = $value;
+ }
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: