本文整理汇总了PHP中humhub\modules\space\models\Space::getAvailableModules方法的典型用法代码示例。如果您正苦于以下问题:PHP Space::getAvailableModules方法的具体用法?PHP Space::getAvailableModules怎么用?PHP Space::getAvailableModules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类humhub\modules\space\models\Space
的用法示例。
在下文中一共展示了Space::getAvailableModules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAdmin
/**
* Setup Administrative User
*
* This should be the last step, before the user is created also the
* application secret will created.
*/
public function actionAdmin()
{
// Admin account already created
if (User::find()->count() > 0) {
return $this->redirect(Yii::$app->getModule('installer')->getNextConfigStepUrl());
}
$userModel = new User();
$userModel->scenario = 'registration_email';
$userPasswordModel = new Password();
$userPasswordModel->scenario = 'registration';
$profileModel = $userModel->profile;
$profileModel->scenario = 'registration';
// Build Form Definition
$definition = array();
$definition['elements'] = array();
// Add User Form
$definition['elements']['User'] = array('type' => 'form', 'elements' => array('username' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 25), 'email' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 100)));
// Add User Password Form
$definition['elements']['Password'] = array('type' => 'form', 'elements' => array('newPassword' => array('type' => 'password', 'class' => 'form-control', 'maxlength' => 255), 'newPasswordConfirm' => array('type' => 'password', 'class' => 'form-control', 'maxlength' => 255)));
// Add Profile Form
$definition['elements']['Profile'] = array_merge(array('type' => 'form'), $profileModel->getFormDefinition());
// Get Form Definition
$definition['buttons'] = array('save' => array('type' => 'submit', 'class' => 'btn btn-primary', 'label' => Yii::t('InstallerModule.controllers_ConfigController', 'Create Admin Account')));
$form = new \humhub\compat\HForm($definition);
$form->models['User'] = $userModel;
$form->models['Password'] = $userPasswordModel;
$form->models['Profile'] = $profileModel;
if ($form->submitted('save') && $form->validate()) {
$form->models['User']->status = User::STATUS_ENABLED;
$form->models['User']->language = '';
$form->models['User']->tags = 'Administration, Support, HumHub';
$form->models['User']->last_activity_email = new \yii\db\Expression('NOW()');
$form->models['User']->save();
$form->models['Profile']->user_id = $form->models['User']->id;
$form->models['Profile']->title = "System Administration";
$form->models['Profile']->save();
// Save User Password
$form->models['Password']->user_id = $form->models['User']->id;
$form->models['Password']->setPassword($form->models['Password']->newPassword);
$form->models['Password']->save();
$userId = $form->models['User']->id;
Group::getAdminGroup()->addUser($form->models['User']);
// Reload User
$adminUser = User::findOne(['id' => 1]);
// Switch Identity
Yii::$app->user->switchIdentity($adminUser);
// Create Welcome Space
$space = new Space();
$space->name = Yii::t("InstallerModule.controllers_ConfigController", "Welcome Space");
$space->description = Yii::t("InstallerModule.controllers_ConfigController", "Your first sample space to discover the platform.");
$space->join_policy = Space::JOIN_POLICY_FREE;
$space->visibility = Space::VISIBILITY_ALL;
$space->created_by = $adminUser->id;
$space->auto_add_new_members = 1;
$space->color = '#6fdbe8';
$space->save();
// activate all available modules for this space
foreach ($space->getAvailableModules() as $module) {
$space->enableModule($module->id);
}
// Add Some Post to the Space
$post = new \humhub\modules\post\models\Post();
$post->message = Yii::t("InstallerModule.controllers_ConfigController", "Yay! I've just installed HumHub ;Cool;");
$post->content->container = $space;
$post->content->visibility = \humhub\modules\content\models\Content::VISIBILITY_PUBLIC;
$post->save();
return $this->redirect(Yii::$app->getModule('installer')->getNextConfigStepUrl());
}
return $this->render('admin', array('hForm' => $form));
}