Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into 3.0.x

  • Loading branch information...
commit 09ea593d4894fc6465b50a4e5c2937f7a80b1657 2 parents 229f8a7 + d511fc7
@bharat bharat authored
View
28 modules/user/controllers/admin_users.php
@@ -22,8 +22,34 @@ public function index() {
$view = new Admin_View("admin.html");
$view->page_title = t("Users and groups");
$view->content = new View("admin_users.html");
- $view->content->users = ORM::factory("user")->order_by("name", "ASC")->find_all();
+
+ // @todo: add this as a config option
+ $page_size = module::get_var("user", "page_size", 10);
+ $page = Input::instance()->get("page", "1");
+ $builder = db::build();
+ $user_count = $builder->from("users")->count_records();
+
+ $view->content->pager = new Pagination();
+ $view->content->pager->initialize(
+ array("query_string" => "page",
+ "total_items" => $user_count,
+ "items_per_page" => $page_size,
+ "style" => "classic"));
+
+ // Make sure that the page references a valid offset
+ if ($page < 1) {
+ url::redirect(url::merge(array("page" => 1)));
+ } else if ($page > $view->content->pager->total_pages) {
+ url::redirect(url::merge(array("page" => $view->content->pager->total_pages)));
+ }
+
+ // Join our users against the items table so that we can get a count of their items
+ // in the same query.
+ $view->content->users = ORM::factory("user")
+ ->order_by("users.name", "ASC")
+ ->find_all($page_size, $view->content->pager->sql_offset);
$view->content->groups = ORM::factory("group")->order_by("name", "ASC")->find_all();
+
print $view;
}
View
1  modules/user/css/user.css
@@ -12,6 +12,7 @@
#g-user-admin {
width: auto;
+ margin-bottom: 4em;
}
#g-group-admin {
View
5 modules/user/views/admin_users.html.php
@@ -108,6 +108,11 @@ class="g-button ui-state-disabled ui-corner-all ui-icon-left">
</tr>
<? endforeach ?>
</table>
+
+ <div class="g-paginator">
+ <?= $pager ?>
+ </div>
+
</div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.