Did a little cleaning on the access_history class. Using GLOBALS now and fits in the the accounts class in admin.

This commit is contained in:
skeeter 2001-09-01 23:40:28 +00:00
parent 2df316073d
commit df1d4a732c
4 changed files with 76 additions and 68 deletions

View File

@ -20,8 +20,6 @@
function list_history($account_id,$start,$order,$sort) function list_history($account_id,$start,$order,$sort)
{ {
global $phpgw;
$records = $this->so->list_history($account_id,$start,$order,$sort); $records = $this->so->list_history($account_id,$start,$order,$sort);
while (is_array($records) && list(,$record) = each($records)) while (is_array($records) && list(,$record) = each($records))
{ {
@ -44,12 +42,12 @@
if ($record['li']) if ($record['li'])
{ {
$record['li'] = $phpgw->common->show_date($record['li']); $record['li'] = $GLOBALS['phpgw']->common->show_date($record['li']);
} }
if ($record['lo'] != '') if ($record['lo'] != '')
{ {
$record['lo'] = $phpgw->common->show_date($record['lo']); $record['lo'] = $GLOBALS['phpgw']->common->show_date($record['lo']);
} }
if (ereg('@',$record['loginid'])) if (ereg('@',$record['loginid']))
@ -72,10 +70,9 @@
function grab_fullname($account_id) function grab_fullname($account_id)
{ {
global $phpgw;
$acct = createobject('phpgwapi.accounts',$account_id); $acct = createobject('phpgwapi.accounts',$account_id);
$acct->read_repository(); $acct->read_repository();
return $phpgw->common->display_fullname($acct->data['account_lid'],$acct->data['firstname'],$acct->data['lastname']); return $GLOBALS['phpgw']->common->display_fullname($acct->data['account_lid'],$acct->data['firstname'],$acct->data['lastname']);
} }
function total($account_id) function total($account_id)
@ -87,4 +84,4 @@
{ {
return $this->so->return_logged_out($account_id); return $this->so->return_logged_out($account_id);
} }
} }

View File

@ -20,14 +20,14 @@
function uiaccess_history() function uiaccess_history()
{ {
global $phpgw;
$this->bo = createobject('admin.boaccess_history'); $this->bo = createobject('admin.boaccess_history');
$this->nextmatchs = createobject('phpgwapi.nextmatchs'); $this->nextmatchs = createobject('phpgwapi.nextmatchs');
$this->template = $phpgw->template; $this->template = $GLOBALS['phpgw']->template;
$this->template->set_file(array( $this->template->set_file(
'accesslog' => 'accesslog.tpl' Array(
)); 'accesslog' => 'accesslog.tpl'
)
);
$this->template->set_block('accesslog','list'); $this->template->set_block('accesslog','list');
$this->template->set_block('accesslog','row'); $this->template->set_block('accesslog','row');
$this->template->set_block('accesslog','row_empty'); $this->template->set_block('accesslog','row_empty');
@ -35,52 +35,64 @@
function list_history() function list_history()
{ {
global $account_id, $phpgw, $phpgw_info, $start, $sort, $order; $account_id = ($GLOBALS['HTTP_GET_VARS']['account_id']?$GLOBALS['HTTP_GET_VARS']['account_id']:$GLOBALS['HTTP_POST_VARS']['account_id']);
$start = ($GLOBALS['HTTP_POST_VARS']['start']?$GLOBALS['HTTP_POST_VARS']['start']:0);
$phpgw->common->phpgw_header(); $sort = ($GLOBALS['HTTP_POST_VARS']['sort']?$GLOBALS['HTTP_POST_VARS']['sort']:0);
$order = ($GLOBALS['HTTP_POST_VARS']['order']?$GLOBALS['HTTP_POST_VARS']['order']:0);
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar(); echo parse_navbar();
$total_records = $this->bo->total($account_id); $total_records = $this->bo->total($account_id);
$this->template->set_var('th_bg',$phpgw_info['theme']['th_bg']);
$this->template->set_var('nextmatchs_left',$this->nextmatchs->left('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id)); $var = Array(
$this->template->set_var('nextmatchs_right',$this->nextmatchs->right('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id)); 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
'nextmatchs_left' => $this->nextmatchs->left('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id),
'nextmatchs_right' => $this->nextmatchs->right('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id),
'showing' => $this->nextmatchs->show_hits($total_records,$start),
'lang_loginid' => lang('LoginID'),
'lang_ip' => lang('IP'),
'lang_login' => lang('Login'),
'lang_logout' => lang('Logout'),
'lang_total' => lang('Total')
);
if ($account_id) if ($account_id)
{ {
$this->template->set_var('link_return_to_view_account','<a href="' . $phpgw->link('/admin/viewaccount.php','account_id=' . $account_id) . '">' . lang('Return to view account') . '</a>'); $var['link_return_to_view_account'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php',
$fullname = $this->bo->grab_fullname($account_id); Array(
$this->template->set_var('lang_last_x_logins',lang('Last %1 logins for %2',$total_records,$fullname)); 'menuaction' => 'admin.uiaccounts.view',
'account_id' => $account_id
)
) . '">' . lang('Return to view account') . '</a>';
$var['lang_last_x_logins'] = lang('Last %1 logins for %2',$total_records,$this->bo->grab_fullname($account_id));
} }
else else
{ {
$this->template->set_var('lang_last_x_logins',lang('Last x logins',$total_records)); $var['lang_last_x_logins'] = lang('Last x logins',$total_records);
} }
$this->template->set_var('showing',$this->nextmatchs->show_hits($total_records,$start)); $this->template->set_var($var);
$this->template->set_var('lang_loginid',lang('LoginID'));
$this->template->set_var('lang_ip',lang('IP'));
$this->template->set_var('lang_login',lang('Login'));
$this->template->set_var('lang_logout',lang('Logout'));
$this->template->set_var('lang_total',lang('Total'));
$records = $this->bo->list_history($account_id,$start,$order,$sort); $records = $this->bo->list_history($account_id,$start,$order,$sort);
while (is_array($records) && list(,$record) = each($records)) while (is_array($records) && list(,$record) = each($records))
{ {
$this->nextmatchs->template_alternate_row_color(&$this->template); $this->nextmatchs->template_alternate_row_color($this->template);
$this->template->set_var('row_loginid',$record['loginid']);
$this->template->set_var('row_ip',$record['ip']);
$this->template->set_var('row_li',$record['li']);
$this->template->set_var('row_lo',$record['lo']);
$this->template->set_var('row_total',$record['total']);
$var = Array(
'row_loginid' => $record['loginid'],
'row_ip' => $record['ip'],
'row_li' => $record['li'],
'row_lo' => $record['lo'],
'row_total' => $record['total']
);
$this->template->set_var($var);
$this->template->fp('rows_access','row',True); $this->template->fp('rows_access','row',True);
} }
if (! $total_records && $account_id) if (! $total_records && $account_id)
{ {
$this->nextmatchs->template_alternate_row_color(&$this->template); $this->nextmatchs->template_alternate_row_color($this->template);
$this->template->set_var('row_message',lang('No login history exists for this user')); $this->template->set_var('row_message',lang('No login history exists for this user'));
$this->template->fp('rows_access','row_empty',True); $this->template->fp('rows_access','row_empty',True);
} }
@ -96,21 +108,24 @@
$percent = '0'; $percent = '0';
} }
$this->template->set_var('bg_color',$phpgw_info['themes']['bg_color']); $var = Array(
$this->template->set_var('footer_total',lang('Total records') . ': ' . $total_records); 'bg_color' => $GLOBALS['phpgw_info']['themes']['bg_color'],
'footer_total' => lang('Total records') . ': ' . $total_records
);
if ($account_id) if ($account_id)
{ {
$this->template->set_var('lang_percent',lang('Percent this user has logged out') . ': ' . $percent . '%'); $var['lang_percent'] = lang('Percent this user has logged out') . ': ' . $percent . '%';
} }
else else
{ {
$this->template->set_var('lang_percent',lang('Percent of users that logged out') . ': ' . $percent . '%'); $var['lang_percent'] = lang('Percent of users that logged out') . ': ' . $percent . '%';
} }
// create the menu on the left, if needed // create the menu on the left, if needed
$menuClass = CreateObject('admin.uimenuclass'); $menuClass = CreateObject('admin.uimenuclass');
$this->template->set_var('rows',$menuClass->createHTMLCode('view_account')); $var['rows'] = $menuClass->createHTMLCode('view_account');
$this->template->set_var($var);
$this->template->pfp('out','list'); $this->template->pfp('out','list');
} }
} }

View File

@ -52,23 +52,23 @@
{ {
if (!empty($value['extradata'])) if (!empty($value['extradata']))
{ {
$link = $phpgw->link($value['url'],'account_id=' . $account_id . '&' . $value['extradata']); $link = $GLOBALS['phpgw']->link($value['url'],'account_id=' . $account_id . '&' . $value['extradata']);
} }
else else
{ {
$link = $phpgw->link($value['url'],'account_id=' . $account_id); $link = $GLOBALS['phpgw']->link($value['url'],'account_id=' . $account_id);
} }
$this->section_item($link,lang($value['description']),$this->rowColor[$i%2]); $this->section_item($link,lang($value['description']),$this->rowColor[$i%2]);
$i++; $i++;
} }
$this->t->set_var('th_bg',$phpgw_info["theme"]["th_bg"]); $this->t->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
$this->t->set_var('link_done',$phpgw->link('/admin/accounts.php')); $this->t->set_var('link_done',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_users'));
$this->t->set_var('lang_done',lang('back')); $this->t->set_var('lang_done',lang('back'));
$this->t->set_var('row_on',$this->rowColor[0]); $this->t->set_var('row_on',$this->rowColor[0]);
$this->t->parse("out","menu_links"); $this->t->parse('out','menu_links');
return $this->t->get('out','menu_links'); return $this->t->get('out','menu_links');
} }
@ -76,43 +76,41 @@
// create the html code for the menu // create the html code for the menu
function createHTMLCode($_hookname) function createHTMLCode($_hookname)
{ {
global $phpgw, $menuData;
switch ($_hookname) switch ($_hookname)
{ {
case 'edit_account': case 'edit_user':
$menuData[] = Array $GLOBALS['menuData'][] = Array
( (
'description' => 'userdata', 'description' => 'userdata',
'url' => '/admin/editaccount.php', 'url' => '/index.php',
'extradata' => '' 'extradata' => 'menuaction=admin.uiaccounts.edit_user'
); );
break; break;
case 'view_account': case 'view_user':
$menuData[] = Array $GLOBALS['menuData'][] = Array
( (
'description' => 'userdata', 'description' => 'userdata',
'url' => '/admin/viewaccount.php', 'url' => '/index.php',
'extradata' => '' 'extradata' => 'menuaction=admin.uiaccounts.view_user'
); );
break; break;
} }
$phpgw->common->hook($_hookname); $GLOBALS['phpgw']->common->hook($_hookname);
if (count($menuData) > 1) if (count($GLOBALS['menuData']) > 1)
{ {
$result = $this->display_section($menuData); $result = $this->display_section($GLOBALS['menuData']);
//clear $menuData //clear $menuData
$menuData = ''; $GLOBALS['menuData'] = '';
return $result; return $result;
} }
else else
{ {
// clear $menuData // clear $menuData
$menuData = ''; $GLOBALS['menuData'] = '';
return ''; return '';
} }
} }
} }
?> ?>

View File

@ -8,7 +8,5 @@
); );
//Do not modify below this line //Do not modify below this line
global $menuData; $GLOBALS['menuData'][] = $data;
?>
$menuData[] = $data;
?>