* Addressbook - When viewing a user account's calendar or next/previous dates, use the account calendar over the contact calendar

This commit is contained in:
nathangray 2017-03-08 09:53:52 -07:00
parent d2fb5d56be
commit 78c5f31ff5
4 changed files with 29 additions and 25 deletions

View File

@ -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);

View File

@ -1644,6 +1644,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;
@ -1654,6 +1655,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)
{
@ -1663,7 +1665,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)
@ -1770,9 +1772,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;
}
@ -2238,7 +2240,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
@ -2743,7 +2745,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

View File

@ -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);
}
}
}

View File

@ -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<contact_id>, user accounts <account_id>
* @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;
}
}
}