summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap_cache.php
diff options
context:
space:
mode:
Diffstat (limited to 'program/include/rcube_imap_cache.php')
-rw-r--r--program/include/rcube_imap_cache.php69
1 files changed, 36 insertions, 33 deletions
diff --git a/program/include/rcube_imap_cache.php b/program/include/rcube_imap_cache.php
index ee53dc25c..eaa8a805f 100644
--- a/program/include/rcube_imap_cache.php
+++ b/program/include/rcube_imap_cache.php
@@ -95,7 +95,7 @@ class rcube_imap_cache
{
$this->db = $db;
$this->imap = $imap;
- $this->userid = (int)$userid;
+ $this->userid = $userid;
$this->skip_deleted = $skip_deleted;
}
@@ -290,7 +290,7 @@ class rcube_imap_cache
* @param string $mailbox Folder name
* @param array $msgs Message UIDs
*
- * @return array The list of messages (rcube_mail_header) indexed by UID
+ * @return array The list of messages (rcube_message_header) indexed by UID
*/
function get_messages($mailbox, $msgs = array())
{
@@ -301,7 +301,7 @@ class rcube_imap_cache
// Fetch messages from cache
$sql_result = $this->db->query(
"SELECT uid, data, flags"
- ." FROM ".get_table_name('cache_messages')
+ ." FROM ".$this->db->table_name('cache_messages')
." WHERE user_id = ?"
." AND mailbox = ?"
." AND uid IN (".$this->db->array2list($msgs, 'integer').")",
@@ -348,7 +348,7 @@ class rcube_imap_cache
* from IMAP server
* @param bool $no_cache Enables internal cache usage
*
- * @return rcube_mail_header Message data
+ * @return rcube_message_header Message data
*/
function get_message($mailbox, $uid, $update = true, $cache = true)
{
@@ -362,7 +362,7 @@ class rcube_imap_cache
$sql_result = $this->db->query(
"SELECT flags, data"
- ." FROM ".get_table_name('cache_messages')
+ ." FROM ".$this->db->table_name('cache_messages')
." WHERE user_id = ?"
." AND mailbox = ?"
." AND uid = ?",
@@ -404,9 +404,9 @@ class rcube_imap_cache
/**
* Saves the message in cache.
*
- * @param string $mailbox Folder name
- * @param rcube_mail_header $message Message data
- * @param bool $force Skips message in-cache existance check
+ * @param string $mailbox Folder name
+ * @param rcube_message_header $message Message data
+ * @param bool $force Skips message in-cache existance check
*/
function add_message($mailbox, $message, $force = false)
{
@@ -430,7 +430,7 @@ class rcube_imap_cache
// here will work as select, assume row exist if affected_rows=0)
if (!$force) {
$res = $this->db->query(
- "UPDATE ".get_table_name('cache_messages')
+ "UPDATE ".$this->db->table_name('cache_messages')
." SET flags = ?, data = ?, changed = ".$this->db->now()
." WHERE user_id = ?"
." AND mailbox = ?"
@@ -444,7 +444,7 @@ class rcube_imap_cache
// insert new record
$this->db->query(
- "INSERT INTO ".get_table_name('cache_messages')
+ "INSERT INTO ".$this->db->table_name('cache_messages')
." (user_id, mailbox, uid, flags, changed, data)"
." VALUES (?, ?, ?, ?, ".$this->db->now().", ?)",
$this->userid, $mailbox, (int) $message->uid, $flags, $msg);
@@ -479,7 +479,7 @@ class rcube_imap_cache
}
$this->db->query(
- "UPDATE ".get_table_name('cache_messages')
+ "UPDATE ".$this->db->table_name('cache_messages')
." SET changed = ".$this->db->now()
.", flags = flags ".($enabled ? "+ $idx" : "- $idx")
." WHERE user_id = ?"
@@ -500,7 +500,7 @@ class rcube_imap_cache
{
if (!strlen($mailbox)) {
$this->db->query(
- "DELETE FROM ".get_table_name('cache_messages')
+ "DELETE FROM ".$this->db->table_name('cache_messages')
." WHERE user_id = ?",
$this->userid);
}
@@ -513,11 +513,11 @@ class rcube_imap_cache
}
$this->db->query(
- "DELETE FROM ".get_table_name('cache_messages')
+ "DELETE FROM ".$this->db->table_name('cache_messages')
." WHERE user_id = ?"
- ." AND mailbox = ".$this->db->quote($mailbox)
+ ." AND mailbox = ?"
.($uids !== null ? " AND uid IN (".$this->db->array2list((array)$uids, 'integer').")" : ""),
- $this->userid);
+ $this->userid, $mailbox);
}
}
@@ -536,17 +536,19 @@ class rcube_imap_cache
// otherwise use 'valid' flag to not loose HIGHESTMODSEQ value
if ($remove) {
$this->db->query(
- "DELETE FROM ".get_table_name('cache_index')
- ." WHERE user_id = ".intval($this->userid)
- .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : "")
+ "DELETE FROM ".$this->db->table_name('cache_index')
+ ." WHERE user_id = ?"
+ .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : ""),
+ $this->userid
);
}
else {
$this->db->query(
- "UPDATE ".get_table_name('cache_index')
+ "UPDATE ".$this->db->table_name('cache_index')
." SET valid = 0"
- ." WHERE user_id = ".intval($this->userid)
- .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : "")
+ ." WHERE user_id = ?"
+ .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : ""),
+ $this->userid
);
}
@@ -569,9 +571,10 @@ class rcube_imap_cache
function remove_thread($mailbox = null)
{
$this->db->query(
- "DELETE FROM ".get_table_name('cache_thread')
- ." WHERE user_id = ".intval($this->userid)
- .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : "")
+ "DELETE FROM ".$this->db->table_name('cache_thread')
+ ." WHERE user_id = ?"
+ .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : ""),
+ $this->userid
);
if (strlen($mailbox)) {
@@ -628,7 +631,7 @@ class rcube_imap_cache
// Get index from DB
$sql_result = $this->db->query(
"SELECT data, valid"
- ." FROM ".get_table_name('cache_index')
+ ." FROM ".$this->db->table_name('cache_index')
." WHERE user_id = ?"
." AND mailbox = ?",
$this->userid, $mailbox);
@@ -665,7 +668,7 @@ class rcube_imap_cache
// Get thread from DB
$sql_result = $this->db->query(
"SELECT data"
- ." FROM ".get_table_name('cache_thread')
+ ." FROM ".$this->db->table_name('cache_thread')
." WHERE user_id = ?"
." AND mailbox = ?",
$this->userid, $mailbox);
@@ -709,7 +712,7 @@ class rcube_imap_cache
if ($exists) {
$sql_result = $this->db->query(
- "UPDATE ".get_table_name('cache_index')
+ "UPDATE ".$this->db->table_name('cache_index')
." SET data = ?, valid = 1, changed = ".$this->db->now()
." WHERE user_id = ?"
." AND mailbox = ?",
@@ -717,7 +720,7 @@ class rcube_imap_cache
}
else {
$sql_result = $this->db->query(
- "INSERT INTO ".get_table_name('cache_index')
+ "INSERT INTO ".$this->db->table_name('cache_index')
." (user_id, mailbox, data, valid, changed)"
." VALUES (?, ?, ?, 1, ".$this->db->now().")",
$this->userid, $mailbox, $data);
@@ -740,7 +743,7 @@ class rcube_imap_cache
if ($exists) {
$sql_result = $this->db->query(
- "UPDATE ".get_table_name('cache_thread')
+ "UPDATE ".$this->db->table_name('cache_thread')
." SET data = ?, changed = ".$this->db->now()
." WHERE user_id = ?"
." AND mailbox = ?",
@@ -748,7 +751,7 @@ class rcube_imap_cache
}
else {
$sql_result = $this->db->query(
- "INSERT INTO ".get_table_name('cache_thread')
+ "INSERT INTO ".$this->db->table_name('cache_thread')
." (user_id, mailbox, data, changed)"
." VALUES (?, ?, ?, ".$this->db->now().")",
$this->userid, $mailbox, $data);
@@ -956,7 +959,7 @@ class rcube_imap_cache
$uids = array();
$sql_result = $this->db->query(
"SELECT uid"
- ." FROM ".get_table_name('cache_messages')
+ ." FROM ".$this->db->table_name('cache_messages')
." WHERE user_id = ?"
." AND mailbox = ?",
$this->userid, $mailbox);
@@ -1003,7 +1006,7 @@ class rcube_imap_cache
}
$this->db->query(
- "UPDATE ".get_table_name('cache_messages')
+ "UPDATE ".$this->db->table_name('cache_messages')
." SET flags = ?, changed = ".$this->db->now()
." WHERE user_id = ?"
." AND mailbox = ?"
@@ -1058,7 +1061,7 @@ class rcube_imap_cache
*
* @param array $sql_arr Message row data
*
- * @return rcube_mail_header Message object
+ * @return rcube_message_header Message object
*/
private function build_message($sql_arr)
{