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)
{
global $phpgw;
$records = $this->so->list_history($account_id,$start,$order,$sort);
while (is_array($records) && list(,$record) = each($records))
{
@ -44,12 +42,12 @@
if ($record['li'])
{
$record['li'] = $phpgw->common->show_date($record['li']);
$record['li'] = $GLOBALS['phpgw']->common->show_date($record['li']);
}
if ($record['lo'] != '')
{
$record['lo'] = $phpgw->common->show_date($record['lo']);
$record['lo'] = $GLOBALS['phpgw']->common->show_date($record['lo']);
}
if (ereg('@',$record['loginid']))
@ -72,10 +70,9 @@
function grab_fullname($account_id)
{
global $phpgw;
$acct = createobject('phpgwapi.accounts',$account_id);
$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)

View File

@ -20,14 +20,14 @@
function uiaccess_history()
{
global $phpgw;
$this->bo = createobject('admin.boaccess_history');
$this->nextmatchs = createobject('phpgwapi.nextmatchs');
$this->template = $phpgw->template;
$this->template->set_file(array(
$this->template = $GLOBALS['phpgw']->template;
$this->template->set_file(
Array(
'accesslog' => 'accesslog.tpl'
));
)
);
$this->template->set_block('accesslog','list');
$this->template->set_block('accesslog','row');
$this->template->set_block('accesslog','row_empty');
@ -35,52 +35,64 @@
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);
$sort = ($GLOBALS['HTTP_POST_VARS']['sort']?$GLOBALS['HTTP_POST_VARS']['sort']:0);
$order = ($GLOBALS['HTTP_POST_VARS']['order']?$GLOBALS['HTTP_POST_VARS']['order']:0);
$phpgw->common->phpgw_header();
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
$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));
$this->template->set_var('nextmatchs_right',$this->nextmatchs->right('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id));
$var = Array(
'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)
{
$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>');
$fullname = $this->bo->grab_fullname($account_id);
$this->template->set_var('lang_last_x_logins',lang('Last %1 logins for %2',$total_records,$fullname));
$var['link_return_to_view_account'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php',
Array(
'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
{
$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('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'));
$this->template->set_var($var);
$records = $this->bo->list_history($account_id,$start,$order,$sort);
while (is_array($records) && list(,$record) = each($records))
{
$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']);
$this->nextmatchs->template_alternate_row_color($this->template);
$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);
}
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->fp('rows_access','row_empty',True);
}
@ -96,21 +108,24 @@
$percent = '0';
}
$this->template->set_var('bg_color',$phpgw_info['themes']['bg_color']);
$this->template->set_var('footer_total',lang('Total records') . ': ' . $total_records);
$var = Array(
'bg_color' => $GLOBALS['phpgw_info']['themes']['bg_color'],
'footer_total' => lang('Total records') . ': ' . $total_records
);
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
{
$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
$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');
}
}

View File

@ -52,23 +52,23 @@
{
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
{
$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]);
$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('row_on',$this->rowColor[0]);
$this->t->parse("out","menu_links");
$this->t->parse('out','menu_links');
return $this->t->get('out','menu_links');
}
@ -76,41 +76,39 @@
// create the html code for the menu
function createHTMLCode($_hookname)
{
global $phpgw, $menuData;
switch ($_hookname)
{
case 'edit_account':
$menuData[] = Array
case 'edit_user':
$GLOBALS['menuData'][] = Array
(
'description' => 'userdata',
'url' => '/admin/editaccount.php',
'extradata' => ''
'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccounts.edit_user'
);
break;
case 'view_account':
$menuData[] = Array
case 'view_user':
$GLOBALS['menuData'][] = Array
(
'description' => 'userdata',
'url' => '/admin/viewaccount.php',
'extradata' => ''
'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccounts.view_user'
);
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
$menuData = '';
$GLOBALS['menuData'] = '';
return $result;
}
else
{
// clear $menuData
$menuData = '';
$GLOBALS['menuData'] = '';
return '';
}
}

View File

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