Code

Replaced ou=devices/ou=macro/ou=conferences with get_ou
[gosa.git] / gosa-core / plugins / personal / environment / class_hotplugDialog.inc
1 <?php
3 class hotplugDialog extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary          = "Manage server basic objects";
7   var $cli_description      = "Some longer text\nfor help";
8   var $cli_parameters       = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $hotplugDevices           = ""; 
12   var $hotplugDeviceList        = array(); 
13   var $regex                    = "*";
14   var $depselect                = "/";
15   var $deplist                  = "/";
16   var $skipThese                = array();
18   function hotplugDialog (&$config,$skipThese = array())
19   {
20     $this->skipThese  = $skipThese;
21     $this->config     = $config;
22     $this->depselect  = $_SESSION['CurrentMainBase'];
23   }
25   function execute()
26   {
27     /* Call parent execute */
28     plugin::execute();
30     /* Fill templating stuff */
31     $smarty= get_smarty();
32     $display= "";
34     if(isset($_POST['dialogissubmitted'])){
35       $this->regex=$_POST['regexHot'];
36       $this->depselect = $_POST['depselectHot'];
37     }
39     if((isset($_GET['search']))&&(!empty($_GET['search']))){
40       $this->regex=$_GET['search']."*";
41       $this->regex=preg_replace("/\*\*/","*",$this->regex);
42     }
44     $this->deplist=$this->config->idepartments;
46     $this->hotplugDevices = $this->getHotplugs();
47     $smarty->assign("regexHot"    ,$this->regex);
48     $smarty->assign("deplistHot"  ,$this->deplist);
49     $smarty->assign("depselectHot",$this->depselect);
50     $smarty->assign("apply", apply_filter());
51     $smarty->assign("alphabet", generate_alphabet());
52     $smarty->assign("search_image", get_template_path('images/search.png'));
53     $smarty->assign("tree_image", get_template_path('images/tree.png'));
54     $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
55     $smarty->assign("deplist", $this->config->idepartments);
58     $smarty->assign("hotplugDevices",$this->hotplugDevices);
59     $smarty->assign("hotplugDeviceKeys",array_flip($this->hotplugDevices));
60     $display.= $smarty->fetch(get_template_path('hotplugDialog.tpl', TRUE,dirname(__FILE__)));
61     return($display);
62   }
65   /* Save to LDAP */
66   function save()
67   {
68     $entries = array();
69     foreach($_POST['hotplugName'] as $name){
70       $entries[$name] = $this->hotplugDeviceList[$name];
71     }
72     return $entries;
73   }
75   function getHotplugs()
76   {
77     $ldap= $this->config->get_ldap_link();
78     $ldap->cd(get_ou('deviceou').$this->depselect);
79     $ldap->search("(&(objectClass=gotoDevice)(|(cn=".$this->regex.")(description=".$this->regex.")))",array("gotoHotplugDevice","cn","dn")); 
81     $a_return = array();  
82     $this->hotplugDeviceList = array();
83     while($attr = $ldap->fetch()){
85       if(isset($attr['gotoHotplugDevice'][0])){
87         $hot_plug = $attr['gotoHotplugDevice'][0];
88         $tmp      = preg_split("/\|/",$hot_plug);
89         $tmp2     = array();
90           
91         if(in_array($attr['cn'][0],$this->skipThese)){
92           continue;
93         }
95         $tmp2['name']         = $attr['cn'][0];
96         $tmp2['description']  = $tmp[0];
97         $tmp2['id']           = $tmp[1];
98         $tmp2['produkt']      = $tmp[2];
99         $tmp2['vendor']       = $tmp[3];
100         $tmp2['dn']           = $attr['dn'];
102         $a_return[$attr['cn'][0]]= $attr['cn'][0]." [".$tmp[0]."] ".$tmp[1];
104         $this->hotplugDeviceList[$attr['cn'][0]]=$tmp2;
105       }
106     }
107     return($a_return);
108   }
111 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
112 ?>