userlist works with pagination

This commit is contained in:
Quitta 2013-08-05 21:12:58 +02:00
parent a0e63b09da
commit dbe6e82945
4 changed files with 31 additions and 10 deletions

View file

@ -68,6 +68,7 @@ class WebUsers extends Users{
} }
} }
//returns te id for a given username
public static function getId($username){ public static function getId($username){
$dbw = new DBLayer("web"); $dbw = new DBLayer("web");
$statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:username", array('username' => $username)); $statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:username", array('username' => $username));
@ -75,6 +76,10 @@ class WebUsers extends Users{
return $row['UId']; return $row['UId'];
} }
public function getUId(){
return $this->uId;
}
public function getUsername(){ public function getUsername(){
$dbw = new DBLayer("web"); $dbw = new DBLayer("web");
if(! isset($this->login) || $this->login == ""){ if(! isset($this->login) || $this->login == ""){
@ -148,4 +153,8 @@ class WebUsers extends Users{
return $data; return $data;
} }
public static function getAllUsersQuery(){
return "SELECT * FROM ams_user";
}
} }

View file

@ -2,16 +2,19 @@
function userlist(){ function userlist(){
if(Ticket_User::isMod($_SESSION['ticket_user'])){ 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; $i = 0;
$pageResult['userlist'] = Array(); foreach( $pageResult['userlist'] as $user ){
while($row = $users->fetch(PDO::FETCH_ASSOC)){ $pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission();
$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'];
$i++; $i++;
} }
if (Ticket_User::isAdmin($_SESSION['ticket_user'])){ if (Ticket_User::isAdmin($_SESSION['ticket_user'])){
$pageResult['isAdmin'] = "TRUE"; $pageResult['isAdmin'] = "TRUE";
} }

View file

@ -75,7 +75,7 @@
</div> </div>
{/if} {/if}
<table class="table table-striped table-bordered bootstrap-datatable datatable"> <table class="table table-striped table-bordered">
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>

View file

@ -10,7 +10,7 @@
</div> </div>
</div> </div>
<div class="box-content"> <div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable"> <table class="table table-striped table-bordered">
<thead> <thead>
<tr> <tr>
<th>Id</th> <th>Id</th>
@ -63,6 +63,15 @@
</tbody> </tbody>
</table> </table>
<div style="width: 300px; margin:0px auto;">
<ul class="pagination">
<li><a href="index.php?page=userlist&pagenum=1">&laquo;</a></li>
{foreach from=$links item=link}
<li {if $link == $currentPage}class="active"{/if}><a href="index.php?page=userlist&pagenum={$link}">{$link}</a></li>
{/foreach}
<li><a href="index.php?page=userlist&pagenum={$lastPage}">&raquo;</a></li>
</ul>
</div>
</div> </div>
</div><!--/span--> </div><!--/span-->