| | |
| | | private $result = null; |
| | | private $search_fields; |
| | | private $search_string; |
| | | private $cache; |
| | | private $table_cols = array('name', 'email', 'firstname', 'surname', 'vcard'); |
| | | |
| | | /** public properties */ |
| | |
| | | function set_search_set($filter) |
| | | { |
| | | $this->filter = $filter; |
| | | $this->cache = null; |
| | | } |
| | | |
| | | |
| | |
| | | function set_group($gid) |
| | | { |
| | | $this->group_id = $gid; |
| | | $this->cache = null; |
| | | } |
| | | |
| | | |
| | |
| | | $this->filter = null; |
| | | $this->search_fields = null; |
| | | $this->search_string = null; |
| | | $this->cache = null; |
| | | } |
| | | |
| | | |
| | |
| | | foreach ($fields as $col) { |
| | | if ($col == 'ID' || $col == $this->primary_key) { |
| | | $ids = !is_array($value) ? explode(',', $value) : $value; |
| | | $add_where[] = 'c.' . $this->primary_key.' IN ('.join(',', $ids).')'; |
| | | $ids = join(',', array_map(array($this->db, 'quote'), $ids)); |
| | | $add_where[] = 'c.' . $this->primary_key.' IN ('.$ids.')'; |
| | | } |
| | | else if ($strict) |
| | | $add_where[] = $this->db->quoteIdentifier($col).'='.$this->db->quote($value); |
| | |
| | | */ |
| | | function count() |
| | | { |
| | | return new rcube_result_set($this->_count(), ($this->list_page-1) * $this->page_size); |
| | | $count = isset($this->cache['count']) ? $this->cache['count'] : $this->_count(); |
| | | |
| | | return new rcube_result_set($count, ($this->list_page-1) * $this->page_size); |
| | | } |
| | | |
| | | |
| | |
| | | ); |
| | | |
| | | $sql_arr = $this->db->fetch_assoc($sql_result); |
| | | return (int) $sql_arr['rows']; |
| | | |
| | | $this->cache['count'] = (int) $sql_arr['rows']; |
| | | |
| | | return $this->cache['count']; |
| | | } |
| | | |
| | | |
| | |
| | | if ($insert_id && $this->group_id) |
| | | $this->add_to_group($this->group_id, $insert_id); |
| | | |
| | | $this->cache = null; |
| | | |
| | | return $insert_id; |
| | | } |
| | | |
| | |
| | | */ |
| | | function delete($ids) |
| | | { |
| | | if (is_array($ids)) |
| | | $ids = join(',', $ids); |
| | | if (!is_array($ids)) |
| | | $ids = explode(',', $ids); |
| | | |
| | | $ids = join(',', array_map(array($this->db, 'quote'), $ids)); |
| | | |
| | |
| | | $this->user_id |
| | | ); |
| | | |
| | | $this->cache = null; |
| | | |
| | | return $this->db->affected_rows(); |
| | | } |
| | | |
| | |
| | | function delete_all() |
| | | { |
| | | $this->db->query("DELETE FROM {$this->db_name} WHERE user_id=?", $this->user_id); |
| | | $this->cache = null; |
| | | return $this->db->affected_rows(); |
| | | } |
| | | |
| | |
| | | $gid |
| | | ); |
| | | |
| | | $this->cache = null; |
| | | |
| | | return $this->db->affected_rows(); |
| | | } |
| | | |