From 91e758c1ee2eb5b8e5fb672ed5a5d74d2774d650 Mon Sep 17 00:00:00 2001 From: Quitta Date: Mon, 5 Aug 2013 21:12:58 +0200 Subject: [PATCH] userlist works with pagination --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/www/html/autoload/webusers.php | 9 +++++++++ .../server/ryzom_ams/www/html/inc/userlist.php | 17 ++++++++++------- .../ryzom_ams/www/html/templates/show_queue.tpl | 2 +- .../ryzom_ams/www/html/templates/userlist.tpl | 13 +++++++++++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php index fe21ec7fc..e93137d61 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php @@ -68,6 +68,7 @@ class WebUsers extends Users{ } } + //returns te id for a given username public static function getId($username){ $dbw = new DBLayer("web"); $statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:username", array('username' => $username)); @@ -75,6 +76,10 @@ class WebUsers extends Users{ return $row['UId']; } + public function getUId(){ + return $this->uId; + } + public function getUsername(){ $dbw = new DBLayer("web"); if(! isset($this->login) || $this->login == ""){ @@ -148,4 +153,8 @@ class WebUsers extends Users{ return $data; } + public static function getAllUsersQuery(){ + return "SELECT * FROM ams_user"; + } + } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php index de7414bc7..9e4c8a079 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php @@ -2,16 +2,19 @@ function userlist(){ if(Ticket_User::isMod($_SESSION['ticket_user'])){ - $users = WebUsers::getUsers(); + + $pagination = new Pagination(WebUsers::getAllUsersQuery(),"web",10,"WebUsers"); + $pageResult['userlist'] = Gui_Elements::make_table($pagination->getElements() , Array("getUId","getUsername","getEmail"), Array("id","username","email")); + $pageResult['links'] = $pagination->getLinks(5); + $pageResult['lastPage'] = $pagination->getLast(); + $pageResult['currentPage'] = $pagination->getCurrent(); + $i = 0; - $pageResult['userlist'] = Array(); - while($row = $users->fetch(PDO::FETCH_ASSOC)){ - $pageResult['userlist'][$i]['id'] = $row['UId']; - $pageResult['userlist'][$i]['username'] = $row['Login']; - $pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($row['UId'])->getPermission(); - $pageResult['userlist'][$i]['email'] = $row['Email']; + foreach( $pageResult['userlist'] as $user ){ + $pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission(); $i++; } + if (Ticket_User::isAdmin($_SESSION['ticket_user'])){ $pageResult['isAdmin'] = "TRUE"; } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl index 035ba7bd4..650be9c92 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl @@ -75,7 +75,7 @@ {/if} - +
diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl index 0cc586841..4dbdd77fb 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl @@ -10,7 +10,7 @@
-
ID
+
@@ -62,7 +62,16 @@ {/foreach} -
Id
+ +
+ +