Code

Readded template functionality for workstations and terminals
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 23 Nov 2006 06:30:31 +0000 (06:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 23 Nov 2006 06:30:31 +0000 (06:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5202 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_divListSystem.inc
plugins/admin/systems/class_printGeneric.inc
plugins/admin/systems/class_systemManagement.inc
plugins/admin/systems/class_terminalGeneric.inc
plugins/admin/systems/class_workstationGeneric.inc
plugins/admin/systems/terminal.tpl
plugins/admin/systems/workstation.tpl

index 5350eb7469ba5a8b810ac0ce70b8cf048a71990b..7544aceaef882cc5ee5d91f64f64a1b6890a8109 100644 (file)
@@ -231,7 +231,7 @@ class divListSystem extends MultiSelectWindow
       }
 
       if(isset($val['message'])){
-        $display.= "  (".$val['message']." '".$this->config->idepartments[$_SESSION['CurrentMainBase']]."'  )";
+        $display.= "  (".$val['message'].")";
       }
 
       $img    = $this->parent->convert_list($val);
index 7076727f3859c7371d4d98aa2b95118e68495e1c..4a475c6dedce506ad658693936939ecafe0c65c7 100644 (file)
@@ -66,7 +66,7 @@ class printgeneric extends plugin
     }
 
     /* Update dn, to ensure storing as printer instead of WS / terminal */
-    if($this->BelongsTo == "Terminal"){
+    if($this->BelongsTo == "Terminal" || $this->BelongsTo == "TerminalTemplate"){
       $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
     }
 
index 5a2b8d8345fe57a9fc66783c98563618b84efac6..5d655f75e4c88e4724198d0c361c04b157b2eef3 100644 (file)
@@ -646,6 +646,12 @@ class systems extends plugin
         }
       }
 
+      /* Create a string containing the last part of the department. */
+      $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp)));
+      if(empty($dn_name)){
+        $dn_name = "/";
+      }
+
       /* check if current object is a new one */
       if (preg_match ("/,ou=incoming,/i", $tmp)){
         if (in_array_ics('gotoTerminal', $value['objectClass'])){
@@ -672,7 +678,7 @@ class systems extends plugin
           } else {
             $terminal             = $value;
             $terminal['type']     = "D";
-            $terminal['message']  = _("Terminal template for");
+            $terminal['message']  = _("Terminal template for")."&nbsp;'".$dn_name."'&nbsp;";
             $terminal['location'] = array_search($tmp, $this->config->departments); 
           }
         }
@@ -688,7 +694,7 @@ class systems extends plugin
             $terminal             = $value;
             $terminal['type']     = "D";
             $terminal['location'] = array_search($tmp, $this->config->departments);
-            $terminal['message']  = _("Workstation template for");
+            $terminal['message']  = _("Workstation template for")."&nbsp;'".$dn_name."'&nbsp;";
           }
           if (isset($value["FAIstate"][0])){
             $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
index 8d9c539e9aa4b96faa55dc78c46facdfa8fc20ce..ba256af50ece884b3a9d8b79452f48286895549b 100644 (file)
@@ -373,7 +373,11 @@ class termgeneric extends plugin
   {
     /* Call common method to give check the hook */
     $message= plugin::check();
-    $message= array_merge($message, $this->netConfigDNS->check());
+
+    /* Skip IP & Mac checks if this is a template */
+    if($this->cn != "default"){
+      $message= array_merge($message, $this->netConfigDNS->check());
+    }
 
     /* Permissions for that base? */
     $this->dn= "cn=".$this->cn."ou=terminals,ou=systems,".$this->base;
@@ -395,7 +399,13 @@ class termgeneric extends plugin
     if ($this->orig_dn == 'new'){
       $ldap= $this->config->get_ldap_link();
       $ldap->cd ($this->base);
-      $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn"));
+
+      /* It is possible to have a 'default' terminal on every base */
+      if($this->cn == "default"){
+        $ldap->cat($this->dn);
+      }else{
+        $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn"));
+      }
       if ($ldap->count() != 0){
         while ($attrs= $ldap->fetch()){
           if (preg_match ("/,ou=incoming,/", $ldap->getDN())){
@@ -488,6 +498,12 @@ class termgeneric extends plugin
 
       $this->handle_post_events("modify");
     }
+    
+    /* cn=default and macAddress=- indicates that this is a template */
+    if($this->cn == "default"){
+      $this->netConfigDNS->macAddress = "-";
+    }
+
     $this->netConfigDNS->cn = $this->cn;
     $this->netConfigDNS->save($this->dn);
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/generic with dn '%s' failed."),$this->dn));
index e096867f73a08e60f3e0f6a56c8825827143a65a..8b34d8278bc664254873358c65f8810cde67120e 100644 (file)
@@ -375,7 +375,11 @@ class workgeneric extends plugin
   {
     /* Call common method to give check the hook */
     $message= plugin::check();
-    $message= array_merge($message, $this->netConfigDNS->check());
+  
+    /* Skip IP & Mac checks if this is a template */
+    if($this->cn != "wdefault"){
+      $message= array_merge($message, $this->netConfigDNS->check());
+    }
 
     $this->dn= "cn=".$this->cn.",ou=workstations,ou=systems,".$this->base;
 
@@ -396,7 +400,12 @@ class workgeneric extends plugin
     if ($this->orig_dn != $this->dn){
       $ldap= $this->config->get_ldap_link();
       $ldap->cd ($this->base);
-      $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
+
+      if($this->cn == "wdefault"){
+        $ldap->cat($this->dn);
+      }else{
+        $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
+      }
       if ($ldap->count() != 0){
         while ($attrs= $ldap->fetch()){
           if (preg_match ("/,ou=incoming,/", $ldap->getDN())){
@@ -410,7 +419,7 @@ class workgeneric extends plugin
         }
       }
     }
-    
+
     /* Check for valid ntpServer selection */
     if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
       $message[]= _("There must be at least one NTP server selected, or the inherit mode activated.");
@@ -496,6 +505,12 @@ class workgeneric extends plugin
         $this->handle_post_events("modify");
       }
     }
+
+    /* cn=default and macAddress=- indicates that this is a template */
+    if($this->cn == "wdefault"){
+      $this->netConfigDNS->macAddress = "-";
+    }
+
     $this->netConfigDNS->cn = $this->cn;
     $this->netConfigDNS->save($this->dn);
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn));
index fde61c6bb1717011c2ff9bf4b7e9dd75ee24120c..cbbb965a55d2206f56fb0d05555a621e526cddf5 100644 (file)
   </td>
  </tr>
 </table>
+
+{if $cn neq 'default'}
 <p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
 
 {$netconfig}
-
+{/if}
 <p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
 <h2><img class="center" alt="" align="middle" src="images/rocket.png"> {t}Action{/t}</h2>
 <table summary="">
index 378c7c1266d66caed7b0781601fcb5e8be03e063..df95ee5b954999ba34c5fdc8e589e2bc05707e68 100644 (file)
   </td>
  </tr>
 </table>
+{if $cn neq 'wdefault'}
 <p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
 
 {$netconfig}
-
+{/if}
 <p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
 <h2><img class="center" alt="" align="middle" src="images/rocket.png"> {t}Action{/t}</h2>
 <table summary="">