Code

Apply patch for Trac #3671
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Feb 2010 20:07:29 +0000 (20:07 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Feb 2010 20:07:29 +0000 (20:07 +0000)
- 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

trunk/gosa-plugins/goto/personal/environment/class_hotplugDialog.inc
trunk/gosa-plugins/goto/personal/environment/hotplugDialog.tpl

index 7719fdb06ab3655065a801b2802b340f15e57ce6..2fd7c342e8683fc6b07c81755409c3cb1f16f650 100644 (file)
@@ -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");
index 689ea74bde8032b2204e0e4cf7628c88cb57c380..f39ee4366aede78f931f413b0433361b5b060fc1 100644 (file)
                             </select>
                         </td>
                     </tr>
+                    <tr>
+                        <td>
+                            <input type="checkbox" name='SubSearch' value='1' title='{t}Select to search within subtrees{/t}'  onClick='document.mainform.submit();' {$subtree}>&nbsp;{t}Search in subtrees{/t}
+                        </td>
                 </table>
                         <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
                             <tr>