Fix backport issues

This commit is contained in:
nathangray 2016-07-26 08:38:19 -06:00
parent d05c8708e4
commit 27872faaf6
2 changed files with 44 additions and 2 deletions

View File

@ -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?

View File

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