Unify mail-relations handling across plugins
This commit is contained in:
parent
d96689620f
commit
a7e3a938a7
6 changed files with 27 additions and 16 deletions
|
@ -1744,6 +1744,15 @@ class calendar extends rcube_plugin
|
|||
$event['attachments'][$k]['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']);
|
||||
}
|
||||
|
||||
// convert link URIs references into structs
|
||||
if (array_key_exists('links', $event)) {
|
||||
foreach ((array) $event['links'] as $i => $link) {
|
||||
if (strpos($link, 'imap://') === 0 && ($msgref = $this->driver->get_message_reference($link))) {
|
||||
$event['links'][$i] = $msgref;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check for organizer in attendees list
|
||||
$organizer = null;
|
||||
foreach ((array)$event['attendees'] as $i => $attendee) {
|
||||
|
|
|
@ -383,7 +383,7 @@ class kolab_calendar extends kolab_storage_folder_api
|
|||
|
||||
// Apply event-to-mail relations
|
||||
$config = kolab_storage_config::get_instance();
|
||||
$config->apply_links($events, 'event');
|
||||
$config->apply_links($events);
|
||||
|
||||
// avoid session race conditions that will loose temporary subscriptions
|
||||
$this->cal->rc->session->nowrite = true;
|
||||
|
|
|
@ -441,7 +441,7 @@ class kolab_notes extends rcube_plugin
|
|||
{
|
||||
$config = kolab_storage_config::get_instance();
|
||||
$tags = $config->apply_tags($records);
|
||||
$config->apply_links($records, 'note');
|
||||
$config->apply_links($records);
|
||||
|
||||
foreach ($records as $i => $rec) {
|
||||
unset($records[$i]['description']);
|
||||
|
@ -558,6 +558,8 @@ class kolab_notes extends rcube_plugin
|
|||
if ($result) {
|
||||
// get note tags
|
||||
$result['tags'] = $this->get_tags($result['uid']);
|
||||
// get note links
|
||||
$result['links'] = $this->get_links($result['uid']);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -566,7 +568,7 @@ class kolab_notes extends rcube_plugin
|
|||
/**
|
||||
* Helper method to encode the given note record for use in the client
|
||||
*/
|
||||
private function _client_encode(&$note, $resolve = false)
|
||||
private function _client_encode(&$note)
|
||||
{
|
||||
foreach ($note as $key => $prop) {
|
||||
if ($key[0] == '_' || $key == 'x-custom') {
|
||||
|
@ -586,11 +588,13 @@ class kolab_notes extends rcube_plugin
|
|||
$note['html'] = $this->_wash_html($note['description']);
|
||||
}
|
||||
|
||||
// resolve message links
|
||||
if (!array_key_exists('links', $note)) {
|
||||
$note['links'] = array_map(function($link) {
|
||||
return kolab_storage_config::get_message_reference($link, 'note') ?: array('uri' => $link);
|
||||
}, $this->get_links($note['uid']));
|
||||
// convert link URIs references into structs
|
||||
if (array_key_exists('links', $note)) {
|
||||
foreach ((array)$note['links'] as $i => $link) {
|
||||
if (strpos($link, 'imap://') === 0 && ($msgref = kolab_storage_config::get_message_reference($link, 'note'))) {
|
||||
$note['links'][$i] = $msgref;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $note;
|
||||
|
|
|
@ -595,10 +595,9 @@ class kolab_storage_config
|
|||
/**
|
||||
* Assign links (relations) to kolab objects
|
||||
*
|
||||
* @param array $records List of kolab objects
|
||||
* @param string $type Object type
|
||||
* @param array $records List of kolab objects
|
||||
*/
|
||||
public function apply_links(&$records, $type = null)
|
||||
public function apply_links(&$records)
|
||||
{
|
||||
$links = array();
|
||||
$uids = array();
|
||||
|
@ -646,11 +645,10 @@ class kolab_storage_config
|
|||
// make relation members up-to-date
|
||||
kolab_storage_config::resolve_members($relation);
|
||||
|
||||
// replace link URIs with message reference URLs
|
||||
$members = array();
|
||||
foreach ((array) $relation['members'] as $member) {
|
||||
if (strpos($member, 'imap://') === 0) {
|
||||
$members[$member] = kolab_storage_config::get_message_reference($member, $type) ?: array('uri' => $member);
|
||||
$members[$member] = $member;
|
||||
}
|
||||
}
|
||||
$members = array_values($members);
|
||||
|
|
|
@ -598,7 +598,7 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
}
|
||||
|
||||
$config->apply_tags($results);
|
||||
$config->apply_links($results, 'task');
|
||||
$config->apply_links($results);
|
||||
|
||||
foreach (array_keys($results) as $idx) {
|
||||
$results[$idx] = $this->_to_rcube_task($results[$idx], $results[$idx]['list_id']);
|
||||
|
|
|
@ -1256,8 +1256,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 && ($msgref = $this->driver->get_message_reference($link))) {
|
||||
foreach ((array) $rec['links'] as $i => $link) {
|
||||
if (strpos($link, 'imap://') === 0 && ($msgref = $this->driver->get_message_reference($link, 'task'))) {
|
||||
$rec['links'][$i] = $msgref;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue