From e52c09e0a621a93f010dd6c09a0c9ace47c52091 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 23 Apr 2006 14:48:19 +0000 Subject: [PATCH] allow to search for fullname --- phpgwapi/inc/class.accounts.inc.php | 2 +- phpgwapi/inc/class.accounts_sql.inc.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/phpgwapi/inc/class.accounts.inc.php b/phpgwapi/inc/class.accounts.inc.php index ecc0eea845..829c34e4ac 100644 --- a/phpgwapi/inc/class.accounts.inc.php +++ b/phpgwapi/inc/class.accounts.inc.php @@ -664,7 +664,7 @@ * convert an alphanumeric account-value (account_lid, account_email) to the account_id * * @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) */ function name2id($name,$which='account_lid') diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php index 2919c2b0d9..80fe1ae2cb 100644 --- a/phpgwapi/inc/class.accounts_sql.inc.php +++ b/phpgwapi/inc/class.accounts_sql.inc.php @@ -228,7 +228,9 @@ */ 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()) { return ($this->db->f('account_type') == 'g' ? -1 : 1) * $this->db->f('account_id');