Modified .004-.005 to work with ldap also, hope sql still works

This commit is contained in:
Miles Lott 2001-07-13 11:13:24 +00:00
parent 9c1f5e1b6b
commit 4f0070ec5b

View File

@ -1901,31 +1901,49 @@
$test[] = '0.9.13.004';
function phpgwapi_upgrade0_9_13_004()
{
global $setup_info, $phpgw_setup;
global $setup_info, $phpgw_setup, $phpgw_info, $phpgw;
$phpgw_setup->oProc->AddColumn('phpgw_access_log','account_id',array('type' => 'int', 'precision' => 4, 'default' => 0, 'nullable' => False));
// !! NOTE !!
// This does NOT work with LDAP, if they have fully moved there accounts over
// they will not be able to use the new features for old records.
// This is why I decied to do this now, instead of later.
// If you have a better soultion, let me know. (jengo)
$db2 = $phpgw_setup->db;
global $phpgw;
class phpgw
{
var $common;
var $accounts;
var $applications;
var $db;
}
$phpgw = new phpgw;
$phpgw->common = CreateObject('phpgwapi.common');
$phpgw_setup->oProc->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__);
while ($phpgw_setup->oProc->next_record())
{
$config[$phpgw_setup->oProc->f('config_name')] = $phpgw_setup->oProc->f('config_value');
}
$phpgw_info['server']['ldap_host'] = $config['ldap_host'];
$phpgw_info['server']['ldap_context'] = $config['ldap_context'];
$phpgw_info['server']['ldap_group_context'] = $config['ldap_group_context'];
$phpgw_info['server']['ldap_root_dn'] = $config['ldap_root_dn'];
$phpgw_info['server']['ldap_root_pw'] = $config['ldap_root_pw'];
$phpgw_info['server']['account_repository'] = $config['account_repository'];
$accounts = CreateObject('phpgwapi.accounts');
$accounts->db = $phpgw_setup->db;
$phpgw_setup->oProc->query("select * from phpgw_access_log");
while ($phpgw_setup->oProc->next_record())
{
$lid = explode('@',$phpgw_setup->oProc->f('loginid'));
$account_lid = $lid[0];
$account_id = $accounts->name2id($account_lid);
$db2->query("select account_id from phpgw_accounts where account_lid='$account_lid'");
$db2->next_record();
$db2->query("update phpgw_access_log set account_id='" . $db2->f('account_id')
. "' where sessionid='" . $phpgw_setup->oProc->f('sessionid') . "'");
$phpgw_setup->db->query("update phpgw_access_log set account_id='" . $account_id
. "' where sessionid='" . $phpgw_setup->oProc->f('sessionid') . "'");
}
$setup_info['phpgwapi']['currentver'] = '0.9.13.005';
return $setup_info['phpgwapi']['currentver'];
}
?>
?>