From 7f5a849e7816e7b4c7b13a72d38a9c777632d7cd Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 07 Jul 2011 07:44:26 -0400
Subject: [PATCH] - Added possibility to undo last contact delete operation
---
program/include/rcube_contacts.php | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php
index b097b3b..52667fa 100644
--- a/program/include/rcube_contacts.php
+++ b/program/include/rcube_contacts.php
@@ -52,6 +52,7 @@
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 @@
/**
+ * 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();
}
--
Gitblit v1.9.1