本文整理汇总了PHP中UserRepository::Update方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::Update方法的具体用法?PHP UserRepository::Update怎么用?PHP UserRepository::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository::Update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateProfile
private function UpdateProfile(User $user)
{
$user->ChangeEmailPreference(new ReservationApprovedEvent(), $this->page->GetApproved());
$user->ChangeEmailPreference(new ReservationCreatedEvent(), $this->page->GetCreated());
$user->ChangeEmailPreference(new ReservationUpdatedEvent(), $this->page->GetUpdated());
$user->ChangeEmailPreference(new ReservationDeletedEvent(), $this->page->GetDeleted());
$this->userRepository->Update($user);
}
示例2: ChangeColor
public function ChangeColor()
{
$userId = $this->page->GetUserId();
Log::Debug('Changing reservation color for userId: %s', $userId);
$color = $this->page->GetReservationColor();
$user = $this->userRepository->LoadById($userId);
$user->ChangePreference(UserPreferences::RESERVATION_COLOR, $color);
$this->userRepository->Update($user);
}
示例3: ChangeDefaultSchedule
public function ChangeDefaultSchedule()
{
$userSession = ServiceLocator::GetServer()->GetUserSession();
$scheduleId = $this->page->GetDefaultSchedule();
Log::Debug('ProfilePresenter updating default schedule to %s for user %s', $scheduleId, $userSession->UserId);
$user = $this->userRepository->LoadById($userSession->UserId);
$user->ChangeDefaultSchedule($scheduleId);
$this->userRepository->Update($user);
$userSession->ScheduleId = $this->page->GetDefaultSchedule();
ServiceLocator::GetServer()->SetUserSession($userSession);
}
示例4: SendRandomPassword
public function SendRandomPassword()
{
$emailAddress = $this->_page->GetEmailAddress();
Log::Debug('Password reset request for email address %s requested from REMOTE_ADDR: %s REMOTE_HOST: %s', $emailAddress, $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_HOST']);
$temporaryPassword = Password::GenerateRandom();
$passwordEncryption = new PasswordEncryption();
$salt = $passwordEncryption->Salt();
$encrypted = $passwordEncryption->Encrypt($temporaryPassword, $salt);
$userRepository = new UserRepository();
$user = $userRepository->FindByEmail($emailAddress);
if ($user != null) {
$user->ChangePassword($encrypted, $salt);
$userRepository->Update($user);
$emailMessage = new ForgotPasswordEmail($user, $temporaryPassword);
ServiceLocator::GetEmailService()->Send($emailMessage);
}
}
示例5: ImportUsers
public function ImportUsers()
{
set_time_limit(300);
$groupsList = $this->groupViewRepository->GetList();
/** @var GroupItemView[] $groups */
$groups = $groupsList->Results();
$groupsIndexed = array();
foreach ($groups as $group) {
$groupsIndexed[$group->Name()] = $group->Id();
}
$importFile = $this->page->GetImportFile();
$csv = new UserImportCsv($importFile);
$importCount = 0;
$messages = array();
$rows = $csv->GetRows();
if (count($rows) == 0) {
$this->page->SetImportResult(new CsvImportResult(0, array(), 'Empty file or missing header row'));
return;
}
for ($i = 0; $i < count($rows); $i++) {
$row = $rows[$i];
try {
$emailValidator = new EmailValidator($row->email);
$uniqueEmailValidator = new UniqueEmailValidator($this->userRepository, $row->email);
$uniqueUsernameValidator = new UniqueUserNameValidator($this->userRepository, $row->username);
$emailValidator->Validate();
$uniqueEmailValidator->Validate();
$uniqueUsernameValidator->Validate();
if (!$emailValidator->IsValid()) {
$messages[] = $emailValidator->Messages()[0] . " ({$row->email})";
continue;
}
if (!$uniqueEmailValidator->IsValid()) {
$messages[] = $uniqueEmailValidator->Messages()[0] . " ({$row->email})";
continue;
}
if (!$uniqueUsernameValidator->IsValid()) {
$messages[] = $uniqueUsernameValidator->Messages()[0] . " ({$row->username})";
continue;
}
$timezone = empty($row->timezone) ? Configuration::Instance()->GetKey(ConfigKeys::DEFAULT_TIMEZONE) : $row->timezone;
$password = empty($row->password) ? 'password' : $row->password;
$language = empty($row->language) ? 'en_us' : $row->language;
$user = $this->manageUsersService->AddUser($row->username, $row->email, $row->firstName, $row->lastName, $password, $timezone, $language, Configuration::Instance()->GetKey(ConfigKeys::DEFAULT_HOMEPAGE), array(UserAttribute::Phone => $row->phone, UserAttribute::Organization => $row->organization, UserAttribute::Position => $row->position), array());
$userGroups = array();
foreach ($row->groups as $groupName) {
if (array_key_exists($groupName, $groupsIndexed)) {
Log::Debug('Importing user %s with group %s', $row->username, $groupName);
$userGroups[] = new UserGroup($groupsIndexed[$groupName], $groupName);
}
}
if (count($userGroups) > 0) {
$user->ChangeGroups($userGroups);
$this->userRepository->Update($user);
}
$importCount++;
} catch (Exception $ex) {
Log::Error('Error importing users. %s', $ex);
}
}
$this->page->SetImportResult(new CsvImportResult($importCount, $csv->GetSkippedRowNumbers(), $messages));
}
示例6: HandleInvitationAction
/**
* @param $invitationAction
* @return string|null
*/
private function HandleInvitationAction($invitationAction)
{
$referenceNumber = $this->page->GetInvitationReferenceNumber();
$userId = $this->page->GetUserId();
$userRepository = new UserRepository();
$user = $userRepository->LoadById($userId);
$userCredit = $user->GetAttributeValue(8);
Log::Debug('Invitation action %s for user %s and reference number %s', $invitationAction, $userId, $referenceNumber);
$series = $this->reservationRepository->LoadByReferenceNumber($referenceNumber);
foreach ($this->rules as $rule) {
$ruleResult = $rule->Validate($series);
if (!$ruleResult->IsValid()) {
return Resources::GetInstance()->GetString('ParticipationNotAllowed');
}
}
$error = null;
$reservationCredit = $series->GetAttributeValue(6);
if ($invitationAction == InvitationAction::Accept) {
$error = $this->CheckCapacityAndReturnAnyError($series);
if (!$error && $userCredit >= $reservationCredit) {
$userCredit -= $reservationCredit;
$user->ChangeCustomAttribute(8, $userCredit);
$userRepository->Update($user);
$series->AcceptInvitation($userId);
} else {
$error = "Yeterli kredininiz bulunmamaktadır. Kredi almak için ödeme gerçekleştirebilirsiniz.";
}
}
if ($invitationAction == InvitationAction::Decline) {
$series->DeclineInvitation($userId);
}
if ($invitationAction == InvitationAction::CancelInstance) {
$cancelCredit = $user->GetAttributeValue(12);
//iptal hakkı
if ($cancelCredit > 0) {
$cancelCredit -= 1;
$reservationCredit = $series->GetAttributeValue(6);
$userCredit += $reservationCredit;
$user->ChangeCustomAttribute(8, $userCredit);
$user->ChangeCustomAttribute(12, $cancelCredit);
/* first training date optional logic
$firstTrainingDate= $user->GetAttributeValue(19);
$reservationDate= $series->CurrentInstance()->StartDate();
// One more logic should be added to cancel.
if(strcmp($firstTrainingDate,$reservationDate)==0 ) {
$user->ChangeCustomAttribute(19,null);
}
*/
$userRepository->Update($user);
$series->CancelInstanceParticipation($userId);
} else {
$error = "You dont have cancel right";
}
}
if ($invitationAction == InvitationAction::CancelAll) {
$series->CancelInstanceParticipation($userId);
$series->CancelAllParticipation($userId);
}
if ($invitationAction == InvitationAction::Join) {
if (!$series->GetAllowParticipation()) {
$error = Resources::GetInstance()->GetString('ParticipationNotAllowed');
} else {
$error = $this->CheckCapacityAndReturnAnyError($series);
$reservationCredit = $series->GetAttributeValue(6);
if (!$error && $userCredit >= $reservationCredit) {
$userCredit -= $reservationCredit;
$user->ChangeCustomAttribute(8, $userCredit);
$firstTrainingDate = $user->GetAttributeValue(19);
$reservationDate = $series->CurrentInstance()->StartDate()->ToTimezone($user->Timezone());
// One more logic should be added to cancel.
if ($firstTrainingDate == null || $firstTrainingDate == 0) {
$firstTrainingDate = $reservationDate;
$user->ChangeCustomAttribute(19, $firstTrainingDate);
}
$userRepository->Update($user);
$series->JoinReservationSeries($userId);
} else {
$series->JoinInviteeList($userId);
$error = "Eğitime katılmak için ödeme yapmanız gerekmektedir. Ödeme yaptıktan sonra eğitiminizi onaylayıp katılabilirsiniz. ";
}
}
}
if ($invitationAction == InvitationAction::JoinAll) {
if (!$series->GetAllowParticipation()) {
$error = Resources::GetInstance()->GetString('ParticipationNotAllowed');
} else {
$reservationAmount = count($series->Instances());
$reservationCredit = $reservationAmount * $series->GetAttributeValue(6);
/** Bugfix added by Deniz. prevention against participation to reservation in occurence of an error * */
$error = $this->CheckCapacityAndReturnAnyError($series);
if (!$error && $userCredit >= $reservationCredit) {
$userCredit -= $reservationCredit;
$user->ChangeCustomAttribute(8, $userCredit);
$firstTrainingDate = $user->GetAttributeValue(19);
//.........这里部分代码省略.........
示例7: Login
public function Login($username, $loginContext)
{
$username = $this->CleanUsername($username);
if ($this->LdapUserExists()) {
$this->Synchronize($username);
}
$repo = new UserRepository();
$user = $repo->LoadByUsername($username);
$user->Deactivate();
$user->Activate();
$repo->Update($user);
return $this->authToDecorate->Login($username, $loginContext);
}
示例8: testChangesEmailPreferences
public function testChangesEmailPreferences()
{
$id = 123;
$user = new User();
$user->WithId($id);
$emailPreferences = new EmailPreferences();
$emailPreferences->Add(EventCategory::Reservation, ReservationEvent::Updated);
$user->WithEmailPreferences($emailPreferences);
$user->ChangeEmailPreference(new ReservationUpdatedEvent(), false);
$user->ChangeEmailPreference(new ReservationCreatedEvent(), false);
$user->ChangeEmailPreference(new ReservationApprovedEvent(), true);
$repo = new UserRepository();
$repo->Update($user);
$addEmailPreferenceCommand = new AddEmailPreferenceCommand($id, EventCategory::Reservation, ReservationEvent::Approved);
$removeEmailPreferenceCommand = new DeleteEmailPreferenceCommand($id, EventCategory::Reservation, ReservationEvent::Updated);
$this->assertTrue($this->db->ContainsCommand($addEmailPreferenceCommand));
$this->assertTrue($this->db->ContainsCommand($removeEmailPreferenceCommand));
}