From 8060a2efee3e8afc2a77909b71f41252250a2e51 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Thu, 10 May 2001 09:34:47 +0000 Subject: [PATCH] change create to use account_XXX, made newgroup use newer create --- admin/newaccount.php | 14 +++++------ admin/newgroup.php | 28 +++++++++++++++++++++- phpgwapi/inc/class.accounts_ldap.inc.php | 28 +++++++++++----------- phpgwapi/inc/class.accounts_sql.inc.php | 6 ++--- setup/ldap.php | 30 ++++++++++++------------ 5 files changed, 66 insertions(+), 40 deletions(-) diff --git a/admin/newaccount.php b/admin/newaccount.php index 53359ea914..4b8a862791 100755 --- a/admin/newaccount.php +++ b/admin/newaccount.php @@ -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); diff --git a/admin/newgroup.php b/admin/newgroup.php index 04b001bc67..f1ba4d28be 100755 --- a/admin/newgroup.php +++ b/admin/newgroup.php @@ -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)); diff --git a/phpgwapi/inc/class.accounts_ldap.inc.php b/phpgwapi/inc/class.accounts_ldap.inc.php index 982f487616..aaec6aed99 100644 --- a/phpgwapi/inc/class.accounts_ldap.inc.php +++ b/phpgwapi/inc/class.accounts_ldap.inc.php @@ -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'; diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php index 841d24dead..fdddf4b07e 100644 --- a/phpgwapi/inc/class.accounts_sql.inc.php +++ b/phpgwapi/inc/class.accounts_sql.inc.php @@ -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__); } diff --git a/setup/ldap.php b/setup/ldap.php index 092a9bd34e..b9a3a79655 100644 --- a/setup/ldap.php +++ b/setup/ldap.php @@ -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); }