1 <?php
3 class goto_task extends plugin
4 {
5 /* Definitions */
6 var $plHeadline = "System mass deployment";
7 var $plDescription = "This does something";
9 var $parent = NULL;
10 var $data = array();
12 var $attributes = array("MACADDRESS","ID","STATUS","HEADERTAG");
14 function goto_task(&$config, &$parent, $data = array())
15 {
16 /* Set parent object */
17 $this->parent = &$parent;
18 $this->data = $data;
20 /* Intialize plugin */
21 $this->config = &$config;
22 }
25 function execute()
26 {
27 $smarty = get_smarty();
28 $smarty->assign("Actions",$this->parent->get_actions());
29 foreach($this->attributes as $attr){
30 if(isset($this->data[$attr])){
31 $smarty->assign($attr,$this->data[$attr]);
32 }else{
33 $smarty->assign($attr,"");
34 }
35 }
37 $year = substr($this->data['TIMESTAMP'],0,4);
38 $month = substr($this->data['TIMESTAMP'],4,2);
39 $day = substr($this->data['TIMESTAMP'],6,2);
41 $hour = substr($this->data['TIMESTAMP'],8,2);
42 $minute = substr($this->data['TIMESTAMP'],10,2);
43 $second = substr($this->data['TIMESTAMP'],12,2);
45 $years = array();
46 for($i = date("Y",time()); $i <= 2037 ;$i ++){
47 $years[$i] = $i;
48 }
49 $months = array();
50 for($i = 1; $i <= 12; $i ++){
51 $e = str_pad($i,2,"0",STR_PAD_LEFT);
52 $months[$e] = $e;
53 }
54 $days = array();
55 for($i = 1; $i <= cal_days_in_month(CAL_GREGORIAN,$month,$year); $i ++){
56 $e = str_pad($i,2,"0",STR_PAD_LEFT);
57 $days[$e] = $e;
58 }
59 $hours = array();
60 for($i = 0; $i < 24; $i ++){
61 $e = str_pad($i,2,"0",STR_PAD_LEFT);
62 $hours[$e] = $e;
63 }
64 $minutes = array();
65 for($i = 0; $i < 60; $i ++){
66 $e = str_pad($i,2,"0",STR_PAD_LEFT);
67 $minutes[$e] = $e;
68 }
69 $seconds = array();
70 for($i = 0; $i < 60; $i ++){
71 $e = str_pad($i,2,"0",STR_PAD_LEFT);
72 $seconds[$e] = $e;
73 }
75 $smarty->assign("years", $years);
76 $smarty->assign("months", $months);
77 $smarty->assign("days", $days);
78 $smarty->assign("hours", $hours);
79 $smarty->assign("minutes", $minutes);
80 $smarty->assign("seconds", $seconds);
82 $smarty->assign("time_year",$year);
83 $smarty->assign("time_month",$month);
84 $smarty->assign("time_day",$day);
85 $smarty->assign("time_hour",$hour);
86 $smarty->assign("time_minute",$minute);
87 $smarty->assign("time_second",$second);
89 return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE)));
90 }
93 function save_object()
94 {
95 if(isset($_POST['HeaderTag'])){
96 $possible_tags = $this->parent->get_actions();
97 $tag = $_POST['HeaderTag'];
98 if(isset($possible_tags[$tag])){
99 $this->data['HEADERTAG'] = $tag;
100 }
101 }
102 foreach(array("status","macaddress") as $attr){
103 if(isset($_POST[$attr])){
104 $this->data[strtoupper($attr)] = $_POST[$attr];
105 }
106 }
107 $date = "";
108 foreach(array("time_year","time_month","time_day","time_hour","time_minute","time_second") as $attr){
109 if(isset($_POST[$attr])){
110 $date .= $_POST[$attr];
111 }
112 }
113 if(strlen($date) == 14){
114 $this->data['TIMESTAMP'] = $date;
115 }
116 }
118 function save()
119 {
120 $tmp = array();
121 foreach(array("STATUS","MACADDRESS","HEADERTAG","TIMESTAMP") as $attr){
122 if(isset($this->data[$attr])){
123 $tmp[$attr] = $this->data[$attr];
124 }
125 }
126 return($tmp);
127 }
128 }
129 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
130 ?>