Added account expires feature

This commit is contained in:
jengo 2001-05-02 09:06:14 +00:00
parent eacb8a099e
commit 99ff1cb575
7 changed files with 83 additions and 22 deletions

View File

@ -44,17 +44,18 @@
$this->db->query("select * from phpgw_accounts where account_id='" . $this->account_id . "'",__LINE__,__FILE__); $this->db->query("select * from phpgw_accounts where account_id='" . $this->account_id . "'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
$this->data["userid"] = $this->db->f("account_lid"); $this->data['userid'] = $this->db->f('account_lid');
$this->data["account_id"] = $this->db->f("account_id"); $this->data['account_id'] = $this->db->f('account_id');
$this->data["account_lid"] = $this->db->f("account_lid"); $this->data['account_lid'] = $this->db->f('account_lid');
$this->data["firstname"] = $this->db->f("account_firstname"); $this->data['firstname'] = $this->db->f('account_firstname');
$this->data["lastname"] = $this->db->f("account_lastname"); $this->data['lastname'] = $this->db->f('account_lastname');
$this->data["fullname"] = $this->db->f("account_firstname") . " " $this->data['fullname'] = $this->db->f('account_firstname') . ' '
. $this->db->f("account_lastname"); . $this->db->f('account_lastname');
$this->data["lastlogin"] = $this->db->f("account_lastlogin"); $this->data['lastlogin'] = $this->db->f('account_lastlogin');
$this->data["lastloginfrom"] = $this->db->f("account_lastloginfrom"); $this->data['lastloginfrom'] = $this->db->f('account_lastloginfrom');
$this->data["lastpasswd_change"] = $this->db->f("account_lastpwd_change"); $this->data['lastpasswd_change'] = $this->db->f('account_lastpwd_change');
$this->data["status"] = $this->db->f("account_status"); $this->data['status'] = $this->db->f('account_status');
$this->data['expires'] = $this->db->f('account_expires');
return $this->data; return $this->data;
} }
@ -62,7 +63,8 @@
{ {
$this->db->query("update phpgw_accounts set account_firstname='" . $this->data['firstname'] $this->db->query("update phpgw_accounts set account_firstname='" . $this->data['firstname']
. "', account_lastname='" . $this->data['lastname'] . "', account_status='" . "', account_lastname='" . $this->data['lastname'] . "', account_status='"
. $this->data['status'] . "' where account_id='" . $this->account_id . "'",__LINE__,__FILE__); . $this->data['status'] . "', account_expires='" . $this->data['expires'] . "' where account_id='"
. $this->account_id . "'",__LINE__,__FILE__);
} }
function delete($accountid = '') function delete($accountid = '')
@ -142,12 +144,13 @@
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record()) { while ($this->db->next_record()) {
$accounts[] = Array( $accounts[] = Array(
"account_id" => $this->db->f("account_id"), 'account_id' => $this->db->f('account_id'),
"account_lid" => $this->db->f("account_lid"), 'account_lid' => $this->db->f('account_lid'),
"account_type" => $this->db->f("account_type"), 'account_type' => $this->db->f('account_type'),
"account_firstname" => $this->db->f("account_firstname"), 'account_firstname' => $this->db->f('account_firstname'),
"account_lastname" => $this->db->f("account_lastname"), 'account_lastname' => $this->db->f('account_lastname'),
"account_status" => $this->db->f("account_status") 'account_status' => $this->db->f('account_status'),
'account_expires' => $this->db->f('account_expires')
); );
} }
return $accounts; return $accounts;
@ -207,6 +210,8 @@
return $this->db->f(0) > 0; return $this->db->f(0) > 0;
} }
// !! NOTE: We should pass an array to this to make updates easier, plus I need to add account_expires
// I didn't want to risk breaking too much code at once, I will do this soon. (jengo)
function create($account_type, $account_lid, $account_pwd, $account_firstname, $account_lastname, $account_status, $account_id='', $account_home='',$account_shell='') function create($account_type, $account_lid, $account_pwd, $account_firstname, $account_lastname, $account_status, $account_id='', $account_home='',$account_shell='')
{ {
// $account_home and $account_shell not used here // $account_home and $account_shell not used here

View File

@ -148,6 +148,11 @@
else else
{ {
$this->read_repositories(); $this->read_repositories();
if ($this->user['expires'] != -1 && $this->user['expires'] < time())
{
return False;
}
$phpgw_info['user'] = $this->user; $phpgw_info['user'] = $this->user;
$phpgw_info['hooks'] = $this->hooks; $phpgw_info['hooks'] = $this->hooks;
} }
@ -268,6 +273,11 @@
} }
$this->read_repositories(); $this->read_repositories();
if ($this->user['expires'] != -1 && $this->user['expires'] < time())
{
return False;
}
$phpgw_info['user'] = $this->user; $phpgw_info['user'] = $this->user;
$phpgw_info['hooks'] = $this->hooks; $phpgw_info['hooks'] = $this->hooks;
if ($phpgw_info['server']['cache_phpgw_info']) if ($phpgw_info['server']['cache_phpgw_info'])

View File

@ -42,6 +42,7 @@
account_lastloginfrom varchar(255), account_lastloginfrom varchar(255),
account_lastpwd_change int(11), account_lastpwd_change int(11),
account_status enum('A','L'), account_status enum('A','L'),
account_expires int,
account_type char(1), account_type char(1),
PRIMARY KEY (account_id), PRIMARY KEY (account_id),
UNIQUE account_lid (account_lid) UNIQUE account_lid (account_lid)
@ -361,7 +362,7 @@
)"; )";
$phpgw_setup->db->query($sql); $phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.005'; $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.006';
$phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi']; $phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi'];
update_version_table(); update_version_table();
// $phpgw_setup->update_version_table(); // $phpgw_setup->update_version_table();

View File

@ -1599,7 +1599,18 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.005'; $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.005';
} }
$test[] = '0.9.11.005';
function upgrade0_9_11_005()
{
global $phpgw_info,$phpgw_setup;
$phpgw_setup->db->query("alter table phpgw_accounts add column account_expires int after account_status",__LINE__,__FILE__);
$phpgw_setup->db->query("update phpgw_accounts set account_expires='-1'",__LINE__,__FILE__);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.006';
}
reset ($test); reset ($test);
while (list ($key, $value) = each ($test)){ while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -42,6 +42,7 @@
account_lastloginfrom varchar(255), account_lastloginfrom varchar(255),
account_lastpwd_change int, account_lastpwd_change int,
account_status char(1), account_status char(1),
account_expires int,
account_type char(1), account_type char(1),
unique(account_lid) unique(account_lid)
)"; )";
@ -329,7 +330,7 @@
)"; )";
$phpgw_setup->db->query($sql); $phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.005'; $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.006';
$phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi']; $phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi'];
update_version_table(); update_version_table();
?> ?>

View File

@ -2057,6 +2057,39 @@
} }
$test[] = '0.9.11.005';
function upgrade0_9_11_005()
{
global $phpgw_info, $phpgw_setup;
$phpgw_setup->db->query("create table phpgw_accounts_temp as select * from phpgw_accounts",__LINE__,__FILE__);
$phpgw_setup->db->query("drop sequence phpgw_accounts_account_id_seq",__LINE__,__FILE__);
$phpgw_setup->db->query("drop table phpgw_accounts",__LINE__,__FILE__);
$sql = "create table phpgw_accounts (
account_id serial,
account_lid varchar(25) NOT NULL,
account_pwd char(32) NOT NULL,
account_firstname varchar(50),
account_lastname varchar(50),
account_lastlogin int,
account_lastloginfrom varchar(255),
account_lastpwd_change int,
account_status char(1),
account_expires int,
account_type char(1),
unique(account_lid)
)";
$phpgw_setup->db->query($sql);
$phpgw_setup->db->query("insert into phpgw_accounts select * from phpgw_accounts_temp",__LINE__,__FILE__);
$phpgw_setup->db->query("drop table phpgw_accounts_temp",__LINE__,__FILE__);
$phpgw_setup->db->query("update phpgw_accounts set account_expires='-1'",__LINE__,__FILE__);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.006';
}
reset ($test); reset ($test);
while (list ($key, $value) = each ($test)){ while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -11,5 +11,5 @@
/* $Id$ */ /* $Id$ */
$phpgw_info['server']['versions']['phpgwapi'] = '0.9.11.005'; $phpgw_info['server']['versions']['phpgwapi'] = '0.9.11.006';
$phpgw_info['server']['versions']['current_header'] = '1.11'; $phpgw_info['server']['versions']['current_header'] = '1.11';