Code

Fixed printGeneric select user/groups
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Nov 2006 10:54:20 +0000 (10:54 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Nov 2006 10:54:20 +0000 (10:54 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5232 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_selectUserToPrinterDialog.inc
plugins/admin/systems/printer.tpl

index 9cb403b5d74d45e33438606faedf65458b460c5d..8f1c8eca2a56ca190b6ee79423b2894097994226 100644 (file)
@@ -80,10 +80,43 @@ class selectUserToPrinterDialog extends plugin
       $this->regex=preg_replace("/\*\*/","*",$this->regex);
     }
 
+
+    /* 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);
+
+    /* Load possible departments */
+    $ui     = get_userinfo();
+  
+    /* Allowed user departments */
+    $udeps  = $ui->get_module_departments("users");
+
+    /* Allowed groups department */
+    $gdeps  = $ui->get_module_departments("groups");
+
+    /* Combine both arrays */
+    $tdeps  = array_unique(array_merge($udeps,$gdeps));
+
+    /* Create usable departments array */
+    $ids = $this->config->idepartments;
+    $deps = array();
+    foreach($deps_res as $dep){
+      if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+        $value = $ids[$dep['dn']];
+        $deps[$dep['dn']] = $value;
+      }
+    }
+    if(!isset($deps[$this->depselect])){
+      $this->depselect = key($deps);
+    }
+
+
+
     $tmp_printers= $this->getPrinter();
     natcasesort($tmp_printers);
     $smarty->assign("regexPrinter"        , $this->regex);
-    $smarty->assign("deplistPrinter"      , $this->config->idepartments);//deplist);
+    $smarty->assign("deplistPrinter"      , $deps);;//deplist);
     $smarty->assign("depselectPrinter"    , $this->depselect);
     $smarty->assign("gotoPrinters"        , $tmp_printers);
     $smarty->assign("gotoPrinterKeys"     , array_flip($tmp_printers));
@@ -93,7 +126,7 @@ class selectUserToPrinterDialog extends plugin
     $smarty->assign("tree_image"          , get_template_path('images/tree.png'));
     $smarty->assign("infoimage"           , get_template_path('images/info.png'));
     $smarty->assign("launchimage"         , get_template_path('images/small_filter.png'));
-    $smarty->assign("deplist"             , $this->config->idepartments);
+    $smarty->assign("deplist"             , $deps);
 
     $display.= $smarty->fetch(get_template_path('selectUserToPrinterDialog.tpl', TRUE,dirname(__FILE__)));
     return($display);
index 2639e9b4de5a328fadc1bd9a764f2bfecce8d469..12836edcc52732bb3a03796ce919f22999700d89 100644 (file)
 
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
+
   <!-- // First input field on page
-  document.mainform.cn.focus();
+  if(document.mainform.cn)
+         document.mainform.cn.focus();         
   -->
 </script>