Better module error handling and removed the 'restart' function of the start page.

master
penguinc 2005-01-23 06:39:20 +00:00
parent 9648184fde
commit db4b7919db
4 changed files with 24 additions and 17 deletions

View File

@ -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()

View File

@ -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: ") .

View File

@ -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();

View File

@ -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>
@ -36,4 +26,4 @@ class="item0"><input type="text" name="command" size="30" class="input"
/></td></tr><tr class="control"><td class="control" colspan="2"><input
type="hidden" name="actionId" value="raw" /><input type="submit"
name="submitbutton" value="Send" class="button" /></td></tr>
</table></form>
</table></form>