Better module error handling and removed the 'restart' function of the start page.
parent
9648184fde
commit
db4b7919db
|
@ -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()
|
||||
|
|
|
@ -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: ") .
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -8,16 +8,6 @@ class="button" /></td></tr>
|
|||
|
||||
<br />
|
||||
|
||||
<form name="restartserver" action="<?php echo Horde::selfUrl() ?>"
|
||||
method="POST"><table width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr class="header"><td class="header">Restart Server</td></tr>
|
||||
<tr class="control"><td class="control"><input type="hidden" name="actionId"
|
||||
value="restart" /><input type="submit" name="submitbutton" value="Restart"
|
||||
class="button" /></td></tr>
|
||||
</table></form>
|
||||
|
||||
<br />
|
||||
|
||||
<form name="killserver" action="<?php echo Horde::selfUrl() ?>"
|
||||
method="POST"><table width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr class="header"><td class="header">Kill Server</td></tr>
|
||||
|
|
Reference in New Issue