egroupware_official/admin/inc/class.uicurrentsessions.inc.php

169 lines
6.3 KiB
PHP
Raw Normal View History

2001-08-16 03:38:14 +02:00
<?php
/**************************************************************************\
2004-08-08 23:29:14 +02:00
* eGroupWare - Administration *
* http://www.egroupware.org *
2001-08-16 03:38:14 +02:00
* This file written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class uicurrentsessions
{
var $template;
var $bo;
var $public_functions = array(
2001-12-21 04:41:06 +01:00
'list_sessions' => True,
'kill' => True
);
2001-08-16 03:38:14 +02:00
function uicurrentsessions()
{
2005-10-14 19:03:16 +02:00
if ($GLOBALS['egw']->acl->check('current_sessions_access',1,'admin'))
{
2005-10-14 19:03:16 +02:00
$GLOBALS['egw']->redirect_link('/index.php');
}
2005-10-14 19:03:16 +02:00
$this->template =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
$this->bo =& CreateObject('admin.bocurrentsessions');
$this->nextmatchs =& CreateObject('phpgwapi.nextmatchs');
2001-08-16 03:38:14 +02:00
}
function header()
{
2005-10-14 19:03:16 +02:00
if(!@is_object($GLOBALS['egw']->js))
{
2005-10-14 19:03:16 +02:00
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
}
2005-10-14 19:03:16 +02:00
$GLOBALS['egw']->js->validate_file('jscode','openwindow','admin');
$GLOBALS['egw']->common->egw_header();
echo parse_navbar();
2001-08-16 03:38:14 +02:00
}
function store_location($info)
{
2005-10-14 19:03:16 +02:00
$GLOBALS['egw']->session->appsession('currentsessions_session_data','admin',$info);
2001-08-16 03:38:14 +02:00
}
function list_sessions()
{
2005-10-14 19:03:16 +02:00
$info = $GLOBALS['egw']->session->appsession('currentsessions_session_data','admin');
2001-08-16 03:38:14 +02:00
if (! is_array($info))
{
$info = array(
'start' => 0,
'sort' => 'asc',
'order' => 'session_dla'
);
$this->store_location($info);
}
if ($_REQUEST['start'] || $_REQUEST['sort'] || $_REQUEST['order'])
2001-08-16 03:38:14 +02:00
{
if ($_REQUEST['start'] == 0 || $_REQUEST['start'] && $_REQUEST['start'] != $info['start'])
2001-08-16 03:38:14 +02:00
{
$info['start'] = $_REQUEST['start'];
2001-08-16 03:38:14 +02:00
}
if ($_REQUEST['sort'] && $_REQUEST['sort'] != $info['sort'])
2001-08-16 03:38:14 +02:00
{
$info['sort'] = $_REQUEST['sort'];
2001-08-16 03:38:14 +02:00
}
if ($_REQUEST['order'] && $_REQUEST['order'] != $info['order'])
2001-08-16 03:38:14 +02:00
{
$info['order'] = $_REQUEST['order'];
2001-08-16 03:38:14 +02:00
}
$this->store_location($info);
}
2005-10-14 19:03:16 +02:00
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('List of current users');
2001-08-16 03:38:14 +02:00
$this->header();
$this->template->set_file('current','currentusers.tpl');
$this->template->set_block('current','list','list');
$this->template->set_block('current','row','row');
2005-10-14 19:03:16 +02:00
$can_view_action = !$GLOBALS['egw']->acl->check('current_sessions_access',2,'admin');
$can_view_ip = !$GLOBALS['egw']->acl->check('current_sessions_access',4,'admin');
$can_kill = !$GLOBALS['egw']->acl->check('current_sessions_access',8,'admin');
2001-08-16 03:38:14 +02:00
$total = $this->bo->total();
2005-10-14 19:03:16 +02:00
$this->template->set_var('bg_color',$GLOBALS['egw_info']['theme']['bg_color']);
2001-08-16 03:38:14 +02:00
$this->template->set_var('left_next_matchs',$this->nextmatchs->left('/admin/currentusers.php',$info['start'],$total));
$this->template->set_var('right_next_matchs',$this->nextmatchs->right('/admin/currentusers.php',$info['start'],$total));
2005-10-14 19:03:16 +02:00
$this->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
2001-08-16 03:38:14 +02:00
$this->template->set_var('sort_loginid',$this->nextmatchs->show_sort_order($info['sort'],'session_lid',$info['order'],
'/admin/currentusers.php',lang('LoginID')));
$this->template->set_var('sort_ip',$this->nextmatchs->show_sort_order($info['sort'],'session_ip',$info['order'],
'/admin/currentusers.php',lang('IP')));
$this->template->set_var('sort_login_time',$this->nextmatchs->show_sort_order($info['sort'],'session_logintime',$info['order'],
'/admin/currentusers.php',lang('Login Time')));
$this->template->set_var('sort_action',$this->nextmatchs->show_sort_order($info['sort'],'session_action',$info['order'],
'/admin/currentusers.php',lang('Action')));
$this->template->set_var('sort_idle',$this->nextmatchs->show_sort_order($info['sort'],'session_dla',$info['order'],
'/admin/currentusers.php',lang('idle')));
$this->template->set_var('lang_kill',lang('Kill'));
$values = $this->bo->list_sessions($info['start'],$info['order'],$info['sort']);
while (list(,$value) = @each($values))
2001-08-16 03:38:14 +02:00
{
$this->nextmatchs->template_alternate_row_color($this->template);
2001-08-16 03:38:14 +02:00
$this->template->set_var('row_loginid',$value['session_lid']);
$this->template->set_var('row_ip',$can_view_ip?$value['session_ip']:'&nbsp;');
2001-08-16 03:38:14 +02:00
$this->template->set_var('row_logintime',$value['session_logintime']);
$this->template->set_var('row_idle',$value['session_idle']);
if ($value['session_action'] && $can_view_action)
2001-08-16 03:38:14 +02:00
{
2005-10-14 19:03:16 +02:00
$this->template->set_var('row_action',$GLOBALS['egw']->strip_html($value['session_action']));
2001-08-16 03:38:14 +02:00
}
else
{
$this->template->set_var('row_action','&nbsp;');
2001-08-16 03:38:14 +02:00
}
2001-12-21 04:41:06 +01:00
2005-10-14 19:03:16 +02:00
if ($value['session_id'] != $GLOBALS['egw_info']['user']['sessionid'] && $can_kill)
2001-08-16 03:38:14 +02:00
{
2005-10-14 19:03:16 +02:00
$this->template->set_var('row_kill','<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=admin.uicurrentsessions.kill&ksession='
2001-08-16 03:38:14 +02:00
. $value['session_id'] . '&kill=true') . '">' . lang('Kill').'</a>');
}
else
{
$this->template->set_var('row_kill','&nbsp;');
}
2001-12-21 04:41:06 +01:00
2001-08-16 03:38:14 +02:00
$this->template->parse('rows','row',True);
}
$this->template->pfp('out','list');
2001-08-16 03:38:14 +02:00
}
function kill()
{
2005-10-14 19:03:16 +02:00
if ($GLOBALS['egw']->acl->check('current_sessions_access',8,'admin'))
{
2005-10-14 19:03:16 +02:00
$GLOBALS['egw']->redirect_link('/index.php');
}
2005-10-14 19:03:16 +02:00
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Kill session');
$this->header();
$this->template->set_file('form','kill_session.tpl');
$this->template->set_var('lang_message',lang('Are you sure you want to kill this session ?'));
2005-10-14 19:03:16 +02:00
$this->template->set_var('link_no','<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=admin.uicurrentsessions.list_sessions') . '">' . lang('No') . '</a>');
$this->template->set_var('link_yes','<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=admin.bocurrentsessions.kill&ksession=' . $_GET['ksession']) . '">' . lang('Yes') . '</a>');
$this->template->pfp('out','form');
}
}