Code

Removed reference
[gosa.git] / gosa-plugins / goto / addons / goto / class_goto_log_view.inc
1 <?php
3 class goto_log_view extends plugin
4 {
5   
6   var $mac;
7   var $logs;
8   var $event;
9   var $parent;
10   var $config;
11   
12   var $o_queue;  
14   var $selected_date;
15   var $selected_file = 0;
17   var $attributes = array("selected_file","selected_date");
18  
19   function __construct($config,$event,&$parent)
20   {
21     $this->config = $config;
22     $this->event = $event;
23     $this->parent = $parent;
24     
25     /* Try to fetch logs for the given event (mac)
26      */
27     $this->o_queue = new gosaSupportDaemon();
29     /* Fetch logs for this event (mac)
30      */      
31     if(isset($this->event['MACADDRESS'])){
32       $this->mac = $this->event['MACADDRESS'];
33     }
34     $res = $this->o_queue->get_log_info_for_mac($this->mac);
35     if($this->o_queue->is_error()){
36       msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
37     }
38     if(!isset($res[$this->mac]) || !is_array($res[$this->mac])){
39       $this->logs = array();
40     }else{
41       $this->selected_date = key($res[$this->mac]);
42       $this->logs = $res;
43     }
44   }
46   function execute()
47   {
48     $smarty = get_smarty();
49     $smarty->assign("logs",$this->logs);   
50     $smarty->assign("logs_available", isset($this->logs[$this->mac]));
51     $smarty->assign("mac",$this->mac);
52     $smarty->assign("selected_file",$this->selected_file);
53     $smarty->assign("selected_date",$this->selected_date);
54     $smarty->assign("log_file", $this->get_log($this->mac,$this->selected_date,$this->selected_file));        
55     return($smarty->fetch(get_template_path('log_view.tpl', TRUE)));
56   }
59   function get_log($mac,$date,$file)
60   {
61     $this->mac = "00:01:6c:9d:b9:fa";
62     $res = $this->o_queue->get_log_file($mac,$date,$file);
63     if($this->o_queue->is_error()){
64       msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
65     }
66     $res = nl2br(htmlentities($res));
67     return($res);
68   }
70   
71   function save_object()
72   {
73     plugin::save_object();
74     foreach($this->attributes as $attr){
75       if(isset($_POST[$attr])){
76         $this->$attr = get_post($attr);
77       }
78     }
79   }
81 }
86 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
87 ?>