allow to search for fullname

This commit is contained in:
Ralf Becker 2006-04-23 14:48:19 +00:00
parent 6922784f83
commit e52c09e0a6
2 changed files with 4 additions and 2 deletions

View File

@ -664,7 +664,7 @@
* convert an alphanumeric account-value (account_lid, account_email) to the account_id * convert an alphanumeric account-value (account_lid, account_email) to the account_id
* *
* @param string $name value to convert * @param string $name value to convert
* @param string $which='account_lid' type of $name: account_lid (default), account_email * @param string $which='account_lid' type of $name: account_lid (default), account_email, person_id, account_fullname
* @return int/false numeric account_id or false on error ($name not found) * @return int/false numeric account_id or false on error ($name not found)
*/ */
function name2id($name,$which='account_lid') function name2id($name,$which='account_lid')

View File

@ -228,7 +228,9 @@
*/ */
function name2id($name,$which='account_lid') function name2id($name,$which='account_lid')
{ {
$this->db->select($this->table,'account_id,account_type',array($which=>$name),__LINE__,__FILE__); $where = $which == 'account_fullname' ? '('.$this->db->concat('account_firstname',"' '",'account_lastname').')='.$this->db->quote($name) :
array($which => $name);
$this->db->select($this->table,'account_id,account_type',$where,__LINE__,__FILE__);
if($this->db->next_record()) if($this->db->next_record())
{ {
return ($this->db->f('account_type') == 'g' ? -1 : 1) * $this->db->f('account_id'); return ($this->db->f('account_type') == 'g' ? -1 : 1) * $this->db->f('account_id');