summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcmail.php2
-rw-r--r--program/include/rcube_addressbook.php13
-rw-r--r--program/include/rcube_contacts.php34
-rw-r--r--program/include/rcube_json_output.php5
-rwxr-xr-xprogram/include/rcube_template.php13
5 files changed, 56 insertions, 11 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index e94e205e7..fe2d99475 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -507,7 +507,7 @@ class rcmail
$this->output->set_env('comm_path', $this->comm_path);
$this->output->set_charset(RCMAIL_CHARSET);
- // add some basic label to client
+ // add some basic labels to client
$this->output->add_label('loading', 'servererror');
return $this->output;
diff --git a/program/include/rcube_addressbook.php b/program/include/rcube_addressbook.php
index cefe4612f..3581b83d1 100644
--- a/program/include/rcube_addressbook.php
+++ b/program/include/rcube_addressbook.php
@@ -38,6 +38,7 @@ abstract class rcube_addressbook
public $primary_key;
public $groups = false;
public $readonly = true;
+ public $undelete = false;
public $ready = false;
public $group_id = null;
public $list_page = 1;
@@ -256,7 +257,17 @@ abstract class rcube_addressbook
}
/**
- * Remove all records from the database
+ * Unmark delete flag on contact record(s)
+ *
+ * @param array Record identifiers
+ */
+ function undelete($ids)
+ {
+ /* empty for read-only address books */
+ }
+
+ /**
+ * Mark all records in database as deleted
*/
function delete_all()
{
diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php
index b097b3bc0..52667fab3 100644
--- a/program/include/rcube_contacts.php
+++ b/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();
}
diff --git a/program/include/rcube_json_output.php b/program/include/rcube_json_output.php
index d1c9de279..efb672888 100644
--- a/program/include/rcube_json_output.php
+++ b/program/include/rcube_json_output.php
@@ -164,14 +164,15 @@ class rcube_json_output
* @param string $type Message type [notice|confirm|error]
* @param array $vars Key-value pairs to be replaced in localized text
* @param boolean $override Override last set message
+ * @param int $timeout Message displaying time in seconds
* @uses self::command()
*/
- public function show_message($message, $type='notice', $vars=null, $override=true)
+ public function show_message($message, $type='notice', $vars=null, $override=true, $timeout=0)
{
if ($override || !$this->message) {
$this->message = $message;
$msgtext = rcube_label_exists($message) ? rcube_label(array('name' => $message, 'vars' => $vars)) : $message;
- $this->command('display_message', $msgtext, $type);
+ $this->command('display_message', $msgtext, $type, $timeout * 1000);
}
}
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 39b22826a..a4c1a6915 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -238,18 +238,19 @@ class rcube_template extends rcube_html_page
/**
* Invoke display_message command
*
- * @param string Message to display
- * @param string Message type [notice|confirm|error]
- * @param array Key-value pairs to be replaced in localized text
- * @param boolean Override last set message
+ * @param string $message Message to display
+ * @param string $type Message type [notice|confirm|error]
+ * @param array $vars Key-value pairs to be replaced in localized text
+ * @param boolean $override Override last set message
+ * @param int $timeout Message display time in seconds
* @uses self::command()
*/
- public function show_message($message, $type='notice', $vars=null, $override=true)
+ public function show_message($message, $type='notice', $vars=null, $override=true, $timeout=0)
{
if ($override || !$this->message) {
$this->message = $message;
$msgtext = rcube_label_exists($message) ? rcube_label(array('name' => $message, 'vars' => $vars)) : $message;
- $this->command('display_message', $msgtext, $type);
+ $this->command('display_message', $msgtext, $type, $timeout * 1000);
}
}