diff options
author | thomascube <thomas@roundcube.net> | 2007-07-03 17:25:05 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2007-07-03 17:25:05 +0000 |
commit | 3fc00e67bbfa5bad7b0d29d268545036f6dc684d (patch) | |
tree | ca892af590f512760116b31d2f23c5fa23ba7c35 /program | |
parent | b716bd92d833e2d2546b3f2de6f2c6d001dc166a (diff) |
Fix address adding bug reported by David Koblas
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcube_contacts.inc | 6 | ||||
-rw-r--r-- | program/include/rcube_ldap.inc | 4 | ||||
-rw-r--r-- | program/steps/addressbook/save.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/addcontact.inc | 2 |
4 files changed, 8 insertions, 6 deletions
diff --git a/program/include/rcube_contacts.inc b/program/include/rcube_contacts.inc index 3902e2a3b..c6dc40dfd 100644 --- a/program/include/rcube_contacts.inc +++ b/program/include/rcube_contacts.inc @@ -171,7 +171,7 @@ class rcube_contacts * @param boolean True if results are requested, False if count only * @return Indexed list of contact records and 'count' value */ - function search($fields, $value, $select=true) + function search($fields, $value, $strict=false, $select=true) { if (!is_array($fields)) $fields = array($fields); @@ -184,6 +184,8 @@ class rcube_contacts $ids = !is_array($value) ? split(',', $value) : $value; $add_where[] = $this->primary_key." IN (".join(',', $ids).")"; } + else if ($strict) + $add_where[] = $this->db->quoteIdentifier($col)."=".$this->db->quote($value); else $add_where[] = $this->db->quoteIdentifier($col)." LIKE ".$this->db->quote(strlen($value)>2 ? "%$value%" : "$value%"); } @@ -278,7 +280,7 @@ class rcube_contacts $insert_id = $existing = false; if ($check) - $existing = $this->search('email', $save_data['email'], false); + $existing = $this->search('email', $save_data['email'], true, false); $a_insert_cols = $a_insert_values = array(); foreach ($this->table_cols as $col) diff --git a/program/include/rcube_ldap.inc b/program/include/rcube_ldap.inc index 055c346e1..1aa88f1c8 100644 --- a/program/include/rcube_ldap.inc +++ b/program/include/rcube_ldap.inc @@ -231,7 +231,7 @@ class rcube_ldap * @param boolean True if results are requested, False if count only * @return Indexed list of contact records and 'count' value */ - function search($fields, $value, $select=true) + function search($fields, $value, $strict=false, $select=true) { // special treatment for ID-based search if ($fields == 'ID' || $fields == $this->primary_key) @@ -249,7 +249,7 @@ class rcube_ldap } $filter = '(|'; - $wc = $this->prop['fuzzy_search'] ? '*' : ''; + $wc = !$strict && $this->prop['fuzzy_search'] ? '*' : ''; if (is_array($this->prop['search_fields'])) { foreach ($this->prop['search_fields'] as $k => $field) diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc index 72e54b173..c16d4729f 100644 --- a/program/steps/addressbook/save.inc +++ b/program/steps/addressbook/save.inc @@ -83,7 +83,7 @@ if (!empty($cid)) else { // check for existing contacts - $existing = $CONTACTS->search('email', $a_record['email'], false); + $existing = $CONTACTS->search('email', $a_record['email'], true, false); // show warning message if ($existing->count) diff --git a/program/steps/mail/addcontact.inc b/program/steps/mail/addcontact.inc index 484b0d4ba..2cf190358 100644 --- a/program/steps/mail/addcontact.inc +++ b/program/steps/mail/addcontact.inc @@ -40,7 +40,7 @@ if (!empty($_POST['_address'])) $contact['name'] = ucfirst(preg_replace('/[\.\-]/', ' ', substr($contact['email'], 0, strpos($contact['email'], '@')))); // check for existing contacts - $existing = $CONTACTS->search('email', $contact['email'], false); + $existing = $CONTACTS->search('email', $contact['email'], true, false); if ($done = $existing->count) $OUTPUT->show_message('contactexists', 'warning'); else if ($done = $CONTACTS->insert($contact)) |