From c8ea65828db0d78d75497586f39a03842bbd7d57 Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 6 Jul 2016 13:18:36 -0600 Subject: [PATCH] Allow contact lists as event participants --- calendar/inc/class.calendar_bo.inc.php | 5 ++++ calendar/inc/class.calendar_boupdate.inc.php | 23 +++++++++++++++++++ ...ss.calendar_owner_etemplate_widget.inc.php | 2 +- calendar/js/app.js | 1 + calendar/js/et2_widget_timegrid.js | 16 +++---------- calendar/js/et2_widget_view.js | 2 +- calendar/templates/default/app.css | 10 ++++---- calendar/templates/pixelegg/app.css | 10 ++++---- 8 files changed, 44 insertions(+), 25 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 0a677dae10..791eff9f0f 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -251,6 +251,11 @@ class calendar_bo 'info' => __CLASS__.'::email_info', 'app' => 'email', ); + $this->resources['l'] = array( + 'type' => 'l',// one char type-identifier for this resources + 'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id + 'app' => 'Mailing list' + ); $this->resources[''] = array( 'type' => '', 'app' => 'api-accounts', diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index 36b92d8fa8..630e92e667 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -825,6 +825,7 @@ class calendar_boupdate extends calendar_bo $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; // add all group-members to the notification, unless they are already participants + $contact_obj = false; foreach($to_notify as $userid => $statusid) { if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && @@ -838,6 +839,28 @@ class calendar_boupdate extends calendar_bo } } } + // Mailing lists + else if (!is_numeric($userid) && $userid[0] == 'l') + { + if(!$contact_obj) + { + $contact_obj = new Api\Contacts(); + } + $options = array('list' => substr($user,1)); + $contacts = $contact_obj->search('',true,'','','',false,'AND',false,$options); + if(!$contacts) + { + continue; + } + foreach($contacts as &$contact) + { + $contact = 'c'.$contact['id']; + if ($contact && !isset($to_notify[$contact])) // already added? + { + $to_notify[$contact] = 'G'; + } + } + } } $user_prefs = $GLOBALS['egw_info']['user']['preferences']; $startdate = new Api\DateTime($event['start']); diff --git a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php index 8bfc3eeee0..0efbae92e3 100644 --- a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php +++ b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php @@ -253,4 +253,4 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist } return $label; } -} \ No newline at end of file +} diff --git a/calendar/js/app.js b/calendar/js/app.js index c8941cb5e6..4eb5453450 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -2753,6 +2753,7 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( jQuery.extend({}, state, {owner: value[i].owner}), this.sidebox_et2 ? null : this.et2.getInstanceManager() ); + need_data = false; } } diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index faa32e93b1..2b48c7e798 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -108,7 +108,7 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. .appendTo(this.scrolling); // Used for owners - this.owner = et2_createWidget('select-account_ro',{},this); + this.owner = et2_createWidget('description',{},this); this._labelContainer = jQuery(document.createElement("label")) .addClass("et2_label et2_link") @@ -1586,17 +1586,7 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. if(typeof _owner == 'string' && isNaN(_owner)) { this.set_label(''); - switch(_owner[0]) - { - case 'c': - this.owner.options.application = 'addressbook'; - this.owner.set_value(_owner.substr(1)); - break; - case 'r': - this.owner.options.application = 'resources'; - this.owner.set_value(_owner.substr(1)); - break; - } + this.owner.set_value(this._get_owner_name(_owner)); // Label is empty, but give extra space for the owner name this.div.removeClass('calendar_TimeGridNoLabel'); @@ -1615,7 +1605,7 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. else { this.owner.options.application = 'api-accounts'; - this.owner.set_value(typeof _owner == "string" || typeof _owner == "number" ? _owner : jQuery.extend([],_owner)); + this.owner.set_value(this._get_owner_name(_owner)); this.set_label(''); jQuery(this.getDOMNode(this.owner)).prepend(this.owner.getDOMNode()); } diff --git a/calendar/js/et2_widget_view.js b/calendar/js/et2_widget_view.js index f6c55fb9b3..1f3d005347 100644 --- a/calendar/js/et2_widget_view.js +++ b/calendar/js/et2_widget_view.js @@ -345,7 +345,7 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend var options = false if(app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner')) { - options = app.calendar.sidebox_et2.getWidgetById('owner').options.select_options; + options = app.calendar.sidebox_et2.getWidgetById('owner').taglist.getSelection(); } else { diff --git a/calendar/templates/default/app.css b/calendar/templates/default/app.css index 215d2134ff..0c61354c9c 100644 --- a/calendar/templates/default/app.css +++ b/calendar/templates/default/app.css @@ -39,10 +39,10 @@ } /* Let hidden user names be visible */ - #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader > ul { + #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader > span.et2_label { position: static; } - #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader > ul > li { + #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader > span.et2_label { overflow: visible !important; } } @@ -313,12 +313,12 @@ Hide subsequent headers in week view with non-consolidated owners #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader .calendar_calDayColHeader > div[data-date] { display:none; } -#calendar-view_view.hideDayColHeader tr .calendar_calGridHeader > ul > li { +#calendar-view_view.hideDayColHeader tr .calendar_calGridHeader > span.et2_label { white-space:nowrap; text-overflow: ellipsis; overflow: hidden; } -#calendar-view_view.hideDayColHeader tr .calendar_calGridHeader > ul:hover { +#calendar-view_view.hideDayColHeader tr .calendar_calGridHeader > span.et2_label:hover { overflow: visible; width: auto; background-color: inherit; @@ -535,7 +535,7 @@ Hide subsequent headers in week view with non-consolidated owners text-align: center; } -.calendar_calGridHeader > ul { +.calendar_calGridHeader > span.et2_label { position: absolute; width: 55px; } diff --git a/calendar/templates/pixelegg/app.css b/calendar/templates/pixelegg/app.css index 5fabb15598..16957597ce 100755 --- a/calendar/templates/pixelegg/app.css +++ b/calendar/templates/pixelegg/app.css @@ -51,10 +51,10 @@ overflow-y: hidden !important; } /* Let hidden user names be visible */ - #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader > ul { + #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader > span.et2_label { position: static; } - #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader > ul > li { + #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader > span.et2_label { overflow: visible !important; } } @@ -316,12 +316,12 @@ Hide subsequent headers in week view with non-consolidated owners #calendar-view_view.hideDayColHeader tr:not(:first-of-type) .calendar_calGridHeader .calendar_calDayColHeader > div[data-date] { display: none; } -#calendar-view_view.hideDayColHeader tr .calendar_calGridHeader > ul > li { +#calendar-view_view.hideDayColHeader tr .calendar_calGridHeader > span.et2_label { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } -#calendar-view_view.hideDayColHeader tr .calendar_calGridHeader > ul:hover { +#calendar-view_view.hideDayColHeader tr .calendar_calGridHeader > span.et2_label:hover { overflow: visible; width: auto; background-color: inherit; @@ -532,7 +532,7 @@ Hide subsequent headers in week view with non-consolidated owners width: 58px; text-align: center; } -.calendar_calGridHeader > ul { +.calendar_calGridHeader > span.et2_label { position: absolute; width: 55px; }