Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 362

Přidáno uživatelem Michal Kliment před asi 15 roky(ů)

Dodelany mensi opravy login_logs, pridan odkaz do menu....

Zobrazit rozdíly:

freenetis/trunk/kohana/application/models/login_log.php
* Returns last login of all user
* @return ORM iterator
*/
public function get_all_login_logs()
public function get_all_login_logs($sql_offset = 0, $limit_results = 500)
{
return self::$db->query('SELECT id, CONCAT(\'<a href="'.url_lang::base().'users/show/\',id,\'">\',name,\'</a>\') AS name, IFNULL(last_time,\''.url_lang::lang('texts.Never').'\') as last_time FROM (SELECT * FROM (SELECT u.id, CONCAT(u.name,\' \',u.surname) AS name, l.time AS last_time FROM users u
LEFT JOIN login_logs l ON u.id = l.user_id ORDER BY time DESC) AS q1 GROUP BY q1.id) AS q3 ORDER BY q3.last_time DESC LIMIT '.$sql_offset.', '.$limit_results);
}
/**
* @author Michal Kliment
* Returns last login of all user
* @return ORM iterator
*/
public function count_all_login_logs()
{
$query = self::$db->query('SELECT id, CONCAT(\'<a href="'.url_lang::base().'users/show/\',id,\'">\',name,\'</a>\') AS name, IFNULL(last_time,\''.url_lang::lang('texts.Never').'\') as last_time FROM (SELECT * FROM (SELECT u.id, CONCAT(u.name,\' \',u.surname) AS name, l.time AS last_time FROM users u
LEFT JOIN login_logs l ON u.id = l.user_id ORDER BY time DESC) AS q1 GROUP BY q1.id) AS q3 ORDER BY q3.last_time DESC');
return count($query);
}
}
freenetis/trunk/kohana/application/controllers/login_logs.php
class Login_logs_Controller extends Controller
{
public function index()
{
url::redirect(url_lang::base().'login_logs/show_all');
}
/**
* @author Michal Kliment
* Shows last time login of users
*/
public function index()
public function show_all($limit_results = 200, $page_word = null, $page = 1)
{
/**
* @todo access control
*/
// gets new selector
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
$login_log_model = new Login_log_Model();
$login_logs = $login_log_model->get_all_login_logs();
$total_login_logs = count($login_logs);
$total_login_logs = $login_log_model->count_all_login_logs();
if (($sql_offset = ($page - 1) * $limit_results) > $total_login_logs)
$sql_offset = 0;
$login_logs = $login_log_model->get_all_login_logs($sql_offset, (int)$limit_results);
// create grid
$grid = new Grid(url_lang::base().'login_logs', url_lang::lang('texts.Login logs'), array(
$grid = new Grid(url_lang::base().'login_logs/show_all', url_lang::lang('texts.Login logs'), array(
//'separator' => '',
'use_paginator' => true,
'use_selector' => true,
'current' => 500, //current selected 'records_per_page' value
'current' => $limit_results, //current selected 'records_per_page' value
'selector_increace' => 200, // increace
'selector_min' => 200, // minimum where selector start
'selector_max_multiplier' => 10,
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
'base_url' => Config::item('locale.lang').'/login_logs/show_all/'.$limit_results ,
'total_items' => $total_login_logs, // use db count query here of course
'items_per_page' => 500, // it may be handy to set defaults for stuff like this in config/pagination.php
'items_per_page' => $limit_results, // it may be handy to set defaults for stuff like this in config/pagination.php
'style' => 'classic',
'order_by' => 'last_time',
'order_by_direction' => 'desc',
'limit_results' => 500
'limit_results' => $limit_results
));
$grid->field('id')->label(url_lang::lang('texts.Id'));
freenetis/trunk/kohana/application/libraries/MY_Controller.php
if ($this->acl_check_2D('menu', 'administration'))
$myMenu .= '<li class="administration"><h2>'.url_lang::lang('texts.Administration').'</h2>
<ul>
<li>'.html::anchor(url_lang::base().'login_logs', url_lang::lang('texts.Login logs')).'</li>
<li>'.html::anchor(url_lang::base().'settings', url_lang::lang('texts.Settings')).'</li>
<li>'.html::anchor(url_lang::base().'fees', url_lang::lang('texts.Fees')).'</li>
<li>'.html::anchor(url_lang::base().'access_rights', url_lang::lang('texts.Access rights')).'</li>

Také k dispozici: Unified diff