Added in expiring accounts field

This commit is contained in:
jengo 2001-05-06 11:20:02 +00:00
parent e69fad5950
commit 6f9a837e70
7 changed files with 120 additions and 28 deletions

View File

@ -30,7 +30,7 @@
return $phpgw->db->f(0);
}
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(array(
'list' => 'accounts.tpl',

View File

@ -11,10 +11,11 @@
/* $Id$ */
$phpgw_info['flags'] = array(
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'admin',
'parent_page' => 'accounts.php'
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'admin',
'parent_page' => 'accounts.php',
'enable_sbox_class' => True
);
include('../header.inc.php');
@ -61,6 +62,19 @@
$userData = $account->read_repository();
$userGroups = $account->memberships($_account_id);
$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']);
}
}
$t->set_var('form_action',$phpgw->link('/admin/editaccount.php',
@ -82,10 +96,16 @@
$t->set_var('lang_reenter_password',lang('Re-Enter Password'));
$t->set_var('lang_lastname',lang('Last Name'));
$t->set_var('lang_groups',lang('Groups'));
$t->set_var('lang_expires',lang('Expires'));
$t->set_var('lang_firstname',lang('First Name'));
$t->set_var('lang_button',lang('Save'));
$t->parse('form_buttons','form_buttons_',True);
$_y = $phpgw->sbox->getyears('account_expires_year',$userData['account_expires_year'],date('Y'),date('Y')+10);
$_m = $phpgw->sbox->getmonthtext('account_expires_month',$userData['account_expires_month']);
$_d = $phpgw->sbox->getdays('account_expires_day',$userData['account_expires_day']);
$t->set_var('input_expires',$phpgw->common->dateformatorder($_y,$_m,$_d,True));
$t->set_var('account_lid','<input name="account_lid" value="' . $userData['account_lid'] . '">');
if ($phpgw_info["server"]["ldap_extra_attributes"]) {
@ -268,7 +288,7 @@
// otherwise the error array
function userDataInvalid($_userData)
{
global $phpgw,$phpgw_info;
global $phpgw,$phpgw_info,$userData;
$totalerrors = 0;
@ -305,6 +325,22 @@
$totalerrors++;
}
if ($_userData['account_expires_month'] || $_userData['account_expires_day'] || $_userData['account_expires_year'])
{
if (! checkdate($_userData['account_expires_month'],$_userData['account_expires_day'],$_userData['account_expires_year']))
{
$error[$totalerrors] = lang('You have entered an invalid expiration date');
}
else
{
$userData['expires'] = mktime(2,0,0,$_userData['account_expires_month'],$_userData['account_expires_day'],$_userData['account_expires_year']);
}
}
else
{
$userData['expires'] = -1;
}
if ($totalerrors == 0)
{
return FALSE;
@ -325,18 +361,21 @@
if ($submit)
{
$userData = array(
'account_lid' => $account_lid,
'firstname' => $account_firstname,
'lastname' => $account_lastname,
'account_passwd' => $account_passwd,
'status' => $account_status,
'old_loginid' => rawurldecode($old_loginid),
'account_id' => $account_id,
'account_passwd_2' => $account_passwd_2,
'account_groups' => $account_groups,
'account_permissions' => $account_permissions,
'homedirectory' => $homedirectory,
'loginshell' => $loginshell
'account_lid' => $account_lid,
'firstname' => $account_firstname,
'lastname' => $account_lastname,
'account_passwd' => $account_passwd,
'status' => $account_status,
'old_loginid' => rawurldecode($old_loginid),
'account_id' => $account_id,
'account_passwd_2' => $account_passwd_2,
'account_groups' => $account_groups,
'account_permissions' => $account_permissions,
'homedirectory' => $homedirectory,
'loginshell' => $loginshell,
'account_expires_month' => $account_expires_month,
'account_expires_day' => $account_expires_day,
'account_expires_year' => $account_expires_year
);
if (!$errors = userDataInvalid($userData))

View File

@ -12,10 +12,11 @@
/* $Id$ */
$phpgw_info['flags'] = array(
'currentapp' => 'admin',
'noheader' => True,
'nonavbar' => True,
'parent_page' => 'accounts.php'
'currentapp' => 'admin',
'noheader' => True,
'nonavbar' => True,
'parent_page' => 'accounts.php',
'enable_sbox_class' => True
);
include('../header.inc.php');
@ -74,6 +75,22 @@
$error[$totalerrors++] = lang('That loginid has already been taken');
}
if ($account_expires_month || $account_expires_day || $account_expires_year)
{
if (! checkdate($account_expires_month,$account_expires_day,$account_expires_year))
{
$error[] = lang('You have entered an invalid expiration date');
}
else
{
$account_expires = mktime(2,0,0,$account_expires_month,$account_expires_day,$account_expires_year);
}
}
else
{
$account_expires = -1;
}
if (! $error)
{
$phpgw->db->lock(array(
@ -84,7 +101,17 @@
'phpgw_acl',
'phpgw_applications'
));
$phpgw->accounts->create('u', $account_lid, $account_passwd, $account_firstname, $account_lastname, $account_status, '', $homedirectory,$loginshell);
$account_info = array(
'type' => 'u',
'lid' => $account_lid,
'passwd' => $account_passwd,
'firstname' => $account_firstname,
'lastname' => $account_lastname,
'status' => $account_status,
'expires' => $account_expires
);
$phpgw->accounts->create($account_info);
$account_id = $phpgw->accounts->name2id($account_lid);
@ -246,6 +273,12 @@
$phpgw->template->set_var('lang_groups',lang('Groups'));
$phpgw->template->set_var('lang_expires',lang('Expires'));
$_y = $phpgw->sbox->getyears('account_expires_year',$account_expires_year,date('Y'),date('Y')+10);
$_m = $phpgw->sbox->getmonthtext('account_expires_month',$account_expires_month);
$_d = $phpgw->sbox->getdays('account_expires_day',$account_expires_day);
$phpgw->template->set_var('input_expires',$phpgw->common->dateformatorder($_y,$_m,$_d,True));
$phpgw->template->parse('form_buttons','form_buttons_',True);
// groups list

View File

@ -30,6 +30,11 @@
<td colspan=3>{groups_select}&nbsp;</td>
</tr>
<tr bgcolor="{tr_color1}">
<td>{lang_expires}</td>
<td colspan=3>{expires_list}&nbsp;</td>
</tr>
{permissions_list}
{gui_hooks}

View File

@ -8,7 +8,7 @@
<td colspan="4">&nbsp;</td>
</tr>
<tr bgcolor="{tr_color1}">
<tr bgcolor="{tr_color2}">
<td width="25%">{lang_loginid}</td>
<td width="25%">{account_lid}&nbsp;</td>
@ -16,7 +16,7 @@
<td width="25%">{account_status}</td>
</tr>
<tr bgcolor="{tr_color2}">
<tr bgcolor="{tr_color1}">
<td>{lang_firstname}</td>
<td>{account_firstname}&nbsp;</td>
<td>{lang_lastname}</td>
@ -25,9 +25,14 @@
{password_fields}
<tr bgcolor="{tr_color2}">
<tr bgcolor="{tr_color1}">
<td>{lang_groups}</td>
<td colspan=3>{groups_select}&nbsp;</td>
<td colspan="3">{groups_select}&nbsp;</td>
</tr>
<tr bgcolor="{tr_color2}">
<td>{lang_expires}</td>
<td colspan="3">{input_expires}&nbsp;</td>
</tr>
{permissions_list}

View File

@ -1,5 +1,5 @@
<tr bgcolor="{tr_color1}">
<tr bgcolor="{tr_color2}">
<td>{lang_password}</td>
<td><input type="password" name="account_passwd" value="{account_passwd}"></td>
<td>{lang_reenter_password}</td>

View File

@ -51,6 +51,7 @@
$t->set_var('lang_firstname',lang('First Name'));
$t->set_var('lang_lastlogin',lang('Last login'));
$t->set_var('lang_lastloginfrom',lang('Last login from'));
$t->set_var('lang_expires',lang('Expires'));
$account = CreateObject('phpgwapi.accounts',$account_id);
$userData = $account->read_repository();
@ -90,6 +91,15 @@
}
$t->parse('password_fields','form_logininfo',True);
// Account expires
if ($userData['expires'] != -1)
{
$t->set_var('input_expires',$phpgw->common->show_date($userData['expires']));
}
else
{
$t->set_var('input_expires',lang('Never'));
}
// Find out which groups they are members of
$usergroups = $account->memberships(intval($account_id));