コード例 #1
0
ファイル: Edit.php プロジェクト: mothership-ec/cog-user
    /**
     * Change the user details for a given user.
     *
     * @param  User   $user        	The user to change the details for
     * @param  string $newTitle
     * @param  string $newForename
     * @param  string $newSurname
     * @param  string $newEmail
     *
     * @return User                The user that was updated
     *
     * @author Eleanor Shakeshaft
     */
    public function save(User $user)
    {
        $user->authorship->update(new DateTimeImmutable(), $this->_currentUser->id);
        $result = $this->_query->run('
			UPDATE
				user
			SET
				title 	   = :title?s,
				forename   = :forename?s,
				surname    = :surname?s,
				email      = :email?s,
				updated_at = :updatedAt?d,
				updated_by = :updatedBy?in
			WHERE
				user_id = :userID?i
		', ['userID' => $user->id, 'title' => $user->title, 'forename' => $user->forename, 'surname' => $user->surname, 'email' => $user->email, 'updatedAt' => $user->authorship->updatedAt(), 'updatedBy' => $user->authorship->updatedBy()]);
        $event = new Event\Event($user);
        return $event->getUser();
    }
コード例 #2
0
 /**
  * Set status to complete if a referred user has signed up and logged in. Unfortunately, this needs to listen out
  * for logins, as the create event is not dispatched, despite existing. However, even if it does, the user is saved
  * to the database via a database transaction, which means that the referral `updated_by` column cannot be saved
  *
  * @param UserEvent $event
  */
 public function setStatusToComplete(UserEvent $event)
 {
     $user = $event->getUser();
     if (!$user) {
         throw new \LogicException('No user on user create event!');
     }
     $referrals = $this->get('refer.referral.loader')->getByEmail($user->email, Referral\Statuses::PENDING);
     if (empty($referrals)) {
         return;
     }
     $transaction = clone $this->get('db.transaction');
     $referralEdit = clone $this->get('refer.referral.edit');
     $referralEdit->setTransaction($transaction);
     foreach ($referrals as $referral) {
         if ($referral->hasTriggered(UserEvent::LOGIN) && $this->_isValid($referral)) {
             $referral->setStatus(Referral\Statuses::COMPLETE);
             $event = new Referral\Event\ReferralEvent();
             $event->setReferral($referral);
             $this->get('event.dispatcher')->dispatch(Referral\Event\Events::SIGN_UP, $event);
             $referralEdit->save($referral);
         }
     }
     $transaction->commit();
 }
コード例 #3
0
ファイル: Login.php プロジェクト: mothership-ec/cog-user
 /**
  * Updates the "last login" timestamp for a user when they have logged in.
  *
  * @see Message\User\Edit::updateLastLoginTime
  *
  * @param  Event $event The event instance
  *
  * @return boolean      Result of setting the "last login" timestamp
  */
 public function updateLastLoginTimestamp(Event $event)
 {
     return $this->_services['user.edit']->updateLastLoginTime($event->getUser());
 }
コード例 #4
0
 public function setProfileType(UserEvent $event)
 {
     $profile = $this->get('user.profile.factory')->getProfile('none');
     $this->get('user.profile.type.edit')->save($event->getUser(), $profile->getType());
 }