From f65c12afe331efa949b7f00df72c780e8420112f Mon Sep 17 00:00:00 2001 From: psc Date: Tue, 9 Feb 2010 20:07:29 +0000 Subject: [PATCH] Apply patch for Trac #3671 - Add sub search checkbox to hotplug device selection dialog - Use get_list instead of ldap->search to get the list of hotplug devices and honor the subsearch flag while on it. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@15604 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../environment/class_hotplugDialog.inc | 33 ++++++++++++------- .../personal/environment/hotplugDialog.tpl | 4 +++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/trunk/gosa-plugins/goto/personal/environment/class_hotplugDialog.inc b/trunk/gosa-plugins/goto/personal/environment/class_hotplugDialog.inc index 7719fdb06..2fd7c342e 100644 --- a/trunk/gosa-plugins/goto/personal/environment/class_hotplugDialog.inc +++ b/trunk/gosa-plugins/goto/personal/environment/class_hotplugDialog.inc @@ -9,6 +9,7 @@ class hotplugDialog extends plugin var $depselect = "/"; var $deplist = "/"; var $skipThese = array(); + var $subtree = FALSE; function hotplugDialog (&$config,$skipThese = array()) { @@ -31,6 +32,8 @@ class hotplugDialog extends plugin $this->depselect = $_POST['depselectHot']; } + $this->subtree = isset($_POST['SubSearch']); + if((isset($_GET['search']))&&(!empty($_GET['search']))){ $this->regex=$_GET['search']."*"; $this->regex=preg_replace("/\*\*/","*",$this->regex); @@ -48,6 +51,7 @@ class hotplugDialog extends plugin $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png')); $smarty->assign("launchimage", get_template_path('images/lists/action.png')); $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("subtree", $this->subtree?"checked":""); $smarty->assign("hotplugDevices",$this->hotplugDevices); @@ -80,34 +84,41 @@ class hotplugDialog extends plugin function getHotplugs() { - $ldap= $this->config->get_ldap_link(); - $ldap->cd(get_ou('deviceRDN').$this->depselect); - $ldap->search("(&(objectClass=gotoDevice)(|(cn=".$this->regex.")(description=".$this->regex.")))",array("gotoHotplugDevice","cn","dn")); + $filter = "(&(objectClass=gotoDevice)(|(cn=".$this->regex.")(description=".$this->regex.")))"; + $base = get_ou('deviceRDN').$this->depselect; + $attrs = array("gotoHotplugDevice", "cn", "dn"); + $cat = "devices"; + + if ($this->subtree) { + $res = get_list($filter, $cat, $this->depselect, $attrs, GL_SUBSEARCH); + } else { + $res = get_list($filter, $cat, $base, $attrs); + } $a_return = array(); $this->hotplugDeviceList = array(); - while($attr = $ldap->fetch()){ + foreach ($res as $device) { - if(isset($attr['gotoHotplugDevice'][0])){ + if(isset($device['gotoHotplugDevice'][0])){ - $hot_plug = $attr['gotoHotplugDevice'][0]; + $hot_plug = $device['gotoHotplugDevice'][0]; $tmp = preg_split("/\|/",$hot_plug); $tmp2 = array(); - if(in_array($attr['cn'][0],$this->skipThese)){ + if(in_array($device['cn'][0],$this->skipThese)){ continue; } - $tmp2['name'] = $attr['cn'][0]; + $tmp2['name'] = $device['cn'][0]; $tmp2['description'] = $tmp[0]; $tmp2['id'] = $tmp[1]; $tmp2['produkt'] = $tmp[2]; $tmp2['vendor'] = $tmp[3]; - $tmp2['dn'] = $attr['dn']; + $tmp2['dn'] = $device['dn']; - $a_return[$attr['cn'][0]]= $attr['cn'][0]." [".$tmp[0]."] ".$tmp[1]; + $a_return[$device['cn'][0]]= $device['cn'][0]." [".$tmp[0]."] ".$tmp[1]; - $this->hotplugDeviceList[$attr['cn'][0]]=$tmp2; + $this->hotplugDeviceList[$device['cn'][0]]=$tmp2; } } uksort($a_return,"strnatcasecmp"); diff --git a/trunk/gosa-plugins/goto/personal/environment/hotplugDialog.tpl b/trunk/gosa-plugins/goto/personal/environment/hotplugDialog.tpl index 689ea74bd..f39ee4366 100644 --- a/trunk/gosa-plugins/goto/personal/environment/hotplugDialog.tpl +++ b/trunk/gosa-plugins/goto/personal/environment/hotplugDialog.tpl @@ -36,6 +36,10 @@ + + +  {t}Search in subtrees{/t} + -- 2.30.2