Code

Added support for general check hooks
[gosa.git] / plugins / admin / systems / class_printGeneric.inc
index 9fe83499302db8fa79e847d05b3242de7c9958ba..df9f7f12879878165062bdcb7a533e930683fa9c 100644 (file)
@@ -30,6 +30,7 @@ class printgeneric extends plugin
   var $AdminMemberKeys  =array();
 
   var $is_terminalBased = false; 
+  var $gotoUserPrinter ;
 
   var $PPDdialogToSave  = NULL;
  
@@ -39,9 +40,12 @@ class printgeneric extends plugin
   var $dialog           =NULL;
 
   var $netConfigDNS;
+  var $baseSelection    = false;
+
+  var $macAddress       = "";
 
   /* attribute list for save action */
-  var $attributes     = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD");
+  var $attributes     = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress");
   var $objectclasses  = array("top", "gotoPrinter");
 
   function printgeneric ($config, $dn= NULL)
@@ -155,18 +159,11 @@ class printgeneric extends plugin
       }
     }
 
-    /* This attributes is sometimes written with Uri instead of URI
-       In RFC 2079 it is defined with URI ...
-     */
-    if(isset($this->attrs['labeledUri'])){
-      $this->labeledURI = $this->attrs['labeledUri'][0];
-    }
-
     /* A printer was only saved if the printer belongs to a workstation. 
      * If there was a new single printer created, it was never saved.
      * -This allows new printers to be saved.
      */
-    if($this->dn == "new"){
+    if(($this->dn == "new")&&(!$this->is_terminal)){
       $this->is_account = true;
     }
   }
@@ -253,6 +250,34 @@ class printgeneric extends plugin
       }
     }
 
+    /* Base select dialog */
+    $once = true;
+    foreach($_POST as $name => $value){
+      if(preg_match("/^chooseBase/",$name) && $once){
+        $once = false;
+        $this->dialog = new baseSelectDialog($this->config);
+        $this->dialog->setCurrentBase($this->base);
+        $this->baseSelection = true;
+      }
+    }
+
+    /* Dialog handling */
+    if(is_object($this->dialog)){
+      /* Must be called before save_object */
+      $this->dialog->save_object();
+      if($this->baseSelection){
+        if($this->dialog->isClosed()){
+          $this->dialog = false;
+          $this->baseSelection = false;
+        }elseif($this->dialog->isSelected()){
+          $this->base = $this->dialog->isSelected();
+          $this->dialog= false;
+          $this->baseSelection = false;
+        }else{
+          return($this->dialog->execute());
+        }
+      }
+    }
 
     /* Do we represent a valid printer? */
     if (!$this->is_account && $this->parent == NULL){
@@ -470,7 +495,9 @@ class printgeneric extends plugin
   /* Check supplied data */
   function check()
   {
-    $message= $this->netConfigDNS->check();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+    $message= array_merge($message, $this->netConfigDNS->check());
 
     if(isset($this->parent->by_name['workgeneric'])){
       if($this->parent->by_object['workgeneric']->cn == "wdefault"){
@@ -586,6 +613,9 @@ class printgeneric extends plugin
 
     /* Append printer user 
      */
+    if(is_string( $this->attrs['gotoUserPrinter'])){
+       $this->attrs['gotoUserPrinter']=array();
+    }
     foreach($this->member['AddUser'] as $mem){
       $this->attrs['gotoUserPrinter'][]=$mem['uid'][0];
     }
@@ -622,7 +652,9 @@ class printgeneric extends plugin
       }
 
       $ldap->cd($this->dn);
-      $ldap->modify($this->attrs);
+      $this->cleanup();
+$ldap->modify ($this->attrs); 
+
       $this->handle_post_events("modify");
     }
     show_ldap_error($ldap->get_error());