- Moved kill session over to 3 tier design

- Added ACL checks to current sessions
This commit is contained in:
jengo 2001-09-05 02:13:27 +00:00
parent 3051d1645d
commit af907736ed
5 changed files with 82 additions and 64 deletions

View File

@ -14,7 +14,11 @@
class bocurrentsessions
{
var $ui;
var $so;
var $public_functions = array(
'kill' => True
);
function bocurrentsessions()
{
@ -61,4 +65,14 @@
return $_values;
}
function kill()
{
if ($GLOBALS['ksession'] && $GLOBALS['sessionid'] != $GLOBALS['ksession'] && ! $GLOBALS['phpgw']->acl->check('current_sessions_access',8,'admin'))
{
$GLOBALS['phpgw']->session->destroy($GLOBALS['ksession']);
}
$this->ui = createobject('admin.uicurrentsessions');
$this->ui->list_sessions();
}
}

View File

@ -17,7 +17,8 @@
var $template;
var $bo;
var $public_functions = array(
'list_sessions' => True
'list_sessions' => True,
'kill' => True
);
function uicurrentsessions()
@ -77,6 +78,16 @@
$this->template->set_block('current','list','list');
$this->template->set_block('current','row','row');
if (! $GLOBALS['phpgw']->acl->check('current_sessions_access',4,'admin'))
{
$can_view_ip = True;
}
if (! $GLOBALS['phpgw']->acl->check('current_sessions_access',2,'admin'))
{
$can_view_action = True;
}
$total = $this->bo->total();
$this->template->set_var('lang_current_users',lang('List of current users'));
@ -98,27 +109,41 @@
$this->template->set_var('lang_kill',lang('Kill'));
$values = $this->bo->list_sessions($info['start'],$info['order'],$info['sort']);
while (list(,$value) = each($values))
{
$this->nextmatchs->template_alternate_row_color(&$this->template);
$this->template->set_var('row_loginid',$value['session_lid']);
$this->template->set_var('row_ip',$value['session_ip']);
$this->template->set_var('row_logintime',$value['session_logintime']);
$this->template->set_var('row_idle',$value['session_idle']);
if ($value['session_action'])
if ($can_view_ip)
{
$this->template->set_var('row_action',$GLOBALS['phpgw']->strip_html($value['session_action']));
$this->template->set_var('row_ip',$value['session_ip']);
}
else
{
$this->template->set_var('row_action',' ');
$this->template->set_var('row_ip','  --  ');
}
$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)
{
$this->template->set_var('row_action',$GLOBALS['phpgw']->strip_html($value['session_action']));
}
else if (! $can_view_action)
{
$this->template->set_var('row_action','  --  ');
}
else
{
$this->template->set_var('row_action',' ');
}
if ($value['session_id'] != $GLOBALS['phpgw_info']['user']['sessionid'])
if ($value['session_id'] != $GLOBALS['phpgw_info']['user']['sessionid'] && ! $GLOBALS['phpgw']->acl->check('current_sessions_access',8,'admin'))
{
$this->template->set_var('row_kill','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentusers.kill_session&ksession='
$this->template->set_var('row_kill','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.kill&ksession='
. $value['session_id'] . '&kill=true') . '">' . lang('Kill').'</a>');
}
else
@ -130,8 +155,26 @@
}
$this->template->pparse('out','list');
}
function kill()
{
if ($GLOBALS['phpgw']->acl->check('current_sessions_access',8,'admin'))
{
$this->list_sessions();
return False;
}
$this->header();
$this->template->set_file('form','kill_session.tpl');
$this->template->set_var('lang_title',lang('Kill session'));
$this->template->set_var('lang_message',lang('Are you sure you want to kill this session ?'));
$this->template->set_var('link_no','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.list_sessions') . '">' . lang('No') . '</a>');
$this->template->set_var('link_yes','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.bocurrentsessions.kill&ksession=' . $GLOBALS['ksession']) . '">' . lang('Yes') . '</a>');
$this->template->pfp('out','form');
}
}

View File

@ -1,54 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare - administration *
* http://www.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$ */
$phpgw_info = array();
if ($confirm) {
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
}
$phpgw_info["flags"]["currentapp"] = "admin";
include("../header.inc.php");
if ($ksessionid == $phpgw_info["user"]["sessionid"])
{
Header("Location: " . $phpgw->link("/admin/currentusers.php"));
$phpgw->common->phpgw_exit();
}
if ($confirm)
{
$phpgw->db->query("delete from phpgw_sessions where session_id='$ksession'");
Header("Location: " . $phpgw->link("/admin/currentusers.php","cd=19"));
}
else
{
?>
<center>
<table border="0" with="65%">
<tr colspan="2">
<td align="center">
<?php echo lang('Are you sure you want to kill this session ?'); ?>
<td>
</tr>
<tr>
<td>
<a href="<?php echo $phpgw->link('/admin/currentusers.php') . '">' . lang('No'); ?></a>
</td>
<td>
<a href="<?php echo $phpgw->link('/admin/killsession.php','ksession=' . $ksession . '&confirm=true') . '">' . lang('Yes'); ?></a>
</td>
</tr>
</table>
</center>
<?php
$phpgw->common->phpgw_footer();
}
?>

View File

@ -34,3 +34,5 @@
<td>{row_kill}</td>
</tr>
<!-- END row -->

View File

@ -0,0 +1,13 @@
<b>{lang_title}</b>
<hr><p>
<table border="0" with="65%" align="center">
<tr colspan="2">
<td align="center">{lang_message}<td>
</tr>
<tr>
<td>{link_no}</td>
<td>{link_yes}</td>
</tr>
</table>