Code

Added dummy graphs for plugin usage
[gosa.git] / gosa-core / plugins / generic / dashBoard / dbChannelStatus / class_dbChannelStatus.inc
1 <?php
6 class dbChannelStatus extends plugin
7 {
9     var $receivedStats = array();
11     function __construct($config)
12     {
13         parent::__construct($config, NULL);
15         // Construct the channel list.
16         $this->channelList= new sortableListing();
17         $this->channelList->setDeleteable(false);
18         $this->channelList->setEditable(false);
19         $this->channelList->setColspecs(array('30px','120px','*','100px'));
20         $this->channelList->setHeader(array('?',_("Name"),_("Description"),_("Status")));
21         $this->channelList->setWidth("100%");
22         $this->channelList->setDefaultSortColumn(1);
23         $this->channelList->setHeight("200px");
24         $this->channelList->setAcl("rwcdm");
25     }
27     function execute()
28     {
29         // Transmit daily statistics to GOsa-Server
30         if(isset($_POST['transmitStatistics'])){
32             // First try to retrieve values via RPC
33             if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
34                 $tmp = stats::dumpTables();
35                 $dump = array();
36                 foreach($tmp as $entry){
37                     $dump[] = array_values($entry);
38                 }
40                 $rpc = $this->config->getRpcHandle(
41                         "http://10.3.64.59:4000",
42                         "65717fe6-9e3e-11df-b010-5452005f1250",
43                         "WyukwauWoid2", 
44                         TRUE);
45                 $rpc->updateInstanceStatus($dump);
46                 if(!$rpc->success()){
47                     msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
48                 }
49             }
50         }
52         // Transmit daily statistics to GOsa-Server
53         if(isset($_POST['receiveStatistics'])){
55             // First try to retrieve values via RPC
56             if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
57                 $rpc = $this->config->getRpcHandle(
58                         "http://10.3.64.59:4000",
59                         "65717fe6-9e3e-11df-b010-5452005f1250",
60                         "WyukwauWoid2", 
61                         TRUE);
62                 $res = $rpc->getInstanceStats();
63                 if(!$rpc->success()){
64                     msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
65                 }
67                 $all = array_sum($res['category_count']);
68                 $tmp = array();
69                 $tmpRendered = array();
70                 foreach($res['category_count'] as $category => $count){
71                     $tmp[$category] = floor(($count / $all) * 10000) / 100;
72                     $tmpRendered[$category] = progressbar($tmp[$category]);
73                 }
74                 $this->receivedStats = $tmpRendered;
75             }
76         }
77     
78     
81         $smarty = get_smarty();
82         $smarty->assign("receivedStats",$this->receivedStats);
83     
84         $channel = array();
85         $channel[] = array(
86                         'icon' =>  image('images/true.png'),
87                         'name' =>  'GONICUS support',
88                         'desc' =>  'GONICUS helps you all time!',
89                         'stat' =>  'Online'
90                         );
91         $channel[] = array(
92                         'icon' =>  image('images/true.png'),
93                         'name' =>  'Free',
94                         'desc' =>  'Free channel, basic GOsa plugins!',
95                         'stat' =>  'Online'
96                         );
97         $channel[] = array(
98                         'icon' =>  image('images/small_error.png'),
99                         'name' =>  'Experimental',
100                         'desc' =>  'May be down for maintance!',
101                         'stat' =>  'Offline'
102                         );
105         $data = $lData = array();
106         foreach($channel as $key => $ch){
107             $data[$key] = $ch;
108             $lData[$key] = array('data' => array($ch['icon'],$ch['name'], $ch['desc'], $ch['stat']));
109         }
111         $this->channelList->setListData($data,$lData);
112         $this->channelList->update();
113         $smarty->assign('channelList', $this->channelList->render());
114         return($smarty->fetch(get_template_path('dbChannelStatus/contents.tpl', TRUE)));
115     }
117     function save_object()
118     {
119         parent::save_object();
120     }
122     function save()
123     {
124         parent::save();
125     }
127     function check()
128     {
129         return(parent::check());
130     }
132     function remove_from_parent()
133     {
134         parent::remove_from_parent();
135     }
138 ?>