Skip to content

Commit

Permalink
Merge branch 'Ticket#1557' of git://github.com/Joe7/gallery3
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Jan 15, 2011
2 parents e4a43c9 + df802de commit a7d4f87
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
31 changes: 30 additions & 1 deletion modules/user/controllers/admin_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,37 @@ 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)));
}

$view->content->users = ORM::factory("user")
->select(array("users.id", "users.admin", "users.name", "users.email", "users.full_name",
"users.last_login", "users.guest", db::expr("COUNT(items.id) as item_count")))
->join("items", "items.owner_id", "users.id", "LEFT")
->group_by("users.id")
->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;
}

Expand Down
1 change: 1 addition & 0 deletions modules/user/css/user.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#g-user-admin {
width: auto;
margin-bottom: 4em;
}

#g-group-admin {
Expand Down
7 changes: 6 additions & 1 deletion modules/user/views/admin_users.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class="g-dialog-link g-button g-right ui-icon-left ui-state-default ui-corner-al
<?= ($user->last_login == 0) ? "" : gallery::date($user->last_login) ?>
</td>
<td>
<?= db::build()->from("items")->where("owner_id", "=", $user->id)->count_records() ?>
<?= $user->item_count ?>
</td>
<td>
<a href="<?= url::site("admin/users/edit_user_form/$user->id") ?>"
Expand All @@ -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>

Expand Down

0 comments on commit a7d4f87

Please sign in to comment.