Code

Make terminals save-able
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Oct 2008 12:34:50 +0000 (12:34 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Oct 2008 12:34:50 +0000 (12:34 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12618 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc
gosa-plugins/goto/admin/systems/goto/class_terminalService.inc
gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc

index d2ccc9cbe8d4cd50b96c5d9c0fa95f336cc42493..97c071765b9fb32780f1d629b823f0a9287f8ba9 100644 (file)
@@ -74,7 +74,7 @@ class termgeneric extends plugin
     if(!isset($this->parent->by_object['ogroup'])){
       $ldap = $this->config->get_ldap_link();
       $ldap->cd ($this->config->current['BASE']);
-      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn"));
+      $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))",array("cn"));
       $this->member_of_ogroup = $ldap->count() >= 1;
     }
 
index b6c736d6d84e5477549342ddffc6c87ccee79860..2a580e10f0a197e2cc12128416e9c33ceffe5b97 100644 (file)
@@ -76,7 +76,7 @@ class termservice extends plugin
      */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
+    $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))");
     if($ldap->count()){
       $this->is_ogroup_member = TRUE;
     }
@@ -233,7 +233,7 @@ class termservice extends plugin
         "gotoXMouseType", 
         "gotoXMethod",
         "gotoXMouseport");
-    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",$map);
+    $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))",$map);
     if ($ldap->count() == 1){
       $attrs= $ldap->fetch();
       foreach ($map as $name){
@@ -536,10 +536,9 @@ class termservice extends plugin
     /* Convert to string */
     $this->gotoLpdEnable= $this->gotoLpdEnable?"Yes":"No";
 
-    if($this->is_ogroup){
-      $this->objectclasses = array("gotoWorkstationTemplate");
-    }else{
-      $this->objectclasses = array("GOhard");
+    /* remove objectclass GOhard if this is an ogroup tab */
+    if(isset($this->parent->by_object['ogroup'])){
+           $this->objectclasses = array();
     }
 
     plugin::save();
@@ -578,6 +577,11 @@ class termservice extends plugin
       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
     }
     $this->handle_post_events("modify");
+
+    /* Send goto reload event to gosaSupportDaemon */
+    if(count($this->attrs)){
+           $this->send_goto_reload();
+    }
   }
 
 
@@ -605,6 +609,54 @@ class termservice extends plugin
     return($drivers);
   }
 
+  function send_goto_reload()
+  {
+    if(count($this->attrs) && class_available("DaemonEvent")){
+      $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
+      $o_queue = new gosaSupportDaemon();
+      if(isset($events['TRIGGERED']['DaemonEvent_goto_reload'])){
+        $evt = $events['TRIGGERED']['DaemonEvent_goto_reload'];
+        $macs = array();
+
+        /* Get list of macAddresses
+         */
+        if(isset($this->parent->by_object['ogroup'])){
+
+          /* If we are an object group, add all member macs
+           */
+          $p = $this->parent->by_object['ogroup'];
+          foreach($p->memberList as $dn => $obj){
+            if(preg_match("/".normalizePreg(get_ou("systemIncomingRDN"))."/",$dn)) continue;
+            if(isset($p->objcache[$dn]['macAddress']) && !empty($p->objcache[$dn]['macAddress'])){
+              $macs[] = $p->objcache[$dn]['macAddress'];
+            }
+          }
+        }elseif(isset($this->parent->by_object['workgeneric']->netConfigDNS->macAddress)){
+
+          /* We are a workstation. Add current mac.
+           */
+          $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
+          if(!empty($mac) && !preg_match("/".normalizePreg(get_ou("systemIncomingRDN"))."/",$this->orig_dn)){
+            $macs[] = $mac;
+          }
+        }
+
+        /* Trigger event for all member objects
+         */
+        if(count($macs)){
+          $tmp = new $evt['CLASS_NAME']($this->config);
+          $tmp->set_type(TRIGGERED_EVENT);
+          $target = $o_queue->get_host().":".$o_queue->get_port();
+          $tmp->add_targets(array($target));
+          $tmp->set_macs($macs);
+          if(!$o_queue->append($tmp,TRUE)){
+            msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+          }
+        }
+      }
+    }
+  }
+
 
   /* Return plugin informations for acl handling */
   static function plInfo()
index 665acb09ba6201457dc61da046f445f520829cf8..8bac77b7512888c6c373a241503b2f0eb5806c08 100644 (file)
@@ -116,7 +116,7 @@ class termstartup extends plugin
     /* Load hardware list */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
+    $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))");
     if ($ldap->count() == 1){
       $map= array("gotoLdapServer","gotoBootKernel");
       $attrs= $ldap->fetch();
@@ -341,6 +341,22 @@ class termstartup extends plugin
   /* Save to LDAP */
   function save()
   {
+   /* Depending on the baseobject (Ogroup / WS) we
+     *  use another set of objectClasses
+     * In case of TS itself, we use  "array("GOhard");"
+     * if we are currently editing from ogroup menu we use (array("goTerminalTemplate"))
+     */
+    if(isset($this->parent->by_object['ogroup'])){
+      $this->objectclasses = array("gotoTerminalTemplate");
+    }elseif(isset($this->parent->by_object['termgeneric'])){
+      $this->objectclasses = array("GOhard");
+    }else{
+      msg_dialog::display(_("Fatal error"),
+          "Object Type Configuration is unknown. Please contact the GOsa developers.",
+          FATAL_ERROR_DIALOG);
+      exit();
+    }
+
     /* Find proper terminal path for tftp configuration
        FIXME: This is suboptimal when the default has changed to
        another location! */