summaryrefslogtreecommitdiff
path: root/plugins/tasklist
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/tasklist')
-rw-r--r--plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php31
-rw-r--r--plugins/tasklist/drivers/tasklist_driver.php9
-rw-r--r--plugins/tasklist/tasklist.php47
3 files changed, 22 insertions, 65 deletions
diff --git a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php
index 6c9f418..0cb51ae 100644
--- a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php
+++ b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php
@@ -825,7 +825,7 @@ class tasklist_kolab_driver extends tasklist_driver
private function get_links($uid)
{
$config = kolab_storage_config::get_instance();
- return array_map(array('kolab_storage_config','local_message_uri'), $config->get_object_links($uid));
+ return $config->get_object_links($uid);
}
/**
@@ -838,18 +838,6 @@ class tasklist_kolab_driver extends tasklist_driver
$links = array();
}
- // convert the given (simplified) message links into absolute IMAP URIs
- $links = array_map(function($link) {
- $url = parse_url(substr($link, 8));
- parse_str($url['query'], $linkref);
-
- $path = explode('/', $url['path']);
- $linkref['uid'] = array_pop($path);
- $linkref['folder'] = join('/', array_map('rawurldecode', $path));
-
- return kolab_storage_config::build_member_url($linkref);
- }, $links);
-
$config = kolab_storage_config::get_instance();
$remove = array_diff($config->get_object_links($uid), $links);
return $config->save_object_links($uid, $links, $remove);
@@ -1272,14 +1260,21 @@ class tasklist_kolab_driver extends tasklist_driver
}
/**
- * Build a URI representing the given message reference
+ * Build a struct representing the given message reference
*
- * @see tasklist_driver::get_message_uri()
+ * @see tasklist_driver::get_message_reference()
*/
- public function get_message_uri($headers, $folder)
+ public function get_message_reference($uri_or_headers, $folder = null)
{
- $uri = kolab_storage_config::get_message_uri($headers, $folder);
- return kolab_storage_config::local_message_uri($uri);
+ if (is_object($uri_or_headers)) {
+ $uri_or_headers = kolab_storage_config::get_message_uri($uri_or_headers, $folder);
+ }
+
+ if (is_string($uri_or_headers)) {
+ return kolab_storage_config::get_message_reference($uri_or_headers, 'task');
+ }
+
+ return false;
}
/**
diff --git a/plugins/tasklist/drivers/tasklist_driver.php b/plugins/tasklist/drivers/tasklist_driver.php
index 791d2ab..1de0353 100644
--- a/plugins/tasklist/drivers/tasklist_driver.php
+++ b/plugins/tasklist/drivers/tasklist_driver.php
@@ -288,14 +288,15 @@ abstract class tasklist_driver
public function get_attachment_body($id, $task) { }
/**
- * Build a URI representing the given message reference
+ * Build a struct representing the given message reference
*
- * @param object $headers rcube_message_header instance holding the message headers
+ * @param object|string $uri_or_headers rcube_message_header instance holding the message headers
+ * or an URI from a stored link referencing a mail message.
* @param string $folder IMAP folder the message resides in
*
- * @return string An URI referencing the given IMAP message
+ * @return array An struct referencing the given IMAP message
*/
- public function get_message_uri($headers, $folder)
+ public function get_message_reference($uri_or_headers, $folder = null)
{
// to be implemented by the derived classes
return false;
diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php
index d65507e..b260714 100644
--- a/plugins/tasklist/tasklist.php
+++ b/plugins/tasklist/tasklist.php
@@ -1099,8 +1099,8 @@ class tasklist extends rcube_plugin
// convert link URIs references into structs
if (array_key_exists('links', $rec)) {
foreach ((array)$rec['links'] as $i => $link) {
- if (strpos($link, 'imap://') === 0) {
- $rec['links'][$i] = $this->get_message_reference($link);
+ if (strpos($link, 'imap://') === 0 && ($msgref = $this->driver->get_message_reference($link))) {
+ $rec['links'][$i] = $msgref;
}
}
}
@@ -1395,8 +1395,8 @@ class tasklist extends rcube_plugin
$this->load_driver();
// add a reference to the email message
- if ($msguri = $this->driver->get_message_uri($message->headers, $mbox)) {
- $task['links'] = array($this->get_message_reference($msguri));
+ if ($msgref = $this->driver->get_message_reference($message->headers, $mbox)) {
+ $task['links'] = array($msgref);
}
// copy mail attachments to task
else if ($message->attachments && $this->driver->attachments) {
@@ -1603,45 +1603,6 @@ class tasklist extends rcube_plugin
}
/**
- * Resolve the email message reference from the given URI
- */
- public function get_message_reference($uri)
- {
- if (strpos($uri, 'imap:///') === 0) {
- $url = parse_url(substr($uri, 8));
- parse_str($url['query'], $params);
-
- $path = explode('/', $url['path']);
- $uid = array_pop($path);
- $folder = join('/', array_map('rawurldecode', $path));
- }
-
- if ($folder && $uid) {
- // TODO: check if folder/uid still references an existing message
- // TODO: validate message or resovle the new URI using the message-id parameter
-
- $linkref = array(
- 'folder' => $folder,
- 'uid' => $uid,
- 'subject' => $params['subject'],
- 'uri' => $uri,
- 'mailurl' => $this->rc->url(array(
- 'task' => 'mail',
- 'action' => 'show',
- 'mbox' => $folder,
- 'uid' => $uid,
- 'rel' => 'task',
- ))
- );
- }
- else {
- $linkref = array();
- }
-
- return $linkref;
- }
-
- /**
* Import the full payload from a mail message attachment
*/
public function mail_import_attachment()