Cleanup second call to accounts class which was breaking in some installs

This commit is contained in:
Miles Lott 2001-04-05 19:43:38 +00:00
parent 06957d529b
commit 42f5df0ee9

View File

@ -128,41 +128,49 @@
} }
$acl->save_repository(); $acl->save_repository();
while ($account = each($account_info)) { while ($account = each($account_info))
{
$id_exist = 0; $id_exist = 0;
$thisacctid = $account[1]['account_id'];
$thisacctlid = $account[1]['account_lid'];
$thisfirstname = $account[1]['account_firstname'];
$thislastname = $account[1]['account_lastname'];
// Do some checks before we try to import the data. // Do some checks before we try to import the data.
if (!empty($account[1]['account_id']) && !empty($account[1]['account_lid'])) if (!empty($thisacctid) && !empty($thisacctlid))
$accounts = CreateObject('phpgwapi.accounts',$account[1]['account_id']); {
$accounts = CreateObject('phpgwapi.accounts',intval($thisacctid));
$accounts->db = $phpgw_setup->db; $accounts->db = $phpgw_setup->db;
// Check if the account is already there. // Check if the account is already there.
// If so, we won't try to create it again. // If so, we won't try to create it again.
$acct_exist = $acct->name2id($account[1]['account_lid']); $acct_exist = $acct->name2id($thisacctid);
if ($acct_exist) { if ($acct_exist)
$account[1]['account_id'] = $acct_exist; {
$thisacctid = $acct_exist;
} }
$id_exist = $accounts->exists(intval($account[1]['account_id'])); $id_exist = $accounts->exists(intval($thisacctid));
// If not, create it now. // If not, create it now.
if(!$id_exist) { if(!$id_exist)
$accounts->create('u', $account[1]['account_lid'], 'x', {
$account[1]['account_firstname'], $account[1]['account_lastname'], $accounts->create('u', $thisacctlid, 'x',$thisfirstname, $thislastname,'A',$thisacctid);
'A',$account[1]['account_id']
);
} }
// Insert default acls for this user. // Insert default acls for this user.
// Since the group has app rights, we don't need to give users // Since the group has app rights, we don't need to give users
// these rights. Instead, we make the user a member of the Default group // these rights. Instead, we make the user a member of the Default group
// below. // below.
$acl = CreateObject('phpgwapi.acl',intval($account[1]['account_id'])); $acl = CreateObject('phpgwapi.acl',intval($thisacctid));
$acl->db = $phpgw_setup->db; $acl->db = $phpgw_setup->db;
$acl->read_repository(); $acl->read_repository();
// Only give them admin if we asked for them to have it. // Only give them admin if we asked for them to have it.
// This is typically an exception to apps for run rights // This is typically an exception to apps for run rights
// as a group member. // as a group member.
for ($a=0;$a<count($admins);$a++) { for ($a=0;$a<count($admins);$a++)
if ($admins[$a] == $account[1]['account_id']) { {
if ($admins[$a] == $thisacctid)
{
$acl->delete('admin','run',1); $acl->delete('admin','run',1);
$acl->add('admin','run',1); $acl->add('admin','run',1);
} }
@ -170,7 +178,8 @@
// Now make them a member of the 'Default' group. // Now make them a member of the 'Default' group.
// But, only if the current user is not the group itself. // But, only if the current user is not the group itself.
if ($defaultgroupid != $account[1]['account_id']) { if ($defaultgroupid != $thisacctid)
{
$acl->delete('phpgw_group',$defaultgroupid,1); $acl->delete('phpgw_group',$defaultgroupid,1);
$acl->add('phpgw_group',$defaultgroupid,1); $acl->add('phpgw_group',$defaultgroupid,1);
} }
@ -181,8 +190,9 @@
$setup_complete = True; $setup_complete = True;
} }
} }
}
// Add a check to see if there is no users in LDAP, if not create a default user. // Add a check to see if there are no users in LDAP, if not create a default user.
$phpgw_setup->show_header(); $phpgw_setup->show_header();