@DI\Observe("merge_users")

@param MergeUsersEvent $event
491900
public function onMerge(MergeUsersEvent $event)
    {
        // Replace team manager of Team nodes
        $teamManagerCount = $this->manager->replaceManager($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineTeamBundle] updated Team count (by team manager): $teamManagerCount");

        // Replace user of Team nodes
        $teamUserCount = $this->manager->replaceUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineTeamBundle] updated Team count (by user): $teamUserCount");
    }
146741
public static function create_acceptances_user_created(\core\event\user_created $event) {
        global $USER, $CFG, $DB;

        // Do nothing if not set as the site policies handler.
        if (empty($CFG->sitepolicyhandler) || $CFG->sitepolicyhandler !== 'tool_policy') {
            return;
        }

        $userid = $event->objectid;
        $lang = current_language();
        $user = $event->get_record_snapshot('user', $userid);
        // Do nothing if the user has not accepted the current policies.
        if (!$user->policyagreed) {
            return;
        }

        // Cleanup our bits in the presignup cache (we can not rely on them at this stage any more anyway).
        $cache = \cache::make('core', 'presignup');
        $cache->delete('tool_policy_userpolicyagreed');
        $cache->delete('tool_policy_viewedpolicies');
        $cache->delete('tool_policy_policyversionidsagreed');

        // Mark all compulsory policies as implicitly accepted during the signup.
        if ($policyversions = static::list_current_versions(policy_version::AUDIENCE_LOGGEDIN)) {
            $acceptances = array();
            $now = time();
            foreach ($policyversions as $policyversion) {
                if ($policyversion->optional == policy_version::AGREEMENT_OPTIONAL) {
                    continue;
                }
                $acceptances[] = array(
                    'policyversionid' => $policyversion->id,
                    'userid' => $userid,
                    'status' => 1,
                    'lang' => $lang,
                    'usermodified' => isset($USER->id) ? $USER->id : 0,
                    'timecreated' => $now,
                    'timemodified' => $now,
                );
            }
            $DB->insert_records('tool_policy_acceptances', $acceptances);
        }

        static::update_policyagreed($userid);
    }
43673
public function onMode(Event $event)
    {
        $msg = $event->getMessage();
        $params = $msg['params'];

        $isValidMessage =
            isset($params['channel'], $params['params']) &&
            preg_match('/(?:\+|-)[hovaq+-]+/i', $params['mode'])
        ;

        if (!$isValidMessage) {
            return;
        }

        $chan = $params['channel'];
        $nicks = explode(' ', $params['params']);
        $modes = str_split($params['mode'], 1);

        $operation = array_shift($modes); // + or -
        while ($char = array_shift($modes)) {
            $nick = array_shift($nicks);
            $mode = self::$modesNum[$char];

            $userMode = $this->storage->getUserMode($nick, $chan);
            if (!$userMode) {
                $userMode = self::REGULAR;
            }

            switch ($operation) {
                case '+':
                    $userMode |= $mode;
                    break;
                case '-':
                    $userMode ^= $mode;
                    break;
            }

            $this->storage->setUserMode($nick, $chan, $userMode);
        }
    }
1271323
public function onInit(BaseEvent $event)
    {
        $this->state->loadSettings();
        // It is not possible to know if the user specified --dev or --no-dev so assume it is false.
        // The dev section will be merged later when the other events fire.
        $this->state->setDevMode(false);
        $this->mergeFiles($this->state->getIncludes(), false);
        $this->mergeFiles($this->state->getRequires(), true);
    }
176814
public function preUpdate(UpdateEvent $event)
    {
        $oldData = $event->getOldData();
        $user = $event->getObject();

        if (!empty($oldData) && $oldData['username'] !== $user->getUsername()) {
            $userRole = $this->roleManager->getUserRole($oldData['username']);
            $this->roleManager->renameUserRole($userRole, $user->getUsername());
            // TODO : rename personal WS if user is renamed
        }
    }
185946
public function preUpdate(User $user, PreUpdateEventArgs $event)
    {
        if ($event->hasChangedField('avatarImage')) {
            $oldAvatarImage = $event->getOldValue('avatarImage');
            if (!empty($oldAvatarImage)) {
                $this->userService->deleteAvatar($oldAvatarImage);
            }
        }
    }
357398
public function onMerge(MergeUsersEvent $event)
    {
        // Replace user of Comment nodes
        $commentCount = $this->commentManager->replaceCommentAuthor($event->getRemoved(), $event->getKept());
        $event->addMessage("[IcapBlogBundle] updated Comment count: $commentCount");

        // Replace user of Post nodes
        $postCount = $this->postManager->replacePostAuthor($event->getRemoved(), $event->getKept());
        $event->addMessage("[IcapBlogBundle] updated Post count: $postCount");

        // Replace user of Blog members
        $this->blogManager->replaceMemberAuthor($event->getRemoved(), $event->getKept());
    }
625799
public function onPartChannels(UserEventInterface $event, EventQueueInterface $queue)
    {
        $this->joinOnMatch($event->getNick(), $event, $queue);
    }
1226464
public function onMergeUsers(MergeUsersEvent $event)
    {
        // Replace creator of resource nodes
        $resourcesCount = $this->resourceManager->replaceCreator($event->getRemoved(), $event->getKept());
        $event->addMessage("[CoreBundle] updated resources count: $resourcesCount");

        // Merge all roles onto user to keep
        $rolesCount = $this->userManager->transferRoles($event->getRemoved(), $event->getKept());
        $event->addMessage("[CoreBundle] transferred roles count: $rolesCount");

        // Change personal workspace into regular
        $event->getRemoved()->getPersonalWorkspace()->setPersonal(false);
    }
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);
    }
1362811
public function afterUserLogin(UserEvent $event)
    {
        $settings = DefaultDashboard::$plugin->getSettings();

        // For the moment, only check on CP requests
        if (!Craft::$app->getRequest()->isCpRequest) {
            DefaultDashboard::log("Not a CP request");
            return;
        }

        $currentUser = $event->identity;
        $defaultUser = Craft::$app->users->getUserById($settings->userDashboard);

        if (!$defaultUser) {
            DefaultDashboard::error("Default User not found for ID: $settings->userDashboard");
            return;
        }

        // Proceed if we've got a setting for the default user, and its not that user logging in
        if ($currentUser->id == $defaultUser->id) {
            DefaultDashboard::log("Skip setting dashboard - this is the default user");
            return;
        }

        $currentUserWidgets = $this->_getUserWidgets($currentUser->id);
        $defaultUserWidgets = $this->_getUserWidgets($defaultUser->id);

        DefaultDashboard::log("Current User ID: " . $currentUser->id);
        DefaultDashboard::log("Default User ID: " . $defaultUser->id);
        DefaultDashboard::log("Current User Widget: " . json_encode($this->_widgets($currentUserWidgets)));
        DefaultDashboard::log("Default User Widget: " . json_encode($this->_widgets($defaultUserWidgets)));

        // If this user has no widgets, create them and finish - or, if we're forcing override
        if (!$currentUserWidgets || $settings->override) {
            // To prevent massive re-creating of widgets each login, check if default vs current is different
            if ($this->_compareWidgets($currentUserWidgets, $defaultUserWidgets)) {
                DefaultDashboard::log("Users widgets are the same");
                return;
            }

            // Remove any existing widgets for the user
            $this->_deleteUserWidgets($currentUser->id);

            // Update the logged in users widgets
            $this->_setUserWidgets($currentUser, $defaultUserWidgets);

            // Update the user with their dashboard-set flag so the default widgets aren't added
            Craft::$app->getDb()->createCommand()
                ->update('{{%users}}', ['hasDashboard' => true], ['id' => $currentUser->id])
                ->execute();
        }
    }
1296049
public static function user_deleted(\core\event\user_deleted $event) {
        $userid = $event->objectid;
        subscription_manager::delete_user_subscriptions($userid);
    }
1181534
public function onUserEntityPreSave(StorageEvent $event)
    {
        /** @var Entity\Users $entityRecord */
        $entityRecord = $event->getContent();

        if ($entityRecord instanceof Entity\Users) {
            $this->passwordHash($entityRecord);
        }
    }
429342
public function beforeSave(Event $event, User $user)
    {
        if (!$user->isNew() && $user->has('password') && empty($user->password)) {
            $user->unsetProperty('password');
            $user->dirty('password', false);
        }
    }
718718
public function loadUser(JwtAuthValidEvent $event) {
    $token = $event->getToken();
    $uid = $token->getClaim('webid');
    $user = $this->userStorage->load($uid);
    $event->setUser($user);
  }
1051186
public function onBeforeDeleteUser(UserEvent $event)
    {
        $user = $event->getUser();

        $locks = $this->entityManager->getRepository('PhlexibleElementBundle:ElementLock')
            ->findBy(['userId' => $user->getId()]);

        foreach ($locks as $lock) {
            $this->entityManager->remove($lock);
        }
    }
41832
public function onUserRegister(UserRegisterEvent $event)
    {
        $masterRequest = $this
            ->requestStack
            ->getMasterRequest();

        if (!($masterRequest instanceof Request)) {
            return $this;
        }

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

        $token = $this->createNewToken(
            $event->getUser()
        );

        $this
            ->tokenStorage
            ->setToken($token);

        $event = new InteractiveLoginEvent(
            $masterRequest,
            $token
        );

        $this
            ->dispatcher
            ->dispatch(
                SecurityEvents::INTERACTIVE_LOGIN,
                $event
            );

        return $this;
    }