本文整理汇总了PHP中humhub\modules\space\models\Space::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Space::findAll方法的具体用法?PHP Space::findAll怎么用?PHP Space::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类humhub\modules\space\models\Space
的用法示例。
在下文中一共展示了Space::findAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionBasic
/**
* Returns a List of Users
*/
public function actionBasic()
{
$form = new \humhub\modules\admin\models\forms\BasicSettingsForm();
$form->name = Setting::Get('name');
$form->baseUrl = Setting::Get('baseUrl');
$form->defaultLanguage = Setting::Get('defaultLanguage');
$form->timeZone = Setting::Get('timeZone');
$form->dashboardShowProfilePostForm = Setting::Get('showProfilePostForm', 'dashboard');
$form->tour = Setting::Get('enable', 'tour');
$form->share = Setting::Get('enable', 'share');
$form->defaultSpaceGuid = "";
foreach (\humhub\modules\space\models\Space::findAll(['auto_add_new_members' => 1]) as $defaultSpace) {
$form->defaultSpaceGuid .= $defaultSpace->guid . ",";
}
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
Setting::Set('name', $form->name);
Setting::Set('baseUrl', $form->baseUrl);
Setting::Set('defaultLanguage', $form->defaultLanguage);
Setting::Set('timeZone', $form->timeZone);
Setting::Set('enable', $form->tour, 'tour');
Setting::Set('enable', $form->share, 'share');
Setting::Set('showProfilePostForm', $form->dashboardShowProfilePostForm, 'dashboard');
$spaceGuids = explode(",", $form->defaultSpaceGuid);
// Remove Old Default Spaces
foreach (\humhub\modules\space\models\Space::findAll(['auto_add_new_members' => 1]) as $space) {
if (!in_array($space->guid, $spaceGuids)) {
$space->auto_add_new_members = 0;
$space->save();
}
}
// Add new Default Spaces
foreach ($spaceGuids as $spaceGuid) {
$space = \humhub\modules\space\models\Space::findOne(['guid' => $spaceGuid]);
if ($space != null && $space->auto_add_new_members != 1) {
$space->auto_add_new_members = 1;
$space->save();
}
}
DynamicConfig::rewrite();
// set flash message
Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved'));
return Yii::$app->response->redirect(Url::toRoute('/admin/setting/basic'));
}
return $this->render('basic', array('model' => $form));
}
示例2: setUpApproved
public function setUpApproved()
{
$userInvite = Invite::findOne(['email' => $this->email]);
if ($userInvite !== null) {
// User was invited to a space
if ($userInvite->source == Invite::SOURCE_INVITE) {
$space = \humhub\modules\space\models\Space::findOne(['id' => $userInvite->space_invite_id]);
if ($space != null) {
$space->addMember($this->id);
}
}
// Delete/Cleanup Invite Entry
$userInvite->delete();
}
// Auto Assign User to the Group Space
/* $group = Group::findOne(['id' => $this->group_id]);
if ($group != null && $group->space_id != "") {
$space = \humhub\modules\space\models\Space::findOne(['id' => $group->space_id]);
if ($space !== null) {
$space->addMember($this->id);
}
} */
// Auto Add User to the default spaces
foreach (\humhub\modules\space\models\Space::findAll(['auto_add_new_members' => 1]) as $space) {
$space->addMember($this->id);
}
}
示例3: setUpApproved
public function setUpApproved()
{
$userInvite = Invite::findOne(['email' => $this->email]);
if ($userInvite !== null) {
// User was invited to a space
if ($userInvite->source == Invite::SOURCE_INVITE) {
$space = \humhub\modules\space\models\Space::findOne(['id' => $userInvite->space_invite_id]);
if ($space != null) {
$space->addMember($this->id);
}
}
// Delete/Cleanup Invite Entry
$userInvite->delete();
}
// Auto Assign User to the Group Space
$group = Group::findOne(['id' => $this->group_id]);
if ($group != null && $group->space_id != "") {
$space = \humhub\modules\space\models\Space::findOne(['id' => $group->space_id]);
if ($space !== null) {
$space->addMember($this->id);
}
}
// Auto Add User to the default spaces
foreach (\humhub\modules\space\models\Space::findAll(['auto_add_new_members' => 1]) as $space) {
$space->addMember($this->id);
}
// Create new wall record for this user
$wall = new \humhub\modules\content\models\Wall();
$wall->object_model = $this->className();
$wall->object_id = $this->id;
$wall->save();
$this->wall_id = $wall->id;
$this->update(false, ['wall_id']);
}
示例4: save
/**
* Saves the form
*
* @return boolean
*/
public function save()
{
Yii::$app->settings->set('name', $this->name);
Yii::$app->settings->set('baseUrl', $this->baseUrl);
Yii::$app->settings->set('defaultLanguage', $this->defaultLanguage);
Yii::$app->settings->set('timeZone', $this->timeZone);
Yii::$app->getModule('dashboard')->settings->set('showProfilePostForm', $this->dashboardShowProfilePostForm);
Yii::$app->getModule('tour')->settings->set('enable', $this->tour);
Yii::$app->getModule('friendship')->settings->set('enable', $this->enableFriendshipModule);
Yii::$app->getModule('content')->settings->set('stream.defaultSort', $this->defaultStreamSort);
$spaceGuids = explode(",", $this->defaultSpaceGuid);
// Remove Old Default Spaces
foreach (Space::findAll(['auto_add_new_members' => 1]) as $space) {
if (!in_array($space->guid, $spaceGuids)) {
$space->auto_add_new_members = 0;
$space->save();
}
}
// Add new Default Spaces
foreach ($spaceGuids as $spaceGuid) {
$space = Space::findOne(['guid' => $spaceGuid]);
if ($space != null && $space->auto_add_new_members != 1) {
$space->auto_add_new_members = 1;
$space->save();
}
}
DynamicConfig::rewrite();
return true;
}