Code

Changed "goFonQueueAnnounceHoldtime" into chkbox,
[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 check()
40   {
41   }
43   function execute()
44   {
46     /* Watch for events */
47     if (isset($_POST['action'])){
48       $macaddresses="";
49       $names="";
50       foreach ($this->members as $cn => $macAddress){
51         $macaddresses.= "$macAddress ";
52         $names.= "$cn ";
53       }
55       switch($_POST['saction']){
56         case 'wake':
57           $cmd= search_config($this->config->data['TABS'], "terminfo", "WAKECMD");
58           if ($cmd == ""){
59             print_red(_("No WAKECMD definition found in your gosa.conf"));
60           } else {
61             exec ($cmd." ".$macaddresses, $dummy, $retval);
62             if ($retval != 0){
63               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
64             }
65           }
66           break;
68         case 'reboot':
69           $cmd= search_config($this->config->data['TABS'], "terminfo", "REBOOTCMD");
70           if ($cmd == ""){
71             print_red(_("No REBOOTCMD definition found in your gosa.conf"));
72           } else {
73             exec ($cmd." ".$names, $dummy, $retval);
74             if ($retval != 0){
75               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
76             }
77           }
78           break;
80         case 'halt':
81           $cmd= search_config($this->config->data['TABS'], "terminfo", "HALTCMD");
82           if ($cmd == ""){
83             print_red(_("No HALTCMD definition found in your gosa.conf"));
84           } else {
85             exec ($cmd." ".$names, $dummy, $retval);
86             if ($retval != 0){
87               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
88             }
89           }
90           break;
91       }
92     }
93  
95     
96     /* Set government mode */
97     $smarty= get_smarty();
99     $smarty->assign("actions", array("wake" => _("Wake up"), "halt" => _("Switch off"), "reboot" => _("Reboot")));
100     $smarty->assign("actionACL", chkacl($this->acl, 'action'));
102     /* Show main page */
103     return ($smarty->fetch (get_template_path('termgroup.tpl', TRUE)));
104   }
109 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
110 ?>