Code

* Fixed "add" buttons
[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     if (isset($_POST['hotplugName'])){
65       foreach($_POST['hotplugName'] as $name){
66         $entries[$name] = $this->hotplugDeviceList[$name];
67       }
68     }
70     return $entries;
71   }
73   function getHotplugs()
74   {
75     $ldap= $this->config->get_ldap_link();
76     $ldap->cd(get_ou('deviceou').$this->depselect);
77     $ldap->search("(&(objectClass=gotoDevice)(|(cn=".$this->regex.")(description=".$this->regex.")))",array("gotoHotplugDevice","cn","dn")); 
79     $a_return = array();  
80     $this->hotplugDeviceList = array();
81     while($attr = $ldap->fetch()){
83       if(isset($attr['gotoHotplugDevice'][0])){
85         $hot_plug = $attr['gotoHotplugDevice'][0];
86         $tmp      = preg_split("/\|/",$hot_plug);
87         $tmp2     = array();
88           
89         if(in_array($attr['cn'][0],$this->skipThese)){
90           continue;
91         }
93         $tmp2['name']         = $attr['cn'][0];
94         $tmp2['description']  = $tmp[0];
95         $tmp2['id']           = $tmp[1];
96         $tmp2['produkt']      = $tmp[2];
97         $tmp2['vendor']       = $tmp[3];
98         $tmp2['dn']           = $attr['dn'];
100         $a_return[$attr['cn'][0]]= $attr['cn'][0]." [".$tmp[0]."] ".$tmp[1];
102         $this->hotplugDeviceList[$attr['cn'][0]]=$tmp2;
103       }
104     }
105     return($a_return);
106   }
109 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
110 ?>