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']);
|
$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
|
// check for organizer in attendees list
|
||||||
$organizer = null;
|
$organizer = null;
|
||||||
foreach ((array)$event['attendees'] as $i => $attendee) {
|
foreach ((array)$event['attendees'] as $i => $attendee) {
|
||||||
|
|
|
@ -383,7 +383,7 @@ class kolab_calendar extends kolab_storage_folder_api
|
||||||
|
|
||||||
// Apply event-to-mail relations
|
// Apply event-to-mail relations
|
||||||
$config = kolab_storage_config::get_instance();
|
$config = kolab_storage_config::get_instance();
|
||||||
$config->apply_links($events, 'event');
|
$config->apply_links($events);
|
||||||
|
|
||||||
// avoid session race conditions that will loose temporary subscriptions
|
// avoid session race conditions that will loose temporary subscriptions
|
||||||
$this->cal->rc->session->nowrite = true;
|
$this->cal->rc->session->nowrite = true;
|
||||||
|
|
|
@ -441,7 +441,7 @@ class kolab_notes extends rcube_plugin
|
||||||
{
|
{
|
||||||
$config = kolab_storage_config::get_instance();
|
$config = kolab_storage_config::get_instance();
|
||||||
$tags = $config->apply_tags($records);
|
$tags = $config->apply_tags($records);
|
||||||
$config->apply_links($records, 'note');
|
$config->apply_links($records);
|
||||||
|
|
||||||
foreach ($records as $i => $rec) {
|
foreach ($records as $i => $rec) {
|
||||||
unset($records[$i]['description']);
|
unset($records[$i]['description']);
|
||||||
|
@ -558,6 +558,8 @@ class kolab_notes extends rcube_plugin
|
||||||
if ($result) {
|
if ($result) {
|
||||||
// get note tags
|
// get note tags
|
||||||
$result['tags'] = $this->get_tags($result['uid']);
|
$result['tags'] = $this->get_tags($result['uid']);
|
||||||
|
// get note links
|
||||||
|
$result['links'] = $this->get_links($result['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
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
|
* 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) {
|
foreach ($note as $key => $prop) {
|
||||||
if ($key[0] == '_' || $key == 'x-custom') {
|
if ($key[0] == '_' || $key == 'x-custom') {
|
||||||
|
@ -586,11 +588,13 @@ class kolab_notes extends rcube_plugin
|
||||||
$note['html'] = $this->_wash_html($note['description']);
|
$note['html'] = $this->_wash_html($note['description']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve message links
|
// convert link URIs references into structs
|
||||||
if (!array_key_exists('links', $note)) {
|
if (array_key_exists('links', $note)) {
|
||||||
$note['links'] = array_map(function($link) {
|
foreach ((array)$note['links'] as $i => $link) {
|
||||||
return kolab_storage_config::get_message_reference($link, 'note') ?: array('uri' => $link);
|
if (strpos($link, 'imap://') === 0 && ($msgref = kolab_storage_config::get_message_reference($link, 'note'))) {
|
||||||
}, $this->get_links($note['uid']));
|
$note['links'][$i] = $msgref;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $note;
|
return $note;
|
||||||
|
|
|
@ -596,9 +596,8 @@ class kolab_storage_config
|
||||||
* Assign links (relations) to kolab objects
|
* Assign links (relations) to kolab objects
|
||||||
*
|
*
|
||||||
* @param array $records List of kolab objects
|
* @param array $records List of kolab objects
|
||||||
* @param string $type Object type
|
|
||||||
*/
|
*/
|
||||||
public function apply_links(&$records, $type = null)
|
public function apply_links(&$records)
|
||||||
{
|
{
|
||||||
$links = array();
|
$links = array();
|
||||||
$uids = array();
|
$uids = array();
|
||||||
|
@ -646,11 +645,10 @@ class kolab_storage_config
|
||||||
// make relation members up-to-date
|
// make relation members up-to-date
|
||||||
kolab_storage_config::resolve_members($relation);
|
kolab_storage_config::resolve_members($relation);
|
||||||
|
|
||||||
// replace link URIs with message reference URLs
|
|
||||||
$members = array();
|
$members = array();
|
||||||
foreach ((array) $relation['members'] as $member) {
|
foreach ((array) $relation['members'] as $member) {
|
||||||
if (strpos($member, 'imap://') === 0) {
|
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);
|
$members = array_values($members);
|
||||||
|
|
|
@ -598,7 +598,7 @@ class tasklist_kolab_driver extends tasklist_driver
|
||||||
}
|
}
|
||||||
|
|
||||||
$config->apply_tags($results);
|
$config->apply_tags($results);
|
||||||
$config->apply_links($results, 'task');
|
$config->apply_links($results);
|
||||||
|
|
||||||
foreach (array_keys($results) as $idx) {
|
foreach (array_keys($results) as $idx) {
|
||||||
$results[$idx] = $this->_to_rcube_task($results[$idx], $results[$idx]['list_id']);
|
$results[$idx] = $this->_to_rcube_task($results[$idx], $results[$idx]['list_id']);
|
||||||
|
|
|
@ -1257,7 +1257,7 @@ class tasklist extends rcube_plugin
|
||||||
// convert link URIs references into structs
|
// convert link URIs references into structs
|
||||||
if (array_key_exists('links', $rec)) {
|
if (array_key_exists('links', $rec)) {
|
||||||
foreach ((array) $rec['links'] as $i => $link) {
|
foreach ((array) $rec['links'] as $i => $link) {
|
||||||
if (strpos($link, 'imap://') === 0 && ($msgref = $this->driver->get_message_reference($link))) {
|
if (strpos($link, 'imap://') === 0 && ($msgref = $this->driver->get_message_reference($link, 'task'))) {
|
||||||
$rec['links'][$i] = $msgref;
|
$rec['links'][$i] = $msgref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue