Force or Forbid installer depending on app state

This commit is contained in:
Lucas Bartholemy 2015-06-25 19:48:18 +02:00
parent 84218845f6
commit 6f59e05393
3 changed files with 45 additions and 1 deletions

View File

@ -17,4 +17,4 @@ Yii::setAlias('@webroot', __DIR__);
Yii::setAlias('@app', __DIR__ . DIRECTORY_SEPARATOR . 'protected');
Yii::setAlias('@humhub', '@app/humhub');
(new yii\web\Application($config))->run();
(new humhub\components\Application($config))->run();

View File

@ -0,0 +1,35 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\components;
use Yii;
/**
* Base WebApplication
*
* @author luke
*/
class Application extends \yii\web\Application
{
public function beforeAction($action)
{
/**
* Check if it's already installed - if not force controller module
*/
if (!$this->params['installed'] && $this->controller->module != null && $this->controller->module->id != 'installer') {
$this->controller->redirect(\yii\helpers\Url::to(['/installer/index']));
return false;
}
return parent::beforeAction($action);
}
}

View File

@ -38,6 +38,15 @@ class Module extends \yii\base\Module
$this->layout = '@humhub/core/installer/views/layouts/main.php';
}
public function beforeAction($action)
{
if (Yii::$app->params['installed']) {
throw new \yii\web\HttpException(500, 'HumHub is already installed!');
}
return parent::beforeAction($action);
}
/**
* Checks if database connections works
*