Code

Updated printer user/group selection
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Oct 2008 12:42:24 +0000 (12:42 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Oct 2008 12:42:24 +0000 (12:42 +0000)
-Do not display already assigned objects.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12782 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc
gosa-plugins/goto/admin/systems/goto/class_selectUserToPrinterDialog.inc

index 847da3ac38c2218b48fac60250f98d2b84a4b664..4041548a16441a7066f1e330db44d2b8d17f9c72 100644 (file)
@@ -393,16 +393,16 @@ class printgeneric extends plugin
     }
 
     if(isset($_POST['AddUser'])){
-      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddUser");
+      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddUser",$this->member);
     }
     if(isset($_POST['AddGroup'])){
-      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddGroup");
+      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddGroup",$this->member);
     }
     if(isset($_POST['AddAdminUser'])){
-      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminUser");
+      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminUser",$this->member);
     }
     if(isset($_POST['AddAdminGroup'])){
-      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminGroup");
+      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminGroup",$this->member);
     }
 
     /* Display ppd configure/select dialog      */
index 333fab3a7150b4f25b300e4a1eb3bbcfd7e9393d..246f21516c061099a248dd52bfb80962240af2a6 100644 (file)
@@ -17,8 +17,10 @@ class selectUserToPrinterDialog extends plugin
   var $baseAddition         = "";
   var $type                 = "";
   var $search_cat           = ""; 
+
+  var $dns_used             = array();
  
-  function selectUserToPrinterDialog (&$config, $dn= NULL,$type=false )
+  function selectUserToPrinterDialog (&$config, $dn= NULL,$type=false,$already_assigned )
   {
     plugin::plugin ($config, $dn);
     $this->depselect = $this->config->current['BASE'];
@@ -55,6 +57,13 @@ class selectUserToPrinterDialog extends plugin
     }
     $this->type = $type;
 
+    /* Collect already assigned object dns */
+    $this->dns_used = array();
+    if(isset($already_assigned[$type])){
+      foreach($already_assigned[$type] as $entry){
+        $this->dns_used[] = $entry['dn'];
+      }
+    }
   }
 
   function execute()
@@ -170,6 +179,12 @@ class selectUserToPrinterDialog extends plugin
       $res= get_list($filter,$cat,$base,$attrs);
     }
     foreach($res as $printer){
+
+      /* Skip already used entries */
+      if(in_array($printer['dn'],$this->dns_used)) {
+        continue;
+      }
+
       if(($detailed ==true)){
         if(isset($printer[$this->searchAppend])){
           $a_return[$printer[$this->searchAppend][0]] = $printer;