public function PageLoad()
 {
     if ($this->page->GetUserId() != null) {
         $userList = $this->userRepository->GetList(1, 1, null, null, new SqlFilterEquals(ColumnNames::USER_ID, $this->page->GetUserId()));
     } else {
         $userList = $this->userRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize(), null, null, null, $this->page->GetFilterStatusId());
     }
     $this->page->BindUsers($userList->Results());
     $this->page->BindPageInfo($userList->PageInfo());
     $groups = $this->groupViewRepository->GetList();
     $this->page->BindGroups($groups->Results());
     $resources = array();
     $user = $this->userRepository->LoadById(ServiceLocator::GetServer()->GetUserSession()->UserId);
     $allResources = $this->resourceRepository->GetResourceList();
     foreach ($allResources as $resource) {
         if ($user->IsResourceAdminFor($resource)) {
             $resources[] = $resource;
         }
     }
     $this->page->BindResources($resources);
     $userIds = array();
     /** @var $user UserItemView */
     foreach ($userList->Results() as $user) {
         $userIds[] = $user->Id;
     }
     $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::USER, $userIds);
     $this->page->BindAttributeList($attributeList);
 }
Exemple #2
0
 /**
  * @param $term string
  * @return array|AutocompleteUser[]
  */
 private function GetUsers($term)
 {
     if ($term == 'group') {
         return $this->GetGroupUsers($this->GetQuerystring(QueryStringKeys::GROUP_ID));
     }
     $filter = new SqlFilterLike(ColumnNames::FIRST_NAME, $term);
     $filter->_Or(new SqlFilterLike(ColumnNames::LAST_NAME, $term));
     $filter->_Or(new SqlFilterLike(ColumnNames::EMAIL, $term));
     $users = array();
     $r = new UserRepository();
     $results = $r->GetList(1, PageInfo::All, null, null, $filter)->Results();
     /** @var $result UserItemView */
     foreach ($results as $result) {
         $users[] = new AutocompleteUser($result->Id, $result->First, $result->Last, $result->Email, $result->Username);
     }
     return $users;
 }
 public function PageLoad()
 {
     if ($this->page->GetUserId() != null) {
         $userList = $this->userRepository->GetList(1, 1, null, null, new SqlFilterEquals(ColumnNames::USER_ID, $this->page->GetUserId()));
     } else {
         $userList = $this->userRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize(), null, null, null, $this->page->GetFilterStatusId());
     }
     $this->page->BindUsers($userList->Results());
     $this->page->BindPageInfo($userList->PageInfo());
     $groups = $this->groupViewRepository->GetList();
     $this->page->BindGroups($groups->Results());
     $user = $this->userRepository->LoadById(ServiceLocator::GetServer()->GetUserSession()->UserId);
     $resources = $this->GetResourcesThatCurrentUserCanAdminister($user);
     $this->page->BindResources($resources);
     $attributeList = $this->attributeService->GetByCategory(CustomAttributeCategory::USER);
     $this->page->BindAttributeList($attributeList);
 }
 public function testCanGetPageableListOfUsers()
 {
     $page = 3;
     $pageSize = 5;
     $count = 51;
     $totalPages = 11;
     $offset = 10;
     $countRow = array('total' => $count);
     $row1 = $this->GetUserRow(1, 'first', 'last', 'email', 'un1', '2011-01-01', 'utc', AccountStatus::ACTIVE, null, 'pref1=val1,pref2=val2');
     $row2 = $this->GetUserRow(2, 'first', 'last', 'email', null, '2010-01-01');
     $userRows = array($row1, $row2);
     $this->db->SetRow(0, array($countRow));
     $this->db->SetRow(1, $userRows);
     $userRepo = new UserRepository();
     $pageable = $userRepo->GetList($page, $pageSize);
     $this->assertEquals($count, $pageable->PageInfo()->Total);
     $this->assertEquals($totalPages, $pageable->PageInfo()->TotalPages);
     $this->assertEquals($pageSize, $pageable->PageInfo()->PageSize);
     $this->assertEquals($page, $pageable->PageInfo()->CurrentPage);
     $results = $pageable->Results();
     $this->assertEquals(UserItemView::Create($row1), $results[0]);
     $this->assertEquals(UserItemView::Create($row2), $results[1]);
     $this->assertEquals($offset, $this->db->_Offset);
     $this->assertEquals($pageSize, $this->db->_Limit);
 }