[UPDATE] added pagination to reg and invite

This commit is contained in:
iAmShorty 2014-02-24 11:24:13 +01:00
parent 0f9cdb915c
commit 55266e274a
4 changed files with 48 additions and 9 deletions

View File

@ -120,7 +120,7 @@ class User extends Base {
* @param none
* @return data array All users with db columns as array fields
**/
public function getLastRegisteredUsers($limit=10) {
public function getLastRegisteredUsers($limit=10,$start=0) {
$this->debug->append("STA " . __METHOD__, 4);
$invitation = new Invitation();
$invitation->setMysql($this->mysqli);
@ -132,8 +132,8 @@ class User extends Base {
ON a.email = i.email
LEFT JOIN " . $this->getTableName() . " AS u
ON i.account_id = u.id
ORDER BY a.id DESC LIMIT ?");
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $limit) && $stmt->execute() && $result = $stmt->get_result()) {
ORDER BY a.id DESC LIMIT ?,?");
if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $start, $limit) && $stmt->execute() && $result = $stmt->get_result()) {
return $result->fetch_all(MYSQLI_ASSOC);
}
}
@ -143,7 +143,7 @@ class User extends Base {
* @param none
* @return data array All users with db columns as array fields
**/
public function getTopInviters($limit=10) {
public function getTopInviters($limit=10,$start=0) {
$this->debug->append("STA " . __METHOD__, 4);
$invitation = new Invitation();
$invitation->setMysql($this->mysqli);
@ -157,8 +157,8 @@ class User extends Base {
ON a.id = i.account_id
GROUP BY i.account_id
ORDER BY invitationcount ASC
LIMIT ?");
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $limit) && $stmt->execute() && $result = $stmt->get_result()) {
LIMIT ?,?");
if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $start, $limit) && $stmt->execute() && $result = $stmt->get_result()) {
return $result->fetch_all(MYSQLI_ASSOC);
}
}

View File

@ -7,6 +7,12 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) {
die("404 Page not found");
}
// Some defaults
$iLimit = 10;
$smarty->assign('LIMIT', $iLimit);
empty($_REQUEST['registeredstart']) ? $registeredstart = 0 : $registeredstart = $_REQUEST['registeredstart'];
empty($_REQUEST['invitersstart']) ? $invitersstart = 0 : $invitersstart = $_REQUEST['invitersstart'];
if ($bitcoin->can_connect() === true){
$aGetInfo = $bitcoin->getinfo();
} else {
@ -65,13 +71,13 @@ $aRegistrationInfo = array(
$smarty->assign('USER_REGISTRATIONS', $aRegistrationInfo);
// get last 10 Registrations
$aLastRegisteredUsers = $user->getLastRegisteredUsers();
$aLastRegisteredUsers = $user->getLastRegisteredUsers($iLimit, $registeredstart);
$smarty->assign("LASTREGISTEREDUSERS", $aLastRegisteredUsers);
// Fetching invitation Informations
if (!$setting->getValue('disable_invitations')) {
// get last 10 Inviters
$aTopInviters = $user->getTopInviters();
$aTopInviters = $user->getTopInviters($iLimit, $invitersstart);
$smarty->assign("TOPINVITERS", $aTopInviters);
// Fetch global invitation information

View File

@ -25,6 +25,22 @@
<article class="module width_3_quarter" style="min-height: 150px">
<header><h3>Top 10 Inviters</h3></header>
<div>
<table cellspacing="0" class="tablesorter">
<tbody>
<tr>
<td align="left">
{if $smarty.request.invitersstart|default:"0" > 0}
<a href="{$smarty.server.SCRIPT_NAME}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&invitersstart={$smarty.request.invitersstart|escape|default:"0" - $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><i class="icon-left-open"></i> Previous 10</a>
{else}
<i class="icon-left-open"></i>
{/if}
</td>
<td align="right">
<a href="{$smarty.server.SCRIPT_NAME}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&invitersstart={$smarty.request.invitersstart|escape|default:"0" + $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}">Next 10 <i class="icon-right-open"></i></a>
</td>
</tbody>
</table>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>

View File

@ -26,8 +26,25 @@
</article>
<article class="module width_3_quarter" style="min-height: 150px">
<header><h3>Last 10 registered Users</h3></header>
<header><h3>Last registered Users</h3></header>
<div>
<table cellspacing="0" class="tablesorter">
<tbody>
<tr>
<td align="left">
{if $smarty.request.registeredstart|default:"0" > 0}
<a href="{$smarty.server.SCRIPT_NAME}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&registeredstart={$smarty.request.registeredstart|escape|default:"0" - $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><i class="icon-left-open"></i> Previous 10</a>
{else}
<i class="icon-left-open"></i>
{/if}
</td>
<td align="right">
<a href="{$smarty.server.SCRIPT_NAME}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&registeredstart={$smarty.request.registeredstart|escape|default:"0" + $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}">Next 10 <i class="icon-right-open"></i></a>
</td>
</tbody>
</table>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>