Code

Updated workstation - Startup
[gosa.git] / plugins / admin / systems / class_selectUserToPrinterDialog.inc
index 8f1c8eca2a56ca190b6ee79423b2894097994226..1f110e3557a0a91b6c03d623f988722e94bd9675 100644 (file)
@@ -12,6 +12,7 @@ class selectUserToPrinterDialog extends plugin
   var $attributes           = array();
   var $objectclasses        = array("whatever");
   var $regex                = "*";
+  var $subtree              = FALSE;
   var $depselect            = "/";
   var $deplist              = "/";
 
@@ -22,7 +23,7 @@ class selectUserToPrinterDialog extends plugin
   var $type                 = "";
   var $search_cat           = ""; 
  
-  function selectUserToPrinterDialog ($config, $dn= NULL,$type=false )
+  function selectUserToPrinterDialog (&$config, $dn= NULL,$type=false )
   {
     plugin::plugin ($config, $dn);
     $this->depselect = $this->config->current['BASE'];
@@ -74,6 +75,7 @@ class selectUserToPrinterDialog extends plugin
       $this->regex=$_POST['regexPrinter'];
       $this->depselect = $_POST['depselectPrinter'];
     }
+    $this->subtree= isset($_POST['SubSearch']);
 
     if((isset($_GET['search']))&&(!empty($_GET['search']))){
       $this->regex=$_GET['search']."*";
@@ -83,8 +85,9 @@ class selectUserToPrinterDialog extends plugin
 
     /* Get all departments within this subtree */
     $base = $this->config->current['BASE'];
-    $deps_res= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", array("users","groups"), $this->config->current['BASE'],
-                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+    $deps_res[] = array("dn"=>$this->config->current['BASE']);
+    $deps_res= array_merge($deps_res,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", array("users","groups"), $this->config->current['BASE'],
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
 
     /* Load possible departments */
     $ui     = get_userinfo();
@@ -127,6 +130,7 @@ class selectUserToPrinterDialog extends plugin
     $smarty->assign("infoimage"           , get_template_path('images/info.png'));
     $smarty->assign("launchimage"         , get_template_path('images/small_filter.png'));
     $smarty->assign("deplist"             , $deps);
+    $smarty->assign("subtree", $this->subtree?"checked":"");
 
     $display.= $smarty->fetch(get_template_path('selectUserToPrinterDialog.tpl', TRUE,dirname(__FILE__)));
     return($display);
@@ -166,7 +170,11 @@ class selectUserToPrinterDialog extends plugin
     $attrs  = $this->searchAttrs;
     $cat    = $this->search_cat;
 
-    $res = get_list($filter,$cat,$base,$attrs);
+    if ($this->subtree){
+      $res= get_list($filter,$cat,$this->depselect,$attrs, GL_SUBSEARCH);
+    } else {
+      $res= get_list($filter,$cat,$base,$attrs);
+    }
     foreach($res as $printer){
       if(($detailed ==true)){
         if(isset($printer[$this->searchAppend])){