diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-07-07 11:44:26 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-07-07 11:44:26 +0000 |
| commit | 642cb7e4357030d61f9ff56498aeaa590c7699cf (patch) | |
| tree | def4e09ccdb7d3211eff3a61fc79c9b1577b5ddf /roundcubemail/program/include/rcube_contacts.php | |
| parent | ac1af6d3daf377002fb9875c49dde0a0025a980a (diff) | |
- Added possibility to undo last contact delete operation
git-svn-id: https://svn.roundcube.net/trunk@4916 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/rcube_contacts.php')
| -rw-r--r-- | roundcubemail/program/include/rcube_contacts.php | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/roundcubemail/program/include/rcube_contacts.php b/roundcubemail/program/include/rcube_contacts.php index b097b3bc0..52667fab3 100644 --- a/roundcubemail/program/include/rcube_contacts.php +++ b/roundcubemail/program/include/rcube_contacts.php @@ -52,6 +52,7 @@ class rcube_contacts extends rcube_addressbook public $primary_key = 'contact_id'; public $readonly = false; public $groups = true; + public $undelete = true; public $list_page = 1; public $page_size = 10; public $group_id = 0; @@ -692,12 +693,43 @@ class rcube_contacts extends rcube_addressbook /** + * Undelete one or more contact records + * + * @param array Record identifiers + */ + function undelete($ids) + { + if (!is_array($ids)) + $ids = explode(',', $ids); + + $ids = $this->db->array2list($ids, 'integer'); + + // flag record as deleted + $this->db->query( + "UPDATE ".get_table_name($this->db_name). + " SET del=0, changed=".$this->db->now(). + " WHERE user_id=?". + " AND contact_id IN ($ids)", + $this->user_id + ); + + $this->cache = null; + + return $this->db->affected_rows(); + } + + + /** * Remove all records from the database */ function delete_all() { - $this->db->query("DELETE FROM ".get_table_name($this->db_name)." WHERE user_id = ?", $this->user_id); $this->cache = null; + + $this->db->query("UPDATE ".get_table_name($this->db_name). + " SET del=1, changed=".$this->db->now(). + " WHERE user_id = ?", $this->user_id); + return $this->db->affected_rows(); } |
