Пример #1
0
 public function BuildingPage(User $u)
 {
     $this->_user = $u;
     $this->_queue = ResourceBuilder::GetBuildingListOfColony($u->CurrentColony());
     $this->_time = $this->_queue->BuildList()->CommissionedTime();
     // Include language files for buildings page, useful to put error messages there.
     $this->_text =& array_merge($u->Language()->GetFilesByPage("buildings"), $u->Language()->GetFilesByPage("trader"), $u->Language()->GetFilesByPage("research"));
 }
Пример #2
0
 public function __construct(IRestServer $server, User $user, IEntityAttributeList $attributes)
 {
     $userId = $user->Id();
     $this->id = $userId;
     $this->emailAddress = $user->EmailAddress();
     $this->firstName = $user->FirstName();
     $this->lastName = $user->LastName();
     $this->language = $user->Language();
     $this->lastLogin = Date::FromDatabase($user->LastLogin())->ToIso();
     $this->organization = $user->GetAttribute(UserAttribute::Organization);
     $this->phoneNumber = $user->GetAttribute(UserAttribute::Phone);
     $this->position = $user->GetAttribute(UserAttribute::Position);
     $this->statusId = $user->StatusId();
     $this->timezone = $user->Timezone();
     $this->username = $user->Username();
     $attributeValues = $attributes->GetAttributes($userId);
     if (!empty($attributeValues)) {
         foreach ($attributeValues as $av) {
             $this->customAttributes[] = new CustomAttributeResponse($server, $av->Id(), $av->Label(), $av->Value());
         }
     }
     foreach ($user->AllowedResourceIds() as $allowedResourceId) {
         $this->permissions[] = new ResourceItemResponse($server, $allowedResourceId, '');
     }
     foreach ($user->Groups() as $group) {
         $this->groups[] = new GroupItemResponse($server, $group->GroupId, $group->GroupName);
     }
     if ($user->GetIsCalendarSubscriptionAllowed()) {
         $url = new CalendarSubscriptionUrl($user->GetPublicId(), null, null);
         $this->icsUrl = $url->__toString();
     }
 }
Пример #3
0
 public function __construct(User $reservationOwner, User $participant, ReservationSeries $reservationSeries, IAttributeRepository $attributeRepository)
 {
     parent::__construct($reservationOwner, $reservationSeries, $participant->Language(), $attributeRepository);
     $this->reservationOwner = $reservationOwner;
     $this->reservationSeries = $reservationSeries;
     $this->timezone = $participant->Timezone();
     $this->participant = $participant;
 }
Пример #4
0
 public function __construct(User $reservationOwner, User $invitee, ReservationSeries $reservationSeries, IAttributeRepository $attributeRepository)
 {
     parent::__construct($reservationOwner, $reservationSeries, $invitee->Language(), $attributeRepository);
     $this->reservationOwner = $reservationOwner;
     $this->reservationSeries = $reservationSeries;
     $this->timezone = $invitee->Timezone();
     $this->invitee = $invitee;
 }
Пример #5
0
 public function GalaxyView(User $u, Coordinates $c = NULL)
 {
     $this->_user = $u;
     if ($c == NULL) {
         $this->_coords = $u->CurrentColony()->Coordinates();
     } else {
         $this->_coords = $c;
     }
     // Include language files for galaxy page, useful to put error messages there.
     $this->_text =& $u->Language()->GetFilesByPage("galaxy_view");
 }
Пример #6
0
 public function __construct(User $reservationOwner, ReservationSeries $reservationSeries, $language = null, IAttributeRepository $attributeRepository)
 {
     if (empty($language)) {
         $language = $reservationOwner->Language();
     }
     parent::__construct($language);
     $this->reservationOwner = $reservationOwner;
     $this->reservationSeries = $reservationSeries;
     $this->timezone = $reservationOwner->Timezone();
     $this->attributeRepository = $attributeRepository;
 }
Пример #7
0
 /**
  * @param User $user
  * @return void
  */
 public function Update(User $user)
 {
     $userId = $user->Id();
     $db = ServiceLocator::GetDatabase();
     $updateUserCommand = new UpdateUserCommand($user->Id(), $user->StatusId(), $user->encryptedPassword, $user->passwordSalt, $user->FirstName(), $user->LastName(), $user->EmailAddress(), $user->Username(), $user->Homepage(), $user->Timezone(), $user->LastLogin(), $user->GetIsCalendarSubscriptionAllowed(), $user->GetPublicId(), $user->Language(), $user->GetDefaultScheduleId());
     $db->Execute($updateUserCommand);
     $removedPermissions = $user->GetRemovedPermissions();
     foreach ($removedPermissions as $resourceId) {
         $db->Execute(new DeleteUserResourcePermission($userId, $resourceId));
     }
     $addedPermissions = $user->GetAddedPermissions();
     foreach ($addedPermissions as $resourceId) {
         $db->Execute(new AddUserResourcePermission($userId, $resourceId));
     }
     if ($user->HaveAttributesChanged()) {
         $updateAttributesCommand = new UpdateUserAttributesCommand($userId, $user->GetAttribute(UserAttribute::Phone), $user->GetAttribute(UserAttribute::Organization), $user->GetAttribute(UserAttribute::Position));
         $db->Execute($updateAttributesCommand);
     }
     $removedPreferences = $user->GetRemovedEmailPreferences();
     foreach ($removedPreferences as $event) {
         $db->Execute(new DeleteEmailPreferenceCommand($userId, $event->EventCategory(), $event->EventType()));
     }
     $addedPreferences = $user->GetAddedEmailPreferences();
     foreach ($addedPreferences as $event) {
         $db->Execute(new AddEmailPreferenceCommand($userId, $event->EventCategory(), $event->EventType()));
     }
     foreach ($user->GetRemovedAttributes() as $removed) {
         $db->Execute(new RemoveAttributeValueCommand($removed->AttributeId, $user->Id()));
     }
     foreach ($user->GetAddedAttributes() as $added) {
         $db->Execute(new AddAttributeValueCommand($added->AttributeId, $added->Value, $user->Id(), CustomAttributeCategory::USER));
     }
     foreach ($user->GetPreferences()->AddedPreferences() as $added) {
         $db->Execute(new AddUserPreferenceCommand($user->Id(), $added, $user->GetPreference($added)));
     }
     foreach ($user->GetPreferences()->ChangedPreferences() as $updated) {
         $db->Execute(new UpdateUserPreferenceCommand($user->Id(), $updated, $user->GetPreference($updated)));
     }
     foreach ($user->GetRemovedGroups() as $removed) {
         $db->Execute(new DeleteUserGroupCommand($user->Id(), $removed->GroupId));
     }
     foreach ($user->GetAddedGroups() as $added) {
         $db->Execute(new AddUserGroupCommand($user->Id(), $added->GroupId));
     }
 }
Пример #8
0
 public function __construct(User $user, $activationCode)
 {
     $this->user = $user;
     $this->activationCode = $activationCode;
     parent::__construct($user->Language());
 }
Пример #9
0
 public function __construct(User $user, $temporaryPassword)
 {
     parent::__construct($user->Language());
     $this->user = $user;
     $this->temporaryPassword = $temporaryPassword;
 }
Пример #10
0
 /**
  * @param User $user
  * @param string $loginTime
  * @return UserSession
  */
 private function GetUserSession(User $user, $loginTime)
 {
     $userSession = new UserSession($user->Id());
     $userSession->Email = $user->EmailAddress();
     $userSession->FirstName = $user->FirstName();
     $userSession->LastName = $user->LastName();
     $userSession->Timezone = $user->Timezone();
     $userSession->HomepageId = $user->Homepage();
     $userSession->LanguageCode = $user->Language();
     $userSession->LoginTime = $loginTime;
     $userSession->PublicId = $user->GetPublicId();
     $userSession->ScheduleId = $user->GetDefaultScheduleId();
     $userSession->IsAdmin = $this->roleService->IsApplicationAdministrator($user);
     $userSession->IsGroupAdmin = $this->roleService->IsGroupAdministrator($user);
     $userSession->IsResourceAdmin = $this->roleService->IsResourceAdministrator($user);
     $userSession->IsScheduleAdmin = $this->roleService->IsScheduleAdministrator($user);
     $userSession->CSRFToken = base64_encode(md5(uniqid(rand(), true)));
     foreach ($user->Groups() as $group) {
         $userSession->Groups[] = $group->GroupId;
     }
     foreach ($user->GetAdminGroups() as $group) {
         $userSession->AdminGroups[] = $group->GroupId;
     }
     return $userSession;
 }