Index: account_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/account_page.php,v
retrieving revision 1.41
diff -u -r1.41 account_page.php
--- account_page.php 27 Feb 2003 07:04:57 -0000 1.41
+++ account_page.php 4 Jan 2004 03:59:26 -0000
@@ -48,7 +48,7 @@
# extracts the user information for the currently logged in user
# and prefixes it with u_
- $row = user_get_row( auth_get_current_user_id() );
+ $row = user_get_row( auth_get_current_user_id() );
extract( $row, EXTR_PREFIX_ALL, 'u' );
$t_ldap = ( LDAP == config_get( 'login_method' ) );
@@ -56,6 +56,13 @@
# In case we're using LDAP to get the email address... this will pull out
# that version instead of the one in the DB
$u_email = user_get_email( $u_id, $u_username );
+ if( $t_ldap ) {
+ # new function to return desired LDAP fields
+ $ldap_user_info = ldap_get_user_info( $u_username );
+ //over-write null values that should have been returned by
+ // db query.
+ extract ($row, EXTR_PREFIX_ALL, 'u' );
+ }
html_page_top1();
html_page_top2();
@@ -76,11 +83,15 @@
+
-
-
|
:
Index: core/ldap_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/ldap_api.php,v
retrieving revision 1.12
diff -u -r1.12 ldap_api.php
--- core/ldap_api.php 24 Oct 2003 12:44:26 -0000 1.12
+++ core/ldap_api.php 4 Jan 2004 03:59:27 -0000
@@ -70,6 +70,84 @@
}
# --------------------
+ # Return first name, last name and phone number from ldap to display.
+ # returns an assoc array.
+ function ldap_get_user_info( $p_username ) {
+ $t_ldap_organization = config_get( 'ldap_organization' );
+ $t_ldap_root_dn = config_get( 'ldap_root_dn' );
+
+ $t_search_filter = "(&$t_ldap_organization(uid=$p_username))";
+ $t_search_attrs = array( 'uid', 'givenName','sn','telephoneNumber', 'dn' );
+ $t_ds = ldap_connect_bind();
+
+ $t_sr = ldap_search( $t_ds, $t_ldap_root_dn, $t_search_filter, $t_search_attrs );
+ $t_info = ldap_get_entries( $t_ds, $t_sr );
+ ldap_free_result( $t_sr );
+ ldap_unbind( $t_ds );
+
+ $result_array['firstname'] = $t_info[0]['givenName'][0];
+ $result_array['lastname'] = $t_info[0]['sn'][0];
+ //@@@ this assumes the number in ldap is the users workphone...
+ $result_array['workphone'] = $t_info[0]['telephoneNumber'][0];
+
+ return $result_array;
+ }
+
+ # --------------------
+ # Return a first name from LDAP, given a username
+ function ldap_fname_from_username( $p_username ) {
+ $t_ldap_organization = config_get( 'ldap_organization' );
+ $t_ldap_root_dn = config_get( 'ldap_root_dn' );
+
+ $t_search_filter = "(&$t_ldap_organization(uid=$p_username))";
+ $t_search_attrs = array( 'uid', 'givenname', 'dn' );
+ $t_ds = ldap_connect_bind();
+
+ $t_sr = ldap_search( $t_ds, $t_ldap_root_dn, $t_search_filter, $t_search_attrs );
+ $t_info = ldap_get_entries( $t_ds, $t_sr );
+ ldap_free_result( $t_sr );
+ ldap_unbind( $t_ds );
+
+ return $t_info[0]['givenname'][0];
+ }
+
+ # --------------------
+ # Return a telephone number from LDAP, given a username
+ function ldap_tele_from_username( $p_username ) {
+ $t_ldap_organization = config_get( 'ldap_organization' );
+ $t_ldap_root_dn = config_get( 'ldap_root_dn' );
+
+ $t_search_filter = "(&$t_ldap_organization(uid=$p_username))";
+ $t_search_attrs = array( 'uid', 'telephoneNumber', 'dn' );
+ $t_ds = ldap_connect_bind();
+
+ $t_sr = ldap_search( $t_ds, $t_ldap_root_dn, $t_search_filter, $t_search_attrs );
+ $t_info = ldap_get_entries( $t_ds, $t_sr );
+ ldap_free_result( $t_sr );
+ ldap_unbind( $t_ds );
+
+ return $t_info[0]['telephoneNumber'][0];
+ }
+
+ # --------------------
+ # Return an last name from LDAP, given a username
+ function ldap_lname_from_username( $p_username ) {
+ $t_ldap_organization = config_get( 'ldap_organization' );
+ $t_ldap_root_dn = config_get( 'ldap_root_dn' );
+
+ $t_search_filter = "(&$t_ldap_organization(uid=$p_username))";
+ $t_search_attrs = array( 'uid', 'sn', 'dn' );
+ $t_ds = ldap_connect_bind();
+
+ $t_sr = ldap_search( $t_ds, $t_ldap_root_dn, $t_search_filter, $t_search_attrs );
+ $t_info = ldap_get_entries( $t_ds, $t_sr );
+ ldap_free_result( $t_sr );
+ ldap_unbind( $t_ds );
+
+ return $t_info[0]['sn'][0];
+ }
+
+ # --------------------
# Return true if the $uid has an assigngroup=$p_group tag, false otherwise
function ldap_has_group( $p_user_id, $p_group ) {
$t_ldap_organization = config_get( 'ldap_organization' );
Index: core/user_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/user_api.php,v
retrieving revision 1.63
diff -u -r1.63 user_api.php
--- core/user_api.php 17 Dec 2003 22:20:32 -0000 1.63
+++ core/user_api.php 4 Jan 2004 03:59:28 -0000
@@ -227,7 +227,7 @@
# --------------------
# Create a user.
# returns false if error, the generated cookie string if ok
- function user_create( $p_username, $p_password, $p_email='', $p_access_level=null, $p_protected=false, $p_enabled=true ) {
+ function user_create( $p_username, $p_password, $p_firstname, $p_lastname, $p_email='', $p_access_level=null, $p_protected=false, $p_enabled=true ) {
if ( null === $p_access_level ) {
$p_access_level = config_get( 'default_new_account_access_level');
}
@@ -236,10 +236,13 @@
$c_username = db_prepare_string( $p_username );
$c_password = db_prepare_string( $t_password );
- $c_email = db_prepare_string( $p_email );
+ $c_firstname = db_prepare_string( $p_firstname );
+ $c_lastname = db_prepare_string( $p_lastname );
+ $c_email = db_prepare_string( $p_email );
+
$c_access_level = db_prepare_int( $p_access_level );
- $c_protected = db_prepare_bool( $p_protected );
- $c_enabled = db_prepare_bool( $p_enabled );
+ $c_protected = db_prepare_bool( $p_protected );
+ $c_enabled = db_prepare_bool( $p_enabled );
user_ensure_name_valid( $p_username );
user_ensure_name_unique( $p_username );
@@ -248,16 +251,20 @@
$t_seed = $p_email.$p_username;
$t_cookie_string = auth_generate_unique_cookie_string( $t_seed );
- $t_user_table = config_get( 'mantis_user_table' );
+ $t_user_table = config_get( 'mantis_user_table' );
$query = "INSERT INTO $t_user_table
- ( id, username, email, password, date_created, last_visit,
+ ( id, username, firstname, lastname, email, password, date_created, last_visit,
enabled, access_level, login_count, cookie_string )
VALUES
- ( null, '$c_username', '$c_email', '$c_password', NOW(), NOW(),
+ ( null, '$c_username', '$c_firstname', '$c_lastname', '$c_email', '$c_password', NOW(), NOW(),
$c_enabled, $c_access_level, 0, '$t_cookie_string')";
+
+ $fp = fopen("/tmp/debug.txt", 'w');
+ fwrite($fp,"$query");
+ fclose($fp);
db_query( $query );
-
+
# Create preferences for the user
$t_user_id = db_insert_id();
user_pref_set_default( $t_user_id );
@@ -281,7 +288,7 @@
# If the use_ldap_email config option is on then tries to find email using
# ldap. $p_email may be empty, but the user wont get any emails.
# returns false if error, the generated cookie string if ok
- function user_signup( $p_username, $p_email=null ) {
+ function user_signup( $p_username, $p_firstname, $p_lastname, $p_email=null ) {
if ( null === $p_email ) {
$p_email = '';
@@ -300,21 +307,36 @@
/* $t_email = '';
if ( ON == config_get( 'use_ldap_email' ) ) {
$t_email = ldap_email_from_username( $p_username );
+ $t_firstname = ldap_fname_from_username( $p_username );
+ $t_lastname = ldap_lname_from_username( $p_username );
}
if ( ! is_blank( $t_email ) ) {
$p_email = $t_email;
+
+ }
+
+ if ( ! is_blank( $t_firstname ) ) {
+ $p_firstname = $t_firstname;
+
}
+
+ if ( ! is_blank( $t_lastname ) ) {
+ $p_lastname = $t_lastname;
+
+ }
*/
}
- $p_email = trim( $p_email );
-
+ $p_email = trim( $p_email );
+ $p_firstname = trim( $p_firstname );
+ $p_lastname = trim( $p_lastname );
+
$t_seed = $p_email.$p_username;
# Create random password
$t_password = auth_generate_random_password( $t_seed );
- return user_create( $p_username, $t_password, $p_email );
+ return user_create( $p_username, $t_password, $p_firstname, $p_lastname, $p_email );
}
# --------------------
Index: lang/strings_english.txt
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v
retrieving revision 1.144
diff -u -r1.144 strings_english.txt
--- lang/strings_english.txt 11 Sep 2003 14:14:57 -0000 1.144
+++ lang/strings_english.txt 4 Jan 2004 03:59:29 -0000
@@ -280,11 +280,21 @@
$s_change_preferences_link = 'Preferences';
$s_edit_account_title = 'Edit Account';
$s_username = 'Username';
+$s_firstname = 'First Name';
+$s_lastname = 'Last Name';
$s_email = 'Email';
+$s_email_note = 'where system mail is sent';
+$s_email2 = 'Email 2';
+$s_email3 = 'Email 3';
+$s_homephone = 'Home Phone';
+$s_workphone = 'Work Phone';
+$s_mobilephone = 'Mobile Phone';
+$s_otherphone = 'Other Phone';
$s_password = 'Password';
$s_confirm_password = 'Confirm Password';
$s_access_level = 'Access Level';
$s_update_user_button = 'Update User';
+$s_ldap_message = 'The password is controlled by your LDAP entry. It cannot be edited here.';
# account_prefs_page.php
$s_default_account_preferences_title = 'Account Preferences';
Index: sql/db_generate.sql
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/sql/db_generate.sql,v
retrieving revision 1.14
diff -u -r1.14 db_generate.sql
--- sql/db_generate.sql 22 Mar 2003 10:53:25 -0000 1.14
+++ sql/db_generate.sql 4 Jan 2004 03:59:30 -0000
@@ -684,7 +684,15 @@
CREATE TABLE mantis_user_table (
id int(7) unsigned NOT NULL auto_increment,
username varchar(32) NOT NULL default '',
+ firstname varchar(64) NOT NULL default '',
+ lastname varchar(64) NOT NULL default '',
email varchar(64) NOT NULL default '',
+ email2 varchar(64) NULL,
+ email3 varchar(64) NULL,
+ workphone varchar(20) NULL,
+ homephone varchar(20) NULL,
+ mobilephone varchar(20) NULL,
+ otherphone varchar(20) NULL,
password varchar(32) NOT NULL default '',
date_created datetime NOT NULL default '1970-01-01 00:00:01',
last_visit datetime NOT NULL default '1970-01-01 00:00:01',
@@ -702,5 +710,5 @@
# Dumping data for table 'mantis_user_table'
#
-INSERT INTO mantis_user_table VALUES (1,'administrator','admin','63a9f0ea7bb98050796b649e85481845','2003-02-16 02:03:48','2003-02-16 02:36:38',1,1,90,3,'MN91uSF/JIhos8bcda8acc2ead8d60749ad019e56b54fadkPGTyoBgNBQf91563');
+INSERT INTO mantis_user_table VALUES (1,'administrator','Mantis','Admin','admin',NULL,NULL,NULL,NULL,NULL,NULL,'63a9f0ea7bb98050796b649e85481845','2003-02-16 02:03:48','2003-02-16 02:36:38',1,1,90,3,'MN91uSF/JIhos8bcda8acc2ead8d60749ad019e56b54fadkPGTyoBgNBQf91563');
|