mirror of
https://github.com/humhub/humhub.git
synced 2025-03-04 15:19:06 +01:00
Installer recommended modules & trigger sample data event
This commit is contained in:
parent
8713cea7c7
commit
8c7319879c
@ -60,8 +60,10 @@ class ModuleManager extends \yii\base\Component
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if (!Yii::$app->params['installed'])
|
||||
// Either database installed and not in installed state
|
||||
if (!Yii::$app->params['databaseInstalled'] && !Yii::$app->params['installed']) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Yii::$app instanceof console\Application && !Yii::$app->isDatabaseInstalled()) {
|
||||
$this->enabledModules = [];
|
||||
@ -112,7 +114,7 @@ class ModuleManager extends \yii\base\Component
|
||||
if (isset($config['namespace'])) {
|
||||
Yii::setAlias('@' . str_replace('\\', '/', $config['namespace']), $basePath);
|
||||
}
|
||||
|
||||
|
||||
if (!Yii::$app->params['installed'] && $isInstallerModule) {
|
||||
$this->enabledModules[] = $config['id'];
|
||||
}
|
||||
@ -149,6 +151,8 @@ class ModuleManager extends \yii\base\Component
|
||||
// Register Yii Module
|
||||
Yii::$app->setModule($config['id'], $moduleConfig);
|
||||
|
||||
|
||||
|
||||
// Register Event Handlers
|
||||
if (isset($config['events'])) {
|
||||
foreach ($config['events'] as $event) {
|
||||
|
@ -87,6 +87,7 @@ $config = [
|
||||
],
|
||||
'params' => [
|
||||
'installed' => false,
|
||||
'databaseInstalled' => false,
|
||||
'dynamicConfigFile' => '@app/config/dynamic.php',
|
||||
'moduleAutoloadPaths' => ['@app/modules', '@humhub/modules'],
|
||||
'moduleMarketplacePath' => '@app/modules',
|
||||
|
@ -107,6 +107,16 @@ class Module extends \humhub\components\Module
|
||||
\humhub\libs\DynamicConfig::save($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets application database in installed state
|
||||
*/
|
||||
public function setDatabaseInstalled()
|
||||
{
|
||||
$config = \humhub\libs\DynamicConfig::load();
|
||||
$config['params']['databaseInstalled'] = true;
|
||||
\humhub\libs\DynamicConfig::save($config);
|
||||
}
|
||||
|
||||
protected function initConfigSteps()
|
||||
{
|
||||
|
||||
|
@ -28,6 +28,11 @@ use humhub\models\Setting;
|
||||
class ConfigController extends Controller
|
||||
{
|
||||
|
||||
const EVENT_INSTALL_SAMPLE_DATA = 'install_sample_data';
|
||||
|
||||
/**
|
||||
* Use Cases
|
||||
*/
|
||||
const USECASE_SOCIAL_INTRANET = 'social_intranet';
|
||||
const USECASE_SOCIAL_COLLABORATION = 'social_collab';
|
||||
const USECASE_EDUCATION = 'club';
|
||||
@ -141,13 +146,36 @@ class ConfigController extends Controller
|
||||
*/
|
||||
public function actionModules()
|
||||
{
|
||||
// Only showed purchased modules
|
||||
$marketplace = new \humhub\modules\admin\libs\OnlineModuleManager();
|
||||
$modules = $marketplace->getModules(false);
|
||||
foreach ($modules as $i => $module) {
|
||||
if (!isset($module['useCases']) || strpos($module['useCases'], Setting::Get('useCase')) === false) {
|
||||
unset($modules[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Yii::$app->request->get('ok') == 1) {
|
||||
|
||||
if (Yii::$app->request->method == 'POST') {
|
||||
$enableModules = Yii::$app->request->post('enableModules');
|
||||
if (is_array($enableModules)) {
|
||||
foreach (array_keys($enableModules) as $moduleId) {
|
||||
$marketplace->install($moduleId);
|
||||
$module = Yii::$app->moduleManager->getModule($moduleId);
|
||||
if ($module !== null) {
|
||||
$module->enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->redirect(Yii::$app->getModule('installer')->getNextConfigStepUrl());
|
||||
}
|
||||
|
||||
return $this->render('modules', array());
|
||||
/*
|
||||
if (Yii::$app->request->get('ok') == 1) {
|
||||
return $this->redirect(Yii::$app->getModule('installer')->getNextConfigStepUrl());
|
||||
}
|
||||
*/
|
||||
|
||||
return $this->render('modules', array('modules' => $modules));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,10 +192,11 @@ class ConfigController extends Controller
|
||||
|
||||
$form->sampleData = Setting::Get('sampleData', 'installer');
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
|
||||
$form->sampleData = Setting::Set('sampleData', $form->sampleData, 'installer');
|
||||
Setting::Set('sampleData', $form->sampleData, 'installer');
|
||||
|
||||
if (Setting::Get('sampleData', 'installer') == 1) {
|
||||
// ToDo Create Sample Data
|
||||
$this->trigger(self::EVENT_INSTALL_SAMPLE_DATA);
|
||||
// ToDo: Create Sample Data
|
||||
}
|
||||
|
||||
return $this->redirect(Yii::$app->getModule('installer')->getNextConfigStepUrl());
|
||||
|
@ -139,6 +139,8 @@ class SetupController extends Controller
|
||||
|
||||
DynamicConfig::rewrite();
|
||||
|
||||
$this->module->setDatabaseInstalled();
|
||||
|
||||
return $this->redirect(Url::to(['/installer/config/index']));
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,21 @@ use yii\bootstrap\Html;
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<?= Html::beginForm(); ?>
|
||||
|
||||
TBD
|
||||
<?php foreach ($modules as $module): ?>
|
||||
<?php echo Html::checkbox('enableModules[' . $module['id'] . ']', true); ?>
|
||||
<strong><?php echo $module['name']; ?></strong><br />
|
||||
<?php echo $module['description']; ?><br />
|
||||
<br />
|
||||
<?php endforeach; ?>
|
||||
|
||||
<hr>
|
||||
<?php echo Html::submitButton(Yii::t('base', 'Next'), array('class' => 'btn btn-primary', 'data-loader' => "modal", 'data-message' => Yii::t('InstallerModule.base', 'Downloading & Installing Modules...'))); ?>
|
||||
|
||||
<?php echo Html::a(Yii::t('base', 'Next'), ['modules', 'ok' => 1], array('class' => 'btn btn-primary')); ?>
|
||||
<?= Html::endForm(); ?>
|
||||
|
||||
<?php //echo Html::a(Yii::t('base', 'Next'), ['modules', 'ok' => 1], array('class' => 'btn btn-primary')); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -24,6 +24,9 @@ return [
|
||||
'password' => '',
|
||||
'charset' => 'utf8',
|
||||
],
|
||||
'request' => [
|
||||
'enableCsrfValidation' => false,
|
||||
],
|
||||
'mailer' => [
|
||||
'useFileTransport' => true,
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user