mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Migrated installer module
This commit is contained in:
parent
c2f9327d34
commit
84218845f6
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'installed' => true,
|
||||
'installed' => false,
|
||||
'dynamicConfigFile' => '@app/config/dynamic.php',
|
||||
'availableLanguages' => [
|
||||
'en' => 'English (US)',
|
||||
'en_gb' => 'English (UK)',
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
$params = require(__DIR__ . '/params.php');
|
||||
|
||||
|
||||
$config = [
|
||||
'id' => 'basic',
|
||||
'basePath' => dirname(__DIR__),
|
||||
@ -86,4 +85,10 @@ if (YII_ENV_DEV) {
|
||||
$config['modules']['gii'] = 'yii\gii\Module';
|
||||
}
|
||||
|
||||
if (is_file(__DIR__ . '/dynamic.php')) {
|
||||
return yii\helpers\ArrayHelper::merge(
|
||||
$config, require(__DIR__ . '/dynamic.php')
|
||||
);
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
@ -125,4 +125,22 @@ class MigrateController extends \yii\console\controllers\MigrateController
|
||||
return $migrationPaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow to execute all migrations via web
|
||||
*/
|
||||
public static function webMigrateAll()
|
||||
{
|
||||
defined('STDOUT') or define('STDOUT', fopen('php://output', 'w'));
|
||||
defined('STDERR') or define('STDERR', fopen('php://output', 'w'));
|
||||
|
||||
ob_start();
|
||||
$controller = new self('migrate', Yii::$app);
|
||||
$controller->db = Yii::$app->db;
|
||||
$controller->interactive = false;
|
||||
$controller->includeModuleMigrations = true;
|
||||
$controller->color = false;
|
||||
$controller->runAction('up');
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ class ModuleAutoLoader implements BootstrapInterface
|
||||
|
||||
public function bootstrap($app)
|
||||
{
|
||||
|
||||
foreach (array(Yii::getAlias('@app/modules'), Yii::getAlias('@humhub/core')) as $modulePath) {
|
||||
foreach (scandir($modulePath) as $moduleId) {
|
||||
if ($moduleId == '.' || $moduleId == '..')
|
||||
|
@ -18,31 +18,24 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
namespace humhub\core\installer;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* InstallerModule provides an web installation interface for the applcation
|
||||
*
|
||||
* @package humhub.modules_core.installer
|
||||
* @since 0.5
|
||||
*/
|
||||
class InstallerModule extends HWebModule
|
||||
class Module extends \yii\base\Module
|
||||
{
|
||||
|
||||
public $isCoreModule = true;
|
||||
private $_assetsUrl;
|
||||
|
||||
public function getAssetsUrl()
|
||||
{
|
||||
if ($this->_assetsUrl === null)
|
||||
$this->_assetsUrl = Yii::app()->getAssetManager()->publish(
|
||||
Yii::getPathOfAlias('installer.resources')
|
||||
);
|
||||
return $this->_assetsUrl;
|
||||
}
|
||||
public $controllerNamespace = 'humhub\core\installer\controllers';
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setLayoutPath(Yii::getPathOfAlias('installer.views'));
|
||||
Yii::app()->clientScript->registerCoreScript('jquery');
|
||||
$this->layout = '@humhub/core/installer/views/layouts/main.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,9 +47,9 @@ class InstallerModule extends HWebModule
|
||||
{
|
||||
try {
|
||||
// call setActive with true to open connection.
|
||||
Yii::app()->db->setActive(true);
|
||||
Yii::$app->db->open();
|
||||
// return the current connection state.
|
||||
return Yii::app()->db->getActive();
|
||||
return Yii::$app->db->getIsActive();
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
@ -69,7 +62,7 @@ class InstallerModule extends HWebModule
|
||||
*/
|
||||
public function isConfigured()
|
||||
{
|
||||
if (HSetting::Get('secret') != "") {
|
||||
if (\humhub\models\Setting::Get('secret') != "") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -80,9 +73,9 @@ class InstallerModule extends HWebModule
|
||||
*/
|
||||
public function setInstalled()
|
||||
{
|
||||
$config = HSetting::getConfiguration();
|
||||
$config = \humhub\libs\DynamicConfig::load();
|
||||
$config['params']['installed'] = true;
|
||||
HSetting::setConfiguration($config);
|
||||
\humhub\libs\DynamicConfig::save($config);
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,8 @@
|
||||
<?php
|
||||
|
||||
# Disable until migrated
|
||||
return;
|
||||
|
||||
// Only activate installer mode, when not installed yet or we are in console (translation files)
|
||||
if (!Yii::app()->params['installed'] || Yii::app() instanceof CConsoleApplication) {
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'installer',
|
||||
'class' => 'application.modules_core.installer.InstallerModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
'application.modules_core.installer.*',
|
||||
),
|
||||
));
|
||||
}
|
||||
Yii::$app->moduleManager->register([
|
||||
'id' => 'installer',
|
||||
'class' => humhub\core\installer\Module::className(),
|
||||
'isCoreModule' => true,
|
||||
]);
|
||||
?>
|
@ -18,6 +18,16 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
namespace humhub\core\installer\controllers;
|
||||
|
||||
use Yii;
|
||||
use humhub\components\Controller;
|
||||
use humhub\core\space\models\Space;
|
||||
use humhub\core\user\models\User;
|
||||
use humhub\core\user\models\Password;
|
||||
use yii\helpers\Url;
|
||||
use humhub\models\Setting;
|
||||
|
||||
/**
|
||||
* ConfigController allows inital configuration of humhub.
|
||||
* E.g. Name of Network, Root User
|
||||
@ -30,38 +40,38 @@
|
||||
class ConfigController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var String layout to use
|
||||
*/
|
||||
public $layout = '_layout';
|
||||
|
||||
/**
|
||||
* Before each config controller action check if
|
||||
* - Database Connection works
|
||||
* - Database Migrated Up
|
||||
* - Not already configured (e.g. update)
|
||||
*
|
||||
* @param type $action
|
||||
* @param boolean
|
||||
*/
|
||||
protected function beforeAction($action)
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (parent::beforeAction($action)) {
|
||||
|
||||
// Flush Caches
|
||||
Yii::app()->cache->flush();
|
||||
// Flush Caches
|
||||
Yii::$app->cache->flush();
|
||||
|
||||
// Database Connection seems not to work
|
||||
if (!$this->getModule()->checkDBConnection()) {
|
||||
$this->redirect(Yii::app()->createUrl('//installer/setup/'));
|
||||
}
|
||||
|
||||
// When not at index action, verify that database is not already configured
|
||||
if ($action->id != 'finished') {
|
||||
if ($this->getModule()->isConfigured()) {
|
||||
$this->redirect($this->createUrl('finished'));
|
||||
// Database Connection seems not to work
|
||||
if (!$this->module->checkDBConnection()) {
|
||||
$this->redirect(Url::to(['/installer/setup']));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
// When not at index action, verify that database is not already configured
|
||||
if ($action->id != 'finished') {
|
||||
if ($this->module->isConfigured()) {
|
||||
$this->redirect(Url::to(['finished']));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,13 +81,13 @@ class ConfigController extends Controller
|
||||
public function actionIndex()
|
||||
{
|
||||
|
||||
if (HSetting::Get('name') == "") {
|
||||
HSetting::Set('name', "HumHub");
|
||||
if (Setting::Get('name') == "") {
|
||||
Setting::Set('name', "HumHub");
|
||||
}
|
||||
|
||||
$this->setupInitialData();
|
||||
\humhub\core\installer\libs\InitialData::bootstrap();
|
||||
|
||||
$this->redirect(Yii::app()->createUrl('//installer/config/basic'));
|
||||
return $this->redirect(Url::to(['//installer/config/basic']));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,29 +95,16 @@ class ConfigController extends Controller
|
||||
*/
|
||||
public function actionBasic()
|
||||
{
|
||||
Yii::import('installer.forms.*');
|
||||
$form = new \humhub\core\installer\forms\ConfigBasicForm();
|
||||
$form->name = Setting::Get('name');
|
||||
|
||||
$form = new ConfigBasicForm;
|
||||
$form->name = HSetting::Get('name');
|
||||
|
||||
if (isset($_POST['ajax']) && $_POST['ajax'] === 'basic-form') {
|
||||
echo CActiveForm::validate($form);
|
||||
Yii::app()->end();
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
|
||||
Setting::Set('name', $form->name);
|
||||
Setting::Set('systemEmailName', $form->name, 'mailing');
|
||||
return $this->redirect(Url::to(['/installer/config/admin']));
|
||||
}
|
||||
|
||||
if (isset($_POST['ConfigBasicForm'])) {
|
||||
$_POST['ConfigBasicForm'] = Yii::app()->input->stripClean($_POST['ConfigBasicForm']);
|
||||
$form->attributes = $_POST['ConfigBasicForm'];
|
||||
|
||||
if ($form->validate()) {
|
||||
// Set some default settings
|
||||
HSetting::Set('name', $form->name);
|
||||
HSetting::Set('systemEmailName', $form->name, 'mailing');
|
||||
$this->redirect(Yii::app()->createUrl('//installer/config/admin'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('basic', array('model' => $form));
|
||||
return $this->render('basic', array('model' => $form));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,12 +115,13 @@ class ConfigController extends Controller
|
||||
*/
|
||||
public function actionAdmin()
|
||||
{
|
||||
Yii::import('installer.forms.*');
|
||||
|
||||
$userModel = new User('register');
|
||||
$userPasswordModel = new UserPassword('newPassword');
|
||||
$userModel = new User();
|
||||
$userModel->scenario = 'registration';
|
||||
$userPasswordModel = new Password();
|
||||
$userPasswordModel->scenario = 'registration';
|
||||
$profileModel = $userModel->profile;
|
||||
$profileModel->scenario = 'register';
|
||||
$profileModel->scenario = 'registration';
|
||||
|
||||
// Build Form Definition
|
||||
$definition = array();
|
||||
@ -132,7 +130,6 @@ class ConfigController extends Controller
|
||||
// Add User Form
|
||||
$definition['elements']['User'] = array(
|
||||
'type' => 'form',
|
||||
#'title' => 'Account',
|
||||
'elements' => array(
|
||||
'username' => array(
|
||||
'type' => 'text',
|
||||
@ -148,7 +145,7 @@ class ConfigController extends Controller
|
||||
);
|
||||
|
||||
// Add User Password Form
|
||||
$definition['elements']['UserPassword'] = array(
|
||||
$definition['elements']['Password'] = array(
|
||||
'type' => 'form',
|
||||
'elements' => array(
|
||||
'newPassword' => array(
|
||||
@ -176,49 +173,37 @@ class ConfigController extends Controller
|
||||
),
|
||||
);
|
||||
|
||||
$form = new HForm($definition);
|
||||
$form['User']->model = $userModel;
|
||||
$form['User']->model->group_id = 1;
|
||||
$form['UserPassword']->model = $userPasswordModel;
|
||||
$form['Profile']->model = $profileModel;
|
||||
|
||||
if (isset($_POST['Profile'])) {
|
||||
$_POST['Profile'] = Yii::app()->input->stripClean($_POST['Profile']);
|
||||
}
|
||||
|
||||
if (isset($_GET['Profile'])) {
|
||||
$_GET['Profile'] = Yii::app()->input->stripClean($_GET['Profile']);
|
||||
}
|
||||
$form = new \humhub\compat\HForm($definition);
|
||||
$form->models['User'] = $userModel;
|
||||
$form->models['User']->group_id = 1;
|
||||
$form->models['Password'] = $userPasswordModel;
|
||||
$form->models['Profile'] = $profileModel;
|
||||
|
||||
if ($form->submitted('save') && $form->validate()) {
|
||||
$this->forcePostRequest();
|
||||
|
||||
if (HSetting::Get('secret') == "") {
|
||||
HSetting::Set('secret', UUID::v4());
|
||||
if (Setting::Get('secret') == "") {
|
||||
Setting::Set('secret', \humhub\libs\UUID::v4());
|
||||
}
|
||||
|
||||
$form['User']->model->status = User::STATUS_ENABLED;
|
||||
$form['User']->model->super_admin = true;
|
||||
$form['User']->model->language = '';
|
||||
$form['User']->model->last_activity_email = new CDbExpression('NOW()');
|
||||
$form['User']->model->save();
|
||||
$form->models['User']->status = User::STATUS_ENABLED;
|
||||
$form->models['User']->super_admin = true;
|
||||
$form->models['User']->language = '';
|
||||
$form->models['User']->last_activity_email = new \yii\db\Expression('NOW()');
|
||||
$form->models['User']->save();
|
||||
|
||||
$form['Profile']->model->user_id = $form['User']->model->id;
|
||||
$form['Profile']->model->title = "System Administration";
|
||||
$form['Profile']->model->save();
|
||||
$form->models['Profile']->user_id = $form->models['User']->id;
|
||||
$form->models['Profile']->title = "System Administration";
|
||||
$form->models['Profile']->save();
|
||||
|
||||
// Save User Password
|
||||
$form['UserPassword']->model->user_id = $form['User']->model->id;
|
||||
$form['UserPassword']->model->setPassword($form['UserPassword']->model->newPassword);
|
||||
$form['UserPassword']->model->save();
|
||||
$form->models['Password']->user_id = $form->models['User']->id;
|
||||
$form->models['Password']->setPassword($form->models['Password']->newPassword);
|
||||
$form->models['Password']->save();
|
||||
|
||||
$userId = $form['User']->model->id;
|
||||
$userId = $form->models['User']->id;
|
||||
|
||||
// Switch Identity
|
||||
Yii::import('application.modules_core.user.components.*');
|
||||
$newIdentity = new UserIdentity($form['User']->model->username, '');
|
||||
$newIdentity->fakeAuthenticate();
|
||||
Yii::app()->user->login($newIdentity);
|
||||
Yii::$app->user->switchIdentity($form->models['User']);
|
||||
|
||||
// Create Welcome Space
|
||||
$space = new Space();
|
||||
@ -230,20 +215,20 @@ class ConfigController extends Controller
|
||||
$space->auto_add_new_members = 1;
|
||||
$space->save();
|
||||
|
||||
$profileImage = new ProfileImage($space->guid);
|
||||
$profileImage->setNew($this->getModule()->getPath() . DIRECTORY_SEPARATOR . "resources" . DIRECTORY_SEPARATOR . 'welcome_space.jpg');
|
||||
$profileImage = new \humhub\libs\ProfileImage($space->guid);
|
||||
$profileImage->setNew(Yii::getAlias("@webroot/resources/installer/welcome_space.jpg"));
|
||||
|
||||
// Add Some Post to the Space
|
||||
$post = new Post();
|
||||
$post = new \humhub\core\post\models\Post();
|
||||
$post->message = "Yay! I've just installed HumHub :-)";
|
||||
$post->content->container = $space;
|
||||
$post->content->visibility = Content::VISIBILITY_PUBLIC;
|
||||
$post->content->visibility = \humhub\core\content\models\Content::VISIBILITY_PUBLIC;
|
||||
$post->save();
|
||||
|
||||
$this->redirect($this->createUrl('finished'));
|
||||
return $this->redirect(Url::to(['finished']));
|
||||
}
|
||||
|
||||
$this->render('admin', array('form' => $form));
|
||||
return $this->render('admin', array('hForm' => $form));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,23 +238,23 @@ class ConfigController extends Controller
|
||||
{
|
||||
|
||||
// Should not happen
|
||||
if (HSetting::Get('secret') == "") {
|
||||
if (Setting::Get('secret') == "") {
|
||||
throw new CException("Finished without secret setting!");
|
||||
}
|
||||
|
||||
// Rewrite whole configuration file, also sets application
|
||||
// in installed state.
|
||||
HSetting::RewriteConfiguration();
|
||||
\humhub\libs\DynamicConfig::rewrite();
|
||||
|
||||
// Set to installed
|
||||
$this->module->setInstalled();
|
||||
|
||||
try {
|
||||
Yii::app()->user->logout();
|
||||
Yii::$app->user->logout();
|
||||
} catch (Exception $e) {
|
||||
;
|
||||
}
|
||||
$this->render('finished');
|
||||
return $this->render('finished');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -279,442 +264,7 @@ class ConfigController extends Controller
|
||||
*/
|
||||
private function setupInitialData()
|
||||
{
|
||||
|
||||
// Seems database is already initialized
|
||||
if (HSetting::Get('paginationSize') == 10)
|
||||
return;
|
||||
|
||||
Yii::app()->search->rebuild();
|
||||
|
||||
HSetting::Set('baseUrl', Yii::app()->getBaseUrl(true));
|
||||
HSetting::Set('paginationSize', 10);
|
||||
HSetting::Set('displayNameFormat', '{profile.firstname} {profile.lastname}');
|
||||
|
||||
// Authentication
|
||||
HSetting::Set('authInternal', '1', 'authentication');
|
||||
HSetting::Set('authLdap', '0', 'authentication');
|
||||
HSetting::Set('refreshUsers', '1', 'authentication_ldap');
|
||||
HSetting::Set('needApproval', '0', 'authentication_internal');
|
||||
HSetting::Set('anonymousRegistration', '1', 'authentication_internal');
|
||||
HSetting::Set('internalUsersCanInvite', '1', 'authentication_internal');
|
||||
|
||||
// Mailing
|
||||
HSetting::Set('transportType', 'php', 'mailing');
|
||||
HSetting::Set('systemEmailAddress', 'social@example.com', 'mailing');
|
||||
HSetting::Set('systemEmailName', 'My Social Network', 'mailing');
|
||||
HSetting::Set('receive_email_activities', User::RECEIVE_EMAIL_DAILY_SUMMARY, 'mailing');
|
||||
HSetting::Set('receive_email_notifications', User::RECEIVE_EMAIL_WHEN_OFFLINE, 'mailing');
|
||||
|
||||
// File
|
||||
HSetting::Set('maxFileSize', '1048576', 'file');
|
||||
HSetting::Set('maxPreviewImageWidth', '200', 'file');
|
||||
HSetting::Set('maxPreviewImageHeight', '200', 'file');
|
||||
HSetting::Set('hideImageFileInfo', '0', 'file');
|
||||
|
||||
// Caching
|
||||
HSetting::Set('type', 'CFileCache', 'cache');
|
||||
HSetting::Set('expireTime', '3600', 'cache');
|
||||
HSetting::Set('installationId', md5(uniqid("", true)), 'admin');
|
||||
|
||||
// Design
|
||||
HSetting::Set('theme', "HumHub");
|
||||
HSetting::Set('spaceOrder', 0, 'space');
|
||||
|
||||
// Basic
|
||||
HSetting::Set('enable', 1, 'tour');
|
||||
HSetting::Set('defaultLanguage', Yii::app()->getLanguage());
|
||||
|
||||
// Notification
|
||||
HSetting::Set('enable_html5_desktop_notifications', 0, 'notification');
|
||||
|
||||
// Add Categories
|
||||
$cGeneral = new ProfileFieldCategory;
|
||||
$cGeneral->title = "General";
|
||||
$cGeneral->sort_order = 100;
|
||||
$cGeneral->visibility = 1;
|
||||
$cGeneral->is_system = 1;
|
||||
$cGeneral->description = '';
|
||||
$cGeneral->save();
|
||||
|
||||
$cCommunication = new ProfileFieldCategory;
|
||||
$cCommunication->title = "Communication";
|
||||
$cCommunication->sort_order = 200;
|
||||
$cCommunication->visibility = 1;
|
||||
$cCommunication->is_system = 1;
|
||||
$cCommunication->description = '';
|
||||
$cCommunication->save();
|
||||
|
||||
$cSocial = new ProfileFieldCategory;
|
||||
$cSocial->title = "Social bookmarks";
|
||||
$cSocial->sort_order = 300;
|
||||
$cSocial->visibility = 1;
|
||||
$cSocial->is_system = 1;
|
||||
$cSocial->description = '';
|
||||
$cSocial->save();
|
||||
|
||||
// Add Fields
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "firstname";
|
||||
$field->title = 'Firstname';
|
||||
$field->sort_order = 100;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->ldap_attribute = 'givenName';
|
||||
$field->is_system = 1;
|
||||
$field->required = 1;
|
||||
$field->show_at_registration = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 20;
|
||||
$field->fieldType->save();
|
||||
} else {
|
||||
throw new CHttpException(500, print_r($field->getErrors(), true));
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "lastname";
|
||||
$field->title = 'Lastname';
|
||||
$field->sort_order = 200;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->ldap_attribute = 'sn';
|
||||
$field->show_at_registration = 1;
|
||||
$field->required = 1;
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 30;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "title";
|
||||
$field->title = 'Title';
|
||||
$field->sort_order = 300;
|
||||
$field->ldap_attribute = 'title';
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 50;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "gender";
|
||||
$field->title = 'Gender';
|
||||
$field->sort_order = 300;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeSelect';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->options = "male=>Male\nfemale=>Female\ncustom=>Custom";
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "street";
|
||||
$field->title = 'Street';
|
||||
$field->sort_order = 400;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 150;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "zip";
|
||||
$field->title = 'Zip';
|
||||
$field->sort_order = 500;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->is_system = 1;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 10;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "city";
|
||||
$field->title = 'City';
|
||||
$field->sort_order = 600;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "country";
|
||||
$field->title = 'Country';
|
||||
$field->sort_order = 700;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "state";
|
||||
$field->title = 'State';
|
||||
$field->sort_order = 800;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "birthday";
|
||||
$field->title = 'Birthday';
|
||||
$field->sort_order = 900;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeBirthday';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "about";
|
||||
$field->title = 'About';
|
||||
$field->sort_order = 900;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeTextArea';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
#$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "phone_private";
|
||||
$field->title = 'Phone Private';
|
||||
$field->sort_order = 100;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "phone_work";
|
||||
$field->title = 'Phone Work';
|
||||
$field->sort_order = 200;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "mobile";
|
||||
$field->title = 'Mobile';
|
||||
$field->sort_order = 300;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "fax";
|
||||
$field->title = 'Fax';
|
||||
$field->sort_order = 400;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "im_skype";
|
||||
$field->title = 'Skype Nickname';
|
||||
$field->sort_order = 500;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "im_msn";
|
||||
$field->title = 'MSN';
|
||||
$field->sort_order = 600;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "im_icq";
|
||||
$field->title = 'ICQ Number';
|
||||
$field->sort_order = 700;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeNumber';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "im_xmpp";
|
||||
$field->title = 'XMPP Jabber Address';
|
||||
$field->sort_order = 800;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'email';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url";
|
||||
$field->title = 'Url';
|
||||
$field->sort_order = 100;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_facebook";
|
||||
$field->title = 'Facebook URL';
|
||||
$field->sort_order = 200;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_linkedin";
|
||||
$field->title = 'LinkedIn URL';
|
||||
$field->sort_order = 300;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_xing";
|
||||
$field->title = 'Xing URL';
|
||||
$field->sort_order = 400;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_youtube";
|
||||
$field->title = 'Youtube URL';
|
||||
$field->sort_order = 500;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_vimeo";
|
||||
$field->title = 'Vimeo URL';
|
||||
$field->sort_order = 600;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_flickr";
|
||||
$field->title = 'Flickr URL';
|
||||
$field->sort_order = 700;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_myspace";
|
||||
$field->title = 'MySpace URL';
|
||||
$field->sort_order = 800;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_googleplus";
|
||||
$field->title = 'Google+ URL';
|
||||
$field->sort_order = 900;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_twitter";
|
||||
$field->title = 'Twitter URL';
|
||||
$field->sort_order = 1000;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeText';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$group = new Group();
|
||||
$group->name = "Users";
|
||||
$group->description = "Example Group by Installer";
|
||||
$group->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,14 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
namespace humhub\core\installer\controllers;
|
||||
|
||||
use Yii;
|
||||
use humhub\components\Controller;
|
||||
use humhub\core\user\models\Group;
|
||||
use humhub\core\user\models\User;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* Index Controller shows a simple welcome page.
|
||||
*
|
||||
@ -26,18 +34,12 @@
|
||||
class IndexController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var String layout to use
|
||||
*/
|
||||
public $layout = '_layout';
|
||||
|
||||
/**
|
||||
* Index View just provides a welcome page
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$this->render('index', array());
|
||||
return $this->render('index', array());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,10 +47,11 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function actionGo()
|
||||
{
|
||||
if ($this->getModule()->checkDBConnection()) {
|
||||
$this->redirect(Yii::app()->createUrl('//installer/setup/init'));
|
||||
if ($this->module->checkDBConnection()) {
|
||||
return $this->redirect(Url::to(['setup/init']));
|
||||
} else {
|
||||
$this->redirect(Yii::app()->createUrl('//installer/setup/prerequisites'));
|
||||
return $this->redirect(Url::to(['setup/rerequisites']));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,14 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
namespace humhub\core\installer\controllers;
|
||||
|
||||
use Yii;
|
||||
use humhub\components\Controller;
|
||||
use humhub\core\user\models\Group;
|
||||
use humhub\core\user\models\User;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* SetupController checks prerequisites and is responsible for database
|
||||
* connection and schema setup.
|
||||
@ -28,16 +36,11 @@
|
||||
class SetupController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var String layout to use
|
||||
*/
|
||||
public $layout = '_layout';
|
||||
|
||||
const PASSWORD_PLACEHOLDER = 'n0thingToSeeHere!';
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$this->redirect(Yii::app()->createUrl('prerequisites'));
|
||||
return $this->redirect(Url::to(['prerequisites']));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,8 +51,7 @@ class SetupController extends Controller
|
||||
*/
|
||||
public function actionPrerequisites()
|
||||
{
|
||||
|
||||
$checks = SelfTest::getResults();
|
||||
$checks = \humhub\libs\SelfTest::getResults();
|
||||
|
||||
$hasError = false;
|
||||
foreach ($checks as $check) {
|
||||
@ -58,7 +60,7 @@ class SetupController extends Controller
|
||||
}
|
||||
|
||||
// Render Template
|
||||
$this->render('prerequisites', array('checks' => $checks, 'hasError' => $hasError));
|
||||
return $this->render('prerequisites', array('checks' => $checks, 'hasError' => $hasError));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +83,7 @@ class SetupController extends Controller
|
||||
|
||||
if (isset($_POST['ajax']) && $_POST['ajax'] === 'database-form') {
|
||||
echo CActiveForm::validate($form);
|
||||
Yii::app()->end();
|
||||
Yii::$app->end();
|
||||
}
|
||||
|
||||
if (isset($_POST['DatabaseForm'])) {
|
||||
@ -96,7 +98,7 @@ class SetupController extends Controller
|
||||
$password = $config['components']['db']['password'];
|
||||
|
||||
// Create Test DB Connection
|
||||
Yii::app()->setComponent('db', array(
|
||||
Yii::$app->setComponent('db', array(
|
||||
'connectionString' => $connectionString,
|
||||
'username' => $form->username,
|
||||
'password' => $password,
|
||||
@ -106,7 +108,7 @@ class SetupController extends Controller
|
||||
|
||||
try {
|
||||
// Check DB Connection
|
||||
Yii::app()->db->getServerVersion();
|
||||
Yii::$app->db->getServerVersion();
|
||||
|
||||
// Write Config
|
||||
$config['components']['db']['connectionString'] = $connectionString;
|
||||
@ -121,9 +123,8 @@ class SetupController extends Controller
|
||||
HSetting::setConfiguration($config);
|
||||
|
||||
$success = true;
|
||||
|
||||
|
||||
$this->redirect(array('init'));
|
||||
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
}
|
||||
@ -153,20 +154,19 @@ class SetupController extends Controller
|
||||
public function actionInit()
|
||||
{
|
||||
|
||||
if (!$this->getModule()->checkDBConnection())
|
||||
$this->redirect(Yii::app()->createUrl('//installer/setup/database'));
|
||||
if (!$this->module->checkDBConnection())
|
||||
$this->redirect(Url::to(['/installer/setup/database']));
|
||||
|
||||
// Flush Caches
|
||||
Yii::app()->cache->flush();
|
||||
Yii::$app->cache->flush();
|
||||
|
||||
// Disable max execution time to avoid timeouts during database installation
|
||||
@ini_set('max_execution_time', 0);
|
||||
|
||||
// Migrate Up Database
|
||||
Yii::import('application.commands.shell.ZMigrateCommand');
|
||||
ZMigrateCommand::AutoMigrate();
|
||||
|
||||
$this->redirect(Yii::app()->createUrl('//installer/config/index'));
|
||||
// Migrate Up Database
|
||||
$result = \humhub\commands\MigrateController::webMigrateAll();
|
||||
|
||||
return $this->redirect(Url::to(['/installer/config/index']));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,20 +18,26 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
namespace humhub\core\installer\forms;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* ConfigBasicForm holds basic application settings.
|
||||
*
|
||||
* @package humhub.modules_core.installer.forms
|
||||
* @since 0.5
|
||||
*/
|
||||
class ConfigBasicForm extends CFormModel {
|
||||
class ConfigBasicForm extends \yii\base\Model
|
||||
{
|
||||
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Declares the validation rules.
|
||||
*/
|
||||
public function rules() {
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('name', 'required'),
|
||||
);
|
||||
@ -42,7 +48,8 @@ class ConfigBasicForm extends CFormModel {
|
||||
* If not declared here, an attribute would have a label that is
|
||||
* the same as its name with the first letter in upper case.
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
'name' => Yii::t('InstallerModule.forms_ConfigBasicForm', 'Name of your network'),
|
||||
);
|
||||
|
@ -18,13 +18,16 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
namespace humhub\core\installer\forms;
|
||||
|
||||
/**
|
||||
* DatabaseForm holds all required database settings.
|
||||
*
|
||||
* @package humhub.modules_core.installer.forms
|
||||
* @since 0.5
|
||||
*/
|
||||
class DatabaseForm extends CFormModel {
|
||||
class DatabaseForm extends \yii\base\Model
|
||||
{
|
||||
|
||||
public $hostname;
|
||||
public $username;
|
||||
@ -34,9 +37,10 @@ class DatabaseForm extends CFormModel {
|
||||
/**
|
||||
* Declares the validation rules.
|
||||
*/
|
||||
public function rules() {
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('hostname, username, database', 'required'),
|
||||
array(['hostname', 'username', 'database'], 'required'),
|
||||
array('password', 'safe'),
|
||||
);
|
||||
}
|
||||
@ -46,7 +50,8 @@ class DatabaseForm extends CFormModel {
|
||||
* If not declared here, an attribute would have a label that is
|
||||
* the same as its name with the first letter in upper case.
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
'hostname' => Yii::t('InstallerModule.forms_DatabaseForm', 'Hostname'),
|
||||
'username' => Yii::t('InstallerModule.forms_DatabaseForm', 'Username'),
|
||||
|
470
protected/humhub/core/installer/libs/InitialData.php
Normal file
470
protected/humhub/core/installer/libs/InitialData.php
Normal file
@ -0,0 +1,470 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\core\installer\libs;
|
||||
|
||||
use Yii;
|
||||
use humhub\models\Setting;
|
||||
use yii\base\Exception;
|
||||
use humhub\core\user\models\ProfileFieldCategory;
|
||||
use humhub\core\user\models\ProfileField;
|
||||
use humhub\core\user\models\User;
|
||||
use humhub\core\space\models\Space;
|
||||
use humhub\core\user\models\Group;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* Description of InitalData
|
||||
*
|
||||
* @author luke
|
||||
*/
|
||||
class InitialData
|
||||
{
|
||||
|
||||
public static function bootstrap()
|
||||
{
|
||||
// Seems database is already initialized
|
||||
if (Setting::Get('paginationSize') == 10)
|
||||
return;
|
||||
|
||||
//Yii::$app->search->rebuild();
|
||||
|
||||
Setting::Set('baseUrl', Url::home(true));
|
||||
Setting::Set('paginationSize', 10);
|
||||
Setting::Set('displayNameFormat', '{profile.firstname} {profile.lastname}');
|
||||
|
||||
// Authentication
|
||||
Setting::Set('authInternal', '1', 'authentication');
|
||||
Setting::Set('authLdap', '0', 'authentication');
|
||||
Setting::Set('refreshUsers', '1', 'authentication_ldap');
|
||||
Setting::Set('needApproval', '0', 'authentication_internal');
|
||||
Setting::Set('anonymousRegistration', '1', 'authentication_internal');
|
||||
Setting::Set('internalUsersCanInvite', '1', 'authentication_internal');
|
||||
|
||||
// Mailing
|
||||
Setting::Set('transportType', 'php', 'mailing');
|
||||
Setting::Set('systemEmailAddress', 'social@example.com', 'mailing');
|
||||
Setting::Set('systemEmailName', 'My Social Network', 'mailing');
|
||||
Setting::Set('receive_email_activities', User::RECEIVE_EMAIL_DAILY_SUMMARY, 'mailing');
|
||||
Setting::Set('receive_email_notifications', User::RECEIVE_EMAIL_WHEN_OFFLINE, 'mailing');
|
||||
|
||||
// File
|
||||
Setting::Set('maxFileSize', '1048576', 'file');
|
||||
Setting::Set('maxPreviewImageWidth', '200', 'file');
|
||||
Setting::Set('maxPreviewImageHeight', '200', 'file');
|
||||
Setting::Set('hideImageFileInfo', '0', 'file');
|
||||
|
||||
// Caching
|
||||
Setting::Set('type', 'CFileCache', 'cache');
|
||||
Setting::Set('expireTime', '3600', 'cache');
|
||||
Setting::Set('installationId', md5(uniqid("", true)), 'admin');
|
||||
|
||||
// Design
|
||||
Setting::Set('theme', "HumHub");
|
||||
Setting::Set('spaceOrder', 0, 'space');
|
||||
|
||||
// Basic
|
||||
Setting::Set('enable', 1, 'tour');
|
||||
Setting::Set('defaultLanguage', Yii::$app->language);
|
||||
|
||||
// Notification
|
||||
Setting::Set('enable_html5_desktop_notifications', 0, 'notification');
|
||||
|
||||
// Add Categories
|
||||
$cGeneral = new ProfileFieldCategory;
|
||||
$cGeneral->title = "General";
|
||||
$cGeneral->sort_order = 100;
|
||||
$cGeneral->visibility = 1;
|
||||
$cGeneral->is_system = 1;
|
||||
$cGeneral->description = '';
|
||||
if (!$cGeneral->save()) {
|
||||
throw new Exception(print_r($cGeneral->getErrors(), true));
|
||||
}
|
||||
|
||||
$cCommunication = new ProfileFieldCategory;
|
||||
$cCommunication->title = "Communication";
|
||||
$cCommunication->sort_order = 200;
|
||||
$cCommunication->visibility = 1;
|
||||
$cCommunication->is_system = 1;
|
||||
$cCommunication->description = '';
|
||||
$cCommunication->save();
|
||||
|
||||
$cSocial = new ProfileFieldCategory;
|
||||
$cSocial->title = "Social bookmarks";
|
||||
$cSocial->sort_order = 300;
|
||||
$cSocial->visibility = 1;
|
||||
$cSocial->is_system = 1;
|
||||
$cSocial->description = '';
|
||||
$cSocial->save();
|
||||
|
||||
// Add Fields
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "firstname";
|
||||
$field->title = 'Firstname';
|
||||
$field->sort_order = 100;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->ldap_attribute = 'givenName';
|
||||
$field->is_system = 1;
|
||||
$field->required = 1;
|
||||
$field->show_at_registration = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 20;
|
||||
$field->fieldType->save();
|
||||
} else {
|
||||
throw new Exception(print_r($field->getErrors(), true));
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "lastname";
|
||||
$field->title = 'Lastname';
|
||||
$field->sort_order = 200;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->ldap_attribute = 'sn';
|
||||
$field->show_at_registration = 1;
|
||||
$field->required = 1;
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 30;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "title";
|
||||
$field->title = 'Title';
|
||||
$field->sort_order = 300;
|
||||
$field->ldap_attribute = 'title';
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 50;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "gender";
|
||||
$field->title = 'Gender';
|
||||
$field->sort_order = 300;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeSelect';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->options = "male=>Male\nfemale=>Female\ncustom=>Custom";
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "street";
|
||||
$field->title = 'Street';
|
||||
$field->sort_order = 400;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 150;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "zip";
|
||||
$field->title = 'Zip';
|
||||
$field->sort_order = 500;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->is_system = 1;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 10;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "city";
|
||||
$field->title = 'City';
|
||||
$field->sort_order = 600;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "country";
|
||||
$field->title = 'Country';
|
||||
$field->sort_order = 700;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "state";
|
||||
$field->title = 'State';
|
||||
$field->sort_order = 800;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "birthday";
|
||||
$field->title = 'Birthday';
|
||||
$field->sort_order = 900;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeBirthday';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "about";
|
||||
$field->title = 'About';
|
||||
$field->sort_order = 900;
|
||||
$field->profile_field_category_id = $cGeneral->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeTextArea';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
#$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "phone_private";
|
||||
$field->title = 'Phone Private';
|
||||
$field->sort_order = 100;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "phone_work";
|
||||
$field->title = 'Phone Work';
|
||||
$field->sort_order = 200;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "mobile";
|
||||
$field->title = 'Mobile';
|
||||
$field->sort_order = 300;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "fax";
|
||||
$field->title = 'Fax';
|
||||
$field->sort_order = 400;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "im_skype";
|
||||
$field->title = 'Skype Nickname';
|
||||
$field->sort_order = 500;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "im_msn";
|
||||
$field->title = 'MSN';
|
||||
$field->sort_order = 600;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->maxLength = 100;
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "im_icq";
|
||||
$field->title = 'ICQ Number';
|
||||
$field->sort_order = 700;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = 'ProfileFieldTypeNumber';
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "im_xmpp";
|
||||
$field->title = 'XMPP Jabber Address';
|
||||
$field->sort_order = 800;
|
||||
$field->profile_field_category_id = $cCommunication->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'email';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url";
|
||||
$field->title = 'Url';
|
||||
$field->sort_order = 100;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_facebook";
|
||||
$field->title = 'Facebook URL';
|
||||
$field->sort_order = 200;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_linkedin";
|
||||
$field->title = 'LinkedIn URL';
|
||||
$field->sort_order = 300;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_xing";
|
||||
$field->title = 'Xing URL';
|
||||
$field->sort_order = 400;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_youtube";
|
||||
$field->title = 'Youtube URL';
|
||||
$field->sort_order = 500;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_vimeo";
|
||||
$field->title = 'Vimeo URL';
|
||||
$field->sort_order = 600;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_flickr";
|
||||
$field->title = 'Flickr URL';
|
||||
$field->sort_order = 700;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_myspace";
|
||||
$field->title = 'MySpace URL';
|
||||
$field->sort_order = 800;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_googleplus";
|
||||
$field->title = 'Google+ URL';
|
||||
$field->sort_order = 900;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$field = new ProfileField();
|
||||
$field->internal_name = "url_twitter";
|
||||
$field->title = 'Twitter URL';
|
||||
$field->sort_order = 1000;
|
||||
$field->profile_field_category_id = $cSocial->id;
|
||||
$field->field_type_class = \humhub\core\user\models\fieldtype\Text::className();
|
||||
$field->is_system = 1;
|
||||
if ($field->save()) {
|
||||
$field->fieldType->validator = 'url';
|
||||
$field->fieldType->save();
|
||||
}
|
||||
|
||||
$group = new Group();
|
||||
$group->name = "Users";
|
||||
$group->description = "Example Group by Installer";
|
||||
$group->save();
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php /* @var $this Controller */ ?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta name="language" content="en"/>
|
||||
|
||||
<link type="text/css" href="<?php echo Yii::app()->baseUrl; ?>/css/animate.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->baseUrl; ?>/css/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->baseUrl; ?>/css/style.css"/>
|
||||
<link href="<?php echo Yii::app()->baseUrl; ?>/themes/HumHub/css/theme.css" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="<?php echo Yii::app()->baseUrl; ?>/resources/font-awesome/css/font-awesome.min.css">
|
||||
|
||||
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container installer" style="margin: 0 auto; max-width: 700px;">
|
||||
<div class="logo">
|
||||
<?php if (Yii::app()->name == "HumHub") : ?>
|
||||
<a class="animated fadeIn" href="http://www.humhub.org" target="_blank" class="">
|
||||
<img src="<?php echo $this->module->assetsUrl; ?>/humhub-logo.png" alt="Logo">
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<h1 class="animated fadeIn"><?php echo CHtml::encode(Yii::app()->name); ?></h1>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php echo $content; ?>
|
||||
<div class="text text-center powered">
|
||||
Powered by <a href="http://www.humhub.org" target="_blank">HumHub</a>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -7,8 +7,10 @@
|
||||
<div class="panel-body">
|
||||
<p><?php echo Yii::t('InstallerModule.views_config_admin', "You're almost done. In the last step you have to fill out the form to create an admin account. With this account you can manage the whole network."); ?></p>
|
||||
<hr/>
|
||||
<?php echo $form; ?>
|
||||
|
||||
|
||||
<?php $form = \yii\widgets\ActiveForm::begin(); ?>
|
||||
<?php echo $hForm->render($form); ?>
|
||||
<?php \yii\widgets\ActiveForm::end(); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -20,7 +22,7 @@
|
||||
})
|
||||
|
||||
// Shake panel after wrong validation
|
||||
<?php foreach($form->models as $model) : ?>
|
||||
<?php foreach($hForm->models as $model) : ?>
|
||||
<?php if ($model->hasErrors()) : ?>
|
||||
$('#create-admin-account-form').removeClass('fadeIn');
|
||||
$('#create-admin-account-form').addClass('shake');
|
||||
|
@ -1,3 +1,11 @@
|
||||
<?php
|
||||
|
||||
use humhub\compat\CActiveForm;
|
||||
use humhub\compat\CHtml;
|
||||
use humhub\models\Setting;
|
||||
use yii\helpers\Url;
|
||||
use humhub\core\user\models\User;
|
||||
?>
|
||||
<div id="name-form" class="panel panel-default animated fadeIn">
|
||||
|
||||
<div class="panel-heading">
|
||||
@ -8,12 +16,8 @@
|
||||
|
||||
<p><?php echo Yii::t('InstallerModule.views_config_basic', 'Of course, your new social network needs a name. Please change the default name with one you like. (For example the name of your company, organization or club)'); ?></p>
|
||||
|
||||
<?php
|
||||
$form = $this->beginWidget('CActiveForm', array(
|
||||
'id' => 'basic-form',
|
||||
'enableAjaxValidation' => false,
|
||||
));
|
||||
?>
|
||||
|
||||
<?php $form = CActiveForm::begin(); ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'name'); ?>
|
||||
@ -25,7 +29,7 @@
|
||||
|
||||
<?php echo CHtml::submitButton(Yii::t('InstallerModule.views_config_basic', 'Next'), array('class' => 'btn btn-primary')); ?>
|
||||
|
||||
<?php $this->endWidget(); ?>
|
||||
<?php CActiveForm::end(); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -37,10 +41,10 @@
|
||||
})
|
||||
|
||||
// Shake panel after wrong validation
|
||||
<?php if ($form->errorSummary($model) != null) { ?>
|
||||
$('#name-form').removeClass('fadeIn');
|
||||
$('#name-form').addClass('shake');
|
||||
<?php } ?>
|
||||
<?php if ($model->hasErrors()) { ?>
|
||||
$('#name-form').removeClass('fadeIn');
|
||||
$('#name-form').addClass('shake');
|
||||
<?php } ?>
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Url;
|
||||
use yii\helpers\Html;
|
||||
?>
|
||||
<div class="panel panel-default animated fadeIn">
|
||||
|
||||
<div class="panel-body text-center">
|
||||
@ -8,7 +13,7 @@
|
||||
|
||||
<div class="text-center">
|
||||
<br>
|
||||
<?php echo HHtml::link(Yii::t('InstallerModule.views_config_finished', 'Sign in'), Yii::app()->createUrl('/site/index'), array('class' => 'btn btn-primary')); ?>
|
||||
<?php echo Html::a(Yii::t('InstallerModule.views_config_finished', 'Sign in'), Url::home(), array('class' => 'btn btn-primary')); ?>
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,3 +1,9 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
?>
|
||||
|
||||
<div class="panel panel-default animated fadeIn">
|
||||
|
||||
<div class="panel-body text-center">
|
||||
@ -8,7 +14,7 @@
|
||||
<br>
|
||||
<hr>
|
||||
<br>
|
||||
<?php echo HHtml::link(Yii::t('InstallerModule.views_index_index', "Next") . ' <i class="fa fa-arrow-circle-right"></i>', array('go'), array('class' => 'btn btn-lg btn-primary')); ?>
|
||||
<?php echo Html::a(Yii::t('InstallerModule.views_index_index', "Next") . ' <i class="fa fa-arrow-circle-right"></i>', Url::to(['go']), array('class' => 'btn btn-lg btn-primary')); ?>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
@ -16,4 +22,4 @@
|
||||
|
||||
</div>
|
||||
|
||||
<?php $this->widget('application.widgets.LanguageChooser'); ?>
|
||||
<?php echo humhub\widgets\LanguageChooser::widget(); ?>
|
||||
|
50
protected/humhub/core/installer/views/layouts/main.php
Normal file
50
protected/humhub/core/installer/views/layouts/main.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use humhub\assets\AppAsset;
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $content string */
|
||||
|
||||
AppAsset::register($this);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title><?php echo Html::encode($this->title); ?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta name="language" content="en"/>
|
||||
<?= Html::csrfMetaTags() ?>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo Yii::getAlias("@web"); ?>/css/bootstrap.min.css"/>
|
||||
<link type="text/css" href="<?php echo Yii::getAlias("@web"); ?>/css/animate.min.css" rel="stylesheet"/>
|
||||
<?php $this->head() ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php $this->beginBody() ?>
|
||||
|
||||
<div class="container installer" style="margin: 0 auto; max-width: 700px;">
|
||||
<div class="logo">
|
||||
<?php if (Yii::$app->name == "HumHub") : ?>
|
||||
<a class="animated fadeIn" href="http://www.humhub.org" target="_blank" class="">
|
||||
<img src="<?php echo Yii::getAlias("@web/resources/installer"); ?>/humhub-logo.png" alt="Logo">
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<h1 class="animated fadeIn"><?php echo Html::encode(Yii::$app->name); ?></h1>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php echo $content; ?>
|
||||
|
||||
<div class="text text-center powered">
|
||||
Powered by <a href="http://www.humhub.org" target="_blank">HumHub</a>
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
<?php $this->endBody() ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php $this->endPage() ?>
|
@ -3,6 +3,8 @@
|
||||
namespace humhub\core\space\models;
|
||||
|
||||
use Yii;
|
||||
use humhub\core\content\models\Wall;
|
||||
use humhub\core\activity\models\Activity;
|
||||
|
||||
/**
|
||||
* This is the model class for table "space".
|
||||
@ -129,35 +131,37 @@ class Space extends \humhub\core\content\components\activerecords\ContentContain
|
||||
|
||||
$userId = $this->created_by;
|
||||
|
||||
if ($this->isNewRecord) {
|
||||
if ($insert) {
|
||||
// Create new wall record for this space
|
||||
$wall = new Wall();
|
||||
$wall->object_model = 'Space';
|
||||
$wall->object_id = $this->id;
|
||||
$wall->save();
|
||||
$this->wall_id = $wall->id;
|
||||
$this->wall = $wall;
|
||||
Space::model()->updateByPk($this->id, array('wall_id' => $wall->id));
|
||||
$this->update(false, ['wall_id']);
|
||||
|
||||
// Auto add creator as admin
|
||||
$membership = new SpaceMembership;
|
||||
$membership = new Membership();
|
||||
$membership->space_id = $this->id;
|
||||
$membership->user_id = $userId;
|
||||
$membership->status = SpaceMembership::STATUS_MEMBER;
|
||||
$membership->status = Membership::STATUS_MEMBER;
|
||||
$membership->invite_role = 1;
|
||||
$membership->admin_role = 1;
|
||||
$membership->share_role = 1;
|
||||
$membership->save();
|
||||
|
||||
/*
|
||||
$activity = new Activity;
|
||||
$activity->content->created_by = $userId;
|
||||
$activity->content->space_id = $this->id;
|
||||
$activity->content->user_id = $userId;
|
||||
$activity->content->visibility = Content::VISIBILITY_PUBLIC;
|
||||
$activity->content->visibility = \humhub\core\content\models\Content::VISIBILITY_PUBLIC;
|
||||
$activity->created_by = $userId;
|
||||
$activity->type = "ActivitySpaceCreated";
|
||||
$activity->save();
|
||||
$activity->fire();
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
Yii::$app->cache->delete('userSpaces_' . $userId);
|
||||
@ -334,7 +338,7 @@ class Space extends \humhub\core\content\components\activerecords\ContentContain
|
||||
|
||||
$membership = $this->getMembership($userId);
|
||||
|
||||
if ($membership != null && $membership->share_role == 1 && $membership->status == SpaceMembership::STATUS_MEMBER)
|
||||
if ($membership != null && $membership->share_role == 1 && $membership->status == Membership::STATUS_MEMBER)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -37,7 +37,7 @@ class ProfileFieldCategory extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['title', 'description', 'sort_order'], 'required'],
|
||||
[['title', 'sort_order'], 'required'],
|
||||
[['description'], 'string'],
|
||||
[['sort_order', 'module_id', 'visibility', 'created_by', 'updated_by', 'is_system'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
|
@ -404,9 +404,8 @@ class User extends \humhub\core\content\components\activerecords\ContentContaine
|
||||
$wall->save();
|
||||
|
||||
$this->wall_id = $wall->id;
|
||||
$this->wall = $wall;
|
||||
|
||||
$this->update(false, 'wall_id');
|
||||
$this->update(false, ['wall_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
160
protected/humhub/libs/DynamicConfig.php
Normal file
160
protected/humhub/libs/DynamicConfig.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\libs;
|
||||
|
||||
use humhub\models\Setting;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* Description of DynamicConfig
|
||||
*
|
||||
* @author luke
|
||||
*/
|
||||
class DynamicConfig extends \yii\base\Object
|
||||
{
|
||||
|
||||
public static function onSettingChange($setting)
|
||||
{
|
||||
// Only rewrite static configuration file when necessary
|
||||
if ($setting->module_id != 'mailing' &&
|
||||
$setting->module_id != 'cache' &&
|
||||
$setting->name != 'name' &&
|
||||
$setting->name != 'theme' &&
|
||||
$setting->name != 'authentication_internal'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::rewrite();
|
||||
}
|
||||
|
||||
public static function load()
|
||||
{
|
||||
$configFile = self::getConfigFilePath();
|
||||
|
||||
if (!is_file($configFile)) {
|
||||
self::save([]);
|
||||
}
|
||||
|
||||
$config = require($configFile);
|
||||
|
||||
if (!is_array($config))
|
||||
return array();
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function save($config)
|
||||
{
|
||||
$content = "<" . "?php return ";
|
||||
$content .= var_export($config, true);
|
||||
$content .= "; ?" . ">";
|
||||
|
||||
$configFile = self::getConfigFilePath();
|
||||
file_put_contents($configFile, $content);
|
||||
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($configFile);
|
||||
}
|
||||
|
||||
if (function_exists('apc_compile_file')) {
|
||||
apc_compile_file($configFile);
|
||||
}
|
||||
}
|
||||
|
||||
public static function rewrite()
|
||||
{
|
||||
|
||||
// Get Current Configuration
|
||||
$config = self::load();
|
||||
|
||||
// Add Application Name to Configuration
|
||||
$config['name'] = Setting::Get('name');
|
||||
|
||||
// Add Default language
|
||||
$defaultLanguage = Setting::Get('defaultLanguage');
|
||||
if ($defaultLanguage !== null && $defaultLanguage != "") {
|
||||
$config['language'] = Setting::Get('defaultLanguage');
|
||||
} else {
|
||||
$config['language'] = Yii::$app->language;
|
||||
}
|
||||
|
||||
// Add Caching
|
||||
/*
|
||||
$cacheClass = Setting::Get('type', 'cache');
|
||||
if (!$cacheClass) {
|
||||
$cacheClass = "CDummyCache";
|
||||
}
|
||||
$config['components']['cache'] = array(
|
||||
'class' => $cacheClass,
|
||||
);
|
||||
*/
|
||||
|
||||
/*
|
||||
// Add User settings
|
||||
$config['components']['user'] = array();
|
||||
if (Setting::Get('defaultUserIdleTimeoutSec', 'authentication_internal')) {
|
||||
$config['components']['user']['authTimeout'] = Setting::Get('defaultUserIdleTimeoutSec', 'authentication_internal');
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// Install Mail Component
|
||||
$mail = array(
|
||||
'class' => 'ext.yii-mail.YiiMail',
|
||||
'transportType' => Setting::Get('transportType', 'mailing'),
|
||||
'viewPath' => 'application.views.mail',
|
||||
'logging' => true,
|
||||
'dryRun' => false,
|
||||
);
|
||||
if (Setting::Get('transportType', 'mailing') == 'smtp') {
|
||||
|
||||
$mail['transportOptions'] = array();
|
||||
|
||||
if (Setting::Get('hostname', 'mailing'))
|
||||
$mail['transportOptions']['host'] = Setting::Get('hostname', 'mailing');
|
||||
|
||||
if (Setting::Get('username', 'mailing'))
|
||||
$mail['transportOptions']['username'] = Setting::Get('username', 'mailing');
|
||||
|
||||
if (Setting::Get('password', 'mailing'))
|
||||
$mail['transportOptions']['password'] = Setting::Get('password', 'mailing');
|
||||
|
||||
if (Setting::Get('encryption', 'mailing'))
|
||||
$mail['transportOptions']['encryption'] = Setting::Get('encryption', 'mailing');
|
||||
|
||||
if (Setting::Get('port', 'mailing'))
|
||||
$mail['transportOptions']['port'] = Setting::Get('port', 'mailing');
|
||||
|
||||
if (Setting::Get('allowSelfSignedCerts', 'mailing')) {
|
||||
$mail['transportOptions']['options']['ssl']['allow_self_signed'] = true;
|
||||
$mail['transportOptions']['options']['ssl']['verify_peer'] = false;
|
||||
}
|
||||
}
|
||||
$config['components']['mail'] = $mail;
|
||||
*/
|
||||
|
||||
// Add Theme
|
||||
/*
|
||||
$theme = Setting::Get('theme');
|
||||
if ($theme && $theme != "") {
|
||||
$config['theme'] = $theme;
|
||||
} else {
|
||||
unset($config['theme']);
|
||||
}
|
||||
*/
|
||||
|
||||
self::save($config);
|
||||
}
|
||||
|
||||
public function getConfigFilePath()
|
||||
{
|
||||
return Yii::getAlias(Yii::$app->params['dynamicConfigFile']);
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace humhub\models;
|
||||
|
||||
use Yii;
|
||||
use humhub\libs\DynamicConfig;
|
||||
|
||||
/**
|
||||
* This is the model class for table "setting".
|
||||
@ -61,6 +62,18 @@ class Setting extends \yii\db\ActiveRecord
|
||||
];
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
parent::afterSave($insert, $changedAttributes);
|
||||
DynamicConfig::onSettingChange($this);
|
||||
}
|
||||
|
||||
public function afterDelete()
|
||||
{
|
||||
parent::afterDelete();
|
||||
DynamicConfig::onSettingChange($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a record by name and module id.
|
||||
* The result is cached.
|
||||
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
Loading…
x
Reference in New Issue
Block a user