Code

Bgcolor changed, table width fixed
[gosa.git] / plugins / admin / ogroups / class_termgroup.inc
1 <?php
3 class termgroup extends plugin
4 {
5   /* attribute list for save action */
6   var $attributes= array();
7   var $objectclasses= array();
9   var $members= array();
11   function termgroup ($config, $dn= NULL)
12   {
13     plugin::plugin($config, $dn);
14     $ldap= $config->get_ldap_link();
16     
17     /* We're only interested in the terminal members here, evaluate
18        these... */
19     for ($i= 0; $i<$this->attrs['member']['count']; $i++){
20       $member= $this->attrs['member'][$i];
21       $ldap->cat($member);
22       if (preg_match("/success/i", $ldap->error)){
23         $attrs = $ldap->fetch();
24         if (in_array("gotoTerminal", $attrs['objectClass']) ||
25             in_array("gotoWorkstation", $attrs['objectClass'])){
26           if (isset($attrs['macAddress'])){
27             $this->members[$attrs['cn'][0]]= $attrs['macAddress'][0];
28           } else {
29             $this->members[$attrs['cn'][0]]= "";
30           }
31         }
32       }
33     }
35     /* Include config object */
36     $this->config= $config;
37   }
39   function execute()
40   {
42     /* Watch for events */
43     if (isset($_POST['action'])){
44       $macaddresses="";
45       $names="";
46       foreach ($this->members as $cn => $macAddress){
47         $macaddresses.= "$macAddress ";
48         $names.= "$cn ";
49       }
51       switch($_POST['saction']){
52         case 'wake':
53           $cmd= search_config($this->config->data['TABS'], "terminfo", "WAKECMD");
54           if ($cmd == ""){
55             print_red(_("No WAKECMD definition found in your gosa.conf"));
56           } else {
57             exec ($cmd." ".$macaddresses, $dummy, $retval);
58             if ($retval != 0){
59               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
60             }
61           }
62           break;
64         case 'reboot':
65           $cmd= search_config($this->config->data['TABS'], "terminfo", "REBOOTCMD");
66           if ($cmd == ""){
67             print_red(_("No REBOOTCMD definition found in your gosa.conf"));
68           } else {
69             exec ($cmd." ".$names, $dummy, $retval);
70             if ($retval != 0){
71               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
72             }
73           }
74           break;
76         case 'halt':
77           $cmd= search_config($this->config->data['TABS'], "terminfo", "HALTCMD");
78           if ($cmd == ""){
79             print_red(_("No HALTCMD definition found in your gosa.conf"));
80           } else {
81             exec ($cmd." ".$names, $dummy, $retval);
82             if ($retval != 0){
83               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
84             }
85           }
86           break;
87       }
88     }
89  
91     
92     /* Set government mode */
93     $smarty= get_smarty();
95     $smarty->assign("actions", array("wake" => _("Wake up"), "halt" => _("Switch off"), "reboot" => _("Reboot")));
96     $smarty->assign("actionACL", chkacl($this->acl, 'action'));
98     /* Show main page */
99     return ($smarty->fetch (get_template_path('termgroup.tpl', TRUE)));
100   }
105 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
106 ?>