Changeset 5708 in subversion
- Timestamp:
- Jan 4, 2012 8:32:14 AM (17 months ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 2 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_contacts.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r5707 r5708 2 2 =========================== 3 3 4 - Fix strict email address searching if contact has more than one address 4 5 - Use proper timezones from PHP's internal timezonedb (#1485592) 5 6 - Add separate pagesize setting for mail messages and contacts (#1488269) -
trunk/roundcubemail/program/include/rcube_contacts.php
r5406 r5708 63 63 'birthday', 'anniversary', 'website', 'im', 'notes', 'photo'); 64 64 65 const SEPARATOR = ','; 66 65 67 66 68 /** … … 233 235 if ($read_vcard) 234 236 $sql_arr = $this->convert_db_data($sql_arr); 235 else 236 $sql_arr['email'] = preg_split('/,\s*/', $sql_arr['email']); 237 else { 238 $sql_arr['email'] = explode(self::SEPARATOR, $sql_arr['email']); 239 $sql_arr['email'] = array_map('trim', $sql_arr['email']); 240 } 237 241 238 242 // make sure we have a name to display … … 288 292 $where = $and_where = array(); 289 293 $mode = intval($mode); 294 $WS = ' '; 295 $AS = self::SEPARATOR; 290 296 291 297 foreach ($fields as $idx => $col) { 292 298 // direct ID search 293 299 if ($col == 'ID' || $col == $this->primary_key) { 294 $ids = !is_array($value) ? explode( ',', $value) : $value;300 $ids = !is_array($value) ? explode(self::SEPARATOR, $value) : $value; 295 301 $ids = $this->db->array2list($ids, 'integer'); 296 302 $where[] = 'c.' . $this->primary_key.' IN ('.$ids.')'; … … 300 306 else if ($col == '*') { 301 307 $words = array(); 302 foreach (explode( " ", self::normalize_string($value)) as $word) {308 foreach (explode($WS, self::normalize_string($value)) as $word) { 303 309 switch ($mode) { 304 310 case 1: // strict 305 $words[] = '(' . $this->db->ilike('words', $word .'%')306 . ' OR ' . $this->db->ilike('words', '% '.$word.'%')307 . ' OR ' . $this->db->ilike('words', '% '.$word) . ')';311 $words[] = '(' . $this->db->ilike('words', $word . '%') 312 . ' OR ' . $this->db->ilike('words', '%' . $WS . $word . $WS . '%') 313 . ' OR ' . $this->db->ilike('words', '%' . $WS . $word) . ')'; 308 314 break; 309 315 case 2: // prefix 310 $words[] = '(' . $this->db->ilike('words', $word .'%')311 . ' OR ' . $this->db->ilike('words', '% '.$word.'%') . ')';316 $words[] = '(' . $this->db->ilike('words', $word . '%') 317 . ' OR ' . $this->db->ilike('words', '%' . $WS . $word . '%') . ')'; 312 318 break; 313 319 default: // partial 314 $words[] = $this->db->ilike('words', '%' .$word.'%');320 $words[] = $this->db->ilike('words', '%' . $word . '%'); 315 321 } 316 322 } … … 323 329 switch ($mode) { 324 330 case 1: // strict 325 $where[] = $this->db->quoteIdentifier($col).' = '.$this->db->quote($val); 331 $where[] = '(' . $this->db->quoteIdentifier($col) . ' = ' . $this->db->quote($val) 332 . ' OR ' . $this->db->ilike($col, $val . $AS . '%') 333 . ' OR ' . $this->db->ilike($col, '%' . $AS . $val . $AS . '%') 334 . ' OR ' . $this->db->ilike($col, '%' . $AS . $val) . ')'; 326 335 break; 327 336 case 2: // prefix 328 $where[] = $this->db->ilike($col, $val.'%'); 337 $where[] = '(' . $this->db->ilike($col, $val . '%') 338 . ' OR ' . $this->db->ilike($col, $AS . $val . '%') . ')'; 329 339 break; 330 340 default: // partial 331 $where[] = $this->db->ilike($col, '%' .$val.'%');341 $where[] = $this->db->ilike($col, '%' . $val . '%'); 332 342 } 333 343 } … … 338 348 switch ($mode) { 339 349 case 1: // strict 340 $words[] = '(' . $this->db->ilike('words', $word .'%')341 . ' OR ' . $this->db->ilike('words', '% '.$word.'%')342 . ' OR ' . $this->db->ilike('words', '% '.$word) . ')';350 $words[] = '(' . $this->db->ilike('words', $word . $WS . '%') 351 . ' OR ' . $this->db->ilike('words', '%' . $AS . $word . $WS .'%') 352 . ' OR ' . $this->db->ilike('words', '%' . $AS . $word) . ')'; 343 353 break; 344 354 case 2: // prefix 345 $words[] = '(' . $this->db->ilike('words', $word .'%')346 . ' OR ' . $this->db->ilike('words', ' '.$word.'%') . ')';355 $words[] = '(' . $this->db->ilike('words', $word . '%') 356 . ' OR ' . $this->db->ilike('words', $AS . $word . '%') . ')'; 347 357 break; 348 358 default: // partial 349 $words[] = $this->db->ilike('words', '%' .$word.'%');359 $words[] = $this->db->ilike('words', '%' . $word . '%'); 350 360 } 351 361 } … … 688 698 else { 689 699 $record += $sql_arr; 690 $record['email'] = preg_split('/,\s*/', $record['email']); 700 $record['email'] = explode(self::SEPARATOR, $record['email']); 701 $record['email'] = array_map('trim', $record['email']); 691 702 } 692 703 … … 721 732 if (!isset($save_data[$key])) 722 733 $key .= ':home'; 723 if (isset($save_data[$key])) 724 $out[$col] = is_array($save_data[$key]) ? join(',', $save_data[$key]) : $save_data[$key]; 734 if (isset($save_data[$key])) { 735 if (is_array($save_data[$key])) 736 $out[$col] = join(self::SEPARATOR, $save_data[$key]); 737 else 738 $out[$col] = $save_data[$key]; 739 } 725 740 } 726 741 727 742 // save all e-mails in database column 728 $out['email'] = join( ", ", $vcard->email);743 $out['email'] = join(self::SEPARATOR, $vcard->email); 729 744 730 745 // join words for fulltext search … … 744 759 { 745 760 if (!is_array($ids)) 746 $ids = explode( ',', $ids);761 $ids = explode(self::SEPARATOR, $ids); 747 762 748 763 $ids = $this->db->array2list($ids, 'integer'); … … 771 786 { 772 787 if (!is_array($ids)) 773 $ids = explode( ',', $ids);788 $ids = explode(self::SEPARATOR, $ids); 774 789 775 790 $ids = $this->db->array2list($ids, 'integer'); … … 888 903 { 889 904 if (!is_array($ids)) 890 $ids = explode( ',', $ids);905 $ids = explode(self::SEPARATOR, $ids); 891 906 892 907 $added = 0; … … 933 948 { 934 949 if (!is_array($ids)) 935 $ids = explode( ',', $ids);950 $ids = explode(self::SEPARATOR, $ids); 936 951 937 952 $ids = $this->db->array2list($ids, 'integer');
Note: See TracChangeset
for help on using the changeset viewer.
