True, 'add_user' => True, 'delete_user' => True, 'edit_user' => True, 'view_user' => True ); var $bo; var $nextmatchs; function uiaccounts() { $this->bo = createobject('admin.boaccounts'); $this->nextmatchs = createobject('phpgwapi.nextmatchs'); } function row_action($action,$type,$account_id) { return ' '.lang($action).' '; } function list_users($param_cd='') { 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( 'accounts' => 'accounts.tpl' ) ); $p->set_block('accounts','list','list'); $p->set_block('accounts','row','row'); $p->set_block('accounts','row_empty','row_empty'); $total = $this->bo->account_total($query); $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), 'lang_user_accounts' => lang('user accounts'), 'right_next_matchs' => $this->nextmatchs->right($url,$start,$total), '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_add' => lang('add'), 'lang_search' => lang('search') ); $p->set_var($var); $account_info = $GLOBALS['phpgw']->accounts->get_list('accounts',$start,$sort,$order,$query); 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)) { $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']), 'row_edit' => $this->row_action('edit','user',$account['account_id']), 'row_delete' => ($GLOBALS['phpgw_info']['user']['userid'] != $account['account_lid']?$this->row_action('delete','user',$account['account_id']):' '), 'row_view' => $this->row_action('view','user',$account['account_id']) ); $p->set_var($var); $p->parse('rows','row',True); } } // End else $p->pparse('out','list'); } function add_user() { $this->create_edit_user(0); } function delete_user() { if($GLOBALS['phpgw_info']['user']['account_id'] == $GLOBALS['HTTP_GET_VARS']['account_id']) { Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_users')); $GLOBALS['phpgw']->common->phpgw_exit(); } 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_user($cd='',$account_id='') { $cdid = $cd; settype($cd,'integer'); $cd = ($GLOBALS['HTTP_GET_VARS']['cd']?$GLOBALS['HTTP_GET_VARS']['cd']:$cdid); $accountid = $account_id; settype($account_id,'integer'); $account_id = ($GLOBALS['HTTP_GET_VARS']['account_id']?$GLOBALS['HTTP_GET_VARS']['account_id']:$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_users')); } else { $this->create_edit_user($account_id); } } function view_user() { if (!$GLOBALS['HTTP_GET_VARS']['account_id']) { Header('Location: ' . $phpgw->link('/index.php','menuaction=admin.uiaccounts.list_users')); } 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( 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 'tr_color1' => $GLOBALS['phpgw_info']['theme']['row_on'], 'tr_color2' => $GLOBALS['phpgw_info']['theme']['row_off'], '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',$GLOBALS['HTTP_GET_VARS']['account_id']); $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("%s%s",lang($perm_display[$i]['translatedName']),($_userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?'  X':' ')); } $i++; if ($perm_display[$i]['translatedName']) { $part2 = sprintf("%s%s",lang($perm_display[$i]['translatedName']),($_userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?'  X':' ')); } else { $part2 = ' '; } $appRightsOutput .= sprintf("$part1$part2\n",$GLOBALS['phpgw_info']['theme']['row_on']); } $var['permissions_list'] = $appRightsOutput; // create the menu on the left, if needed $menuClass = CreateObject('admin.uimenuclass'); $var['rows'] = $menuClass->createHTMLCode('view_user'); $t->set_var($var); $t->pfp('out','form'); } function create_edit_user($_account_id,$_userData='',$_errors='') { $sbox = createobject('phpgwapi.sbox'); 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'); if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'] && ($GLOBALS['phpgw_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'); print_debug('Type : '.gettype($_userData).'
_userData(size) = "'.$_userData.'"('.strlen($_userData).')'); if (is_array($_userData)) { $userData = Array(); $userData=$_userData; @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',$_account_id); $userData = $account->read_repository(); $userGroups = $account->membership($_account_id); } else { $account = CreateObject('phpgwapi.accounts'); $userData = Array(); $userData['status'] = 'A'; $userGroups = Array(); } $allGroups = $account->get_list('groups'); if ($userData['expires'] == -1) { $userData['account_expires_month'] = 0; $userData['account_expires_day'] = 0; $userData['account_expires_year'] = 0; } else { $userData['account_expires_month'] = date('m',$userData['expires']); $userData['account_expires_day'] = date('d',$userData['expires']); $userData['account_expires_year'] = date('Y',$userData['expires']); } } $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['phpgw']->link('/index.php',$page_params), 'error_messages' => (!$_errors?'':'
'.$GLOBALS['phpgw']->common->error_list($_errors).'
'), 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 'tr_color1' => $GLOBALS['phpgw_info']['theme']['row_on'], 'tr_color2' => $GLOBALS['phpgw_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_password' => lang('Password'), 'lang_reenter_password' => lang('Re-Enter Password'), 'lang_lastname' => lang('Last Name'), 'lang_groups' => lang('Groups'), 'lang_expires' => lang('Expires'), 'lang_firstname' => lang('First Name'), 'lang_button' => ($_account_id?lang('Save'):lang('Add')), /* 'lang_file_space' => lang('File Space') */ ); $t->set_var($var); $t->parse('form_buttons','form_buttons_',True); if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes']) { $lang_homedir = lang('home directory'); $lang_shell = lang('login shell'); $homedirectory = ''; $loginshell = ''; } else { $lang_homedir = ''; $lang_shell = ''; $homedirectory = ''; $loginshell = ''; } $_y = $sbox->getyears('account_expires_year',$userData['account_expires_year'],date('Y'),date('Y')+10); $_m = $sbox->getmonthtext('account_expires_month',$userData['account_expires_month']); $_d = $sbox->getdays('account_expires_day',$userData['account_expires_day']); $account_file_space = ''; /* if (!$userData['file_space']) { $userData['file_space'] = $GLOBALS['phpgw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['phpgw_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); */ $var = Array( 'input_expires' => $GLOBALS['phpgw']->common->dateformatorder($_y,$_m,$_d,True), 'account_lid' => '', 'lang_homedir' => $lang_homedir, 'lang_shell' => $lang_shell, 'homedirectory' => $homedirectory, 'loginshell' => $loginshell, 'account_status' => '', 'account_firstname' => '', 'account_lastname' => '', 'account_passwd' => $account_passwd, 'account_passwd_2' => $account_passwd_2, 'account_file_space' => $account_file_space ); $t->set_var($var); $t->parse('password_fields','form_passwordinfo',True); // $allAccounts; // $userGroups; $groups_select = ''; reset($allGroups); while (list($key,$value) = each($allGroups)) { $groups_select .= ''."\n"; } /* create list of available apps */ $i = 0; $apps = CreateObject('phpgwapi.applications',$_account_id); $db_perms = $apps->read_account_specific(); @reset($GLOBALS['phpgw_info']['apps']); $availableApps = $GLOBALS['phpgw_info']['apps']; @asort($availableApps); @reset($availableApps); while (list($key,$application) = each($availableApps)) { if ($application['enabled'] && $application['status'] != 3) { $perm_display[$i]['appName'] = $key; $perm_display[$i]['translatedName'] = $application['title']; $i++; } } /* create apps output */ $appRightsOutput = ''; // @reset($perm_display); for ($i=0;$i%s', lang($perm_display[$i]['translatedName']), $perm_display[$i]['appName'], ($userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?' checked':'')); } $i++; if ($perm_display[$i]['translatedName']) { $part2 = sprintf('%s', lang($perm_display[$i]['translatedName']), $perm_display[$i]['appName'], ($userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?' checked':'')); } else { $part2 = ' '; } $appRightsOutput .= sprintf('%s%s',$GLOBALS['phpgw_info']['theme']['row_on'], $part1, $part2); } $var = Array( 'groups_select' => ''."\n", 'permissions_list' => $appRightsOutput ); $t->set_var($var); // create the menu on the left, if needed $menuClass = CreateObject('admin.uimenuclass'); $t->set_var('rows',$menuClass->createHTMLCode('edit_user')); echo $t->fp('out','form'); } } ?>