Code

default is now visible as _("inherited")
[gosa.git] / plugins / admin / systems / class_servGeneric.inc
index 9252d16a969a181f0935a791947f6c4aee1069a5..7679c72e2d9683167f0bae3117d0ae0006d55a45 100644 (file)
@@ -19,15 +19,23 @@ class servgeneric extends plugin
   var $orig_dn= "";
 
   /* attribute list for save action */
-  var $attributes= array("cn", "description");
-  var $objectclasses= array("top", "goServer");
+  var $attributes= array("cn", "description","gotoMode");
+  var $objectclasses= array("top", "GOhard", "goServer");
+
+  var $gotoMode= "locked";
 
   var $netConfigDNS;
+  var $modes = array();
 
   function servgeneric ($config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
 
+    $this->modes["active"]= _("Activated");
+    $this->modes["locked"]= _("Locked");
+    $this->modes["memcheck"]= _("Memory test");
+    $this->modes["sysinfo"]= _("System analysis");
+
     /* Set base */
     if ($this->dn == "new"){
       $ui= get_userinfo();
@@ -94,6 +102,31 @@ class servgeneric extends plugin
       }
     }
 
+    /* Base select dialog */
+    $once = true;
+    foreach($_POST as $name => $value){
+      if(preg_match("/^chooseBase/",$name) && $once){
+        $once = false;
+        $this->dialog = new baseSelectDialog($this->config);
+        $this->dialog->setCurrentBase($this->base);
+      }
+    }
+
+    /* Dialog handling */
+    if(is_object($this->dialog)){
+      /* Must be called before save_object */
+      $this->dialog->save_object();
+
+      if($this->dialog->isClosed()){
+        $this->dialog = false;
+      }elseif($this->dialog->isSelected()){
+        $this->base = $this->dialog->isSelected();
+        $this->dialog= false;
+      }else{
+        return($this->dialog->execute());
+      }
+    }
+
     /* Fill templating stuff */
     $smarty= get_smarty();
     $smarty->assign("bases", $this->config->idepartments);
@@ -112,14 +145,20 @@ class servgeneric extends plugin
 
     /* Offline */
     if ($retval == 0){
-      $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot")));
+      $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
+                                       "instant_update" => _("Instant update"),
+                                       "update" => _("Scheduled update"),
+                                       "reinstall" => _("Reinstall"),
+                                       "rescan" => _("Rescan hardware")));
     } else {
-      $smarty->assign("actions", array("wake" => _("Wake up")));
+      $smarty->assign("actions", array("wake" => _("Wake up"),
+                                       "reinstall" => _("Reinstall"),
+                                       "update" => _("Scheduled update")));
     }
 
-
     /* Show main page */
     $smarty->assign("netconfig", $this->netConfigDNS->execute());
+    $smarty->assign("modes", $this->modes);
 
     return($smarty->fetch (get_template_path('server.tpl', TRUE)));
   }
@@ -129,7 +168,7 @@ class servgeneric extends plugin
     $this->netConfigDNS->remove_from_parent();
     $ldap= $this->config->get_ldap_link();
     $ldap->rmdir($this->dn);
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Removing server failed"));
 
     /* Delete references to object groups */
     $ldap->cd ($this->config->current['BASE']);
@@ -139,7 +178,7 @@ class servgeneric extends plugin
       unset($og->member[$this->dn]);
       $og->save ();
     }
-    $this->handle_post_events("remove");
+    $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress));
   }
 
 
@@ -158,7 +197,9 @@ class servgeneric extends plugin
   /* Check supplied data */
   function check()
   {
-    $message= $this->netConfigDNS->check();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+    $message= array_merge($message, $this->netConfigDNS->check());
     $this->dn= "cn=".$this->cn.",ou=servers,ou=systems,".$this->base;
 
     /* must: cn */
@@ -235,13 +276,13 @@ class servgeneric extends plugin
   
       $ldap->cd($this->dn);
       $this->cleanup();
-$ldap->modify ($this->attrs); 
+      $ldap->modify ($this->attrs); 
 
       $mode= "modify";
     }
     $this->netConfigDNS->cn = $this->cn;
     $this->netConfigDNS->save($this->dn);
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Saving server failed"));
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events($mode);