Code

Added divlist dialog for groups
[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     if(isset($this->attrs['member'])){
20       for ($i= 0; $i<$this->attrs['member']['count']; $i++){
21         $member= $this->attrs['member'][$i];
22         $ldap->cat($member);
23         if (preg_match("/success/i", $ldap->error)){
24           $attrs = $ldap->fetch();
25           if (in_array("gotoTerminal", $attrs['objectClass']) ||
26               in_array("gotoWorkstation", $attrs['objectClass'])){
27             if (isset($attrs['macAddress'])){
28               $this->members[$attrs['cn'][0]]= $attrs['macAddress'][0];
29             } else {
30               $this->members[$attrs['cn'][0]]= "";
31             }
32           }
33         }
34       }
35     }
37     /* Include config object */
38     $this->config= $config;
39   }
41   function check()
42   {
43   }
45   function execute()
46   {
47         /* Call parent execute */
48         plugin::execute();
51     /* Watch for events */
52     if (isset($_POST['action'])){
53       $macaddresses="";
54       $names="";
55       foreach ($this->members as $cn => $macAddress){
56         $macaddresses.= "$macAddress ";
57         $names.= "$cn ";
58       }
60       switch($_POST['saction']){
61         case 'wake':
62           $cmd= search_config($this->config->data['TABS'], "terminfo", "WAKECMD");
63           if ($cmd == ""){
64             print_red(_("No WAKECMD definition found in your gosa.conf"));
65           } else {
66             exec ($cmd." ".$macaddresses, $dummy, $retval);
67             if ($retval != 0){
68               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
69             }
70           }
71           break;
73         case 'reboot':
74           $cmd= search_config($this->config->data['TABS'], "terminfo", "REBOOTCMD");
75           if ($cmd == ""){
76             print_red(_("No REBOOTCMD definition found in your gosa.conf"));
77           } else {
78             exec ($cmd." ".$names, $dummy, $retval);
79             if ($retval != 0){
80               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
81             }
82           }
83           break;
85         case 'halt':
86           $cmd= search_config($this->config->data['TABS'], "terminfo", "HALTCMD");
87           if ($cmd == ""){
88             print_red(_("No HALTCMD definition found in your gosa.conf"));
89           } else {
90             exec ($cmd." ".$names, $dummy, $retval);
91             if ($retval != 0){
92               print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
93             }
94           }
95           break;
96       }
97     }
98  
100     
101     /* Set government mode */
102     $smarty= get_smarty();
104     $smarty->assign("actions", array("wake" => _("Wake up"), "halt" => _("Switch off"), "reboot" => _("Reboot")));
105     $smarty->assign("actionACL", chkacl($this->acl, 'action'));
107     /* Show main page */
108     return ($smarty->fetch (get_template_path('termgroup.tpl', TRUE)));
109   }
114 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
115 ?>