Esempio n. 1
0
 /**
  * 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));
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 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']);
 }
Esempio n. 4
0
 /**
  * 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;
 }