From de17d9a2ea54cd3dbec6966f518326e0b04eaf12 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 15 Feb 2018 11:50:55 -0700 Subject: [PATCH] * Calendar - new placeholders {{participant_emails}} for non-declined participants and {{participant_summary}} for a summary of participants by status --- calendar/inc/class.calendar_merge.inc.php | 91 +++++++++++++++++++++++ calendar/lang/egw_en.lang | 3 + 2 files changed, 94 insertions(+) diff --git a/calendar/inc/class.calendar_merge.inc.php b/calendar/inc/class.calendar_merge.inc.php index d098675908..b2835c1296 100644 --- a/calendar/inc/class.calendar_merge.inc.php +++ b/calendar/inc/class.calendar_merge.inc.php @@ -249,6 +249,12 @@ class calendar_merge extends Api\Storage\Merge $replacements['$$'.($prefix ? $prefix . '/' : '') . "calendar_participants/{$t_id}$$"] = implode(', ',$type); } } + // Participant email list (not declined) + $this->participant_emails($replacements, $record, $prefix, $content); + + // Add participant summary + $this->participant_summary($replacements, $record, $prefix, $content); + if(!$replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$']) { // Need to set it to '' if not set or previous record may be used @@ -288,6 +294,88 @@ class calendar_merge extends Api\Storage\Merge return $replacements; } + /** + * Generate placeholder(s) for email addresses of all participants who have + * them. + * + * @param Array $replacements Array of replacements + * @param calendar_egw_record $record Event record + * @param string $prefix Prefix of placeholder + * @param string $content Content with placeholders in it + */ + public function participant_emails(&$replacements, &$record, $prefix, &$content) + { + // Early exit if the placeholder is not used + if(strpos($content, '$$'.($prefix?$prefix.'/':'').'participant_emails$$') === FALSE) + { + return false; + } + + $emails = array(); + foreach($record->participants as $uid => $status) + { + // Skip rejected + if (in_array(substr($status, 0, 1), array('R'))) + { + continue; + } + + $info = $this->bo->resource_info($uid); + if($info['email']) + { + $emails[] = $info['email']; + } + } + $replacements['$$'.($prefix?$prefix.'/':'').'participant_emails$$'] = implode(', ', $emails); + } + + /** + * Generate placeholder for a summary of participant status: + * 3 Participants: 1 Accepted, 2 Unknown + * + * Blank if only one participant, matches what's shown in UI event hover + * + * @param Array $replacements Array of replacements + * @param calendar_egw_record $record Event record + * @param string $prefix Prefix of placeholder + * @param string $content Content with placeholders in it + */ + public function participant_summary(&$replacements, &$record, $prefix, &$content) + { + // Early exit if the placeholder is not used + if(strpos($content, '$$'.($prefix?$prefix.'/':'').'participant_summary$$') === FALSE) + { + return false; + } + + $placeholder = '$$'.($prefix?$prefix.'/':'').'participant_summary$$'; + + // No summary for 1 participant + if(count($record->participants) < 2) + { + $replacements[$placeholder] = ''; + } + + $participant_status = array('A' => 0, 'R' => 0, 'T' => 0, 'U' => 0, 'D' => 0); + $status_label = array('A' => 'accepted', 'R' => 'rejected', 'T' => 'tentative', 'U' => 'unknown', 'D' => 'delegated'); + $participant_summary = count($record->participants) . ' ' . lang('Participants').': '; + $status_totals = []; + + foreach($record->participants as $uid => $status) + { + $participant_status[substr($status,0,1)]++; + } + foreach($participant_status as $status => $count) + { + if($count > 0) + { + $status_totals[] = $count . ' ' . lang($status_label[$status]); + } + } + $summary = $participant_summary . join(', ',$status_totals); + $replacements[$placeholder] = $summary; + } + /** * Table plugin for event * Lists events for a certain day of the week. Only works for one week at a time, so for multiple weeks, @@ -795,6 +883,9 @@ class calendar_merge extends Api\Storage\Merge echo '

'.lang('Participants').":

"; + echo '{{participant_emails}}'.lang('A list of email addresses of all participants who have not declined')."\n"; + echo '{{participant_summary}}'.lang('Summary of participant status: 3 Participants: 1 Accepted, 2 Unknown')."\n"; + echo ''.lang('Participant names by type').''; echo '{{calendar_participants/account}}'.lang('Accounts')."\n"; echo '{{calendar_participants/group}}'.lang('Groups')."\n"; foreach($this->bo->resources as $resource) diff --git a/calendar/lang/egw_en.lang b/calendar/lang/egw_en.lang index 98a40f283e..e69d869b36 100644 --- a/calendar/lang/egw_en.lang +++ b/calendar/lang/egw_en.lang @@ -15,6 +15,7 @@ (without a custom url we use nation of user preference to load holidays from %s) calendar en (Without a custom URL we use nation of user preference to load holidays from %s) , exceptions preserved calendar en , exceptions preserved , stati of participants reset calendar en , status of participants reset +a list of email addresses of all participants who have not declined calendar en A list of email addresses of all participants who have not declined a non blocking event will not conflict with other events calendar en A non blocking event will not conflict with other events accept calendar en Accept accept or reject an invitation calendar en Accept or reject an invitation @@ -401,6 +402,7 @@ open todo's: calendar en Open ToDo's: optional calendar en Optional overlap holiday calendar en Overlap holiday owner too calendar en Owner too +participant names by type calendar en Participant names by type participant table calendar en Participant table participants calendar en Participants participants disinvited from an event calendar en Participants disinvited from an event @@ -524,6 +526,7 @@ status for all future scheduled days changed calendar en Status for all future s status for this particular day changed calendar en Status for this particular day changed. status of participants set to unknown because of missing category rights calendar en Status of participants set to unknown because of missing category rights. submit to repository calendar en Submit to repository +summary of participant status: 3 participants: 1 accepted, 2 unknown calendar en Summary of participant status: 3 Participants: 1 Accepted, 2 Unknown sun calendar en Sun tag to mark positions for address labels calendar en Tag to mark positions for address labels tentative calendar en Tentative