change create to use account_XXX, made newgroup use newer create

This commit is contained in:
Miles Lott 2001-05-10 09:34:47 +00:00
parent 12132dac30
commit 8060a2efee
5 changed files with 66 additions and 40 deletions

View File

@ -103,13 +103,13 @@
));
$account_info = array(
'type' => 'u',
'lid' => $account_lid,
'passwd' => $account_passwd,
'firstname' => $account_firstname,
'lastname' => $account_lastname,
'status' => $account_status,
'expires' => $account_expires
'account_type' => 'u',
'account_lid' => $account_lid,
'account_passwd' => $account_passwd,
'account_firstname' => $account_firstname,
'account_lastname' => $account_lastname,
'account_status' => $account_status,
'account_expires' => $account_expires
);
$phpgw->accounts->create($account_info);

View File

@ -47,6 +47,23 @@
}
}
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(
@ -59,7 +76,16 @@
));
$group = CreateObject('phpgwapi.accounts',$group_id);
$group->create('g', $n_group, 'Group', $n_group, '', '');
$account_info = array(
'account_type' => 'g',
'account_lid' => $n_group,
'account_passwd' => '',
'account_firstname' => $n_group,
'account_lastname' => 'Group',
'account_status' => 'A',
'account_expires' => $account_expires
);
$group->create($account_info);
$group_id = $phpgw->accounts->name2id($n_group);
$apps = CreateObject('phpgwapi.applications',intval($group_id));

View File

@ -338,7 +338,7 @@
$ds = $phpgw->common->ldapConnect();
if (! $account_info['id'])
if (! $account_info['account_id'])
{
if ($phpgw_info['server']['account_min_id']) { $min = $phpgw_info['server']['account_min_id']; }
if ($phpgw_info['server']['account_max_id']) { $max = $phpgw_info['server']['account_max_id']; }
@ -371,22 +371,22 @@
}
$this->db->query("insert into phpgw_accounts (account_id, account_lid, account_type, account_pwd, "
. "account_firstname, account_lastname, account_status, account_expires) values ('" . $account_id . "','" . $account_info['lid']
. "','" . $account_info['type'] . "','" . md5($account_info['passwd']) . "', '" . $account_info['firstname']
. "','" . $account_info['lastname'] . "','" . $account_info['status'] . "'," . $account_info['expires'] . ")",__LINE__,__FILE__);
. "account_firstname, account_lastname, account_status, account_expires) values ('" . $account_id . "','" . $account_info['account_lid']
. "','" . $account_info['account_type'] . "','" . md5($account_info['account_passwd']) . "', '" . $account_info['account_firstname']
. "','" . $account_info['account_lastname'] . "','" . $account_info['account_status'] . "'," . $account_info['account_expires'] . ")",__LINE__,__FILE__);
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'],'uid=' . $account_info['lid']);
$allValues = ldap_get_entries($ds, $sri);
$entry['uidnumber'] = $account_id;
$entry['gidnumber'] = $account_id;
$entry['uid'] = $account_info['lid'];
$entry['cn'] = sprintf('%s %s', $account_firstname, $account_info['lastname']);
$entry['sn'] = $account_info['lastname'];
$entry['givenname'] = $account_info['firstname'];
$entry['userpassword'] = $phpgw->common->encrypt_password($account_info['passwd']);
$entry['uid'] = $account_info['account_lid'];
$entry['cn'] = sprintf('%s %s', $account_firstname, $account_info['account_lastname']);
$entry['sn'] = $account_info['account_lastname'];
$entry['givenname'] = $account_info['account_firstname'];
$entry['userpassword'] = $phpgw->common->encrypt_password($account_info['account_passwd']);
if ($phpgw_info['server']['ldap_extra_attributes'] && $account_info['type'] != 'g')
if ($phpgw_info['server']['ldap_extra_attributes'] && $account_info['account_type'] != 'g')
{
if ($account_home)
{
@ -394,7 +394,7 @@
}
else
{
$entry['homedirectory'] = $phpgw_info['server']['ldap_account_home'].SEP.$account_info['lid'];
$entry['homedirectory'] = $phpgw_info['server']['ldap_account_home'].SEP.$account_info['account_lid'];
}
if ($account_shell)
@ -438,7 +438,7 @@
// $tmpentry["objectclass"][1] = 'posixGroup';
// }
// else
if ($account_info['type'] == 'u')
if ($account_info['account_type'] == 'u')
{
$tmpentry['objectclass'][0] = 'top';
$tmpentry['objectclass'][1] = 'person';
@ -459,9 +459,9 @@
// $entry["objectclass"][1] = 'posixGroup';
// }
// else
if ($account_info['type'] == 'u')
if ($account_info['account_type'] == 'u')
{
$dn = 'uid=' . $account_info['lid'] . ',' . $phpgw_info['server']['ldap_context'];
$dn = 'uid=' . $account_info['account_lid'] . ',' . $phpgw_info['server']['ldap_context'];
$entry['objectclass'][0] = 'top';
$entry['objectclass'][1] = 'person';
$entry['objectclass'][2] = 'organizationalPerson';

View File

@ -213,9 +213,9 @@
function create($account_info)
{
$this->db->query("insert into phpgw_accounts (account_lid, account_type, account_pwd, "
. "account_firstname, account_lastname, account_status, account_expires) values ('" . $account_info['lid']
. "','" . $account_info['type'] . "','" . md5($account_info['passwd']) . "', '" . $account_info['firstname']
. "','" . $account_info['lastname'] . "','" . $account_info['status'] . "','" . $account_info['expires']
. "account_firstname, account_lastname, account_status, account_expires) values ('" . $account_info['account_lid']
. "','" . $account_info['account_type'] . "','" . md5($account_info['account_passwd']) . "', '" . $account_info['account_firstname']
. "','" . $account_info['account_lastname'] . "','" . $account_info['account_status'] . "','" . $account_info['account_expires']
. "')",__LINE__,__FILE__);
}

View File

@ -113,14 +113,14 @@
$id_exist = $acct->exists(intval($defaultgroupid));
// if not, create it, using our original groupid.
$thisgroup_info = array(
'type' => 'g',
'id' => $defaultgroupid,
'lid' => 'Default',
'passwd' => $passwd,
'firstname' => 'Default',
'lastname' => 'Group',
'status' => 'A',
'expires' => -1
'account_type' => 'g',
'account_id' => $defaultgroupid,
'account_lid' => 'Default',
'account_passwd' => $passwd,
'account_firstname' => 'Default',
'account_lastname' => 'Group',
'account_status' => 'A',
'account_expires' => -1
);
if(!$id_exist)
{
@ -169,13 +169,13 @@
if(!$id_exist)
{
$thisaccount_info = array(
'type' => 'u',
'lid' => $thisacctlid,
'passwd' => 'x',
'firstname' => $thisfirstname,
'lastname' => $thislastname,
'status' => 'A',
'expires' => -1
'account_type' => 'u',
'account_lid' => $thisacctlid,
'account_passwd' => 'x',
'account_firstname' => $thisfirstname,
'account_lastname' => $thislastname,
'account_status' => 'A',
'account_expires' => -1
);
$accounts->create($thisaccount_info);
}