Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/return value of group add user #6875

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ HumHub Changelog
- Fix #6849: In the "Module Administration" page, remove "Show in Marketplace" for modules not in the `@app/modules` directory
- Fix #6863: If a top menu entry opens a modal box, don't mark it as active when clicked
- Enh #6873: Change people header with selected group
- Fix #6875: On Group::addUser(), if the current user is not logged in (console command or user registration), the method returns false even if the user was added to the group
16 changes: 8 additions & 8 deletions protected/humhub/modules/user/models/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ public function addUser($user, $isManager = false)
$newGroupUser->created_at = date('Y-m-d H:i:s');
$newGroupUser->created_by = Yii::$app->user->id;
$newGroupUser->is_group_manager = $isManager;
if ($newGroupUser->save() && !Yii::$app->user->isGuest) {
if ($this->notify_users) {
if ($newGroupUser->save()) {
if ($this->notify_users && !Yii::$app->user->isGuest) {
if (!($user instanceof User)) {
$user = User::findOne(['id' => $user]);
}
Expand Down Expand Up @@ -429,10 +429,10 @@ public static function notifyAdminsForUserApproval($user)
Yii::$app->i18n->setUserLocale($manager);

$html = Yii::t(
'UserModule.auth',
'Hello {displayName},',
['displayName' => $manager->displayName]
) . "<br><br>\n\n" .
'UserModule.auth',
'Hello {displayName},',
['displayName' => $manager->displayName]
) . "<br><br>\n\n" .
Yii::t(
'UserModule.auth',
'a new user {displayName} needs approval.',
Expand Down Expand Up @@ -512,10 +512,10 @@ public function getGroupSpaces()
public function canDelete()
{
return Yii::$app->user->can(ManageGroups::class) && !(
$this->isNewRecord ||
$this->isNewRecord ||
$this->is_admin_group ||
$this->is_default_group ||
$this->is_protected
);
);
}
}