Checks whether the user changed his email address.

@param  ProfileWasUpdated $event

@return bool
344587
protected function emailWasChanged(ProfileWasUpdated $event) : bool
    {
        $newEmail = $event->request->get('email');

        return ! is_null($newEmail) && $newEmail != Auth::user()->email;
    }
367541
public function deleted(Events\Deleted $event): bool
    {
        if (config('tenancy.website.auto-delete-tenant-directory')) {
            $stat = $this->filesystem()->deleteDirectory($event->website->uuid);

            if ($stat) {
                $this->emitEvent(
                    new DirectoryDeleted($event->website, $this->filesystem())
                );
            }

            return $stat;
        }

        return true;
    }
1143947
public function getUpdateUserSettings(ProfileSettings $request)
    {

        // Update the rest of the settings
        Profile::set('main_character_id', $request->main_character_id);
        Profile::set('skin', $request->skin);
        Profile::set('language', $request->language);
        Profile::set('sidebar', $request->sidebar);
        Profile::set('mail_threads', $request->mail_threads);

        Profile::set('thousand_seperator', $request->thousand_seperator);
        Profile::set('decimal_seperator', $request->decimal_seperator);

        Profile::set('email_notifications', $request->email_notifications);

        return redirect()->back()
            ->with('success', 'Profile settings updated!');
    }
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
        }
    }
519157
public function hasAddress($email)
    {
        foreach ($this->addresses as $addr) {
            if (strcasecmp($addr->getEmail(), $email) === 0) {
                return true;
            }
        }
        return false;
    }
468741
private function checkIfUserChanged(array $data)
    {
        $model = $this->getModel()->newQuery()->find($this->getVisitorData('id'));

        if (
            ! is_null($model) &&
            ! is_null($model->user_id) &&
            ! is_null($data['user_id']) &&
            $data['user_id'] !== $model->user_id
        ) {
            $newVisitor = $this->regenerateSystemVisitor($data);
            $model      = $this->findByUuid($newVisitor['uuid']);
            $model->update(Arr::except($data, ['id', 'uuid']));
        }
    }
16944
function doUpdateEmail(Userinfo $userinfo, Userinfo &$existinguser, $overwrite)
	{
		$changed = false;

		if (strtolower($existinguser->email) != strtolower($userinfo->email)) {
			$this->debugger->addDebug(Text::_('EMAIL_CONFLICT'));
			$update_email = $this->params->get('update_email', false);
			if ($update_email || $overwrite) {
				$this->debugger->addDebug(Text::_('EMAIL_CONFLICT_OVERWITE_ENABLED'));
				try {
					$this->updateEmail($userinfo, $existinguser);
					$changed = true;
				} catch (Exception $e) {
					$this->debugger->addError(Text::_('EMAIL_UPDATE_ERROR') . ' ' . $e->getMessage());
				}
			} else {
				//return a email conflict
				$this->debugger->addDebug(Text::_('EMAIL_CONFLICT_OVERWITE_DISABLED'));

				$this->debugger->set('userinfo', $existinguser);
				throw new RuntimeException(Text::_('EMAIL') . ' ' . Text::_('CONFLICT') . ': ' . $existinguser->email . ' -> ' . $userinfo->email);
			}
		}
		return $changed;
	}
105345
public static function member_removed(\core\event\cohort_member_removed $event) {
        global $DB;

        // Does anything want to sync with this cohort?
        if (!$instances = $DB->get_records('enrol', array('customint1'=>$event->objectid, 'enrol'=>'cohort'), 'id ASC')) {
            return true;
        }

        $plugin = enrol_get_plugin('cohort');
        $unenrolaction = $plugin->get_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL);

        foreach ($instances as $instance) {
            if (!$ue = $DB->get_record('user_enrolments', array('enrolid'=>$instance->id, 'userid'=>$event->relateduserid))) {
                continue;
            }
            if ($unenrolaction == ENROL_EXT_REMOVED_UNENROL) {
                $plugin->unenrol_user($instance, $event->relateduserid);

            } else {
                if ($ue->status != ENROL_USER_SUSPENDED) {
                    $plugin->update_user_enrol($instance, $ue->userid, ENROL_USER_SUSPENDED);
                    $context = context_course::instance($instance->courseid);
                    role_unassign_all(array('userid'=>$ue->userid, 'contextid'=>$context->id, 'component'=>'enrol_cohort', 'itemid'=>$instance->id));
                }
            }
        }

        return true;
    }
1149711
public function onReadAtChanged($event)
    {
        $sender = $event->sender;
        /* @var $sender static */
        $raAttribute = $sender->readAtAttribute;
        if (!is_string($raAttribute) || empty($raAttribute)) {
            return;
        }
        $reaAttribute = $sender->receivedAtAttribute;
        if (is_string($reaAttribute) && !$sender->isInitDatetime($sender->$raAttribute) && $sender->isInitDatetime($sender->$reaAttribute)) {
            $sender->$reaAttribute = $sender->currentDatetime();
        }
        // If it is permitted to change read time, it will return directly.
        if ($sender->permitChangeReadAt) {
            return;
        }
        $oldRa = $sender->getOldAttribute($raAttribute);
        if ($oldRa != null && !$sender->isInitDatetime($oldRa) && $sender->$raAttribute != $oldRa) {
            $sender->$raAttribute = $oldRa;
        }
    }
1299211
public function onFrontpageLastModified(ContentEvent $event)
    {
        $e = new ContentEvent();
        $frontpageRoute = $this->getParam('frontpage');
        if($frontpageRoute != 'frontpage') {
            $e->setRoute($frontpageRoute.'_lastmodified');
            $this->dispatch($frontpageRoute.'_lastmodified', $e);
            $lastmodified = $e->getLastModified();
        } else {
            $lastmodified = $event->getLastModified();
        }

        $event->setLastModified($lastmodified);

        return true;
    }
70123
public function has_events($event)
	{
		if (isset($this->_events[$event]) and count($this->_events[$event]) > 0)
		{
			return true;
		}
		return false;
	}
780049
public static function onPreUpdate(Event $event)
    {
        $page = $event->getTarget();
        $eventArgs = $event->getEventArgs();
        $updateParents = false;
        $new = $old = null;

        $pageCountModifier = -1;
        if ($eventArgs instanceof PreUpdateEventArgs) {
            if ($page instanceof Page && $eventArgs->hasChangedField('_section')) {
                $old = $eventArgs->getOldValue('_section');
                $new = $eventArgs->getNewValue('_section');

                if ($new->getUid() === $page->getUid()) {
                    return;
                }
                $updateParents = true;
            }

            if ($page instanceof Page && $eventArgs->hasChangedField('_state')) {
                if ($page->getParent() !== null) {
                    if ($eventArgs->getNewValue('_state') >= 4) {
                        $old = $page->getParent()->getSection();
                        if (!$page->isLeaf()) {
                            $pageCountModifier = 0;
                        }
                    } else {
                        $new = $page->getParent()->getSection();
                    }
                    $updateParents = true;
                }
            }

            if ($page instanceof Section && $eventArgs->hasChangedField('_parent')) {
                $old = $eventArgs->getOldValue('_parent');
                $new = $eventArgs->getNewValue('_parent');
                $updateParents = true;
            }

            if ($updateParents) {
                $em = $event->getApplication()->getEntityManager();

                self::setSectionHasChildren($em, $old, $pageCountModifier);
                self::setSectionHasChildren($em, $new, +1);
            }
        }
    }
611383
public function onAfterAddPerson(AnEvent $event)
    {
        $person = $event->person;

        if (! $this->_canPerform()) {
            return false;
        }

        $this->_createToken($person->username);

        $user = $this->_api->getUser();

        if (AnRequest::get('post.import_avatar', 'cmd') && $user->large_avatar) {
            $person->setPortraitImage(array('url' => $user->large_avatar));
        }

        $person->enabled = true;
        $person->save();
    }
371158
public function isMappedUserExistInUsersTable() {

        // get the mapped recipient (valid because $this->isInboundEmailToEmailAddressMapToUser() is already done)
        $mappedRoutes = config('lasallecmsmailgun.inbound_map_mailgun_routes_with_user_email_address');

        foreach ($mappedRoutes as $route => $user) {

            // if "from" email address is the same as the route specified in the config...
            if ($this->request->input('recipient') == $route) {
                $userEmailAddress = $user;
            }
        }

        if ($this->userRepository->findUserIdByEmail($userEmailAddress)) {
            return true;
        }

        return false;
    }
349851
public function update(ProfileRequest $request, User $user)
    {
        event(new ProfileWasUpdated($request));

        if ($request->wantsJson()) {
            return $this->respondsWithSuccess('ok');
        }

        return back();
    }
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;
    }
202122
public static function profile_criteria_review(\core\event\user_updated $event) {
        global $DB, $CFG;

        if (!empty($CFG->enablebadges)) {
            require_once($CFG->dirroot.'/lib/badgeslib.php');
            $userid = $event->objectid;

            if ($rs = $DB->get_records('badge_criteria', array('criteriatype' => BADGE_CRITERIA_TYPE_PROFILE))) {
                foreach ($rs as $r) {
                    $badge = new badge($r->badgeid);
                    if (!$badge->is_active() || $badge->is_issued($userid)) {
                        continue;
                    }

                    if ($badge->criteria[BADGE_CRITERIA_TYPE_PROFILE]->review($userid)) {
                        $badge->criteria[BADGE_CRITERIA_TYPE_PROFILE]->mark_complete($userid);

                        if ($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]->review($userid)) {
                            $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]->mark_complete($userid);
                            $badge->issue($userid);
                        }
                    }
                }
            }
        }
    }