From 27872faaf6d9bdffdc842375f2d40b1341917ea6 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 26 Jul 2016 08:38:19 -0600 Subject: [PATCH] Fix backport issues --- calendar/inc/class.calendar_bo.inc.php | 18 ++++++++++++ ...ss.calendar_owner_etemplate_widget.inc.php | 28 +++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index bc644eb398..0a677dae10 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -255,6 +255,11 @@ class calendar_bo 'type' => '', 'app' => 'api-accounts', ); + $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' => 'Distribution list' + ); Api\Cache::setSession('calendar', 'resources', $this->resources); } //error_log(__METHOD__ . " registered resources=". array2string($this->resources)); @@ -445,6 +450,19 @@ class calendar_bo foreach($_users as $user) { $user = trim($user); + + // Handle email lists + if(!is_numeric($user) && $user[0] == 'l') + { + foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) + { + if ($contact && !in_array($contact,$users)) // already added? + { + $users[] = $contact; + } + } + continue; + } if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user)) { if ($user && !in_array($user,$users)) // already added? diff --git a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php index 0e2054c0cc..8bfc3eeee0 100644 --- a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php +++ b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php @@ -157,7 +157,10 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist { $account_options = $options + array('account_type' => 'both'); $_results += Api\Accounts::link_query($query, $account_options); - if (!empty($_REQUEST['checkgrants'])) $_results = array_intersect_key($_results, $GLOBALS['egw']->acl->get_grants('calendar')); + if (!empty($_REQUEST['checkgrants'])) + { + $_results = array_intersect_key($_results, $GLOBALS['egw']->acl->get_grants('calendar')); + } } else if ($data['app'] && $data['search']) { @@ -167,7 +170,28 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist { $_results = Link::query($data['app'], $query,$options); } - if(!$_results) continue; + if ($type == 'l') + { + // Include mailing lists + $contacts_obj = new Api\Contacts(); + $lists = array_filter( + $contacts_obj->get_lists(Api\Acl::READ), + function($element) use($query) { + return (stripos($element, $query) !== false); + } + ); + foreach($lists as $list_id => $list) + { + $_results[$list_id] = array( + 'label' => $list, + 'resources' => $bo->enum_mailing_list($type.$list_id) + ); + } + } + if(!$_results) + { + continue; + } foreach(array_unique($_results) as $id => $title) {