summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2010-04-15 06:33:30 +0000
committerthomascube <thomas@roundcube.net>2010-04-15 06:33:30 +0000
commita35062a1eba5c6c15f703686cd4fecc5536d74df (patch)
treebde3c4df3b2cc4073cd6c2b4a6af0f8700f17305 /program/include
parent58892824a6ee7f9a545372730b615ec9abafbe5c (diff)
Always set changed date when marking a DB record as deleted + provide a cleanup script
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcube_contacts.php18
-rw-r--r--program/include/rcube_user.php14
2 files changed, 11 insertions, 21 deletions
diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php
index dd37972c2..b8307d49a 100644
--- a/program/include/rcube_contacts.php
+++ b/program/include/rcube_contacts.php
@@ -403,16 +403,10 @@ class rcube_contacts extends rcube_addressbook
if (is_array($ids))
$ids = join(',', $ids);
- // delete all group members linked with these contacts
- if ($this->groups) {
- $this->db->query(
- "DELETE FROM ".get_table_name('contactgroupmembers')."
- WHERE contact_id IN (".$ids.")");
- }
-
+ // flag record as deleted
$this->db->query(
"UPDATE ".$this->db_name."
- SET del=1
+ SET del=1, changed=".$this->db->now()."
WHERE user_id=?
AND contact_id IN (".$ids.")",
$this->user_id);
@@ -456,18 +450,14 @@ class rcube_contacts extends rcube_addressbook
}
/**
- * Delete the given group and all linked group members
+ * Delete the given group (and all linked group members)
*
* @param string Group identifier
* @return boolean True on success, false if no data was changed
*/
function delete_group($gid)
{
- $sql_result = $this->db->query(
- "DELETE FROM ".get_table_name('contactgroupmembers')."
- WHERE contactgroup_id=?",
- $gid);
-
+ // flag group record as deleted
$sql_result = $this->db->query(
"UPDATE ".get_table_name('contactgroups')."
SET del=1, changed=".$this->db->now()."
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index 6ed16dbac..2d0eff2da 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -194,7 +194,7 @@ class rcube_user
$query_params[] = $this->ID;
$sql = "UPDATE ".get_table_name('identities')."
- SET ".join(', ', $query_cols)."
+ SET changed=".$this->db->now().", ".join(', ', $query_cols)."
WHERE identity_id=?
AND user_id=?
AND del<>1";
@@ -229,8 +229,8 @@ class rcube_user
$insert_values[] = $this->ID;
$sql = "INSERT INTO ".get_table_name('identities')."
- (".join(', ', $insert_cols).")
- VALUES (".join(', ', array_pad(array(), sizeof($insert_values), '?')).")";
+ (changed, ".join(', ', $insert_cols).")
+ VALUES (".$this->db->now().", ".join(', ', array_pad(array(), sizeof($insert_values), '?')).")";
call_user_func_array(array($this->db, 'query'),
array_merge(array($sql), $insert_values));
@@ -250,9 +250,9 @@ class rcube_user
if (!$this->ID)
return false;
- $sql_result = $this->db->query("SELECT count(*) AS ident_count FROM " .
- get_table_name('identities') .
- " WHERE user_id = ? AND del <> 1",
+ $sql_result = $this->db->query(
+ "SELECT count(*) AS ident_count FROM ".get_table_name('identities')."
+ WHERE user_id = ? AND del <> 1",
$this->ID);
$sql_arr = $this->db->fetch_assoc($sql_result);
@@ -261,7 +261,7 @@ class rcube_user
$this->db->query(
"UPDATE ".get_table_name('identities')."
- SET del=1
+ SET del=1, changed=".$this->db->now()."
WHERE user_id=?
AND identity_id=?",
$this->ID,