Elgg  Version 2.3
login_history.php
Go to the documentation of this file.
1 <?php
2 
4 
5 $log = get_system_log($user->guid, 'login', '', 'user', '', 20);
6 if (empty($log)) {
7  return;
8 }
9 $body = '<table class="elgg-table">';
10 $body .= '<thead><tr>';
11 $body .= '<th>' . elgg_echo('usersettings:statistics:login_history:date') . '</th><th>' . elgg_echo('usersettings:statistics:login_history:ip') . '</th>';
12 $body .= '</tr></thead>';
13 $body .= '<tbody>';
14 
15 foreach ($log as $entry) {
16  if ($entry->ip_address) {
17  $ip_address = $entry->ip_address;
18  } else {
19  $ip_address = elgg_echo('unknown');
20  }
21 
22  $time = date(elgg_echo('friendlytime:date_format'), $entry->time_created);
23 
24  $body .= "<tr><td>{$time}</td><td>{$ip_address}</td></tr>";
25 }
26 
27 $body .= '</tbody></table>';
28 
29 echo elgg_view_module('info', elgg_echo('usersettings:statistics:login_history'), $body);
$user
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
if(empty($log)) $body
$log
get_system_log($by_user="", $event="", $class="", $type="", $subtype="", $limit=null, $offset=0, $count=false, $timebefore=0, $timeafter=0, $object_id=0, $ip_address="")
Retrieve the system log based on a number of parameters.
Definition: system_log.php:30
elgg echo
Translates a string.
Definition: languages.js:48
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:56
elgg_view_module($type, $title, $body, array $vars=array())
Wrapper function for the module display pattern.
Definition: views.php:1250