Code

* Code cleanup for non pre-defined ttag variable
[gosa.git] / plugins / admin / systems / class_printGeneric.inc
index d0f2cebf5aeedac7fa29fd8ae589aaf578b10969..9d3c2cfe25ef6e524d4ccaacec09d0d064271f5e 100644 (file)
@@ -2,11 +2,6 @@
 
 class printgeneric extends plugin
 {
-  /* CLI vars */
-  var $cli_summary      = "Manage terminal base objects";
-  var $cli_description  = "Some longer text\nfor help";
-  var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* Generic terminal attributes */
   var $interfaces     = array();
   var $ignore_account = FALSE;
@@ -91,6 +86,7 @@ class printgeneric extends plugin
     
     /* create dns object */
     $this->netConfigDNS = new termDNS($this->config, $this->dn,$this->objectclasses);
+    $this->netConfigDNS->acl = $this->acl;
 
     /* Set base */
     if ($this->dn == "new"){
@@ -243,6 +239,8 @@ class printgeneric extends plugin
 
   function execute()
   {
+    $this->netConfigDNS->acl = $this->acl;
+
     /* Call parent execute */
     plugin::execute();
 
@@ -251,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);
     }
 
@@ -396,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;
       }
     }
 
@@ -500,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 */
@@ -534,15 +533,26 @@ 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)));
   }
 
   function remove_from_parent()
   {
+    $this->netConfigDNS->acl = $this->acl;
+
     /* Only remove if there was initially an account */
     if($this->initially_was_account){
 
@@ -575,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']);
@@ -636,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'.");
       }
@@ -655,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;
@@ -670,6 +683,8 @@ class printgeneric extends plugin
   /* Save to LDAP */
   function save()
   {
+    $this->netConfigDNS->acl = $this->acl;
+
     /* Update dn, to ensure storing as printer instead of WS / terminal
      */
     if($this->BelongsTo == "Terminal"){
@@ -678,8 +693,7 @@ class printgeneric extends plugin
 
     if($this->BelongsTo == "Workstation"){
       $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
-      $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
-      $this->netConfigDNS->macAddress = $mac;
+      $this->macAddress = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
     }
     
     if(!$this->is_account) return;
@@ -702,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){
@@ -773,6 +793,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 +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);
@@ -813,17 +834,16 @@ 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"));
 
-
-    $this->netConfigDNS->cn = $this->cn;
-    $this->netConfigDNS->dn = $this->dn;
-    $this->netConfigDNS->save($this->dn);
-
-    /* Optionally execute a command after we're done */
-    $this->postcreate();
+    /* Only save dns stuff if we are a standalone printer */
+    if($this->BelongsTo == "Printer"){
+      $this->netConfigDNS->cn = $this->cn;
+      $this->netConfigDNS->dn = $this->dn;
+      $this->netConfigDNS->save($this->dn);
+    }
 
     /* This is a multi object. Handle tagging here... */
     $this->handle_object_tagging();