Code

Added printer tab to workstations
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 30 Aug 2005 11:52:08 +0000 (11:52 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 30 Aug 2005 11:52:08 +0000 (11:52 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1263 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_printGeneric.inc
plugins/admin/systems/tabs_workstation.inc

index ed2263c21f9f229c18a7fb8a2d498720f8509fba..3394cc566927478f8cb511d7f67e99b3be0423f5 100644 (file)
@@ -54,7 +54,23 @@ class printgeneric extends plugin
     }
 
 
-    if(in_array("gotoTerminal",$this->attrs['objectClass'])){
+    if((in_array("gotoWorkstation",$this->attrs['objectClass']))){
+      $this->is_terminal = "true";   
+      $this->dn   = preg_replace("/ou=workstation/","ou=printer",$this->dn);
+
+      // Reload plugin with new dn... (ou=printers instead of ou=terminals)
+      plugin::plugin ($this->config, $this->dn);
+      $ldap->cat($this->dn);
+      if(count($ldap->fetch())>0){
+        $this->orig_dn= $this->dn;
+        $this->is_account=true;
+        $this->initially_was_account = true;
+      }else{
+        $this->orig_dn = "new";
+        $this->is_account=false;
+        $this->initially_was_account = false;
+      }
+    }elseif((in_array("gotoTerminal",$this->attrs['objectClass']))){
       $this->is_terminal = "true";
       $this->dn   = preg_replace("/ou=terminal/","ou=printer",$this->dn);
 
@@ -106,6 +122,7 @@ class printgeneric extends plugin
 
   function execute()
   {
+    print_a($this);
     $smarty= get_smarty();
     $display="";
     /* Template management.
@@ -317,17 +334,23 @@ class printgeneric extends plugin
   /* Save to LDAP */
   function save()
   {
+    $dn= $this->dn;
     plugin::save();
-    
+   
+    if((in_array("gotoTerminal",$this->attrs['objectClass']))){
+      $this->dn= preg_replace("/ou=terminal/","ou=printer",$this->dn);
+    }
+    if((in_array("gotoWorkstation",$this->attrs['objectClass']))){
+      $this->dn= preg_replace("/ou=workstation/","ou=printer",$this->dn);
+    }
+
     $ldap= $this->config->get_ldap_link();
-  
     /* We are currently editing a Terminal, so we want to save a seperate printer which cn is the terminla cn 
     */
     if($this->is_terminal){
       
-      /* Save in ou=printers instead of ou=terminals */
-      $this->dn   = preg_replace("/ou=terminal/","ou=printer",$this->dn);
-
       /* reduce objectClasses to minimun */
       $this->attrs['objectClass']= $this->objectclasses;
 
index 13df2dc0f3867b9ec2a00bcc0bc9f58c28c8760b..4f59e1d5685e0f424a7d3aaca32240cb626af6da 100644 (file)
@@ -31,6 +31,10 @@ class worktabs extends tabs
     }
 
     tabs::save(TRUE);
+    if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){
+      $this->by_object['printgeneric']->remove_from_parent();
+    }
+
   }
 
 }