Code

Updated filtering again
[gosa.git] / plugins / admin / systems / class_printGeneric.inc
index 88ed075bea1ecb02f75ca1ef52e030e7fdf0e3a6..d2f3b6beaf826d3b6f86b6043a7c1542441894fe 100644 (file)
@@ -249,7 +249,7 @@ class printgeneric extends plugin
      */
     if($this->BelongsTo == "unknown"){
       $display= $this->show_header(_("Add printer extension"),
-          _("Could not intialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
+          _("Could not initialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
       return($display);
     }
 
@@ -394,6 +394,7 @@ class printgeneric extends plugin
         $this->dialog = $this->PPDdialogToSave;
       }else{
         $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
+        $this->dialog->cn= $this->cn;
       }
     }
 
@@ -498,10 +499,10 @@ class printgeneric extends plugin
           $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
         }
       }else{
-        $smarty->assign("driverInfo", _("not defined"));
+        $smarty->assign("driverInfo", _("Not defined"));
       }
     }else{
-      $smarty->assign("driverInfo",_("can't get ppd informations."));
+      $smarty->assign("driverInfo",_("Can't get ppd informations."));
     }
 
     /* Create user & admin user list */
@@ -532,10 +533,19 @@ class printgeneric extends plugin
     if($this->BelongsTo == "Printer"){
       $this->netConfigDNS->cn= $this->cn;
       $smarty->assign("netconfig", $this->netConfigDNS->execute());
+
+      /* Display sub dialog from network settings */
+      if($this->netConfigDNS->dialog){
+        $this->dialog = TRUE;
+        return($this->netConfigDNS->execute());
+      }else{ 
+        $this->dialog = FALSE;
+      }
     } else {
       $smarty->assign("netconfig", "");
     }
 
+
     return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE)));
   }
 
@@ -575,11 +585,11 @@ class printgeneric extends plugin
       $this->netConfigDNS->remove_from_parent();
       $ldap->rmdir($this->dn);
       show_ldap_error($ldap->get_error(), _("Removing printer failed"));
-      $this->handle_post_events("remove");
+      $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
 
       /* Delete references to object groups */
       $ldap->cd ($this->config->current['BASE']);
-      $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
+      $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
       while ($ldap->fetch()){
         $og= new ogroup($this->config, $ldap->getDN());
         unset($og->member[$this->dn]);
@@ -630,13 +640,18 @@ class printgeneric extends plugin
 
     /* must: cn */
     if(($this->BelongsTo == "Printer") && (empty($this->cn))){
-      $message[]= "The required field 'Printer name' is not set.";
+      $message[]= _("The required field 'Printer name' is not set.");
+    }
+
+    /* must: cn */
+    if(($this->BelongsTo == "Printer") && !is_dns_name($this->cn)){
+      $message[]= _("Invalid character in printer name.");
     }
 
     if($this->BelongsTo == "Printer"){
       $ui= get_userinfo();
       $acl= get_permissions ($dn, $ui->subtreeACL);
-      $acl= get_module_permission($acl, "printer", $this->dn);
+      $acl= get_module_permission($acl, "printgeneric", $dn);
       if (chkacl($acl, "create") != ""){
         $message[]= _("You have no permissions to create a printer on this 'Base'.");
       }
@@ -655,6 +670,9 @@ class printgeneric extends plugin
       $ldap->ls("(cn=".$this->cn.")","ou=printers,ou=systems,".$this->base, array("cn"));
       if ($ldap->count() != 0){
         while ($attrs= $ldap->fetch()){
+          if(preg_match("/cn=dhcp,/",$attrs['dn'])){
+            continue;
+          }
           if ($attrs['dn'] != $this->orig_dn){
             $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
             break;
@@ -680,6 +698,7 @@ class printgeneric extends plugin
 
     if($this->BelongsTo == "Workstation"){
       $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
+      $this->macAddress = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
     }
     
     if(!$this->is_account) return;
@@ -702,6 +721,14 @@ class printgeneric extends plugin
     if($this->PPDdialogToSave){
       $this->PPDdialogToSave->save_ppd();
     }
+    if($this->orig_dn != $this->dn){
+      if(!empty($this->gotoPrinterPPD)) {
+        $this->PPDdialogToSave = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
+        $this->PPDdialogToSave->cn = $this->cn;
+        $this->PPDdialogToSave->generateProperties();
+        $this->PPDdialogToSave->update_ppd_url();
+      }
+    }
 
     /* Remove previously selected ppd file.*/
     if($this->initial_PPD != $this->gotoPrinterPPD){
@@ -773,6 +800,7 @@ class printgeneric extends plugin
 
     if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
       $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+      $this->attrs['gosaUnitTag'] = $this->gosaUnitTag;
     }
 
     if($this->orig_dn == 'new'){
@@ -803,7 +831,7 @@ class printgeneric extends plugin
       }
       
       $ldap->add($this->attrs);
-      $this->handle_post_events("add");
+      $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
     } else {
       if ($this->orig_dn != $this->dn){
         $this->move($this->orig_dn, $this->dn);
@@ -813,7 +841,7 @@ class printgeneric extends plugin
       $this->cleanup();
       $ldap->modify ($this->attrs); 
 
-      $this->handle_post_events("modify");
+      $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
     }
     show_ldap_error($ldap->get_error(), _("Saving printer failed"));
 
@@ -824,9 +852,6 @@ class printgeneric extends plugin
       $this->netConfigDNS->save($this->dn);
     }
 
-    /* Optionally execute a command after we're done */
-    $this->postcreate();
-
     /* This is a multi object. Handle tagging here... */
     $this->handle_object_tagging();
   }