@DI\Observe("merge_users")

@param MergeUsersEvent $event
545983
public function onMerge(MergeUsersEvent $event)
    {
        // Replace user of Pdf nodes
        $pdfCount = $this->manager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolinePdfGeneratorBundle] updated Pdf count: $pdfCount");
    }
1098500
public function onMerge(MergeUsersEvent $event)
    {
        // Replace manager of Category nodes
        $categoryCount = $this->clacoFormManager->replaceCategoryManager($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineClacoFormBundle] updated Category count: $categoryCount");

        // Replace user of Comment nodes
        $commentCount = $this->clacoFormManager->replaceCommentUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineClacoFormBundle] updated Comment count: $commentCount");

        // Replace user of Entry nodes
        $entryCount = $this->clacoFormManager->replaceEntryUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineClacoFormBundle] updated Entry count: $entryCount");

        // Replace user of EntryUser nodes
        $entryUserCount = $this->clacoFormManager->replaceEntryUserUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineClacoFormBundle] updated EntryUser count: $entryUserCount");
    }
70733
public function handle(MemberUpdated $event)
    {
        if (is_null($event->actor)) {
            return;
        }

        if ($event->member->isDirty($event->member->getKeyName())
            || $event->member->isClean('password')) {
            return;
        }

        $data = [
            'ip' => request()->ip(),
            'ua' => request()->header('User-Agent'),
        ];

        $event->actor->log('member.change_password', $data);
    }
465642
public function onChangeEmail(SubscriberEvent $event)
    {
        $this->listRepository->changeEmailAddress(
            $event->getListId(),
            $event->getSubscriber(),
            $event->getOldEmail()
        );
    }
545695
public function onMerge(MergeUsersEvent $event)
    {
        // Replace user of Item nodes
        $itemCount = $this->itemManager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[UJMExoBundle] updated Item count: $itemCount");

        // Replace user of Shared nodes
        $sharedCount = $this->sharedManager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[UJMExoBundle] updated Shared count: $sharedCount");

        // Replace user of Paper nodes
        $paperCount = $this->paperManager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[UJMExoBundle] updated Paper count: $paperCount");
    }
361560
public function onMerge(MergeUsersEvent $event)
    {
        // Replace user of Favourite nodes
        $favouriteCount = $this->favouriteManager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[HeVinciFavouriteBundle] updated Favourite count: $favouriteCount");
    }
209199
public function setDefaultUser(ConfigureOptionsEvent $event)
    {
        $optionsResolver = $event->getOptions();

        $optionsResolver->setDefault(static::USER_OPTION, null);

        if (null === $this->tokenStorage) {
            return;
        }

        $token = $this->tokenStorage->getToken();

        if (null === $token || $token instanceof AnonymousToken) {
            return;
        }

        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return;
        }

        $optionsResolver->setDefault(static::USER_OPTION, $user->getId());
    }
350769
public function removeUser(UserEventInterface $event, EventQueueInterface $queue)
    {
        $logger = $this->getLogger();
        $logger->debug('Removing user from all channels');
        $connectionMask = $this->getConnectionMask($event->getConnection());
        if (isset($this->modes[$connectionMask])) {
            $this->removeUserData(
                $connectionMask,
                array_keys($this->modes[$connectionMask]),
                $event->getNick()
            );
        }
    }
488715
public function ModerationController_MergeDiscussions_Create($Sender) {
      $Session = Gdn::Session();
      $Sender->Form = new Gdn_Form();
      $Sender->Title(T('Merge Discussions'));

      $DiscussionModel = new DiscussionModel();
      $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
      if (!is_array($CheckedDiscussions))
         $CheckedDiscussions = array();
       
      $DiscussionIDs = $CheckedDiscussions;
      $Sender->SetData('DiscussionIDs', $DiscussionIDs);
      $CountCheckedDiscussions = count($DiscussionIDs);
      $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
      $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
      $Sender->SetData('Discussions', $Discussions);
      
      // Perform the merge
      if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
            if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
               $MergeDiscussion = $Discussion;
               break;
            }
         }
         if ($MergeDiscussion) {
            $ErrorCount = 0;
            
            // Verify that the user has permission to perform the merge.
            $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
            if ($Category && !$Category['PermsDiscussionsEdit'])
               throw PermissionException('Vanilla.Discussions.Edit');
            
            // Assign the comments to the new discussion record
            $DiscussionModel->SQL
               ->Update('Comment')
               ->Set('DiscussionID', $MergeDiscussionID)
               ->WhereIn('DiscussionID', $DiscussionIDs)
               ->Put();
               
            $CommentModel = new CommentModel();
            foreach ($Discussions as $Discussion) {
               if ($Discussion['DiscussionID'] == $MergeDiscussionID)
                  continue;
               
               // Create a comment out of the discussion.
               $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
               $Comment['DiscussionID'] = $MergeDiscussionID;
               
               $CommentModel->Validation->Results(TRUE);
               $CommentID = $CommentModel->Save($Comment);
               if ($CommentID) {
                  // Move any attachments (FileUpload plugin awareness)
                  if (class_exists('MediaModel')) {
                     $MediaModel = new MediaModel();
                     $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                  }
                  
                  // Delete discussion that was merged
                  $DiscussionModel->Delete($Discussion['DiscussionID']);                  
               } else {
                  $Sender->InformMessage($CommentModel->Validation->ResultsText());
                  $ErrorCount++;
               }
            }
            // Update counts on all affected discussions.
            $CommentModel->UpdateCommentCount($MergeDiscussionID);
            $CommentModel->RemovePageCache($MergeDiscussionID);
   
            // Clear selections
            Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
            ModerationController::InformCheckedDiscussions($Sender);
            if ($ErrorCount == 0)
               $Sender->RedirectUrl = Url("/discussion/$MergeDiscussionID/".Gdn_Format::Url($MergeDiscussion['Name']));
         }
      }
      
      $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
   }
828443
public function onAfterLogin(UserEvent $event)
    {
        if (!$this->identity->is_api_user) {
            Yii::$app->language = $this->getInterfaceLanguage();
        }
    }
544215
public function handle($event): void
    {
        $commentsService = app()->make('InetStudio\Comments\Contracts\Services\Back\CommentsServiceContract');

        $user = $event->user;

        $commentsService->getModel()::where([
            ['user_id', '=', 0],
            ['email', '=', $user->email],
        ])->update([
            'user_id' => $user->id,
            'name' => $user->name,
        ]);
    }
435830
public function onLegacyKernelWebBuild(PreBuildKernelWebHandlerEvent $event)
    {
        if ($this->configResolver->getParameter('legacy_mode') === true) {
            return;
        }

        $injectedMergeSettings = $event->getParameters()->get('injected-merge-settings', []);
        $accessRules = [
            'access;disable',
            'module;user/login',
            'module;user/logout',
        ];
        // Merge existing settings with the new ones if needed.
        if (isset($injectedMergeSettings['site.ini/SiteAccessRules/Rules'])) {
            $accessRules = array_merge($injectedMergeSettings['site.ini/SiteAccessRules/Rules'], $accessRules);
        }
        $injectedMergeSettings['site.ini/SiteAccessRules/Rules'] = $accessRules;
        $event->getParameters()->set('injected-merge-settings', $injectedMergeSettings);
    }
632171
public static function updateLastVisit($event)
    {
        if ($event->isValid) {
            /**
             * @var User $user
             */
            $user = $event->identity;
            $user->last_visit_at = time();
            $user->updateAttributes(['last_visit_at']);
            return true;
        }
        return false;
    }
692900
public function leave(Event $event)
    {
        $this->authorize('join', Event::class);
        $event->deleteUser(User::findOrfail(Auth::id()));

        return redirect()->route('laralum::events.index')
            ->with('success', __('laralum_events::general.left_event', ['id' => $event->id]));
    }
231084
public function onMerge(MergeUsersEvent $event)
    {
        // Replace user of PortfolioComment nodes
        $pdfportfolioCommentCount = $this->portfolioCommentManager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[IcapPortfolioBundle] updated PortfolioComment count: $pdfportfolioCommentCount");

        // Replace user of Portfolio nodes
        $portfolioCount = $this->portfolioManager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[IcapPortfolioBundle] updated Portfolio count: $portfolioCount");

        // Replace user of PortfolioUser nodes
        $portfolioUserCount = $this->portfolioUserManager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[IcapPortfolioBundle] updated PortfolioUser count: $portfolioUserCount");

        // Replace user of PortfolioGuide nodes
        $portfolioGuideCount = $this->portfolioGuideManager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[IcapPortfolioBundle] updated PortfolioGuide count: $portfolioGuideCount");
    }
683263
public function onMerge(MergeUsersEvent $event)
    {
        // Replace user of Drop nodes
        $dropCount = $this->dropzoneManager->replaceDropUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineDropZoneBundle] updated Drop count: $dropCount");

        // Replace user of Correction nodes
        $correctionCount = $this->dropzoneManager->replaceCorrectionUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineDropZoneBundle] updated Correction count: $correctionCount");

        // Replace user of Document nodes
        $documentCount = $this->dropzoneManager->replaceDocumentUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineDropZoneBundle] updated Document count: $documentCount");
    }
433996
public function onDeleteUser(LogGenericEvent $event)
    {
        if ($event instanceof LogUserDeleteEvent) {
            $receiver = $event->getReceiver();
            if (null !== $receiver) {
                $this->externalSyncUserManager->deleteExternalUserByUserId($receiver->getId());
            }
        }
    }