%s%s | ",$perm_display[$i]['title'],($_userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?' X':' '));
}
$i++;
if ($perm_display[$i]['title'])
{
$part2 = sprintf("%s | %s | ",$perm_display[$i]['title'],($_userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?' X':' '));
}
else
{
$part2 = ' | ';
}
$appRightsOutput .= sprintf("$part1$part2
\n",$GLOBALS['egw_info']['theme']['row_on']);
}
$var['permissions_list'] = $appRightsOutput;
// create the menu on the left, if needed
// $menuClass =& CreateObject('admin.uimenuclass');
// This is now using ExecMethod()
$var['rows'] = ExecMethod('admin.uimenuclass.createHTMLCode','view_user');
$t->set_var($var);
$t->pfp('out','form');
}
function group_manager($cd='',$account_id='')
{
if ($GLOBALS['egw']->acl->check('group_access',16,'admin'))
{
$this->list_groups();
return False;
}
$cdid = $cd;
settype($cd,'integer');
$cd = ($_GET['cd']?$_GET['cd']:(int)$cdid);
$accountid = $account_id;
settype($account_id,'integer');
$account_id = (int)($_GET['account_id'] ? $_GET['account_id'] : $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' => (int)$_GET['account_id'],
'account_name' => $GLOBALS['egw']->accounts->id2name($_GET['account_id']),
'account_user' => $GLOBALS['egw']->accounts->member($_GET['account_id']),
'account_managers' => $this->bo->load_group_managers($_GET['account_id'])
);
$this->edit_group_managers($group_info);
}
}
function create_edit_group($group_info,$_errors='')
{
$sbox =& CreateObject('phpgwapi.sbox');
unset($GLOBALS['egw_info']['flags']['noheader']);
unset($GLOBALS['egw_info']['flags']['nonavbar']);
if(!@is_object($GLOBALS['egw']->js))
{
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
}
$GLOBALS['egw']->js->validate_file('jscode','openwindow','admin');
$GLOBALS['egw']->common->egw_header();
$p =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
$p->set_file(Array('edit' => 'group_form.tpl'));
$p->set_block('edit','select');
$p->set_block('edit','popwin');
//fix from Maanus 280105
$accounts =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g');
if (!is_object($GLOBALS['egw']->uiaccountsel))
{
$GLOBALS['egw']->uiaccountsel =& CreateObject('phpgwapi.uiaccountsel');
}
$p->set_var('accounts',$GLOBALS['egw']->uiaccountsel->selection('account_user[]','admin_uiaccounts_user',$group_info['account_user'],'accounts',min(3+count($group_info['account_user']),10),false,'style="width: 300px;"'));
$var = Array(
'form_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.boaccounts.'.($group_info['account_id']?'edit':'add').'_group'),
'hidden_vars' => '',
'lang_group_name' => lang('group name'),
'group_name_value' => $group_info['account_name'],
'lang_include_user' => lang('Select users for inclusion'),
'error' => (!$_errors?'':''.$GLOBALS['egw']->common->error_list($_errors).''),
'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['egw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['egw_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 .= ''."\n";
}
$p->set_var ('lang_file_space', lang('File space'));
$p->set_var ('account_file_space', '');
$p->set_var ('account_file_space_select',''."\n");
*/
reset($GLOBALS['egw_info']['apps']);
$sorted_apps = $GLOBALS['egw_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 = ''.lang('Application').' | '.lang('enabled').' / '.lang('ACL').' | ';
$perm_html = ''.
$perm_html.$perm_html."
\n";
$tr_color = $GLOBALS['egw_info']['theme']['row_off'];
for ($i=0;$i < count($perm_display);$i++)
{
$app = $perm_display[$i][0];
if(!($i & 1))
{
$tr_class = $this->nextmatchs->alternate_row_color('',True);
$perm_html .= '';
}
$perm_html .= '' . $perm_display[$i][1] . ' | '
. ' '
. ($this->apps_with_acl[$app] && $group_info['account_id']?'':' ').' | '.($i & 1?'
':'')."\n";
}
if($i & 1)
{
$perm_html .= ' | ';
}
$var = Array(
'permissions_list' => $perm_html,
'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->set_var('select','');
$p->set_var('popwin','');
$p->pfp('out','edit');
}
function create_edit_user($_account_id,$_userData='',$_errors='')
{
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
$sbox =& CreateObject('phpgwapi.sbox');
$jscal =& CreateObject('phpgwapi.jscalendar');
unset($GLOBALS['egw_info']['flags']['noheader']);
unset($GLOBALS['egw_info']['flags']['nonavbar']);
if(!@is_object($GLOBALS['egw']->js))
{
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
}
$GLOBALS['egw']->js->validate_file('jscode','openwindow','admin');
$GLOBALS['egw']->common->egw_header();
$t =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
$t->set_unknowns('remove');
if ($GLOBALS['egw_info']['server']['ldap_extra_attributes'] && ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap'))
{
$t->set_file(array('account' => 'account_form_ldap.tpl'));
}
else
{
$t->set_file(array('account' => 'account_form.tpl'));
}
$t->set_block('account','form','form');
$t->set_block('account','form_passwordinfo','form_passwordinfo');
$t->set_block('account','form_buttons_','form_buttons_');
$t->set_block('account','link_row','link_row');
$theme = $GLOBALS['egw_info']['user']['preferences']['common']['theme'];
$t->set_var('icon_create_edit', '');
//print_debug('Type : '.gettype($_userData).'
_userData(size) = "'.$_userData.'"('.strlen($_userData).')');
if (is_array($_userData))
{
$userData = Array();
$userData=$_userData;
$userData['firstname'] = $userData['account_firstname'];
$userData['lastname'] = $userData['account_lastname'];
@reset($userData['account_groups']);
while (list($key, $value) = @each($userData['account_groups']))
{
$userGroups[$key]['account_id'] = $value;
}
$account =& CreateObject('phpgwapi.accounts');
$allGroups = $account->get_list('groups');
}
elseif(is_string($_userData) && $_userData=='')
{
if($_account_id)
{
$account =& CreateObject('phpgwapi.accounts',(int)$_account_id,'u');
$userData = $account->read_repository();
$userGroups = $account->membership($_account_id);
$acl =& CreateObject('phpgwapi.acl',$_account_id);
$acl->read_repository();
$userData['anonymous'] = $acl->check('anonymous',1,'phpgwapi');
$userData['changepassword'] = $acl->check('changepassword',0xFFFF,'preferences');
unset($acl);
}
else
{
$account =& CreateObject('phpgwapi.accounts');
$userData = Array();
$userData['status'] = 'A';
$userGroups = Array();
$userData['anonymous'] = False;
$userData['changepassword'] = True;
}
$allGroups = $account->get_list('groups');
}
$page_params['menuaction'] = 'admin.boaccounts.'.($_account_id?'edit':'add').'_user';
if($_account_id)
{
$page_params['account_id'] = $_account_id;
$page_params['old_loginid'] = rawurlencode($userData['account_lid']);
}
$var = Array(
'form_action' => $GLOBALS['egw']->link('/index.php',$page_params),
'error_messages' => (!$_errors?'':''.$GLOBALS['egw']->common->error_list($_errors).''),
'th_bg' => $GLOBALS['egw_info']['theme']['th_bg'],
'tr_color1' => $GLOBALS['egw_info']['theme']['row_on'],
'tr_color2' => $GLOBALS['egw_info']['theme']['row_off'],
'lang_action' => ($_account_id?lang('Edit user account'):lang('Add new account')),
'lang_loginid' => lang('LoginID'),
'lang_account_active' => lang('Account active'),
'lang_email' => lang('email'),
'lang_password' => lang('Password'),
'lang_reenter_password' => lang('Re-Enter Password'),
'lang_lastname' => lang('Last Name'),
'lang_groups' => lang('Groups'),
'lang_primary_group' => lang('primary Group'),
'lang_expires' => lang('Expires'),
'lang_firstname' => lang('First Name'),
'lang_anonymous' => lang('Anonymous User (not shown in list sessions)'),
'lang_changepassword' => lang('Can change password'),
'lang_button' => ($_account_id?lang('Save'):lang('Add')),
'lang_passwds_unequal' => lang('The two passwords are not the same'),
/* 'lang_file_space' => lang('File Space') */
);
$t->set_var($var);
$t->parse('form_buttons','form_buttons_',True);
if ($GLOBALS['egw_info']['server']['ldap_extra_attributes']) {
$lang_homedir = lang('home directory');
$lang_shell = lang('login shell');
$homedirectory = '';
$loginshell = '';
}
else
{
$lang_homedir = '';
$lang_shell = '';
$homedirectory = '';
$loginshell = '';
}
$account_file_space = '';
/*
if (!$userData['file_space'])
{
$userData['file_space'] = $GLOBALS['egw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['egw_info']['server']['vfs_default_account_size_type'];
}
$file_space_array = explode ('-', $userData['file_space']);
$account_file_space_number = $file_space_array[0];
$account_file_space_type = $file_space_array[1];
$account_file_space_type_selected[$account_file_space_type] = ' selected';
$account_file_space = '';
$account_file_space_select ='';
$var = Array(
'lang_file_space' => 'File space',
'account_file_space' => $account_file_space,
'account_file_space_select' => $account_file_space_select
);
$t->set_var($var);
*/
$accountPrefix = '';
if(isset($GLOBALS['egw_info']['server']['account_prefix']))
{
$accountPrefix = $GLOBALS['egw_info']['server']['account_prefix'];
if (preg_match ("/^$accountPrefix(.*)/i", $userData['account_lid'], $matches))
{
$userData['account_lid'] = $matches[1];
}
}
$var = Array(
'input_expires' => $jscal->input('expires',$userData['expires']<0?'':($userData['expires']?$userData['expires']:time()+(60*60*24*7))),
'lang_never' => lang('Never'),
'account_lid' => $accountPrefix.'',
'lang_homedir' => $lang_homedir,
'lang_shell' => $lang_shell,
'homedirectory' => $homedirectory,
'loginshell' => $loginshell,
'anonymous' => '',
'changepassword' => '',
'account_status' => '',
'account_firstname' => '',
'account_lastname' => '',
'account_email' => '',
'account_passwd' => $userData['account_passwd'],
'account_passwd_2' => $userData['account_passwd_2'],
'account_file_space' => $account_file_space,
'account_id' => (int) $userData['account_id'],
);
if($userData['expires'] == -1)
{
$var['never_expires'] = '';
}
else
{
$var['never_expires'] = '';
}
$t->set_var($var);
$t->parse('password_fields','form_passwordinfo',True);
$groups_select = '';
$primary_group_select = '';
reset($allGroups);
while (list($key,$value) = each($allGroups))
{
$groups_select .= '"; */
if (@$userGroups[$i]['account_id'] == $value['account_id'])
{
$groups_select .= ' checked';
}
}
$groups_select .= '>' . $value['account_lid'] . "
\n";
}
if (!$userData['account_primary_group'])
{
$userData['account_primary_group'] = @$userGroups[0]['account_id'] ? @$userGroups[0]['account_id'] : $account->name2id('Default');
}
foreach($allGroups as $key => $value)
{
# print "
$key =>";
# _debug_array($userGroups);
$primary_group_select .= '