Code

Fixed self edit mode
[gosa.git] / plugins / personal / environment / class_selectPrinterDialog.inc
index 7910d24077c6d66f5bd2187e0ec61cdfb29db650..2400b2857909eb1b3fd9a89f33406f0c94de54d8 100644 (file)
@@ -11,20 +11,23 @@ class selectPrinterDialog extends plugin
   var $ignore_account       = TRUE;
   var $attributes           = array();
   var $objectclasses        = array("whatever");
-  var $use_existing         = false;  
+  var $AlreadyAssigned      = array();  
   var $regex                = "*";
   var $depselect            = "/";
   var $deplist              = "/";
 
-  function selectPrinterDialog ($config, $dn= NULL,$use_existing=false )
+  function selectPrinterDialog ($config, $dn= NULL,$alreadyused=array() )
   {
-    $this->use_existing = $use_existing;
+    $this->AlreadyAssigned = $alreadyused;
     plugin::plugin ($config, $dn);
     $this->depselect = $this->config->current['BASE'];
   }
 
   function execute()
   {
+    /* Call parent execute */
+    plugin::execute();
+
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
@@ -39,7 +42,7 @@ class selectPrinterDialog extends plugin
       $this->regex=preg_replace("/\*\*/","*",$this->regex);
     }
 
-    $this->deplist=array_flip($this->config->departments);
+    $this->deplist=$this->config->idepartments;
 
     $smarty->assign("regexPrinter"    ,$this->regex);
     $smarty->assign("deplistPrinter"  ,$this->deplist);
@@ -51,7 +54,7 @@ class selectPrinterDialog extends plugin
     $smarty->assign("search_image", get_template_path('images/search.png'));
     $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/launch.png'));
+    $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
     $smarty->assign("deplist", $this->config->idepartments);
 
     $display.= $smarty->fetch(get_template_path('selectPrinterDialog.tpl', TRUE,dirname(__FILE__)));
@@ -59,7 +62,9 @@ class selectPrinterDialog extends plugin
   }
 
   function check(){
-    $message=array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
     if(empty($_POST['gotoPrinter'])){
       $message[] = _("Please select a printer or press cancel.");
     }
@@ -82,10 +87,17 @@ class selectPrinterDialog extends plugin
     $ldap->cd($this->depselect);
     $ldap->search("(&(objectClass=gotoPrinter)(cn=".$this->regex."))",array("*"));
     while($printer = $ldap->fetch()){
+
+      if(isset($this->AlreadyAssigned[$printer['cn'][0]])) continue;
+
       if($detailed ==true){
         $a_return[$printer['cn'][0]] = $printer;
       }else{
-        $a_return[$printer['cn'][0]] = $printer['cn'][0]." - ".$printer['description'][0]; 
+        if(isset($printer['description'][0])){
+          $a_return[$printer['cn'][0]] = $printer['cn'][0]." - ".$printer['description'][0];  
+        }else{
+          $a_return[$printer['cn'][0]] = $printer['cn'][0];  
+        }
       }
     }
     return($a_return);