本文整理汇总了PHP中UserRepository::LoadById方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::LoadById方法的具体用法?PHP UserRepository::LoadById怎么用?PHP UserRepository::LoadById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository::LoadById方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PageLoad
public function PageLoad()
{
$this->page->SetEmailEnabled(Configuration::Instance()->GetKey(ConfigKeys::ENABLE_EMAIL, new BooleanConverter()));
$userSession = ServiceLocator::GetServer()->GetUserSession();
$user = $this->userRepository->LoadById($userSession->UserId);
if ($this->page->IsPostBack()) {
$this->UpdateProfile($user);
$this->page->SetPreferencesSaved(true);
}
$this->page->SetApproved($user->WantsEventEmail(new ReservationApprovedEvent()));
$this->page->SetCreated($user->WantsEventEmail(new ReservationCreatedEvent()));
$this->page->SetUpdated($user->WantsEventEmail(new ReservationUpdatedEvent()));
$this->page->SetDeleted($user->WantsEventEmail(new ReservationDeletedEvent()));
}
示例2: LoadById
/**
* @param int $userId
* @return User|void
*/
public function LoadById($userId)
{
$user = parent::LoadById($userId);
$me = parent::LoadById($this->userSession->UserId);
if ($userId == $this->userSession->UserId || $me->IsAdminFor($user)) {
return $user;
}
return User::Null();
}
示例3: 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);
}
示例4: 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);
}
示例5: ShowUserAttributes
public function ShowUserAttributes()
{
// User attributes on Dashboard, Added by Burak C.
$userId = ServiceLocator::GetServer()->GetUserSession()->UserId;
$userRepository = new UserRepository();
$this->user = $userRepository->LoadById($userId);
$attributeService = new AttributeService(new AttributeRepository());
$attributes = $attributeService->GetByCategory(CustomAttributeCategory::USER);
$reservationViewRepository = new ReservationViewRepository();
$startDate = Date::Now();
$endDate = $startDate->AddDays(30);
$reservations = $reservationViewRepository->GetReservationList($startDate, $endDate, $userId, ReservationUserLevel::INVITEE);
$this->_page->Set("invitations", $reservations);
$this->_page->Set("user", $this->user);
$this->_page->Set("attributes", $attributes);
}
示例6: SetReservationUser
/**
* @param UserDto $user
* @return void
*/
public function SetReservationUser(UserDto $user)
{
$this->Set('ReservationUserName', $user->FullName());
$this->Set('UserId', $user->Id());
$this->Set('IsAdmin', ServiceLocator::GetServer()->GetUserSession()->IsAdmin);
$userRepo = new UserRepository();
$userAttributes = array();
$loadedUser = $userRepo->LoadById($user->Id());
$userAttributes['traininglevel'] = $loadedUser->GetAttributeValue(17);
$userAttributes['trainingtype'] = $loadedUser->GetAttributeValue(15);
$userAttributes['saat'] = $loadedUser->GetAttributeValue(8);
$this->Set('UserAttributes', $userAttributes);
}
示例7: SetParticipants
public function SetParticipants($reservationRefNum)
{
$reservationRepository = new ReservationRepository();
$series = $reservationRepository->LoadByReferenceNumber($reservationRefNum);
$userrepo = new UserRepository();
$participantIDs = $series->CurrentInstance()->Participants();
foreach ($participantIDs as $value) {
$user = $userrepo->LoadById($value);
$participantnames[] = $user->FullName();
}
return $participantnames;
}
示例8: IsSameTrainingLevel
public function IsSameTrainingLevel(UserSession $session)
{
$reservationType = $this->_reservation->GetAttributeValue(5);
$userId = $session->UserId;
$userRepository = new UserRepository();
$user = $userRepository->LoadById($userId);
$userTrainingType = $user->GetAttributeValue(17);
return $reservationType == $userTrainingType;
}
示例9: GetMyUsers
/**
* @param $term string
* @return array|AutocompleteUser[]
*/
private function GetMyUsers($term)
{
$userSession = ServiceLocator::GetServer()->GetUserSession();
if ($userSession->IsAdmin) {
return $this->GetUsers($term);
}
$userRepo = new UserRepository();
$user = $userRepo->LoadById($userSession->UserId);
$groupIds = array();
foreach ($user->GetAdminGroups() as $group) {
$groupIds[] = $group->GroupId;
}
$users = array();
if (!empty($groupIds)) {
$userFilter = new SqlFilterLike(ColumnNames::FIRST_NAME, $term);
$userFilter->_Or(new SqlFilterLike(ColumnNames::LAST_NAME, $term));
$groupRepo = new GroupRepository();
$results = $groupRepo->GetUsersInGroup($groupIds, null, null, $userFilter)->Results();
/** @var $result UserItemView */
foreach ($results as $result) {
// consolidates results by user id if the user is in multiple groups
$users[$result->Id] = new AutocompleteUser($result->Id, $result->First, $result->Last, $result->Email, $result->Username);
}
}
return array_values($users);
}
示例10: 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);
//.........这里部分代码省略.........
示例11: testLoadsUserFromCacheIfAlreadyLoadedFromDatabase
public function testLoadsUserFromCacheIfAlreadyLoadedFromDatabase()
{
$userId = 1;
$row = $this->GetUserRow();
$this->db->SetRow(0, array($row));
$this->db->SetRow(1, $this->GetEmailPrefRows());
$this->db->SetRow(2, $this->GetPermissionsRows());
$this->db->SetRow(3, $this->GetGroupsRows());
$this->db->SetRow(4, $this->GetAttributeRows());
$this->db->SetRow(5, $this->GetOwnedGroupRows());
$this->db->SetRow(6, $this->GetPreferenceRows());
$userRepository = new UserRepository();
$user = $userRepository->LoadById($userId);
$user = $userRepository->LoadById($userId);
// 2nd call should load from cache
$this->assertEquals(7, count($this->db->_Commands));
}