Changeset c0297f4 in github for program/include/rcube_contacts.php
- Timestamp:
- Mar 31, 2010 11:23:22 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 64d855c
- Parents:
- 3baa72a
- File:
-
- 1 edited
-
program/include/rcube_contacts.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcube_contacts.php
r3baa72a rc0297f4 40 40 var $primary_key = 'contact_id'; 41 41 var $readonly = false; 42 var $groups = true;42 var $groups = false; 43 43 var $list_page = 1; 44 44 var $page_size = 10; … … 59 59 $this->user_id = $user; 60 60 $this->ready = $this->db && !$this->db->is_error(); 61 62 if (in_array('contactgroups', $this->db->list_tables())) 63 $this->groups = true; 61 64 } 62 65 … … 114 117 { 115 118 $results = array(); 119 120 if (!$this->groups) 121 return $results; 122 116 123 $sql_filter = $search ? "AND " . $this->db->ilike('name', '%'.$search.'%') : ''; 117 124 … … 135 142 * List the current set of contact records 136 143 * 137 * @param array List of cols to show 138 * @param int Only return this number of records, use negative values for tail 144 * @param array List of cols to show 145 * @param int Only return this number of records, use negative values for tail 146 * @param boolean True to skip the count query (select only) 139 147 * @return array Indexed list of contact records, each a hash array 140 148 */ 141 function list_records($cols=null, $subset=0 )149 function list_records($cols=null, $subset=0, $nocount=false) 142 150 { 143 151 // count contacts for this user 144 $this->result = $ this->count();152 $this->result = $nocount ? new rcube_result_set(1) : $this->count(); 145 153 $sql_result = NULL; 146 154 … … 149 157 { 150 158 if ($this->group_id) 151 $join = "LEFT JOIN ".get_table_name('contactgroupmembers')." AS rcmgrouplinks".152 " ON ( rcmgrouplinks.contact_id=rcmcontacts.".$this->primary_key.")";159 $join = "LEFT JOIN ".get_table_name('contactgroupmembers')." AS m". 160 " ON (m.contact_id=c.".$this->primary_key.")"; 153 161 154 162 $start_row = $subset < 0 ? $this->result->first + $this->page_size + $subset : $this->result->first; … … 156 164 157 165 $sql_result = $this->db->limitquery( 158 "SELECT * FROM ".$this->db_name." AS rcmcontacts".$join."159 WHERE rcmcontacts.del<>1160 AND rcmcontacts.user_id=?" .161 ($this->group_id ? " AND rcmgrouplinks.contactgroup_id=?" : "").166 "SELECT * FROM ".$this->db_name." AS c ".$join." 167 WHERE c.del<>1 168 AND c.user_id=?" . 169 ($this->group_id ? " AND m.contactgroup_id=?" : ""). 162 170 ($this->filter ? " AND (".$this->filter.")" : "") . 163 " ORDER BY rcmcontacts.name",171 " ORDER BY c.name", 164 172 $start_row, 165 173 $length, … … 177 185 } 178 186 187 if ($nocount) 188 $this->result->count = count($this->result->records); 189 179 190 return $this->result; 180 191 } … … 188 199 * @param boolean True for strict (=), False for partial (LIKE) matching 189 200 * @param boolean True if results are requested, False if count only 201 * @param boolean True to skip the count query (select only) 190 202 * @return Indexed list of contact records and 'count' value 191 203 */ 192 function search($fields, $value, $strict=false, $select=true )204 function search($fields, $value, $strict=false, $select=true, $nocount=false) 193 205 { 194 206 if (!is_array($fields)) … … 213 225 $this->set_search_set(join(' OR ', $add_where)); 214 226 if ($select) 215 $this->list_records( );227 $this->list_records(null, 0, $nocount); 216 228 else 217 229 $this->result = $this->count(); … … 230 242 { 231 243 if ($this->group_id) 232 $join = "LEFT JOIN ".get_table_name('contactgroupmembers')." AS rcmgrouplinks".233 " ON ( rcmgrouplinks.contact_id=rcmcontacts.".$this->primary_key.")";244 $join = "LEFT JOIN ".get_table_name('contactgroupmembers')." AS m". 245 " ON (m.contact_id=c.".$this->primary_key.")"; 234 246 235 247 // count contacts for this user 236 248 $sql_result = $this->db->query( 237 "SELECT COUNT( rcmcontacts.contact_id) AS rows238 FROM ".$this->db_name." AS rcmcontacts".$join."239 WHERE rcmcontacts.del<>1240 AND rcmcontacts.user_id=?".241 ($this->group_id ? " AND rcmgrouplinks.contactgroup_id=?" : "").249 "SELECT COUNT(c.contact_id) AS rows 250 FROM ".$this->db_name." AS c ".$join." 251 WHERE c.del<>1 252 AND c.user_id=?". 253 ($this->group_id ? " AND m.contactgroup_id=?" : ""). 242 254 ($this->filter ? " AND (".$this->filter.")" : ""), 243 255 $this->user_id,
Note: See TracChangeset
for help on using the changeset viewer.
