This will allow admin members to grant group managers to user(s) of a group.

This commit is contained in:
skeeter 2002-01-10 18:18:44 +00:00
parent 813243a9f0
commit 3b71750055
6 changed files with 250 additions and 38 deletions

View File

@ -20,7 +20,8 @@
'delete_group' => True,
'delete_user' => True,
'edit_group' => True,
'edit_user' => True
'edit_user' => True,
'set_group_managers' => True
);
var $xml_functions = array();
@ -550,7 +551,7 @@
}
else
{
ExecMethod('admin.uiaccountsiedit_user',$GLOBALS['HTTP_GET_VARS']['account_id']);
ExecMethod('admin.uiaccounts.edit_user',$GLOBALS['HTTP_GET_VARS']['account_id']);
return False;
}
}
@ -562,6 +563,34 @@
}
}
function set_group_managers()
{
if($GLOBALS['phpgw']->acl->check('group_access',16,'admin') || $GLOBALS['HTTP_POST_VARS']['cancel'])
{
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
$GLOBALS['phpgw']->common->phpgw_exit();
}
elseif($GLOBALS['HTTP_POST_VARS']['submit'])
{
$acl = CreateObject('phpgwapi.acl',intval($GLOBALS['HTTP_POST_VARS']['account_id']));
$users = $GLOBALS['phpgw']->accounts->member($GLOBALS['HTTP_POST_VARS']['account_id']);
@reset($users);
while($managers && list($key,$user) = each($users))
{
$acl->add_repository('phpgw_group',intval($GLOBALS['HTTP_POST_VARS']['account_id']),$user['account_id'],1);
}
$managers = $GLOBALS['HTTP_POST_VARS']['managers'];
@reset($managers);
while($managers && list($key,$manager) = each($managers))
{
$acl->add_repository('phpgw_group',intval($GLOBALS['HTTP_POST_VARS']['account_id']),$manager,(1 + PHPGW_ACL_GROUP_MANAGERS));
}
}
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
$GLOBALS['phpgw']->common->phpgw_exit();
}
function validate_group($group_info)
{
$errors = Array();
@ -770,6 +799,26 @@
return $account_user;
}
function load_group_managers($account_id)
{
$temp_user = $GLOBALS['phpgw']->acl->get_ids_for_location($account_id,PHPGW_ACL_GROUP_MANAGERS,'phpgw_group');
if(!$temp_user)
{
return Array();
}
else
{
$group_user = $temp_user;
}
$account_user = Array();
while (list($key,$user) = each($group_user))
{
$account_user[$user] = ' selected';
}
@reset($account_user);
return $account_user;
}
function load_group_apps($account_id)
{
$apps = CreateObject('phpgwapi.applications',intval($account_id));

View File

@ -22,7 +22,8 @@
'delete_user' => True,
'edit_user' => True,
'edit_group' => True,
'view_user' => True
'view_user' => True,
'group_manager' => True
);
var $bo;
@ -670,6 +671,41 @@
$t->pfp('out','form');
}
function group_manager($cd='',$account_id='')
{
if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin'))
{
$this->list_groups();
return False;
}
$cdid = $cd;
settype($cd,'integer');
$cd = ($GLOBALS['HTTP_GET_VARS']['cd']?$GLOBALS['HTTP_GET_VARS']['cd']:intval($cdid));
$accountid = $account_id;
settype($account_id,'integer');
$account_id = ($GLOBALS['HTTP_GET_VARS']['account_id']?$GLOBALS['HTTP_GET_VARS']['account_id']:intval($accountid));
// todo
// not needed if i use the same file for new groups too
if (! $account_id)
{
$this->list_groups();
}
else
{
$group_info = Array(
'account_id' => intval($GLOBALS['HTTP_GET_VARS']['account_id']),
'account_name' => $GLOBALS['phpgw']->accounts->id2name($GLOBALS['HTTP_GET_VARS']['account_id']),
'account_user' => $GLOBALS['phpgw']->accounts->member($GLOBALS['HTTP_GET_VARS']['account_id']),
'account_managers' => $this->bo->load_group_managers($GLOBALS['HTTP_GET_VARS']['account_id'])
);
$this->edit_group_managers($group_info);
}
}
function create_edit_group($group_info,$_errors='')
{
$apps_with_acl = Array(
@ -771,7 +807,7 @@
. '<td width="5%"><input type="checkbox" name="account_apps['
. $perm_display[$i][0] . ']" value="True"'.($group_info['account_apps'][$app]?' checked':'').'></td><td width="5%">'
.($apps_with_acl[$app] && $group_info['account_id']?'<a href="'.$GLOBALS['phpgw']->link('/preferences/acl_preferences.php','acl_app='.$app.'&owner='.$group_info['account_id'])
.'" target="_blank"><img src="'.$GLOBALS['phpgw']->common->image('admin','dot.gif').'" border="0" hspace="3" align="absmiddle" alt="'
.'" target="_blank"><img src="'.$GLOBALS['phpgw']->common->image('admin','dot').'" border="0" hspace="3" align="absmiddle" alt="'
.lang('Grant Access').'"></a>':'&nbsp;').'</td>'.($i & 1?'</tr>':'')."\n";
}
if($i & 1)
@ -784,6 +820,10 @@
'lang_submit_button' => lang('submit changes')
);
$p->set_var($var);
// create the menu on the left, if needed
$p->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','group_manager'));
$p->pfp('out','form');
}
@ -1045,5 +1085,59 @@
echo $t->fp('out','form');
}
function edit_group_managers($group_info,$_errors='')
{
if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin'))
{
$this->list_groups();
return False;
}
$accounts = CreateObject('phpgwapi.accounts',$group_info['account_id'],'u');
$account_list = $accounts->member($group_info['account_id']);
$user_list = '';
while (list($key,$entry) = each($account_list))
{
$user_list .= '<option value="' . $entry['account_id'] . '"'
. $group_info['account_managers'][intval($entry['account_id'])] . '>'
. $GLOBALS['phpgw']->common->grab_owner_name($entry['account_id'])
. '</option>'."\n";
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw']->common->phpgw_header();
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$t->set_unknowns('remove');
$t->set_file(
Array(
'manager' =>'group_manager.tpl'
)
);
$t->set_block('manager','form','form');
$t->set_block('manager','link_row','link_row');
$var['th_bg'] = $GLOBALS['phpgw_info']['user']['theme']['th_bg'];
$var['lang_group'] = lang('Group');
$var['group_name'] = $group_info['account_name'];
$var['tr_color1'] = $GLOBALS['phpgw_info']['user']['theme']['row_on'];
$var['form_action'] = $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.set_group_managers');
$var['hidden'] = '<input type="hidden" name="account_id" value="'.$group_info['account_id'].'">';
$var['lang_select_managers'] = lang('Select Group Managers');
$var['group_members'] = '<select name="managers[]" size="'.(count($account_list)<5?count($account_list):5).'" multiple>'.$user_list.'</select>';
$var['form_buttons'] = '<tr align="center"><td colspan="2"><input type="submit" name="submit" value="'.lang('Submit').'">&nbsp;&nbsp;'
. '<input type="submit" name="cancel" value="'.lang('Cancel').'"><td></tr>';
$t->set_var($var);
// create the menu on the left, if needed
$t->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','edit_group'));
$t->pfp('out','form');
}
}
?>

View File

@ -61,7 +61,15 @@
$this->t->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
$this->t->set_var('link_done',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_users'));
if(strpos($_userdata[0]['description'],'User'))
{
$destination = 'users';
}
else
{
$destination = 'groups';
}
$this->t->set_var('link_done',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_'.$destination));
$this->t->set_var('lang_done',lang('Back'));
$this->t->set_var('row_on',$this->rowColor[0]);
@ -90,11 +98,25 @@
'extradata' => 'menuaction=admin.uiaccounts.view_user'
);
break;
case 'edit_group':
$GLOBALS['menuData'][] = array(
'description' => 'Edit Group',
'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccounts.edit_group'
);
break;
case 'group_manager':
$GLOBALS['menuData'][] = array(
'description' => 'Group Manager',
'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccounts.group_manager'
);
break;
}
$GLOBALS['phpgw']->hooks->process($_hookname);
if (count($GLOBALS['menuData']) > 1)
if (count($GLOBALS['menuData']) >= 1)
{
$result = $this->display_section($GLOBALS['menuData']);
//clear $menuData

View File

@ -1,38 +1,47 @@
{error}
<table border="0" width="50%" align="center">
<form action="{form_action}" method="POST">
{hidden_vars}
<tr>
<td>{lang_group_name}</td>
<td><input name="account_name" value="{group_name_value}"></td>
</tr>
<tr>
<td>{lang_include_user}</td>
<td><select name="account_user[]" multiple size="{select_size}">
{user_list}
</select>
</td>
</tr>
<tr>
<td>{lang_file_space}</td>
<td>
{account_file_space}{account_file_space_select}
</td>
<tr>
<td valign="top">
{rows}
</td>
<td valign="top">
<table border=0 width=100%>
<form action="{form_action}" method="POST">
{hidden_vars}
<tr>
<td>{lang_group_name}</td>
<td><input name="account_name" value="{group_name_value}"></td>
</tr>
<tr>
<td>{lang_permissions}</td>
<td><table width="100%" border="0" cols="6">
{permissions_list}
</table></td>
</tr>
<tr>
<td>{lang_include_user}</td>
<td><select name="account_user[]" multiple size="{select_size}">
{user_list}
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submit" value="{lang_submit_button}">
</td>
</tr>
</form>
<tr>
<td>{lang_file_space}</td>
<td>
{account_file_space}{account_file_space_select}
</td>
</tr>
<tr>
<td>{lang_permissions}</td>
<td><table width="100%" border="0" cols="6">
{permissions_list}
</table></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submit" value="{lang_submit_button}">
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>

View File

@ -0,0 +1,37 @@
<!-- BEGIN form -->
{error_messages}
<center>
<table border="0" width="70%">
<tr>
<td valign="top">
{rows}
</td>
<td valign="top">
<table border="0" width="100%">
<tr bgcolor="{th_bg}">
<td><b>{lang_group}:</b></td>
<td><b>{group_name}</b></td>
</tr>
<form action="{form_action}" method="post">
{hidden}
<tr bgcolor="{tr_color1}">
<td>{lang_select_managers}</td>
<td>{group_members}</td>
</tr>
{form_buttons}
</form>
</table>
</td>
</tr>
</table>
</center>
<!-- END form -->
<!-- BEGIN link_row -->
<tr bgcolor="{tr_color}">
<td>&nbsp;<a href="{row_link}">{row_text}</a></td>
</tr>
<!-- END link_row -->

View File

@ -708,6 +708,7 @@
define('PHPGW_ACL_EDIT',4);
define('PHPGW_ACL_DELETE',8);
define('PHPGW_ACL_PRIVATE',16);
define('PHPGW_ACL_GROUP_MANAGERS',32);
/****************************************************************************\
* Stuff to use if logging in or logging out *