created a class to create the left menu for plugins

changed the code for editaccount and viewaccount
This commit is contained in:
Lars Kneschke 2001-08-28 21:50:10 +00:00
parent 379260b37c
commit 8d7ba95ea6
9 changed files with 259 additions and 137 deletions

View File

@ -23,7 +23,7 @@
// creates the html for the user data
function createPageBody($_account_id,$_userData='',$_errors='')
{
global $phpgw, $phpgw_info, $t;
global $phpgw, $phpgw_info;
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$t->set_unknowns('remove');
@ -258,8 +258,10 @@
'permissions_list' => $appRightsOutput
);
$t->set_var($var);
$phpgw->common->hook('edit_account');
// create the menu on the left, if needed
$menuClass = CreateObject('admin.uimenuclass');
$t->set_var('rows',$menuClass->createHTMLCode('edit_account'));
echo $t->fp('out','form');
}
@ -280,10 +282,7 @@
$apps = CreateObject('phpgwapi.applications',array(intval($_userData['account_id']),'u'));
$apps->account_type = 'u';
$apps->account_id = $_userData['account_id'];
$apps->account_apps = Array(Array());
$apps_before = $apps->read_account_specific();
if ($_userData['account_permissions'])
{
while($app = each($_userData['account_permissions']))
@ -291,10 +290,6 @@
if($app[1])
{
$apps->add($app[0]);
if(!@$apps_before[$app[0]] || @$apps_before == False)
{
$apps_after[] = $app[0];
}
}
}
}
@ -408,44 +403,6 @@
}
}
function section_item($pref_link='',$pref_text='', $bgcolor)
{
global $phpgw, $phpgw_info, $t;
$t->set_var('row_link',$pref_link);
$t->set_var('row_text',$pref_text);
$t->set_var('tr_color',$bgcolor);
$t->parse('rows','link_row',True);
}
// $file must be in the follow format:
// $file = Array(
// 'Login History' => array('/index.php','menuaction=admin.uiaccess_history.list')
// );
// This allows extra data to be sent along
function display_section($appname,$title,$file)
{
global $phpgw, $phpgw_info, $account_id;
$i = 0;
$color[1] = $phpgw_info['theme']['row_off'];
$color[0] = $phpgw_info['theme']['row_on'];
while(list($text,$_url) = each($file))
{
list($url,$extra_data) = $_url;
if ($extra_data)
{
$link = $phpgw->link($url,'account_id=' . $account_id . '&' . $extra_data);
}
else
{
$link = $phpgw->link($url,'account_id=' . $account_id);
}
section_item($link,lang($text),$color[$i%2]);
$i++;
}
}
// todo
// not needed if i use the same file for new users too
if (! $account_id)
@ -475,10 +432,27 @@
);
if (!$errors = userDataInvalid($userData))
{
{
saveUserData($userData);
Header('Location: ' . $phpgw->link('/admin/accounts.php', 'cd='.$cd));
$phpgw->common->phpgw_exit();
// check if would create a menu
// if we do, we can't return to the users list, because
// there are also some other plugins
$menuClass = CreateObject('admin.uimenuclass');
if (!$menuClass->createHTMLCode('edit_account'))
{
Header('Location: ' . $phpgw->link('/admin/accounts.php', 'cd='.$cd));
$phpgw->common->phpgw_exit();
}
else
{
$linkdata = array
(
'cd' => $cd,
'account_id' => $account_id
);
Header('Location: ' . $phpgw->link('/admin/editaccount.php', $linkdata));
$phpgw->common->phpgw_exit();
}
}
else
{

View File

@ -75,14 +75,14 @@
$this->template->set_var('row_lo',$record['lo']);
$this->template->set_var('row_total',$record['total']);
$this->template->fp('rows','row',True);
$this->template->fp('rows_access','row',True);
}
if (! $total_records && $account_id)
{
$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','row_empty',True);
$this->template->fp('rows_access','row_empty',True);
}
$loggedout = $this->bo->return_logged_out($account_id);
@ -106,6 +106,10 @@
{
$this->template->set_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'));
$this->template->pfp('out','list');
}

View File

@ -0,0 +1,118 @@
<?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$ */
class uimenuclass
{
function uimenuclass()
{
global $phpgw, $phpgw_info;
$this->t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$this->t->set_file(array('menurow' => 'menurow.tpl'));
$this->t->set_block('menurow','menu_links','menu_links');
$this->t->set_block('menurow','link_row','link_row');
$this->rowColor[0] = $phpgw_info["theme"]["row_on"];
$this->rowColor[1] = $phpgw_info["theme"]["row_off"];
}
function section_item($pref_link='',$pref_text='', $bgcolor)
{
global $phpgw, $phpgw_info, $t;
$this->t->set_var('row_link',$pref_link);
$this->t->set_var('row_text',$pref_text);
$this->t->set_var('tr_color',$bgcolor);
$this->t->parse('all_rows','link_row',True);
}
// $file must be in the following format:
// $file = Array(
// 'Login History' => array('/index.php','menuaction=admin.uiaccess_history.list')
// );
// This allows extra data to be sent along
function display_section($_menuData)
{
global $phpgw, $phpgw_info, $account_id;
$i=0;
while(list($key,$value) = each($_menuData))
{
if (!empty($value['extradata']))
{
$link = $phpgw->link($value['url'],'account_id=' . $account_id . '&' . $value['extradata']);
}
else
{
$link = $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('link_done',$phpgw->link('/admin/accounts.php'));
$this->t->set_var('lang_done',lang('back'));
$this->t->set_var('row_on',$this->rowColor[0]);
$this->t->parse("out","menu_links");
return $this->t->get('out','menu_links');
}
// create the html code for the menu
function createHTMLCode($_hookname)
{
global $phpgw, $menuData;
switch ($_hookname)
{
case 'edit_account':
$menuData[] = Array
(
'description' => 'userdata',
'url' => '/admin/editaccount.php',
'extradata' => ''
);
break;
case 'view_account':
$menuData[] = Array
(
'description' => 'userdata',
'url' => '/admin/viewaccount.php',
'extradata' => ''
);
break;
}
$phpgw->common->hook($_hookname);
if (count($menuData) > 1)
{
$result = $this->display_section($menuData);
//clear $menuData
$menuData = '';
return $result;
}
else
{
// clear $menuData
$menuData = '';
return '';
}
}
}
?>

View File

@ -1,8 +1,14 @@
<?php
$title = $appname;
$file = Array(
'Login History' => array('/index.php','menuaction=admin.uiaccess_history.list_history')
// Only Modify the $file and $title variables.....
$data = Array
(
'description' => 'Login History',
'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccess_history.list_history'
);
display_section($appname,$title,$file);
//Do not modify below this line
global $menuData;
$menuData[] = $data;
?>

View File

@ -1,44 +1,46 @@
<!-- BEGIN list -->
<p>
{link_return_to_view_account}
<table border="0" align="center" width="95%">
<tr>
<td align="left">
{lang_last_x_logins}
</td>
<td align="center" colspan="3">
{showing}
</td>
<td align="right">
<table border="0">
<tr>
{nextmatchs_left}
&nbsp;
{nextmatchs_right}
</tr>
</table>
</td>
</tr>
<tr bgcolor="{th_bg}">
<td>{lang_loginid}</td>
<td>{lang_ip}</td>
<td>{lang_login}</td>
<td>{lang_logout}</td>
<td>{lang_total}</td>
</tr>
{rows}
<tr bgcolor="{bg_color}">
<td colspan="5" align="left">{footer_total}</td>
</tr>
<tr bgcolor="{bg_color}">
<td colspan="5" align="left">{lang_percent}</td>
</tr>
</table>
<table border="0" align="center" width="95%">
<tr>
{rows}
<td>
<table border="0" align="center" width="100%">
<tr>
<td align="left">
{lang_last_x_logins}
</td>
<td align="center" colspan="3">
{showing}
</td>
<td align="right">
<table border="0">
<tr>
{nextmatchs_left}&nbsp;{nextmatchs_right}
</tr>
</table>
</td>
</tr>
<tr bgcolor="{th_bg}">
<td>{lang_loginid}</td>
<td>{lang_ip}</td>
<td>{lang_login}</td>
<td>{lang_logout}</td>
<td>{lang_total}</td>
</tr>
{rows_access}
<tr bgcolor="{bg_color}">
<td colspan="5" align="left">{footer_total}</td>
</tr>
<tr bgcolor="{bg_color}">
<td colspan="5" align="left">{lang_percent}</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END list -->
<!-- BEGIN row -->

View File

@ -5,16 +5,7 @@
<center>
<table border="0" width="95%">
<tr>
<td valign="top">
<table border="0" width="100%">
<tr bgcolor="{th_bg}">
<td>&nbsp;</td>
</tr>
{rows}
</table>
</td>
{rows}
<td>
<table border=0 width=100%>

View File

@ -5,34 +5,36 @@
<center>
<table border="0" width="95%">
<tr>
<td valign="top">
{rows}
<td>
<table border="0" width="100%">
<tr bgcolor="{th_bg}">
<td colspan="4">&nbsp;</td>
<td colspan="4">
<b>{lang_action}</b>
</td>
</tr>
<tr bgcolor="{tr_color1}">
<td width="25%">
{lang_loginid}
</td>
<td width="25%">
{account_lid}&nbsp;
</td>
<td width="25%">
{lang_account_active}:
</td>
<td width="25%">
{account_status}
</td>
</tr>
<tr bgcolor="{tr_color2}">
<td>{lang_firstname}</td>
<td>{account_firstname}&nbsp;</td>
<td>{lang_lastname}</td>
<td>{account_lastname}&nbsp;</td>
</tr>
{rows}
</table>
</td>
<td>
<table border="0" width="100%">
<tr bgcolor="{th_bg}">
<td colspan="4"><b>{lang_action}</b></td>
</tr>
<tr bgcolor="{tr_color1}">
<td width="25%">{lang_loginid}</td>
<td width="25%">{account_lid}&nbsp;</td>
<td width="25%">{lang_account_active}:</td>
<td width="25%">{account_status}</td>
</tr>
<tr bgcolor="{tr_color2}">
<td>{lang_firstname}</td>
<td>{account_firstname}&nbsp;</td>
<td>{lang_lastname}</td>
<td>{account_lastname}&nbsp;</td>
</tr>
<tr bgcolor="{tr_color2}">
<td>{lang_homedir}</td>
@ -88,8 +90,3 @@
</tr>
<!-- END form_logininfo -->
<!-- BEGIN link_row -->
<tr bgcolor="{tr_color}">
<td colspan="2">&nbsp;&nbsp;<a href="{row_link}">{row_text}</a></td>
</tr>
<!-- END link_row -->

View File

@ -0,0 +1,27 @@
<!-- BEGIN menu_links -->
<td valign="top" width="140">
<table border="0" width="100%">
<tr bgcolor="{th_bg}">
<td>&nbsp;</td>
</tr>
{all_rows}
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td bgcolor="{row_on}">
&nbsp;&nbsp;<a href="{link_done}">{lang_done}</a>
</td>
</tr>
</table>
</td>
<!-- END menu_links -->
<!-- BEGIN link_row -->
<tr bgcolor="{tr_color}">
<td colspan="2">&nbsp;&nbsp;<a href="{row_link}">{row_text}</a></td>
</tr>
<!-- END link_row -->

View File

@ -225,7 +225,10 @@
$t->set_var('permissions_list',$appRightsOutput);
$phpgw->common->hook('view_account');
// create the menu on the left, if needed
$menuClass = CreateObject('admin.uimenuclass');
$t->set_var('rows',$menuClass->createHTMLCode('view_account'));
$t->pfp('out','form');
$phpgw->common->phpgw_footer();
?>