function login_history_output in Login History 7
Same name and namespace in other branches
- 6 includes/login_history.pages.inc \login_history_output()
Render login histories.
@todo Add XML output format.
Parameters
array $history: A list of login history objects to output.
string $format: Optional format to output log entries in; 'table', 'list', or 'text'.
array $header: Optional An array containing header data for $format 'table'.
Return value
array|string A render array by default (for table) but a string in other cases.
1 call to login_history_output()
- login_history_report_callback in includes/
login_history.pages.inc - Page callback for the login history page.
File
- includes/
login_history.pages.inc, line 64 - The login history page-related code.
Code
function login_history_output(array $history, $format = 'table', array $header = array()) {
switch ($format) {
case 'text':
// Output delimiter in first line, since this may change.
$output = '\\t' . "\n";
foreach ($history as $entry) {
$row = array(
format_date($entry->login, 'small'),
check_plain(format_username($entry->uid)),
check_plain($entry->hostname),
empty($entry->one_time) ? t('Regular login') : t('One-time login'),
check_plain($entry->user_agent),
);
$output .= implode("\t", $row) . "\n";
}
break;
case 'list':
$output = '';
foreach ($history as $entry) {
$one_time = empty($entry->one_time) ? t('Regular login') : t('One-time login');
$output .= '<li>';
$output .= '<span class="login-history-info">' . check_plain(format_username($entry)) . ' ' . format_date($entry->login, 'small') . ' ' . check_plain($entry->hostname) . ' ' . $one_time . ' ' . check_plain($entry->user_agent) . '</span>';
$output .= '</li>';
}
if ($output) {
$output = '<ul id="login-history-backlog">' . $output . '</ul>';
}
break;
case 'table':
default:
$rows = array();
foreach ($history as $entry) {
$rows[] = array(
format_date($entry->login, 'small'),
check_plain(format_username($entry)),
check_plain($entry->hostname),
empty($entry->one_time) ? t('Regular login') : t('One-time login'),
check_plain($entry->user_agent),
);
}
$output['history'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No login history available.'),
);
$output['pager'] = array(
'#theme' => 'pager',
);
break;
}
return $output;
}