diff --git a/src/applications/people/controller/list/PhabricatorPeopleListController.php b/src/applications/people/controller/list/PhabricatorPeopleListController.php index ad31e0a8b8..db8a5b89f6 100644 --- a/src/applications/people/controller/list/PhabricatorPeopleListController.php +++ b/src/applications/people/controller/list/PhabricatorPeopleListController.php @@ -19,8 +19,25 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController { public function processRequest() { + $request = $this->getRequest(); + + $user = new PhabricatorUser(); + + $count = queryfx_one( + $user->establishConnection('r'), + 'SELECT COUNT(*) N FROM %T', + $user->getTableName()); + $count = idx($count, 'N', 0); + + $pager = new AphrontPagerView(); + $pager->setOffset($request->getInt('page', 0)); + $pager->setCount($count); + $pager->setURI($request->getRequestURI(), 'page'); + $users = id(new PhabricatorUser())->loadAllWhere( - '1 = 1 ORDER BY id DESC LIMIT 100'); + '1 = 1 ORDER BY id DESC LIMIT %d, %d', + $pager->getOffset(), + $pager->getPageSize()); $rows = array(); foreach ($users as $user) { @@ -35,15 +52,6 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController { 'href' => '/p/'.$user->getUsername().'/', ), 'View Profile'), -/* - phutil_render_tag( - 'a', - array( - 'class' => 'button grey small', - 'href' => '/people/edit/'.$user->getUsername().'/', - ), - 'Edit'), -*/ ); } @@ -54,7 +62,6 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController { 'Username', 'Real Name', '', -// '', )); $table->setColumnClasses( array( @@ -62,13 +69,12 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController { null, 'wide', 'action', -// 'action', )); $panel = new AphrontPanelView(); - $panel->appendChild($table); $panel->setHeader('People'); -// $panel->setCreateButton('Create New User', '/people/edit/'); + $panel->appendChild($table); + $panel->appendChild($pager); return $this->buildStandardPageResponse($panel, array( 'title' => 'People', diff --git a/src/applications/people/controller/list/__init__.php b/src/applications/people/controller/list/__init__.php index adb44568b3..364bc2dda9 100644 --- a/src/applications/people/controller/list/__init__.php +++ b/src/applications/people/controller/list/__init__.php @@ -8,6 +8,8 @@ phutil_require_module('phabricator', 'applications/people/controller/base'); phutil_require_module('phabricator', 'applications/people/storage/user'); +phutil_require_module('phabricator', 'storage/queryfx'); +phutil_require_module('phabricator', 'view/control/pager'); phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/layout/panel'); diff --git a/src/view/control/pager/AphrontPagerView.php b/src/view/control/pager/AphrontPagerView.php index 1fa253ec66..6b526975c4 100644 --- a/src/view/control/pager/AphrontPagerView.php +++ b/src/view/control/pager/AphrontPagerView.php @@ -19,7 +19,7 @@ final class AphrontPagerView extends AphrontView { private $offset; - private $pageSize; + private $pageSize = 100; private $count; private $hasMorePages; @@ -81,6 +81,10 @@ final class AphrontPagerView extends AphrontView { } public function render() { + if (!$this->uri) { + throw new Exception( + "You must call setURI() before you can call render()."); + } require_celerity_resource('aphront-pager-view-css');