Code

* Code cleanup for non pre-defined ttag variable
[gosa.git] / plugins / admin / systems / class_printGeneric.inc
index 483ca2262a83be5515b11916248510a4aad088aa..9d3c2cfe25ef6e524d4ccaacec09d0d064271f5e 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);
     }
 
@@ -499,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 */
@@ -533,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)));
   }
 
@@ -576,7 +585,7 @@ 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']);
@@ -637,7 +646,7 @@ class printgeneric extends plugin
     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'.");
       }
@@ -656,6 +665,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;
@@ -681,6 +693,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;
@@ -703,6 +716,12 @@ class printgeneric extends plugin
     if($this->PPDdialogToSave){
       $this->PPDdialogToSave->save_ppd();
     }
+    if($this->orig_dn != $this->dn){
+      $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){
@@ -805,7 +824,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);
@@ -815,7 +834,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"));
 
@@ -826,9 +845,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();
   }