1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - Administration * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * -------------------------------------------- * |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \**************************************************************************/ |
---|
11 | |
---|
12 | |
---|
13 | class uiaccess_history |
---|
14 | { |
---|
15 | var $template; |
---|
16 | var $public_functions = array( |
---|
17 | 'list_history' => True |
---|
18 | ); |
---|
19 | |
---|
20 | function uiaccess_history() |
---|
21 | { |
---|
22 | if ($GLOBALS['phpgw']->acl->check('access_log_access',1,'admin')) |
---|
23 | { |
---|
24 | $GLOBALS['phpgw']->redirect_link('/index.php'); |
---|
25 | } |
---|
26 | |
---|
27 | $this->bo = createobject('admin.boaccess_history'); |
---|
28 | $this->nextmatchs = createobject('phpgwapi.nextmatchs'); |
---|
29 | $this->template = $GLOBALS['phpgw']->template; |
---|
30 | $this->template->set_file( |
---|
31 | Array( |
---|
32 | 'accesslog' => 'accesslog.tpl' |
---|
33 | ) |
---|
34 | ); |
---|
35 | $this->template->set_block('accesslog','list'); |
---|
36 | $this->template->set_block('accesslog','row'); |
---|
37 | $this->template->set_block('accesslog','row_empty'); |
---|
38 | } |
---|
39 | |
---|
40 | function list_history() |
---|
41 | { |
---|
42 | $account_id = get_var('account_id',array('GET','POST')); |
---|
43 | $start = get_var('start',array('POST'),0); |
---|
44 | $sort = get_var('sort',array('POST'),0); |
---|
45 | $order = get_var('order',array('POST'),0); |
---|
46 | |
---|
47 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('View access log'); |
---|
48 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
49 | { |
---|
50 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
51 | } |
---|
52 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
53 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
54 | echo parse_navbar(); |
---|
55 | |
---|
56 | $total_records = $this->bo->total($account_id); |
---|
57 | |
---|
58 | $var = Array( |
---|
59 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
60 | 'nextmatchs_left' => $this->nextmatchs->left('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id), |
---|
61 | 'nextmatchs_right' => $this->nextmatchs->right('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id), |
---|
62 | 'showing' => $this->nextmatchs->show_hits($total_records,$start), |
---|
63 | 'lang_loginid' => lang('LoginID'), |
---|
64 | 'lang_ip' => lang('IP'), |
---|
65 | 'lang_login' => lang('Login'), |
---|
66 | 'lang_logout' => lang('Logout'), |
---|
67 | 'lang_total' => lang('Total') |
---|
68 | ); |
---|
69 | |
---|
70 | if ($account_id) |
---|
71 | { |
---|
72 | $var['link_return_to_view_account'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', |
---|
73 | Array( |
---|
74 | 'menuaction' => 'admin.uiaccounts.view', |
---|
75 | 'account_id' => $account_id |
---|
76 | ) |
---|
77 | ) . '">' . lang('Return to view account') . '</a>'; |
---|
78 | $var['lang_last_x_logins'] = lang('Last %1 logins for %2',$total_records,$GLOBALS['phpgw']->common->grab_owner_name($account_id)); |
---|
79 | } |
---|
80 | else |
---|
81 | { |
---|
82 | $var['lang_last_x_logins'] = lang('Last %1 logins',$total_records); |
---|
83 | } |
---|
84 | |
---|
85 | $this->template->set_var($var); |
---|
86 | |
---|
87 | $records = $this->bo->list_history($account_id,$start,$order,$sort); |
---|
88 | while (is_array($records) && list(,$record) = each($records)) |
---|
89 | { |
---|
90 | $this->nextmatchs->template_alternate_row_color($this->template); |
---|
91 | |
---|
92 | $var = array( |
---|
93 | 'row_loginid' => $record['loginid'], |
---|
94 | 'row_ip' => $record['ip'], |
---|
95 | 'row_li' => $record['li'], |
---|
96 | 'row_lo' => $record['account_id'] ? $record['lo'] : '<b>'.lang($record['sessionid']).'</b>', |
---|
97 | 'row_total' => ($record['lo']?$record['total']:' ') |
---|
98 | ); |
---|
99 | $this->template->set_var($var); |
---|
100 | $this->template->fp('rows_access','row',True); |
---|
101 | } |
---|
102 | |
---|
103 | if (! $total_records && $account_id) |
---|
104 | { |
---|
105 | $this->nextmatchs->template_alternate_row_color($this->template); |
---|
106 | $this->template->set_var('row_message',lang('No login history exists for this user')); |
---|
107 | $this->template->fp('rows_access','row_empty',True); |
---|
108 | } |
---|
109 | |
---|
110 | $loggedout = $this->bo->return_logged_out($account_id); |
---|
111 | |
---|
112 | if ($total_records) |
---|
113 | { |
---|
114 | $percent = round((10000 * ($loggedout / $total_records)) / 100); |
---|
115 | } |
---|
116 | else |
---|
117 | { |
---|
118 | $percent = '0'; |
---|
119 | } |
---|
120 | |
---|
121 | $var = Array( |
---|
122 | 'bg_color' => $GLOBALS['phpgw_info']['themes']['bg_color'], |
---|
123 | 'footer_total' => lang('Total records') . ': ' . $total_records |
---|
124 | ); |
---|
125 | if ($account_id) |
---|
126 | { |
---|
127 | $var['lang_percent'] = lang('Percent this user has logged out') . ': ' . $percent . '%'; |
---|
128 | } |
---|
129 | else |
---|
130 | { |
---|
131 | $var['lang_percent'] = lang('Percent of users that logged out') . ': ' . $percent . '%'; |
---|
132 | } |
---|
133 | |
---|
134 | // create the menu on the left, if needed |
---|
135 | $menuClass = CreateObject('admin.uimenuclass'); |
---|
136 | $var['rows'] = $menuClass->createHTMLCode('view_account'); |
---|
137 | |
---|
138 | $this->template->set_var($var); |
---|
139 | $this->template->pfp('out','list'); |
---|
140 | } |
---|
141 | } |
---|