diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php index c9ede7adea..5abe574234 100644 --- a/phpgwapi/inc/class.accounts_sql.inc.php +++ b/phpgwapi/inc/class.accounts_sql.inc.php @@ -44,17 +44,18 @@ $this->db->query("select * from phpgw_accounts where account_id='" . $this->account_id . "'",__LINE__,__FILE__); $this->db->next_record(); - $this->data["userid"] = $this->db->f("account_lid"); - $this->data["account_id"] = $this->db->f("account_id"); - $this->data["account_lid"] = $this->db->f("account_lid"); - $this->data["firstname"] = $this->db->f("account_firstname"); - $this->data["lastname"] = $this->db->f("account_lastname"); - $this->data["fullname"] = $this->db->f("account_firstname") . " " - . $this->db->f("account_lastname"); - $this->data["lastlogin"] = $this->db->f("account_lastlogin"); - $this->data["lastloginfrom"] = $this->db->f("account_lastloginfrom"); - $this->data["lastpasswd_change"] = $this->db->f("account_lastpwd_change"); - $this->data["status"] = $this->db->f("account_status"); + $this->data['userid'] = $this->db->f('account_lid'); + $this->data['account_id'] = $this->db->f('account_id'); + $this->data['account_lid'] = $this->db->f('account_lid'); + $this->data['firstname'] = $this->db->f('account_firstname'); + $this->data['lastname'] = $this->db->f('account_lastname'); + $this->data['fullname'] = $this->db->f('account_firstname') . ' ' + . $this->db->f('account_lastname'); + $this->data['lastlogin'] = $this->db->f('account_lastlogin'); + $this->data['lastloginfrom'] = $this->db->f('account_lastloginfrom'); + $this->data['lastpasswd_change'] = $this->db->f('account_lastpwd_change'); + $this->data['status'] = $this->db->f('account_status'); + $this->data['expires'] = $this->db->f('account_expires'); return $this->data; } @@ -62,7 +63,8 @@ { $this->db->query("update phpgw_accounts set account_firstname='" . $this->data['firstname'] . "', 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 = '') @@ -142,12 +144,13 @@ $this->db->query($sql,__LINE__,__FILE__); while ($this->db->next_record()) { $accounts[] = Array( - "account_id" => $this->db->f("account_id"), - "account_lid" => $this->db->f("account_lid"), - "account_type" => $this->db->f("account_type"), - "account_firstname" => $this->db->f("account_firstname"), - "account_lastname" => $this->db->f("account_lastname"), - "account_status" => $this->db->f("account_status") + 'account_id' => $this->db->f('account_id'), + 'account_lid' => $this->db->f('account_lid'), + 'account_type' => $this->db->f('account_type'), + 'account_firstname' => $this->db->f('account_firstname'), + 'account_lastname' => $this->db->f('account_lastname'), + 'account_status' => $this->db->f('account_status'), + 'account_expires' => $this->db->f('account_expires') ); } return $accounts; @@ -207,6 +210,8 @@ 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='') { // $account_home and $account_shell not used here diff --git a/phpgwapi/inc/class.sessions.inc.php b/phpgwapi/inc/class.sessions.inc.php index e71041df52..3d158d9833 100644 --- a/phpgwapi/inc/class.sessions.inc.php +++ b/phpgwapi/inc/class.sessions.inc.php @@ -148,6 +148,11 @@ else { $this->read_repositories(); + if ($this->user['expires'] != -1 && $this->user['expires'] < time()) + { + return False; + } + $phpgw_info['user'] = $this->user; $phpgw_info['hooks'] = $this->hooks; } @@ -268,6 +273,11 @@ } $this->read_repositories(); + if ($this->user['expires'] != -1 && $this->user['expires'] < time()) + { + return False; + } + $phpgw_info['user'] = $this->user; $phpgw_info['hooks'] = $this->hooks; if ($phpgw_info['server']['cache_phpgw_info']) diff --git a/setup/sql/mysql_newtables.inc.php b/setup/sql/mysql_newtables.inc.php index cbe671e9e9..a9bdab087a 100644 --- a/setup/sql/mysql_newtables.inc.php +++ b/setup/sql/mysql_newtables.inc.php @@ -42,6 +42,7 @@ account_lastloginfrom varchar(255), account_lastpwd_change int(11), account_status enum('A','L'), + account_expires int, account_type char(1), PRIMARY KEY (account_id), UNIQUE account_lid (account_lid) @@ -361,7 +362,7 @@ )"; $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']; update_version_table(); // $phpgw_setup->update_version_table(); diff --git a/setup/sql/mysql_upgrade_beta.inc.php b/setup/sql/mysql_upgrade_beta.inc.php index ed1df7525b..38d47aa66a 100644 --- a/setup/sql/mysql_upgrade_beta.inc.php +++ b/setup/sql/mysql_upgrade_beta.inc.php @@ -1599,7 +1599,18 @@ $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); while (list ($key, $value) = each ($test)){ if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { diff --git a/setup/sql/pgsql_newtables.inc.php b/setup/sql/pgsql_newtables.inc.php index c5700cb5b5..8496d657bf 100644 --- a/setup/sql/pgsql_newtables.inc.php +++ b/setup/sql/pgsql_newtables.inc.php @@ -42,6 +42,7 @@ account_lastloginfrom varchar(255), account_lastpwd_change int, account_status char(1), + account_expires int, account_type char(1), unique(account_lid) )"; @@ -329,7 +330,7 @@ )"; $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']; update_version_table(); ?> diff --git a/setup/sql/pgsql_upgrade_beta.inc.php b/setup/sql/pgsql_upgrade_beta.inc.php index f620fbea79..aff3e2ced2 100644 --- a/setup/sql/pgsql_upgrade_beta.inc.php +++ b/setup/sql/pgsql_upgrade_beta.inc.php @@ -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); while (list ($key, $value) = each ($test)){ if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { diff --git a/version.inc.php b/version.inc.php index 504a91d4d0..b84de3665e 100644 --- a/version.inc.php +++ b/version.inc.php @@ -11,5 +11,5 @@ /* $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';