Fixed users being duplicated if they already existed in a target group during a merge
This commit is contained in:
@@ -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?
|
||||
$target->administrators()->attach($user, ['flag_admin' => true]);
|
||||
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