[ADDED] User login overview to admin dashboard

Fixes #1374 once merged
This commit is contained in:
Sebastian Grewe 2014-01-12 09:05:59 +01:00
parent 20ef443ae1
commit 20305026e8
4 changed files with 38 additions and 2 deletions

View File

@ -133,9 +133,9 @@ class Base {
* @param none
* @param data mixed Count or false
**/
public function getCountFiltered($column='id', $value=NULL, $type='i') {
public function getCountFiltered($column='id', $value=NULL, $type='i', $operator = '=') {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("SELECT COUNT(id) AS count FROM $this->table WHERE $column = ?");
$stmt = $this->mysqli->prepare("SELECT COUNT(id) AS count FROM $this->table WHERE $column $operator ?");
if ($this->checkStmt($stmt) && $stmt->bind_param($type, $value) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_object()->count;
return $this->sqlError();

View File

@ -46,6 +46,16 @@ $aUserInfo = array(
);
$smarty->assign('USER_INFO', $aUserInfo);
// Fetch login information
$aLoginInfo = array(
'24hours' => $user->getCountFiltered('last_login', time() - 3600, 'i', '>='),
'7days' => $user->getCountFiltered('last_login', (time() - (3600 * 7)), 'i', '>='),
'1month' => $user->getCountFiltered('last_login', (time() - (3600 * 7 * 4)), 'i', '>='),
'6month' => $user->getCountFiltered('last_login', (time() - (3600 * 7 * 4 * 6)), 'i', '>='),
'1year' => $user->getCountFiltered('last_login', (time() - (3600 * 365)), 'i', '>=')
);
$smarty->assign('USER_LOGINS', $aLoginInfo);
// Fetch invitation information
if (!$setting->getValue('disable_invitations')) {
$aInvitationInfo = array(

View File

@ -3,4 +3,5 @@
{include file="admin/dashboard/users.tpl"}
{include file="admin/dashboard/status.tpl"}
{if $GLOBAL.config.disable_invitations|default:"0" == 0}{include file="admin/dashboard/invitations.tpl"}{/if}
{include file="admin/dashboard/logins.tpl"}
{/nocache}

View File

@ -0,0 +1,25 @@
{nocache}
<article class="module width_quarter">
<header><h3>Logins</h3></header>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th align="center">24 hours</th>
<th align="center">7 days</th>
<th align="center">1 month</th>
<th align="center">6 months</th>
<th align="center">1 year</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">{$USER_LOGINS.24hours}</td>
<td align="center">{$USER_LOGINS.7days}</td>
<td align="center">{$USER_LOGINS.1month}</td>
<td align="center">{$USER_LOGINS.6month}</td>
<td align="center">{$USER_LOGINS.1year}</td>
</tr>
</tbody>
</table>
</article>
{/nocache}