diff --git a/phpgwapi/inc/class.accounts_ldap.inc.php b/phpgwapi/inc/class.accounts_ldap.inc.php index 0aa8d8bd65..d90b63e3cf 100644 --- a/phpgwapi/inc/class.accounts_ldap.inc.php +++ b/phpgwapi/inc/class.accounts_ldap.inc.php @@ -399,7 +399,7 @@ } elseif ($_type == 'both' || $_type == 'groups') { - $sri = ldap_search($ds, $this->group_context, '(|(gidnumber=*)(phpgwaccounttype=g))'); + $sri = ldap_search($ds, $this->group_context, '(&(gidnumber=*)(phpgwaccounttype=g))'); $allValues = ldap_get_entries($ds, $sri); while (list($null,$allVals) = @each($allValues)) { @@ -773,6 +773,52 @@ return $accountid; } + function get_account_name($accountid,&$lid,&$fname,&$lname) + { + static $account_name; + + $account_id = get_account_id($accountid); + if(isset($account_name[$account_id])) + { + $lid = $account_name[$account_id]['lid']; + $fname = $account_name[$account_id]['fname']; + $lname = $account_name[$account_id]['lname']; + return; + } + /* get an ldap connection handle */ + $ds = $GLOBALS['phpgw']->common->ldapConnect(); + $acct_type = $this->get_type($account_id); + + /* search the dn for the given uid */ + if ( ($acct_type == 'g') && $this->group_context ) + { + $sri = ldap_search($ds, $this->group_context, 'gidnumber='.$account_id); + } + else + { + $sri = ldap_search($ds, $this->user_context, 'uidnumber='.$account_id); + } + $allValues = ldap_get_entries($ds, $sri); + + if($acct_type =='g') + { + $account_name[$account_id]['lid'] = $allValues[0]['cn'][0]; + $account_name[$account_id]['fname'] = $allValues[0]['cn'][0]; + $account_name[$account_id]['lname'] = 'Group'; + } + else + { + $account_name[$account_id]['lid'] = $allValues[0]['uid'][0]; + $account_name[$account_id]['fname'] = $allValues[0]['givenname'][0]; + $account_name[$account_id]['lname'] = $allValues[0]['sn'][0]; + } + $lid = $account_name[$account_id]['lid']; + $fname = $account_name[$account_id]['fname']; + $lname = $account_name[$account_id]['lname']; + return; + } + + function getDNforID($_accountid = '') { $_account_id = get_account_id($_accountid); diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php index d73d11c82e..ae1f0de7f2 100644 --- a/phpgwapi/inc/class.accounts_sql.inc.php +++ b/phpgwapi/inc/class.accounts_sql.inc.php @@ -351,5 +351,29 @@ $this->db->transaction_commit(); return $accountid; } + + function get_account_name($accountid,&$lid,&$fname,&$lname) + { + static $account_name; + + $account_id = get_account_id($accountid); + if(isset($account_name[$account_id])) + { + $lid = $account_name[$account_id]['lid']; + $fname = $account_name[$account_id]['fname']; + $lname = $account_name[$account_id]['lname']; + return; + } + $db = $GLOBALS['phpgw']->db; + $db->query('select account_lid,account_firstname,account_lastname from phpgw_accounts where account_id='.$account_id,__LINE__,__FILE__); + $db->next_record(); + $$account_name[$account_id]['lid'] = $$db->f('account_lid'); + $$account_name[$account_id]['fname'] = $$db->f('account_firstname'); + $$account_name[$account_id]['lname'] = $$db->f('account_lastname'); + $lid = $account_name[$account_id]['lid']; + $fname = $account_name[$account_id]['fname']; + $lname = $account_name[$account_id]['lname']; + return; + } } //end of class ?> diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 458ed9475d..dd7cf5b2c6 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -379,12 +379,8 @@ */ function grab_owner_name($accountid = '') { - $account_id = get_account_id($accountid); - $db = $GLOBALS['phpgw']->db; - $db->query('select account_lid,account_firstname,account_lastname from phpgw_accounts where account_id='.$account_id,__LINE__,__FILE__); - $db->next_record(); - - return $this->display_fullname($db->f('account_lid'),$db->f('account_firstname'),$db->f('account_lastname')); + $GLOBALS['phpgw']->accounts->get_account_name($accountid,$lid,$fname,$lname); + return $this->display_fullname($lid,$fname,$lname); } /*!