Use a hardcoded path where to look for modules

refs #7163
This commit is contained in:
Johannes Meyer 2014-10-29 15:43:08 +01:00
parent 2f05ed3d49
commit 47d9426a1f
6 changed files with 18 additions and 20 deletions

View File

@ -41,7 +41,6 @@ class GeneralConfigPage extends Form
// TODO: This is splitted as not all elements are required (as of d201cff) // TODO: This is splitted as not all elements are required (as of d201cff)
$appForm = new ApplicationConfigForm(); $appForm = new ApplicationConfigForm();
$appForm->createElements($formData); $appForm->createElements($formData);
$this->addElement($appForm->getElement('global_modulePath'));
$this->addElement($appForm->getElement('global_filemode')); $this->addElement($appForm->getElement('global_filemode'));
$loggingForm = new LoggingConfigForm(); $loggingForm = new LoggingConfigForm();

View File

@ -20,6 +20,8 @@ class ModulePage extends Form
protected $pageData; protected $pageData;
protected $modulePaths;
/** /**
* Initialize this page * Initialize this page
*/ */
@ -28,6 +30,11 @@ class ModulePage extends Form
$this->setName('setup_modules'); $this->setName('setup_modules');
$this->setViewScript('form/setup-modules.phtml'); $this->setViewScript('form/setup-modules.phtml');
$this->session = Session::getSession()->getNamespace(get_class($this)); $this->session = Session::getSession()->getNamespace(get_class($this));
$this->modulePaths = array();
if (($appModulePath = realpath(Icinga::app()->getApplicationDir() . '/../modules')) !== false) {
$this->modulePaths[] = $appModulePath;
}
} }
public function setPageData(array $pageData) public function setPageData(array $pageData)
@ -115,9 +122,7 @@ class ModulePage extends Form
} }
$moduleManager = Icinga::app()->getModuleManager(); $moduleManager = Icinga::app()->getModuleManager();
$moduleManager->detectInstalledModules( $moduleManager->detectInstalledModules($this->modulePaths);
explode(':', $this->pageData['setup_general_config']['global_modulePath'])
);
foreach ($moduleManager->listInstalledModules() as $moduleName) { foreach ($moduleManager->listInstalledModules() as $moduleName) {
$this->modules[] = $moduleManager->loadModule($moduleName)->getModule($moduleName); $this->modules[] = $moduleManager->loadModule($moduleName)->getModule($moduleName);
} }

View File

@ -144,12 +144,6 @@ class WebSetup extends Wizard implements SetupWizard
} elseif ($page->getName() === 'setup_modules') { } elseif ($page->getName() === 'setup_modules') {
$page->setPageData($this->getPageData()); $page->setPageData($this->getPageData());
$page->handleRequest($request); $page->handleRequest($request);
} elseif ($page->getName() === 'setup_general_config' && $this->getDirection() === static::FORWARD) {
$configData = $this->getPageData($page->getName());
if ($configData !== null && $request->getPost('global_modulePath') !== $configData['global_modulePath']) {
// Drop the ModulePage's session and all associated wizard sessions once the module path changes
$this->getPage('setup_modules')->clearSession();
}
} }
} }

View File

@ -133,10 +133,10 @@ class AuthenticationStep extends Step
. '</table>'; . '</table>';
$adminHtml = '<p>' . (isset($this->data['adminAccountData']['resourceConfig']) ? sprintf( $adminHtml = '<p>' . (isset($this->data['adminAccountData']['resourceConfig']) ? sprintf(
t('Administrative rights will initially be granted to an existing account called "%s".'), t('Administrative rights will initially be granted to a new account called "%s".'),
$this->data['adminAccountData']['username'] $this->data['adminAccountData']['username']
) : sprintf( ) : sprintf(
t('Administrative rights will initially be granted to a new account called "%s".'), t('Administrative rights will initially be granted to an existing account called "%s".'),
$this->data['adminAccountData']['username'] $this->data['adminAccountData']['username']
)) . '</p>'; )) . '</p>';

View File

@ -59,10 +59,6 @@ class GeneralConfigStep extends Step
$generalHtml = '' $generalHtml = ''
. '<ul>' . '<ul>'
. '<li>' . sprintf(
t('Icinga Web 2 will look for modules at: %s'),
$this->data['generalConfig']['global_modulePath']
) . '</li>'
. '<li>' . sprintf( . '<li>' . sprintf(
t('Icinga Web 2 will save new configuration files using the mode "%s".'), t('Icinga Web 2 will save new configuration files using the mode "%s".'),
$this->data['generalConfig']['global_filemode'] $this->data['generalConfig']['global_filemode']

View File

@ -9,23 +9,27 @@ use Icinga\Application\Icinga;
class EnableModuleStep extends Step class EnableModuleStep extends Step
{ {
protected $availableDirs; protected $modulePaths;
protected $moduleName; protected $moduleName;
protected $error; protected $error;
public function __construct($availableDirs, $moduleName) public function __construct($moduleName)
{ {
$this->availableDirs = $availableDirs;
$this->moduleName = $moduleName; $this->moduleName = $moduleName;
$this->modulePaths = array();
if (($appModulePath = realpath(Icinga::app()->getApplicationDir() . '/../modules')) !== false) {
$this->modulePaths[] = $appModulePath;
}
} }
public function apply() public function apply()
{ {
try { try {
$moduleManager = Icinga::app()->getModuleManager(); $moduleManager = Icinga::app()->getModuleManager();
$moduleManager->detectInstalledModules($this->availableDirs); $moduleManager->detectInstalledModules($this->modulePaths);
$moduleManager->enableModule($this->moduleName); $moduleManager->enableModule($this->moduleName);
} catch (Exception $e) { } catch (Exception $e) {
$this->error = $e; $this->error = $e;