Allow to store email message references for note objects (link format tentative) + store message-id in cache for querying
This commit is contained in:
parent
e25fd88b73
commit
e0bc40f160
2 changed files with 36 additions and 12 deletions
|
@ -502,6 +502,11 @@ abstract class kolab_format
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function to extract object attachment data
|
||||||
|
*
|
||||||
|
* @param array Hash array reference to append attachment data into
|
||||||
|
*/
|
||||||
protected function get_attachments(&$object)
|
protected function get_attachments(&$object)
|
||||||
{
|
{
|
||||||
// handle attachments
|
// handle attachments
|
||||||
|
@ -520,13 +525,19 @@ abstract class kolab_format
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (substr($attach->uri(), 0, 4) == 'http') {
|
else if (in_array(substr($attach->uri(), 0, 4), array('http','imap'))) {
|
||||||
$object['links'][] = $attach->uri();
|
$object['links'][] = $attach->uri();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function set_attachments($object)
|
/**
|
||||||
|
* Utility function to set attachment properties to the kolabformat object
|
||||||
|
*
|
||||||
|
* @param array Object data as hash array
|
||||||
|
* @param boolean True to always overwrite attachment information
|
||||||
|
*/
|
||||||
|
protected function set_attachments($object, $write = true)
|
||||||
{
|
{
|
||||||
// save attachments
|
// save attachments
|
||||||
$vattach = new vectorattachment;
|
$vattach = new vectorattachment;
|
||||||
|
@ -537,16 +548,17 @@ abstract class kolab_format
|
||||||
$attach->setLabel((string)$attr['name']);
|
$attach->setLabel((string)$attr['name']);
|
||||||
$attach->setUri('cid:' . $cid, $attr['mimetype'] ?: 'application/octet-stream');
|
$attach->setUri('cid:' . $cid, $attr['mimetype'] ?: 'application/octet-stream');
|
||||||
if ($attach->isValid()) {
|
if ($attach->isValid()) {
|
||||||
$vattach->push($attach);
|
$vattach->push($attach);
|
||||||
|
$write = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rcube::raise_error(array(
|
rcube::raise_error(array(
|
||||||
'code' => 660,
|
'code' => 660,
|
||||||
'type' => 'php',
|
'type' => 'php',
|
||||||
'file' => __FILE__,
|
'file' => __FILE__,
|
||||||
'line' => __LINE__,
|
'line' => __LINE__,
|
||||||
'message' => "Invalid attributes for attachment $cid: " . var_export($attr, true),
|
'message' => "Invalid attributes for attachment $cid: " . var_export($attr, true),
|
||||||
), true);
|
), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,8 +566,11 @@ abstract class kolab_format
|
||||||
$attach = new Attachment;
|
$attach = new Attachment;
|
||||||
$attach->setUri($link, 'unknown');
|
$attach->setUri($link, 'unknown');
|
||||||
$vattach->push($attach);
|
$vattach->push($attach);
|
||||||
|
$write = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->obj->setAttachments($vattach);
|
if ($write) {
|
||||||
|
$this->obj->setAttachments($vattach);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,10 +109,19 @@ class kolab_format_note extends kolab_format
|
||||||
{
|
{
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
|
||||||
foreach ((array) $this->data['categories'] as $cat) {
|
foreach ((array)$this->data['categories'] as $cat) {
|
||||||
$tags[] = rcube_utils::normalize_string($cat);
|
$tags[] = rcube_utils::normalize_string($cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add tag for message references
|
||||||
|
foreach ((array)$this->data['links'] as $link) {
|
||||||
|
$url = parse_url($link);
|
||||||
|
if ($url['scheme'] == 'imap') {
|
||||||
|
parse_str($url['query'], $param);
|
||||||
|
$tags[] = 'ref:' . trim($param['message-id'] ?: urldecode($url['fragment']), '<> ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue