Code

Removed CLI
[gosa.git] / gosa-plugins / goto / personal / environment / class_hotplugDialog.inc
1 <?php
3 class hotplugDialog extends plugin
4 {
5   /* attribute list for save action */
6   var $hotplugDevices           = ""; 
7   var $hotplugDeviceList        = array(); 
8   var $regex                    = "*";
9   var $depselect                = "/";
10   var $deplist                  = "/";
11   var $skipThese                = array();
13   function hotplugDialog (&$config,$skipThese = array())
14   {
15     $this->skipThese  = $skipThese;
16     $this->config     = $config;
17     $this->depselect   = session::get('CurrentMainBase');
18   }
20   function execute()
21   {
22     /* Call parent execute */
23     plugin::execute();
25     /* Fill templating stuff */
26     $smarty= get_smarty();
27     $display= "";
29     if(isset($_POST['dialogissubmitted'])){
30       $this->regex=$_POST['regexHot'];
31       $this->depselect = $_POST['depselectHot'];
32     }
34     if((isset($_GET['search']))&&(!empty($_GET['search']))){
35       $this->regex=$_GET['search']."*";
36       $this->regex=preg_replace("/\*\*/","*",$this->regex);
37     }
39     $this->deplist=$this->config->idepartments;
41     $this->hotplugDevices = $this->getHotplugs();
42     $smarty->assign("regexHot"    ,$this->regex);
43     $smarty->assign("deplistHot"  ,$this->deplist);
44     $smarty->assign("depselectHot",$this->depselect);
45     $smarty->assign("apply", apply_filter());
46     $smarty->assign("alphabet", generate_alphabet());
47     $smarty->assign("search_image", get_template_path('images/search.png'));
48     $smarty->assign("tree_image", get_template_path('images/tree.png'));
49     $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
50     $smarty->assign("deplist", $this->config->idepartments);
53     $smarty->assign("hotplugDevices",$this->hotplugDevices);
54     $smarty->assign("hotplugDeviceKeys",array_flip($this->hotplugDevices));
55     $display.= $smarty->fetch(get_template_path('hotplugDialog.tpl', TRUE,dirname(__FILE__)));
56     return($display);
57   }
60   /* Save to LDAP */
61   function save()
62   {
63     $entries = array();
64     foreach($_POST['hotplugName'] as $name){
65       $entries[$name] = $this->hotplugDeviceList[$name];
66     }
67     return $entries;
68   }
70   function getHotplugs()
71   {
72     $ldap= $this->config->get_ldap_link();
73     $ldap->cd(get_ou('deviceou').$this->depselect);
74     $ldap->search("(&(objectClass=gotoDevice)(|(cn=".$this->regex.")(description=".$this->regex.")))",array("gotoHotplugDevice","cn","dn")); 
76     $a_return = array();  
77     $this->hotplugDeviceList = array();
78     while($attr = $ldap->fetch()){
80       if(isset($attr['gotoHotplugDevice'][0])){
82         $hot_plug = $attr['gotoHotplugDevice'][0];
83         $tmp      = preg_split("/\|/",$hot_plug);
84         $tmp2     = array();
85           
86         if(in_array($attr['cn'][0],$this->skipThese)){
87           continue;
88         }
90         $tmp2['name']         = $attr['cn'][0];
91         $tmp2['description']  = $tmp[0];
92         $tmp2['id']           = $tmp[1];
93         $tmp2['produkt']      = $tmp[2];
94         $tmp2['vendor']       = $tmp[3];
95         $tmp2['dn']           = $attr['dn'];
97         $a_return[$attr['cn'][0]]= $attr['cn'][0]." [".$tmp[0]."] ".$tmp[1];
99         $this->hotplugDeviceList[$attr['cn'][0]]=$tmp2;
100       }
101     }
102     return($a_return);
103   }
106 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
107 ?>