Added the group suport to this class.

This commit is contained in:
skeeter 2001-09-03 02:58:25 +00:00
parent 0d89f77db7
commit 7e6c8e5ab4
7 changed files with 638 additions and 317 deletions

View File

@ -12,7 +12,9 @@
class boaccounts
{
var $public_functions = array(
'add_group' => True,
'add_user' => True,
'delete_group' => True,
'delete_user' => True,
'edit_group' => True,
'edit_user' => True
@ -30,6 +32,64 @@
return $this->so->account_total($account_type,$query);
}
function delete_group()
{
if (!@isset($GLOBALS['HTTP_POST_VARS']['account_id']) || !@$GLOBALS['HTTP_POST_VARS']['account_id'])
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
$GLOBALS['phpgw']->common->phpgw_exit();
}
if($GLOBALS['HTTP_POST_VARS']['account_id'])
{
$account_id = intval($GLOBALS['HTTP_POST_VARS']['account_id']);
$group_name = $GLOBALS['phpgw']->accounts->id2name($account_id);
$GLOBALS['phpgw']->db->lock(
Array(
'phpgw_accounts',
'phpgw_acl'
)
);
$old_group_list = $GLOBALS['phpgw']->acl->get_ids_for_location($account_id,1,'phpgw_group');
@reset($old_group_list);
while($old_group_list && $id = each($old_group_list))
{
$GLOBALS['phpgw']->acl->delete_repository('phpgw_group',$account_id,intval($id[1]));
}
$GLOBALS['phpgw']->db->query('DELETE FROM phpgw_accounts WHERE account_id='.$account_id,__LINE__,__FILE__);
$GLOBALS['phpgw']->acl->delete_repository('%%','run',$account_id);
if (! @rmdir($GLOBALS['phpgw_info']['server']['files_dir'].SEP.'groups'.SEP.$group_name))
{
$cd = 38;
}
else
{
$cd = 32;
}
$GLOBALS['phpgw']->db->unlock();
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',
Array(
'menuaction' => 'admin.uiaccounts.list_groups',
'cd' => $cd
)
)
);
$GLOBALS['phpgw']->common->phpgw_exit();
}
else
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
$GLOBALS['phpgw']->common->phpgw_exit();
}
}
function delete_user()
{
if(isset($GLOBALS['HTTP_POST_VARS']['cancel']))
@ -84,6 +144,119 @@
}
}
function add_group()
{
$temp_users = ($GLOBALS['HTTP_POST_VARS']['account_user']?$GLOBALS['HTTP_POST_VARS']['account_user']:Array());
$account_user = Array();
@reset($temp_users);
while(list($key,$user_id) = each($temp_users))
{
$account_user[$user_id] = ' selected';
}
@reset($account_user);
$group_permissions = ($GLOBALS['HTTP_POST_VARS']['account_apps']?$GLOBALS['HTTP_POST_VARS']['account_apps']:Array());
$account_apps = Array();
@reset($group_permissions);
while(list($key,$value) = each($group_permissions))
{
if($value)
{
$account_apps[$key] = True;
}
}
@reset($account_apps);
$group_info = Array(
'account_id' => ($GLOBALS['HTTP_POST_VARS']['account_id']?intval($GLOBALS['HTTP_POST_VARS']['account_id']):0),
'account_name' => ($GLOBALS['HTTP_POST_VARS']['account_name']?$GLOBALS['HTTP_POST_VARS']['account_name']:''),
'account_user' => $account_user,
'account_apps' => $account_apps
);
$this->validate_group($group_info);
$GLOBALS['phpgw']->db->lock(
Array(
'phpgw_accounts',
'phpgw_nextid',
'phpgw_preferences',
'phpgw_sessions',
'phpgw_acl',
'phpgw_applications'
)
);
$group = CreateObject('phpgwapi.accounts',$group_info['account_id']);
$account_info = array(
'account_type' => 'g',
'account_lid' => $group_info['account_name'],
'account_passwd' => '',
'account_firstname' => $group_info['account_name'],
'account_lastname' => 'Group',
'account_status' => 'A',
'account_expires' => -1
// 'account_file_space' => $account_file_space_number . "-" . $account_file_space_type,
);
$group->create($account_info);
$group_info['account_id'] = $GLOBALS['phpgw']->accounts->name2id($group_info['account_name']);
$apps = CreateObject('phpgwapi.applications',intval($group_id));
$apps->update_data(Array());
reset($group_info['account_apps']);
while(list($app,$value) = each($group_info['account_apps']))
{
$apps->add($app);
$new_apps[] = $app;
}
$apps->save_repository();
$acl = CreateObject('phpgwapi.acl',$group_info['account_id']);
$acl->read_repository();
@reset($group_info['account_user']);
while(list($user_id,$dummy) = each($group_info['account_user']))
{
$acl->add_repository('phpgw_group',$group_info['account_id'],$user_id,1);
$docommit = False;
$GLOBALS['pref'] = CreateObject('phpgwapi.preferences',$user_id);
$t = $GLOBALS['pref']->read_repository();
@reset($new_apps);
while(list($app_key,$app_name) = each($new_apps))
{
if (!$t[($app_name=='admin'?'common':$app_name)])
{
$GLOBALS['phpgw']->common->hook_single('add_def_pref', $app_name);
$docommit = True;
}
}
if ($docommit)
{
$GLOBALS['pref']->save_repository();
}
}
$basedir = $phpgw_info['server']['files_dir'] . SEP . 'groups' . SEP;
$cd = 31;
umask(000);
if (! @mkdir ($basedir . $group_info['account_name'], 0707))
{
$cd = 37;
}
$GLOBALS['phpgw']->db->unlock();
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',
Array(
'menuaction' => 'admin.uiaccounts.list_groups',
'cd' => $cd
)
)
);
$GLOBALS['phpgw']->common->phpgw_exit();
}
function add_user()
{
if ($GLOBALS['HTTP_POST_VARS']['submit'])
@ -232,33 +405,36 @@
function edit_group()
{
$account_id = ($GLOBALS['HTTP_POST_VARS']['account_id']?$GLOBALS['HTTP_POST_VARS']['account_id']:0);
$group_name = ($GLOBALS['HTTP_POST_VARS']['n_group']?$GLOBALS['HTTP_POST_VARS']['n_group']:'');
$group_permissions = ($GLOBALS['HTTP_POST_VARS']['n_group_permissions']?$GLOBALS['HTTP_POST_VARS']['n_group_permissions']:Array());
$group_users = ($GLOBALS['HTTP_POST_VARS']['n_users']?$GLOBALS['HTTP_POST_VARS']['n_users']:Array());
$group = CreateObject('phpgwapi.accounts',intval($account_id));
$group->read_repository();
$old_group_name = $group->id2name($account_id);
if($group_name != $old_group_name)
$temp_users = ($GLOBALS['HTTP_POST_VARS']['account_user']?$GLOBALS['HTTP_POST_VARS']['account_user']:Array());
$account_user = Array();
@reset($temp_users);
while(list($key,$user_id) = each($temp_users))
{
if ($group->exists($group_name))
$account_user[$user_id] = ' selected';
}
@reset($account_user);
$group_permissions = ($GLOBALS['HTTP_POST_VARS']['account_apps']?$GLOBALS['HTTP_POST_VARS']['account_apps']:Array());
$account_apps = Array();
@reset($group_permissions);
while(list($key,$value) = each($group_permissions))
{
if($value)
{
$error = lang('Sorry, that group name has already been taken.');
$ui = createobject('admin.uiaccounts');
$ui->edit_group($account_id,$errors);
$GLOBALS['phpgw']->common->phpgw_exit();
$account_apps[$key] = True;
}
}
@reset($account_apps);
/*
if (preg_match ("/\D/", $account_file_space_number))
{
$error = lang ('File space must be an integer');
}
*/
$group_info = Array(
'account_id' => ($GLOBALS['HTTP_POST_VARS']['account_id']?intval($GLOBALS['HTTP_POST_VARS']['account_id']):0),
'account_name' => ($GLOBALS['HTTP_POST_VARS']['account_name']?$GLOBALS['HTTP_POST_VARS']['account_name']:''),
'account_user' => $account_user,
'account_apps' => $account_apps
);
$this->validate_group($group_info);
// Lock tables
$GLOBALS['phpgw']->db->lock(
Array(
@ -272,74 +448,89 @@
)
);
$group = CreateObject('phpgwapi.accounts',$group_info['account_id']);
$old_group_info = $group->read_repository();
// Set group apps
$apps = CreateObject('phpgwapi.applications',intval($GLOBALS['HTTP_POST_VARS']['account_id']));
$apps = CreateObject('phpgwapi.applications',$group_info['account_info']);
$apps_before = $apps->read_account_specific();
$apps->update_data(Array());
$new_apps = Array();
if(isset($group_permissions))
if(count($group_info['account_apps']))
{
reset($group_permissions);
while($app = each($group_permissions))
reset($group_info['account_apps']);
while(list($app,$value) = each($group_info['account_apps']))
{
if($app[1])
$apps->add($app);
if(!@$apps_before[$app] || @$apps_before == False)
{
$apps->add($app[0]);
if(!@$apps_before[$app[0]] || @$apps_before == False)
{
$new_apps[] = $app[0];
}
$new_apps[] = $app;
}
}
}
$apps->save_repository();
// Set new account_lid, if needed
if($old_group_name <> $group_name)
if($old_group_info['account_lid'] <> $group_info['account_name'])
{
$group->data['account_lid'] = $group_name;
$group->data['account_lid'] = $group_info['account_name'];
$basedir = $GLOBALS['phpgw_info']['server']['files_dir'] . SEP . 'groups' . SEP;
if (! @rename($basedir . $old_group_info['account_lid'], $basedir . $group_info['account_name']))
{
$cd = 39;
}
else
{
$cd = 33;
}
}
else
{
$cd = 33;
}
// Set group acl
$acl = CreateObject('phpgwapi.acl',$account_id);
$acl = CreateObject('phpgwapi.acl',$group_info['account_id']);
$acl->read_repository();
$old_group_list = $acl->get_ids_for_location($account_id,1,'phpgw_group');
$old_group_list = $acl->get_ids_for_location($group_info['account_id'],1,'phpgw_group');
@reset($old_group_list);
while($old_group_list && $user_id = each($old_group_list))
while($old_group_list && list($key,$user_id) = each($old_group_list))
{
$acl->delete_repository('phpgw_group',$account_id,$user_id[1]);
$acl->delete_repository('phpgw_group',$account_id,$user_id);
if(!$group_info['account_user'][$user_id])
{
// If the user is logged in, it will force a refresh of the session_info
$GLOBALS['phpgw']->db->query("update phpgw_sessions set session_action='' "
."where session_lid='" . $GLOBALS['phpgw']->accounts->id2name($user_id)
. '@' . $GLOBALS['phpgw_info']['user']['domain'] . "'",__LINE__,__FILE__);
}
}
for ($i=0; $i<count($group_users);$i++)
@reset($group_info['account_user']);
while(list($user_id,$dummy) = each($group_info['account_user']))
{
$acl->add_repository('phpgw_group',$account_id,$group_users[$i],1);
$acl->add_repository('phpgw_group',$group_info['account_id'],$user_id,1);
// If the user is logged in, it will force a refresh of the session_info
$GLOBALS['phpgw']->db->query("update phpgw_sessions set session_action='' "
."where session_lid='" . $GLOBALS['phpgw']->accounts->id2name(intval($group_users[$i]))
."where session_lid='" . $GLOBALS['phpgw']->accounts->id2name($user_id)
. '@' . $GLOBALS['phpgw_info']['user']['domain'] . "'",__LINE__,__FILE__);
// The following sets any default preferences needed for new applications..
// This is smart enough to know if previous preferences were selected, use them.
$docommit = False;
if($new_apps)
{
$GLOBALS['pref'] = CreateObject('phpgwapi.preferences',intval($group_users[$i]));
$GLOBALS['pref'] = CreateObject('phpgwapi.preferences',$user_id);
$t = $GLOBALS['pref']->read_repository();
for ($j=1;$j<count($new_apps) - 1;$j++)
@reset($new_apps);
while(list($app_key,$app_name) = each($new_apps))
{
if($new_apps[$j]=='admin')
if (!$t[($app_name=='admin'?'common':$app_name)])
{
$check = 'common';
}
else
{
$check = $new_apps[$j];
}
if (!$t[$check])
{
$GLOBALS['phpgw']->common->hook_single('add_def_pref', $new_apps[$j]);
$GLOBALS['phpgw']->common->hook_single('add_def_pref', $app_name);
$docommit = True;
}
}
@ -361,23 +552,6 @@
$group->save_repository();
*/
if ($old_group_name <> $group_name)
{
$basedir = $GLOBALS['phpgw_info']['server']['files_dir'] . SEP . 'groups' . SEP;
if (! @rename($basedir . $old_group_name, $basedir . $group_name))
{
$cd = 39;
}
else
{
$cd = 33;
}
}
else
{
$cd = 33;
}
$GLOBALS['phpgw']->db->unlock();
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',
@ -451,6 +625,40 @@
}
}
function validate_group($group_info)
{
$errors = Array();
$group = CreateObject('phpgwapi.accounts',$group_info['account_id']);
$group->read_repository();
if(!$group_info['account_name'])
{
$errors[] = lang('You must enter a group name.');
}
if($group_info['account_name'] != $group->id2name($group_info['account_id']))
{
if ($group->exists($group_info['account_name']))
{
$errors[] = lang('Sorry, that group name has already been taken.');
}
}
/*
if (preg_match ("/\D/", $account_file_space_number))
{
$errors[] = lang ('File space must be an integer');
}
*/
if(count($errors))
{
$ui = createobject('admin.uiaccounts');
$ui->create_edit_group($group_info,$errors);
$GLOBALS['phpgw']->common->phpgw_exit();
}
}
/* checks if the userdata are valid
returns FALSE if the data are correct
otherwise the error array
@ -566,9 +774,11 @@
$account = CreateObject('phpgwapi.accounts',$_userData['account_id']);
$allGroups = $account->get_list('groups');
if ($_userData['account_groups']) {
if ($_userData['account_groups'])
{
reset($_userData['account_groups']);
while (list($key,$value) = each($_userData['account_groups'])) {
while (list($key,$value) = each($_userData['account_groups']))
{
$newGroups[$value] = $value;
}
}
@ -592,5 +802,31 @@
}
$GLOBALS['phpgw']->session->delete_cache(intval($_userData['account_id']));
}
function load_group_users($account_id)
{
$group_user = $GLOBALS['phpgw']->acl->get_ids_for_location($account_id,1,'phpgw_group');
if (!$group_user) { $group_user = array(); }
$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));
$app_list = $apps->read_account_specific();
$account_apps = Array();
while(list($key,$app) = each($app_list))
{
$account_apps[$app['name']] = True;
}
@reset($account_apps);
return $account_apps;
}
}
?>

View File

@ -13,14 +13,15 @@
{
var $public_functions = array(
'list_users' => True,
'list_groups' => True,
'add_user' => True,
'delete_group' => True,
'delete_user' => True,
'edit_user' => True,
'edit_group' => True,
'view_user' => True
'list_groups' => True,
'list_users' => True,
'add_group' => True,
'add_user' => True,
'delete_group' => True,
'delete_user' => True,
'edit_user' => True,
'edit_group' => True,
'view_user' => True
);
var $bo;
@ -40,6 +41,76 @@
)).'"> '.lang($action).' </a>';
}
function list_groups()
{
if(!$param_cd)
{
$cd = $param_cd;
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw']->common->phpgw_header();
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(
array(
'groups' => 'groups.tpl'
)
);
$p->set_block('groups','list','list');
$p->set_block('groups','row','row');
$p->set_block('groups','row_empty','row_empty');
$total = $this->bo->account_total('g',$query);
$url = $GLOBALS['phpgw']->link('/index.php');
$var = Array(
'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
'left_next_matchs' => $this->nextmatchs->left('/index.php',$start,$total,'menuaction=admin.uiaccounts.list_groups'),
'right_next_matchs' => $this->nextmatchs->right('/admin/groups.php',$start,$total,'menuaction=admin.uiaccounts.list_groups'),
'lang_groups' => lang('user groups'),
'sort_name' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('name'),'menuaction=admin.uiaccounts.list_groups'),
'header_edit' => lang('Edit'),
'header_delete' => lang('Delete')
);
$p->set_var($var);
$account_info = $GLOBALS['phpgw']->accounts->get_list('groups',$start,$sort, $order, $query, $total);
if (!count($account_info))
{
$p->set_var('message',lang('No matchs found'));
$p->parse('rows','row_empty',True);
}
else
{
while (list($null,$account) = each($account_info))
{
$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
$var = Array(
'tr_color' => $tr_color,
'group_name' => (!$account['account_lid']?'&nbsp;':$account['account_lid']),
'edit_link' => $this->row_action('edit','group',$account['account_id']),
'delete_link' => $this->row_action('delete','group',$account['account_id'])
);
$p->set_var($var);
$p->parse('rows','row',True);
}
}
$var = Array(
'new_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.add_group'),
'lang_add' => lang('add'),
'search_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'),
'lang_search' => lang('search')
);
$p->set_var($var);
$p->pparse('out','list');
}
function list_users($param_cd='')
{
if(!$param_cd)
@ -113,11 +184,96 @@
$p->pparse('out','list');
}
function add_group()
{
$group_info = Array(
'account_id' => $GLOBALS['HTTP_GET_VARS']['account_id'],
'account_name' => '',
'account_user' => Array(),
'account_apps' => Array()
);
$this->create_edit_group($group_info);
}
function add_user()
{
$this->create_edit_user(0);
}
function delete_group()
{
if (!@isset($GLOBALS['HTTP_GET_VARS']['account_id']) || !@$GLOBALS['HTTP_GET_VARS']['account_id'])
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw']->common->phpgw_header();
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(
Array(
'body' => 'delete_common.tpl',
'message_row' => 'message_row.tpl',
'form_button' => 'form_button_script.tpl'
)
);
$p->set_var('message_display',lang('Are you sure you want to delete this group ?'));
$p->parse('messages','message_row');
$old_group_list = $GLOBALS['phpgw']->acl->get_ids_for_location(intval($GLOBALS['HTTP_GET_VARS']['account_id']),1,'phpgw_group');
if($old_group_list)
{
$group_name = $GLOBALS['phpgw']->accounts->id2name($GLOBALS['HTTP_GET_VARS']['account_id']);
$p->set_var('message_display','<br>');
$p->parse('messages','message_row',True);
$user_list = '';
while (list(,$id) = each($old_group_list))
{
$user_list .= '<a href="' . $GLOBALS['phpgw']->link('/index.php',
Array(
'menuaction' => 'admin.uiaccounts.edit_user',
'account_id' => $id
)
) . '">' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</a><br>';
}
$p->set_var('message_display',$user_list);
$p->parse('messages','message_row',True);
$p->set_var('message_display',lang("Sorry, the above users are still a member of the group x",$group_name)
. '.<br>' . lang('They must be removed before you can continue'). '.<br>' . lang('Remove all users from this group').'?');
$p->parse('messages','message_row',True);
}
$var = Array(
'submit_button' => lang('Submit'),
'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.delete_group'),
'action_text_button' => lang('Yes'),
'action_confirm_button' => '',
'action_extra_field' => '<input type="hidden" name="account_id" value="'.$GLOBALS['HTTP_GET_VARS']['account_id'].'">'."\n"
);
$p->set_var($var);
$p->parse('yes','form_button');
$var = Array(
'submit_button' => lang('Submit'),
'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'),
'action_text_button' => ' '.lang('No'),
'action_confirm_button' => '',
'action_extra_field' => ''
);
$p->set_var($var);
$p->parse('no','form_button');
$p->pparse('out','body');
}
function delete_user()
{
@ -161,6 +317,35 @@
$t->pparse('out','form');
}
function edit_group($cd='',$account_id='')
{
$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 users too
if (!$account_id)
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
}
else
{
$group_info = Array(
'account_id' => $GLOBALS['HTTP_GET_VARS']['account_id'],
'account_name' => $GLOBALS['phpgw']->accounts->id2name($GLOBALS['HTTP_GET_VARS']['account_id']),
'account_user' => $this->bo->load_group_users($GLOBALS['HTTP_GET_VARS']['account_id']),
'account_apps' => $this->bo->load_group_apps($GLOBALS['HTTP_GET_VARS']['account_id'])
);
$this->create_edit_group($group_info);
}
}
function edit_user($cd='',$account_id='')
{
$cdid = $cd;
@ -340,6 +525,123 @@
$t->pfp('out','form');
}
function create_edit_group($group_info,$_errors='')
{
$apps_with_acl = Array(
'addressbook' => True,
'todo' => True,
'calendar' => True,
'notes' => True,
'projects' => True,
'phonelog' => True,
'infolog' => True,
'phpwebhosting' => True
);
$sbox = createobject('phpgwapi.sbox');
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw']->common->phpgw_header();
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(
Array(
'form' => 'group_form.tpl'
)
);
$accounts = CreateObject('phpgwapi.accounts',$group_info['account_id']);
$account_list = $accounts->get_list('accounts');
$account_num = count($account_list);
$user_list = '';
while (list($key,$entry) = each($account_list))
{
$user_list .= '<option value="' . $entry['account_id'] . '"'
. $group_info['account_user'][intval($entry['account_id'])] . '>'
. $GLOBALS['phpgw']->common->display_fullname(
$entry['account_lid'],
$entry['account_firstname'],
$entry['account_lastname'])
. '</option>'."\n";
}
$var = Array(
'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.'.($group_info['account_id']?'edit':'add').'_group'),
'hidden_vars' => '<input type="hidden" name="account_id" value="' . $group_info['account_id'] . '">',
'lang_group_name' => lang('group name'),
'group_name_value' => $group_info['account_name'],
'lang_include_user' => lang('Select users for inclusion'),
'error' => (!$_errors?'':'<center>'.$GLOBALS['phpgw']->common->error_list($_errors).'</center>'),
'select_size' => ($account_num < 5?$account_num:5),
'user_list' => $user_list,
'lang_permissions' => lang('Permissions this group has')
);
$p->set_var($var);
$group_repository = $accounts->read_repository ();
if (!$group_repository['file_space'])
{
$group_repository['file_space'] = $GLOBALS['phpgw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['phpgw_info']['server']['vfs_default_account_size_type'];
}
/*
$file_space_array = explode ('-', $group_repository['file_space']);
$account_file_space_types = array ('gb', 'mb', 'kb', 'b');
while (list ($num, $type) = each ($account_file_space_types))
{
$account_file_space_select .= '<option value="'.$type.'"'.($type==$file_space_array[1]?' selected':'').'>'.strtoupper ($type).'</option>'."\n";
}
$p->set_var ('lang_file_space', lang('File space'));
$p->set_var ('account_file_space', '<input type=text name="account_file_space_number" value="'.trim($file_space_array[0]).'" size="7">');
$p->set_var ('account_file_space_select','<select name="account_file_space_type">'."\n".$account_file_space_select.'</select>'."\n");
*/
reset($GLOBALS['phpgw_info']['apps']);
$sorted_apps = $GLOBALS['phpgw_info']['apps'];
@asort($sorted_apps);
@reset($sorted_apps);
while ($permission = each($sorted_apps))
{
if ($permission[1]['enabled'] && $permission[1]['status'] != 3)
{
$perm_display[] = Array(
$permission[0],
$permission[1]['title']
);
}
}
$perm_html = '';
$tr_color = $GLOBALS['phpgw_info']['theme']['row_off'];
for ($i=0;$perm_display[$i][1];$i++)
{
$app = $perm_display[$i][0];
if(!($i & 1))
{
$tr_color = $this->nextmatchs->alternate_row_color();
$perm_html .= '<tr bgcolor="'.$tr_color.'">';
}
$perm_html .= '<td width="40%">' . lang($perm_display[$i][1]) . '</td>'
. '<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="'
.lang('Grant Access').'"></a>':'&nbsp;').'</td>'.($i & 1?'</tr>':'');
}
if($i & 1)
{
$perm_html .= '<td colspan="4">&nbsp;</td></tr>';
}
$var = Array(
'permissions_list' => $perm_html,
'lang_submit_button' => lang('submit changes')
);
$p->set_var($var);
$p->pfp('out','form');
}
function create_edit_user($_account_id,$_userData='',$_errors='')
{
$sbox = createobject('phpgwapi.sbox');
@ -584,228 +886,5 @@
echo $t->fp('out','form');
}
function list_groups()
{
if(!$param_cd)
{
$cd = $param_cd;
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw']->common->phpgw_header();
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(
array(
'groups' => 'groups.tpl'
)
);
$p->set_block('groups','list','list');
$p->set_block('groups','row','row');
$p->set_block('groups','row_empty','row_empty');
$total = $this->bo->account_total('g',$query);
$url = $GLOBALS['phpgw']->link('/index.php');
$var = Array(
'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
'left_next_matchs' => $this->nextmatchs->left('/index.php',$start,$total,'menuaction=admin.uiaccounts.list_groups'),
'right_next_matchs' => $this->nextmatchs->right('/admin/groups.php',$start,$total,'menuaction=admin.uiaccounts.list_groups'),
'lang_groups' => lang('user groups'),
'sort_name' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('name'),'menuaction=admin.uiaccounts.list_groups'),
'header_edit' => lang('Edit'),
'header_delete' => lang('Delete')
);
$p->set_var($var);
$account_info = $GLOBALS['phpgw']->accounts->get_list('groups',$start,$sort, $order, $query, $total);
if (!count($account_info))
{
$p->set_var('message',lang('No matchs found'));
$p->parse('rows','row_empty',True);
}
else
{
while (list($null,$account) = each($account_info))
{
$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
$var = Array(
'tr_color' => $tr_color,
'group_name' => (!$account['account_lid']?'&nbsp;':$account['account_lid']),
'edit_link' => $this->row_action('edit','group',$account['account_id']),
'delete_link' => $this->row_action('delete','group',$account['account_id'])
);
$p->set_var($var);
$p->parse('rows','row',True);
}
}
$var = Array(
'new_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.add_group'),
'lang_add' => lang('add'),
'search_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'),
'lang_search' => lang('search')
);
$p->set_var($var);
$p->pparse('out','list');
}
function edit_group($cd='',$account_id='')
{
$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 users too
if (!$account_id)
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
}
else
{
$this->create_edit_group($account_id);
}
}
function create_edit_group($account_id,$_errors='')
{
$apps_with_acl = Array(
'addressbook' => True,
'todo' => True,
'calendar' => True,
'notes' => True,
'projects' => True,
'phonelog' => True,
'infolog' => True,
'phpwebhosting' => True
);
$sbox = createobject('phpgwapi.sbox');
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw']->common->phpgw_header();
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(
Array(
'form' => 'group_form.tpl'
)
);
$group_user = $GLOBALS['phpgw']->acl->get_ids_for_location($account_id,1,'phpgw_group');
if (!$group_user) { $group_user = array(); }
while ($user = each($group_user))
{
$selected_users[intval($user[1])] = ' selected';
}
$apps = CreateObject('phpgwapi.applications',intval($account_id));
$db_perms = $apps->read_account_specific();
$accounts = CreateObject('phpgwapi.accounts',intval($account_id));
$account_list = $accounts->get_list('accounts');
$account_num = count($account_list);
$user_list = '';
while (list($key,$entry) = each($account_list))
{
$user_list .= '<option value="' . $entry['account_id'] . '"'
. $selected_users[intval($entry['account_id'])] . '>'
. $GLOBALS['phpgw']->common->display_fullname(
$entry['account_lid'],
$entry['account_firstname'],
$entry['account_lastname'])
. '</option>'."\n";
}
$var = Array(
'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.'.($account_id?'edit':'add').'_group'),
'hidden_vars' => '<input type="hidden" name="account_id" value="' . $account_id . '">',
'lang_group_name' => lang('group name'),
'group_name_value' => $GLOBALS['phpgw']->accounts->id2name($account_id),
'lang_include_user' => lang('Select users for inclusion'),
'error' => (!$_errors?'':'<center>'.$GLOBALS['phpgw']->common->error_list($_errors).'</center>'),
'select_size' => ($account_num < 5?$account_num:5),
'user_list' => $user_list,
'lang_permissions' => lang('Permissions this group has')
);
$p->set_var($var);
$group_repository = $accounts->read_repository ();
if (!$group_repository['file_space'])
{
$group_repository['file_space'] = $GLOBALS['phpgw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['phpgw_info']['server']['vfs_default_account_size_type'];
}
/*
$file_space_array = explode ("-", $group_repository['file_space']);
$account_file_space_types = array ('gb', 'mb', 'kb', 'b');
while (list ($num, $type) = each ($account_file_space_types))
{
$account_file_space_select .= '<option value="'.$type.'"'.($type==$file_space_array[1]?' selected':'').'>'.strtoupper ($type).'</option>'."\n";
}
$p->set_var ('lang_file_space', lang('File space'));
$p->set_var ('account_file_space', '<input type=text name="account_file_space_number" value="'.trim($file_space_array[0]).'" size="7">');
$p->set_var ('account_file_space_select','<select name="account_file_space_type">'."\n".$account_file_space_select.'</select>'."\n");
*/
$i = 0;
reset($GLOBALS['phpgw_info']['apps']);
$sorted_apps = $GLOBALS['phpgw_info']['apps'];
@asort($sorted_apps);
@reset($sorted_apps);
while ($permission = each($sorted_apps))
{
if ($permission[1]['enabled'] && $permission[1]['status'] != 3)
{
$perm_display[$i][0] = $permission[0];
$perm_display[$i][1] = $permission[1]['title'];
$i++;
}
}
$perm_html = '';
$tr_color = $GLOBALS['phpgw_info']['theme']['row_off'];
for ($i=0;$perm_display[$i][1];$i++)
{
$app = $perm_display[$i][0];
if(!($i & 1))
{
$tr_color = $this->nextmatchs->alternate_row_color();
$perm_html .= '<tr bgcolor="'.$tr_color.'">';
}
$perm_html .= '<td width="40%">' . lang($perm_display[$i][1]) . '</td>'
. '<td width="5%"><input type="checkbox" name="n_group_permissions['
. $perm_display[$i][0] . ']" value="True"'.($n_group_permissions[$app] || $db_perms[$app]?' checked':'').'></td><td width="5%">'
.($apps_with_acl[$app]?'<a href="'.$GLOBALS['phpgw']->link('/preferences/acl_preferences.php','acl_app='.$app.'&owner='.$account_id).'" target="_blank"><img src="'.$GLOBALS['phpgw']->common->image('admin','dot.gif').'" border="0" hspace="3" align="absmiddle" alt="'.lang('Grant Access').'"></a>':'&nbsp;')
.'</td>'.($i & 1?'</tr>':'');
}
if($i & 1)
{
$perm_html .= '<td colspan="4">&nbsp;</td></tr>';
}
$var = Array(
'permissions_list' => $perm_html,
'lang_submit_button' => lang('submit changes')
);
$p->set_var($var);
$p->pfp('out','form');
}
function delete_group()
{
}
}
?>

View File

@ -15,7 +15,7 @@
'Site Configuration' => $phpgw->link('/admin/config.php','appname=admin'),
'Peer Servers' => $phpgw->link('/admin/servers.php'),
'User Accounts' => $phpgw->link('/index.php','menuaction=admin.uiaccounts.list_users'),
'User Groups' => $phpgw->link('/admin/groups.php'),
'User Groups' => $phpgw->link('/index.php','menuaction=admin.uiaccounts.list_groups'),
'Applications' => $phpgw->link('/admin/applications.php'),
'Global Categories' => $phpgw->link('/admin/categories.php'),
'Change Main Screen Message' => $phpgw->link('/admin/mainscreen_message.php'),

View File

@ -1,14 +1,14 @@
<!-- BEGIN form -->
<center>
<table border="0" with="65%">
<table align="center" border="0" width="55%" cols="2">
{messages}
<tr>
<td colspan="2" align="center">
{messages}
<td width="50%" align="center">
{no}
</td>
<td width="50%" align="center">
{yes}
</td>
</tr>
<tr>
<td align="center">{no}</td>
<td align="center">{yes}</td>
</tr>
</table>
</center>

View File

@ -0,0 +1,6 @@
<!-- $Id$ -->
<!-- BEGIN form_button -->
<form action="{action_url_button}" method="post" name="{action_text_button}form">
{action_extra_field} <input type="submit" value="{action_text_button}" {action_confirm_button}>
</form>
<!-- END form_button -->

View File

@ -4,12 +4,12 @@
{hidden_vars}
<tr>
<td>{lang_group_name}</td>
<td><input name="n_group" value="{group_name_value}"></td>
<td><input name="account_name" value="{group_name_value}"></td>
</tr>
<tr>
<td>{lang_include_user}</td>
<td><select name="n_users[]" multiple size="{select_size}">
<td><select name="account_user[]" multiple size="{select_size}">
{user_list}
</select>
</td>

View File

@ -1,5 +1,5 @@
<!-- BEGIN message_row -->
<tr colspan="2">
<td align="center">{message_display}<td>
<tr>
<td colspan="2" align="center">{message_display}<td>
</tr>
<!-- END message_row -->