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,
'group_manager' => True
);
var $bo;
var $nextmatchs;
function uiaccounts()
{
$this->bo = createobject('admin.boaccounts');
$this->nextmatchs = createobject('phpgwapi.nextmatchs');
@set_time_limit(300);
}
function row_action($action,$type,$account_id)
{
return ' '.lang($action).' ';
}
function list_groups()
{
if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin'))
{
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php'));
}
$query = (isset($GLOBALS['HTTP_POST_VARS']['query'])?$GLOBALS['HTTP_POST_VARS']['query']:'');
$GLOBALS['cd'] = ($GLOBALS['HTTP_GET_VARS']['cd']?$GLOBALS['HTTP_GET_VARS']['cd']:0);
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');
if ($GLOBALS['phpgw']->acl->check('group_access',2,'admin'))
{
$account_info = $GLOBALS['phpgw']->accounts->get_list('groups',$start,$sort, $order, $query, $total);
$total = $GLOBALS['phpgw']->accounts->total;
}
else
{
$account_info = $GLOBALS['phpgw']->accounts->get_list('groups',$start,$sort, $order, $query, $total);
$total = $GLOBALS['phpgw']->accounts->total;
}
$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'),
'lang_done' => lang('Done'),
'doneurl' => $GLOBALS['phpgw']->link('/admin/index.php')
);
$p->set_var($var);
if (!count($account_info) || !$total)
{
$p->set_var('message',lang('No matches found'));
$p->parse('rows','row_empty',True);
}
else
{
if (! $GLOBALS['phpgw']->acl->check('group_access',8,'admin'))
{
$can_view = True;
}
if (! $GLOBALS['phpgw']->acl->check('group_access',16,'admin'))
{
$can_edit = True;
}
if (! $GLOBALS['phpgw']->acl->check('group_access',32,'admin'))
{
$can_delete = True;
}
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']?' ':$account['account_lid']),
'delete_link' => $this->row_action('delete','group',$account['account_id'])
);
$p->set_var($var);
if ($can_edit)
{
$p->set_var('edit_link',$this->row_action('edit','group',$account['account_id']));
}
else
{
$p->set_var('edit_link',' ');
}
if ($can_delete)
{
$p->set_var('delete_link',$this->row_action('delete','group',$account['account_id']));
}
else
{
$p->set_var('delete_link',' ');
}
$p->fp('rows','row',True);
}
}
$var = Array(
'new_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.add_group'),
'search_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups')
);
$p->set_var($var);
if (! $GLOBALS['phpgw']->acl->check('group_access',4,'admin'))
{
$p->set_var('input_add','');
}
if (! $GLOBALS['phpgw']->acl->check('group_access',2,'admin'))
{
$p->set_var('input_search',lang('Search') . ' ');
}
$p->pfp('out','list');
}
function list_users($param_cd='')
{
if ($GLOBALS['phpgw']->acl->check('account_access',1,'admin'))
{
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php'));
}
if($param_cd)
{
$cd = $param_cd;
}
$GLOBALS['query'] = (isset($GLOBALS['HTTP_POST_VARS']['query'])?$GLOBALS['HTTP_POST_VARS']['query']:'');
$start = (isset($GLOBALS['HTTP_POST_VARS']['start'])?intval($GLOBALS['HTTP_POST_VARS']['start']):'');
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(
'accounts' => 'accounts.tpl'
)
);
$p->set_block('accounts','list','list');
$p->set_block('accounts','row','row');
$p->set_block('accounts','row_empty','row_empty');
if ($GLOBALS['phpgw']->acl->check('account_access',2,'admin'))
{
$account_info = $GLOBALS['phpgw']->accounts->get_list('accounts',$start,$sort,$order,$GLOBALS['query'],$total);
$total = $GLOBALS['phpgw']->accounts->total;
}
else
{
$account_info = $GLOBALS['phpgw']->accounts->get_list('accounts',$start,$sort,$order,$GLOBALS['query'],$total);
$total = $GLOBALS['phpgw']->accounts->total;
}
$url = $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_users');
$var = Array(
'bg_color' => $GLOBALS['phpgw_info']['theme']['bg_color'],
'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
'left_next_matchs' => $this->nextmatchs->left($url,$start,$total,'menuaction=admin.uiaccounts.list_users'),
'lang_user_accounts' => lang('user accounts'),
'right_next_matchs' => $this->nextmatchs->right($url,$start,$total,'menuaction=admin.uiaccounts.list_users'),
'lang_loginid' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,$url,lang('LoginID')),
'lang_lastname' => $this->nextmatchs->show_sort_order($sort,'account_lastname',$order,$url,lang('last name')),
'lang_firstname' => $this->nextmatchs->show_sort_order($sort,'account_firstname',$order,$url,lang('first name')),
'lang_edit' => lang('edit'),
'lang_delete' => lang('delete'),
'lang_view' => lang('view'),
'actionurl' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.add_user'),
'accounts_url' => $url,
'lang_search' => lang('search'),
'lang_done' => lang('Done'),
'doneurl' => $GLOBALS['phpgw']->link('/admin/index.php')
);
$p->set_var($var);
if (! $GLOBALS['phpgw']->acl->check('account_access',4,'admin'))
{
$p->set_var('input_add','');
}
if (! $GLOBALS['phpgw']->acl->check('account_access',2,'admin'))
{
$p->set_var('input_search',lang('Search') . ' ');
}
if (!count($account_info) || !$total)
{
$p->set_var('message',lang('No matches found'));
$p->parse('rows','row_empty',True);
}
else
{
if (! $GLOBALS['phpgw']->acl->check('account_access',8,'admin'))
{
$can_view = True;
}
if (! $GLOBALS['phpgw']->acl->check('account_access',16,'admin'))
{
$can_edit = True;
}
if (! $GLOBALS['phpgw']->acl->check('account_access',32,'admin'))
{
$can_delete = True;
}
while (list($null,$account) = each($account_info))
{
$this->nextmatchs->template_alternate_row_color($p);
$var = array(
'row_loginid' => $account['account_lid'],
'row_firstname' => (!$account['account_firstname']?' ':$account['account_firstname']),
'row_lastname' => (!$account['account_lastname']?' ':$account['account_lastname'])
);
$p->set_var($var);
if ($can_edit)
{
$p->set_var('row_edit',$this->row_action('edit','user',$account['account_id']));
}
else
{
$p->set_var('row_edit',' ');
}
if ($can_delete)
{
$p->set_var('row_delete',($GLOBALS['phpgw_info']['user']['userid'] != $account['account_lid']?$this->row_action('delete','user',$account['account_id']):' '));
}
else
{
$p->set_var('row_delete',' ');
}
if ($can_view)
{
$p->set_var('row_view',$this->row_action('view','user',$account['account_id']));
}
else
{
$p->set_var('row_view',' ');
}
$p->parse('rows','row',True);
}
} // End else
$p->pfp('out','list');
}
function add_group()
{
if ($GLOBALS['phpgw']->acl->check('group_access',4,'admin'))
{
$this->list_groups();
return False;
}
$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()
{
if ($GLOBALS['phpgw']->acl->check('account_access',4,'admin'))
{
$this->list_users();
}
else
{
$this->create_edit_user(0);
}
}
function delete_group()
{
if (!@isset($GLOBALS['HTTP_GET_VARS']['account_id']) || !@$GLOBALS['HTTP_GET_VARS']['account_id'] || $GLOBALS['phpgw']->acl->check('group_access',32,'admin'))
{
$this->list_groups();
return False;
}
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','
');
$p->parse('messages','message_row',True);
$user_list = '';
while (list(,$id) = each($old_group_list))
{
$user_list .= '' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '
';
}
$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)
. '.
' . lang('They must be removed before you can continue'). '.
' . 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' => ''."\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()
{
if ($GLOBALS['phpgw']->acl->check('account_access',32,'admin') || $GLOBALS['phpgw_info']['user']['account_id'] == $GLOBALS['HTTP_GET_VARS']['account_id'])
{
$this->list_users();
return False;
}
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_file(
Array(
'form' => 'delete_account.tpl'
)
);
$var = Array(
'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.delete_user'),
'account_id' => $GLOBALS['HTTP_GET_VARS']['account_id']
);
// the account can have special chars/white spaces, if it is a ldap dn
$account_id = rawurlencode($GLOBALS['HTTP_GET_VARS']['account_id']);
// Find out who the new owner is of the deleted users records...
$users = $GLOBALS['phpgw']->accounts->get_list('accounts');
$c_users = count($users);
$str = '';
for($i=0;$i<$c_users;$i++)
{
$str .= ''."\n";
}
$var['lang_new_owner'] = lang('Who would you like to transfer ALL records owned by the deleted user to?');
$var['new_owner_select'] = ''."\n";
$var['cancel'] = lang('cancel');
$var['delete'] = lang('delete');
$t->set_var($var);
$t->pparse('out','form');
}
function edit_group($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' => $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='')
{
if ($GLOBALS['phpgw']->acl->check('account_access',16,'admin'))
{
$this->list_users();
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 users too
if (! $account_id)
{
$this->list_users();
return False;
}
else
{
$this->create_edit_user($account_id);
}
}
function view_user()
{
if ($GLOBALS['phpgw']->acl->check('account_access',8,'admin') || ! $GLOBALS['HTTP_GET_VARS']['account_id'])
{
$this->list_users();
return False;
}
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(
'account' => 'account_form.tpl'
)
);
$t->set_block('account','form','form');
$t->set_block('account','form_logininfo');
$t->set_block('account','link_row');
$var = Array(
'lang_action' => lang('View user account'),
'lang_loginid' => lang('LoginID'),
'lang_account_active' => lang('Account active'),
'lang_password' => lang('Password'),
'lang_reenter_password' => lang('Re-Enter Password'),
'lang_lastname' => lang('Last Name'),
'lang_groups' => lang('Groups'),
'lang_firstname' => lang('First Name'),
'lang_lastlogin' => lang('Last login'),
'lang_lastloginfrom' => lang('Last login from'),
'lang_expires' => lang('Expires')
);
$t->parse('password_fields','form_logininfo',True);
$account = CreateObject('phpgwapi.accounts',intval($GLOBALS['HTTP_GET_VARS']['account_id']),'u');
$userData = $account->read_repository();
$var['account_lid'] = $userData['account_lid'];
$var['account_firstname'] = $userData['firstname'];
$var['account_lastname'] = $userData['lastname'];
if ($userData['status'])
{
$var['account_status'] = lang('Enabled');
}
else
{
$var['account_status'] = '' . lang('Disabled') . '';
}
// Last login time
if ($userData['lastlogin'])
{
$var['account_lastlogin'] = $GLOBALS['phpgw']->common->show_date($userData['lastlogin']);
}
else
{
$var['account_lastlogin'] = lang('Never');
}
// Last login IP
if ($userData['lastloginfrom'])
{
$var['account_lastloginfrom'] = $userData['lastloginfrom'];
}
else
{
$var['account_lastloginfrom'] = lang('Never');
}
// Account expires
if ($userData['expires'] != -1)
{
$var['input_expires'] = $GLOBALS['phpgw']->common->show_date($userData['expires']);
}
else
{
$var['input_expires'] = lang('Never');
}
// Find out which groups they are members of
$usergroups = $account->membership(intval($GLOBALS['HTTP_GET_VARS']['account_id']));
if (gettype($usergroups) != 'array')
{
$var['groups_select'] = lang('None');
}
else
{
while (list(,$group) = each($usergroups))
{
$group_names[] = $group['account_name'];
}
$var['groups_select'] = implode(',',$group_names);
}
$account_lastlogin = $userData['account_lastlogin'];
$account_lastloginfrom = $userData['account_lastloginfrom'];
$account_status = $userData['account_status'];
// create list of available app
$i = 0;
$availableApps = $GLOBALS['phpgw_info']['apps'];
@asort($availableApps);
@reset($availableApps);
while ($application = each($availableApps))
{
if ($application[1]['enabled'] && $application[1]['status'] != 2)
{
$perm_display[$i]['appName'] = $application[0];
$perm_display[$i]['translatedName'] = $application[1]['title'];
$i++;
}
}
// create apps output
$apps = CreateObject('phpgwapi.applications',intval($GLOBALS['HTTP_GET_VARS']['account_id']));
$db_perms = $apps->read_account_specific();
@reset($db_perms);
for ($i=0;$i<=count($perm_display);$i++)
{
if ($perm_display[$i]['translatedName'])
{
$part1 = sprintf("