\version 1.00
\date 26.02.2008
This is the base class for all new daemon events.
It implements most of the required functionality.
*/
class DaemonEvent
{
/* Menu Strings */
protected $s_Menu_Name = "s_Menu_Name not set"; // Diplayed in the ActionsMenu->CreateNew
protected $s_Event_Name = "s_Event_Name not set"; // Will be displayed in the Management list.
protected $s_Menu_Image = "images/empty.png"; // Image displayed in Actions->New
protected $s_List_Image = ""; // Image displayed in event listing
public $config; // GOsa configuration object
protected $data; // The event data, when edited
protected $a_targets = array(); // The list of assigned Targets (When newly created)
protected $s_Schedule_Action = ""; // The deamon command name when newly created. (e.g. job_trigger_action_halt)
protected $s_Trigger_Action= ""; // The deamon command name when edited. (e.g. trigger_action_halt)
protected $s_Queued_Action= ""; // The deamon command name when edited. (e.g. trigger_action_halt)
protected $timestamp = 0; // Event execution time;
protected $id = -1; // The Table ID
protected $status = "unknown";// The current event status
protected $is_new = TRUE; // Is TRUE if this is a new event
protected $mode = SCHEDULED_EVENT; // Default action is sheduled.
/* Sub dialog hanlding */
protected $target_listing = NULL; // The listing used by the target add dialog
protected $target_add_list_used = FALSE; // Indicates that the target add list was used.
protected $time_select_used = FALSE; // Indicates that we have used the timestamp select boxes.
protected $target_list_used = FALSE; // Target list was diaplayed?
protected $_target_list = array(); // Object Cache of those objects displayed in the target add dialog
protected $workstation_list = array(); // Used as cache in the target list.
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->mode = $type;
}
function get_type()
{
return($this->mode);
}
/*! \brief Class contructor.
@param Array GOsa configuration object.
@param Array Event data, only given when edited.
*/
public function __construct($config,$data = array())
{
$this->data = $data;
$this->config = $config;
timezone::get_default_timezone();
$this->timestamp = time();
/* Load values from given data */
if(count($data)){
$this->is_new = FALSE;
$attrs = array("id" => "ID");
foreach($attrs as $to => $from){
$this->$to = $data[$from];
}
if(isset($data['TIMESTAMP'])){
$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];
}
}
// Prepare lists
$this->targetList = new sortableListing();
$this->targetList->setDeleteable(true);
$this->targetList->setInstantDelete(false);
$this->targetList->setEditable(false);
$this->targetList->setWidth("100%");
$this->targetList->setHeight("200px");
$this->targetList->setColspecs(array('*'));
$this->targetList->setHeader(array(_("Mac")));
$this->targetList->setDefaultSortColumn(0);
$this->targetList->setAcl('rwcdm');
}
/*! \brief Create the HTML output for the plugin.
@return String The generated HTML output.
*/
public function execute()
{
$this->time_select_used = FALSE;
$this->target_list_used = FALSE;
$str = "
"._("This job has no template!")."
";
$str.= "";
$str.= "
";
return($str);
}
/*! \brief Returns the plugin header, displayed in the template.
@return String HTML header part.
*/
public function get_header()
{
if($this->target_add_list_used){
return("");
}
$str = "