diff --git a/lib/NWNDriver.php b/lib/NWNDriver.php
index 017e5c3..b04790d 100644
--- a/lib/NWNDriver.php
+++ b/lib/NWNDriver.php
@@ -225,14 +225,32 @@ class NWNDriver
return $data;
}
- function useModule($moduleName)
+ function useModule($moduleName, $flush = false)
{
$settings = &$this->_settingsbackend->getSettings();
$settings['module'] = $moduleName;
if ($this->serverRunning()) {
- $this->sendCommand('module ' . $moduleName);
+ $this->sendCommand('module ' . $moduleName, $flush);
+ sleep(2);
+ $result = $this->getLogContent();
+ $lines = explode("\n", $result);
+ $found = false;
+ foreach ($lines as $l) {
+ $l = trim($l);
+ if (!strpos($l, $moduleName) && strpos($l, 'Module loaded')) {
+ $found = true;
+ }
+ }
+ if (!$found) {
+ unset($settings['module']);
+ $this->_settingsbackend->setData($settings);
+ return PEAR::raiseError(_("Could not load the module!"));
+ }
+ } else {
+ $result = PEAR::raiseError(_("Server is not running!"));
}
- return $this->_settingsbackend->setData($settings);
+ $this->_settingsbackend->setData($settings);
+ return true;
}
function getModule()
diff --git a/module.php b/module.php
index 7158a86..6b64d7b 100644
--- a/module.php
+++ b/module.php
@@ -39,7 +39,7 @@ if (isset($actionId) && !isset($moduleName)) {
break;
case 'activate':
if ($admin) {
- $result = $nwndriver->useModule($moduleName);
+ $result = $nwndriver->useModule($moduleName, true);
if (is_a($result, 'PEAR_Error')) {
$notification->push(
_("Module load failure: ") .
diff --git a/start.php b/start.php
index 45f2b15..242620b 100644
--- a/start.php
+++ b/start.php
@@ -26,7 +26,6 @@ if (!$params || is_a($params, 'PEAR_Error') ||
$actionId = Util::getFormData('actionId');
switch ($actionId) {
case 'stop':
-case 'restart':
$wait = true;
$result = $nwndriver->stopServer();
if (is_a($result, 'PEAR_Error')) {
@@ -35,7 +34,7 @@ case 'restart':
} else {
$notification->push(_("The server was stopped."), 'horde.success');
}
- if ($actionId == 'stop') { break; }
+ break;
case 'start':
$wait = true;
$result = $nwndriver->startServer();
diff --git a/templates/start/kill.inc b/templates/start/kill.inc
index 7fc001b..a6a12b7 100644
--- a/templates/start/kill.inc
+++ b/templates/start/kill.inc
@@ -8,16 +8,6 @@ class="button" />
-