Fixed users being duplicated if they already existed in a target group during a merge
This commit is contained in:
1 parent
711968df08
commit
9d84dcec67
1 file changed
+9
-5
@@ -199,14 +199,18 @@ class Organisation extends Model implements OrganisationInterface
|
||||
};
|
||||
|
||||
// Move all the users from this organisation to the target
|
||||
$this->members()->each(function ($user) use ($target, $activityLogger, $currentUser, $logEntry) {
|
||||
$this->members()->detach($user); // NOTE: Should this record be retained? Or is the activity log enough of an audit?
|
||||
$target->members()->attach($user, ['flag_admin' => false]);
|
||||
$logEntry($activityLogger, $currentUser, $user, $target);
|
||||
});
|
||||
$this->administrators()->each(function ($user) use ($target, $activityLogger, $currentUser, $logEntry) {
|
||||
$this->administrators()->detach($user); // NOTE: Should this record be retained? Or is the activity log enough of an audit?
|
||||
if (!$target->administrators()->find($user->id) && !$target->members()->find($user->id)) {
|
||||
$target->administrators()->attach($user, ['flag_admin' => true]);
|
||||
}
|
||||
$logEntry($activityLogger, $currentUser, $user, $target);
|
||||
});
|
||||
$this->members()->each(function ($user) use ($target, $activityLogger, $currentUser, $logEntry) {
|
||||
$this->members()->detach($user); // NOTE: Should this record be retained? Or is the activity log enough of an audit?
|
||||
if (!$target->administrators()->find($user->id) && !$target->members()->find($user->id)) {
|
||||
$target->members()->attach($user, ['flag_admin' => false]);
|
||||
}
|
||||
$logEntry($activityLogger, $currentUser, $user, $target);
|
||||
});
|
||||
$this->save();
|
||||
|
||||
Reference in new issue
Block a user