diff --git a/addressbook/inc/class.addressbook_export_contacts_csv.inc.php b/addressbook/inc/class.addressbook_export_contacts_csv.inc.php index b1d67d003c..dd4ef9e797 100644 --- a/addressbook/inc/class.addressbook_export_contacts_csv.inc.php +++ b/addressbook/inc/class.addressbook_export_contacts_csv.inc.php @@ -251,11 +251,11 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi { if(is_array($_contact) && $_contact['id']) { - $contact_ids[] = $_contact['id']; + $contact_ids[] = $_contact['account_id'] ? $_contact['account_id'] : 'c'.$_contact['id']; } else { - $contact_ids[] = $contact; + $contact_ids[] = 'c'.$contact; } } $events = $this->ui->read_calendar($contact_ids, false); diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index c87cc91630..af31dbf5c0 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -1640,6 +1640,7 @@ window.egw_LAB.wait(function() { $columsel = $this->prefs['nextmatch-addressbook.'.($do_email ? 'email' : 'index').'.rows']; $available_distib_lists=$this->get_lists(Acl::READ); $columselection = $columsel && !$query['csv_export'] ? explode(',',$columsel) : array(); + $ids = $calendar_participants = array(); if (!$id_only && $rows) { $show_custom_fields = (!$columselection || in_array('customfields',$columselection) || $query['csv_export']) && $this->customfields; @@ -1650,6 +1651,7 @@ window.egw_LAB.wait(function() { foreach($rows as $val) { $ids[] = $val['id']; + $calendar_participants[$val['id']] = $val['account_id'] ? $val['account_id'] : 'c'.$val['id']; } if ($show_custom_fields) { @@ -1659,7 +1661,7 @@ window.egw_LAB.wait(function() { } $customfields = $this->read_customfields($ids,$selected_cfs); } - if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($ids); + if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants); // distributionlist memership for the entrys //_debug_array($this->get_lists(Acl::EDIT)); if ($show_distributionlist && $available_distib_lists) @@ -1766,9 +1768,9 @@ window.egw_LAB.wait(function() { $row['distrib_lists'] = implode("\n",array_values($distributionlist[$row['id']])); //if ($show_distributionlist) $readonlys['distrib_lists'] =true; } - if (isset($calendar[$row['id']])) + if (isset($calendar[$calendar_participants[$row['id']]])) { - foreach($calendar[$row['id']] as $name => $data) + foreach($calendar[$calendar_participants[$row['id']]] as $name => $data) { $row[$name] = $data; } @@ -2234,7 +2236,7 @@ window.egw_LAB.wait(function() { if ($content['id']) { // last and next calendar date - list(,$dates) = each($this->read_calendar(array($content['id']),false)); + list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); if(is_array($dates)) $content += $dates; } // Avoid ID conflict with tree & selectboxes @@ -2738,7 +2740,7 @@ window.egw_LAB.wait(function() { if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; // last and next calendar date - if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['id']),false)); + if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); if(is_array($dates)) $content += $dates; // Disable importexport diff --git a/addressbook/js/app.js b/addressbook/js/app.js index a4a2eb010d..b41f3e3e61 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -253,7 +253,17 @@ app.classes.addressbook = AppJS.extend( } else { - extras.owner.push('c'+ids); + // Check to see if this is a user account, we prefer to use + // account ID in calendar + var data = this.egw.dataGetUIDdata(_senders[i].id); + if(data && data.data && data.data.account_id) + { + extras.owner.push(data.data.account_id); + } + else + { + extras.owner.push('c'+ids); + } } } diff --git a/api/src/Contacts.php b/api/src/Contacts.php index bcac1a5556..aace1be91f 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -1601,21 +1601,14 @@ class Contacts extends Contacts\Storage /** * Read the next and last event of given contacts * - * @param array $ids contact_id's + * @param array $uids participant IDs. Contacts should be c, user accounts * @param boolean $extra_title =true if true, use a short date only title and put the full title as extra_title (tooltip) * @return array */ - function read_calendar($ids,$extra_title=true) + function read_calendar($uids,$extra_title=true) { if (!$GLOBALS['egw_info']['user']['apps']['calendar']) return array(); - $uids = array(); - foreach($ids as $id) - { - if (is_numeric($id)) $uids[] = 'c'.$id; - } - if (!$uids) return array(); - $bocal = new calendar_bo(); $events = $bocal->search(array( 'users' => $uids, @@ -1629,17 +1622,16 @@ class Contacts extends Contacts\Storage { foreach($event['participants'] as $uid => $status) { - if ($uid[0] != 'c' || ($status == 'R' && !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected'])) + if ($status == 'R' && !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected']) { continue; } - $id = (int)substr($uid,1); if ($event['start'] < $this->now_su) // past event --> check for last event { - if (!isset($calendars[$id]['last_event']) || $event['start'] > $calendars[$id]['last_event']) + if (!isset($calendars[$uid]['last_event']) || $event['start'] > $calendars[$uid]['last_event']) { - $calendars[$id]['last_event'] = $event['start']; + $calendars[$uid]['last_event'] = $event['start']; $link = array( 'id' => $event['id'], 'app' => 'calendar', @@ -1653,14 +1645,14 @@ class Contacts extends Contacts\Storage $link['extra_title'] = $link['title']; $link['title'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],$event['start']); } - $calendars[$id]['last_link'] = $link; + $calendars[$uid]['last_link'] = $link; } } else // future event --> check for next event { - if (!isset($calendars[$id]['next_event']) || $event['start'] < $calendars[$id]['next_event']) + if (!isset($calendars[$uid]['next_event']) || $event['start'] < $calendars[$uid]['next_event']) { - $calendars[$id]['next_event'] = $event['start']; + $calendars[$uid]['next_event'] = $event['start']; $link = array( 'id' => $event['id'], 'app' => 'calendar', @@ -1674,7 +1666,7 @@ class Contacts extends Contacts\Storage $link['extra_title'] = $link['title']; $link['title'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],$event['start']); } - $calendars[$id]['next_link'] = $link; + $calendars[$uid]['next_link'] = $link; } } }