Changeset 25fdec5 in github
- Timestamp:
- May 10, 2010 3:38:45 PM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 1ac779f
- Parents:
- 5933d98
- Files:
-
- 4 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_contacts.php (modified) (19 diffs)
-
program/include/rcube_ldap.php (modified) (2 diffs)
-
program/steps/mail/autocomplete.inc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
rc833ed4 r25fdec5 2 2 =========================== 3 3 4 - Fix autocomplete shows entries without email (#1486452) 4 5 - Fix listupdate event doesn't trigger on search response (#1486708) 5 6 - Fix select_all_mode value after selecting a message (#1486720) -
program/include/rcube_contacts.php
ra004bb8 r25fdec5 39 39 private $cache; 40 40 private $table_cols = array('name', 'email', 'firstname', 'surname', 'vcard'); 41 41 42 42 /** public properties */ 43 43 var $primary_key = 'contact_id'; … … 49 49 var $ready = false; 50 50 51 51 52 52 /** 53 53 * Object constructor … … 76 76 } 77 77 78 78 79 79 /** 80 80 * Getter for saved search properties … … 110 110 $this->cache = null; 111 111 } 112 112 113 113 114 114 /** … … 121 121 { 122 122 $results = array(); 123 123 124 124 if (!$this->groups) 125 125 return $results; … … 189 189 $this->result->add($sql_arr); 190 190 } 191 191 192 192 $cnt = count($this->result->records); 193 193 … … 203 203 $this->result->count = $this->_count(); 204 204 } 205 205 206 206 return $this->result; 207 207 } … … 216 216 * @param boolean True if results are requested, False if count only 217 217 * @param boolean True to skip the count query (select only) 218 * @param array List of fields that cannot be empty 218 219 * @return Indexed list of contact records and 'count' value 219 220 */ 220 function search($fields, $value, $strict=false, $select=true, $nocount=false )221 function search($fields, $value, $strict=false, $select=true, $nocount=false, $required=array()) 221 222 { 222 223 if (!is_array($fields)) 223 224 $fields = array($fields); 224 225 $add_where = array(); 225 if (!is_array($required) && !empty($required)) 226 $required = array($required); 227 228 $where = $and_where = array(); 229 226 230 foreach ($fields as $col) { 227 231 if ($col == 'ID' || $col == $this->primary_key) { 228 $ids = !is_array($value) ? explode(',', $value) : $value;229 $ids = $this->db->array2list($ids, 'integer');230 $ add_where[] = 'c.' . $this->primary_key.' IN ('.$ids.')';232 $ids = !is_array($value) ? explode(',', $value) : $value; 233 $ids = $this->db->array2list($ids, 'integer'); 234 $where[] = 'c.' . $this->primary_key.' IN ('.$ids.')'; 231 235 } 232 236 else if ($strict) 233 $ add_where[] = $this->db->quoteIdentifier($col).'='.$this->db->quote($value);237 $where[] = $this->db->quoteIdentifier($col).' = '.$this->db->quote($value); 234 238 else 235 $add_where[] = $this->db->ilike($col, '%'.$value.'%'); 236 } 237 238 if (!empty($add_where)) { 239 $this->set_search_set(join(' OR ', $add_where)); 239 $where[] = $this->db->ilike($col, '%'.$value.'%'); 240 } 241 242 foreach ($required as $col) { 243 $and_where[] = $this->db->quoteIdentifier($col).' <> '.$this->db->quote(''); 244 } 245 246 if (!empty($where)) 247 $where = join(' OR ', $where); 248 249 if (!empty($and_where)) 250 $where = ($where ? "($where) AND " : '') . join(' AND ', $and_where); 251 252 if (!empty($where)) { 253 $this->set_search_set($where); 240 254 if ($select) 241 255 $this->list_records(null, 0, $nocount); … … 256 270 { 257 271 $count = isset($this->cache['count']) ? $this->cache['count'] : $this->_count(); 258 272 259 273 return new rcube_result_set($count, ($this->list_page-1) * $this->page_size); 260 274 } … … 271 285 $join = " LEFT JOIN ".get_table_name('contactgroupmembers')." AS m". 272 286 " ON (m.contact_id=c.".$this->primary_key.")"; 273 287 274 288 // count contacts for this user 275 289 $sql_result = $this->db->query( … … 302 316 return $this->result; 303 317 } 304 305 318 319 306 320 /** 307 321 * Get a specific contact record … … 315 329 if ($this->result && ($first = $this->result->first()) && $first[$this->primary_key] == $id) 316 330 return $assoc ? $first : $this->result; 317 331 318 332 $this->db->query( 319 333 "SELECT * FROM ".$this->db_name. … … 423 437 $updated = $this->db->affected_rows(); 424 438 } 425 439 426 440 return $updated; 427 441 } … … 478 492 // make sure we have a unique name 479 493 $name = $this->unique_groupname($name); 480 494 481 495 $this->db->query( 482 496 "INSERT INTO ".get_table_name('contactgroups'). … … 484 498 " VALUES (".intval($this->user_id).", ".$this->db->now().", ".$this->db->quote($name).")" 485 499 ); 486 500 487 501 if ($insert_id = $this->db->insert_id('contactgroups')) 488 502 $result = array('id' => $insert_id, 'name' => $name); 489 503 490 504 return $result; 491 505 } … … 525 539 // make sure we have a unique name 526 540 $name = $this->unique_groupname($newname); 527 541 528 542 $sql_result = $this->db->query( 529 543 "UPDATE ".get_table_name('contactgroups'). … … 548 562 if (!is_array($ids)) 549 563 $ids = explode(',', $ids); 550 564 551 565 $added = 0; 552 566 553 567 foreach ($ids as $contact_id) { 554 568 $sql_result = $this->db->query( … … 613 627 $checkname = $name; 614 628 $num = 2; $hit = false; 615 629 616 630 do { 617 631 $sql_result = $this->db->query( … … 622 636 $this->user_id, 623 637 $checkname); 624 638 625 639 // append number to make name unique 626 640 if ($hit = $this->db->num_rows($sql_result)) 627 641 $checkname = $name . ' ' . $num++; 628 642 } while ($hit > 0); 629 643 630 644 return $checkname; 631 645 } -
program/include/rcube_ldap.php
r93c01888 r25fdec5 307 307 * @param boolean True for strict, False for partial (fuzzy) matching 308 308 * @param boolean True if results are requested, False if count only 309 * @param boolean (Not used) 310 * @param array List of fields that cannot be empty 309 311 * @return array Indexed list of contact records and 'count' value 310 312 */ 311 function search($fields, $value, $strict=false, $select=true )313 function search($fields, $value, $strict=false, $select=true, $nocount=false, $required=array()) 312 314 { 313 315 // special treatment for ID-based search … … 340 342 } 341 343 $filter .= ')'; 342 344 345 // add required (non empty) fields filter 346 $req_filter = ''; 347 foreach ((array)$required as $field) 348 if ($f = $this->_map_field($field)) 349 $req_filter .= "($f=*)"; 350 351 if (!empty($req_filter)) 352 $filter = '(&' . $req_filter . $filter . ')'; 353 343 354 // avoid double-wildcard if $value is empty 344 355 $filter = preg_replace('/\*+/', '*', $filter); 345 356 346 357 // add general filter to query 347 358 if (!empty($this->prop['filter'])) -
program/steps/mail/autocomplete.inc
r53d6261 r25fdec5 32 32 while ($result && ($sql_arr = $result->iterate())) 33 33 $members[] = format_email_recipient($sql_arr['email'], $sql_arr['name']); 34 34 35 35 $OUTPUT->command('replace_group_recipients', $gid, join(', ', $members)); 36 36 } … … 43 43 $abook->set_pagesize($MAXNUM); 44 44 45 if ($result = $abook->search(array('email','name'), $search, false, true, true )) {45 if ($result = $abook->search(array('email','name'), $search, false, true, true, 'email')) { 46 46 while ($sql_arr = $result->iterate()) { 47 47 $contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']); … … 50 50 } 51 51 } 52 52 53 53 // also list matching contact groups 54 54 if ($abook->groups) { … … 57 57 $abook->set_group($group['ID']); 58 58 $result = $abook->count(); 59 59 60 60 if ($result->count) { 61 61 $contacts[] = array('name' => $group['name'] . ' (' . intval($result->count) . ')', 'id' => $group['ID'], 'source' => $id); … … 66 66 } 67 67 } 68 68 69 69 usort($contacts, 'contact_results_sort'); 70 70 }
Note: See TracChangeset
for help on using the changeset viewer.
