forked from extern/egroupware
Calendar - Pass group members on load to save some user data lookups
This commit is contained in:
parent
6892c4508e
commit
fa928efc57
@ -104,14 +104,44 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist
|
||||
{
|
||||
$resource = array('app'=> 'api-accounts');
|
||||
}
|
||||
else if ($owner < 0)
|
||||
{
|
||||
// Add in group memberships as strings
|
||||
$info['resources'] = array_map(function($a) { return ''.$a;},$GLOBALS['egw']->accounts->members($owner, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$sel_options[] = array('value' => $owner, 'label' => $label, 'app' => lang($resource['app'])) + $info;
|
||||
$option = array('value' => $owner, 'label' => $label, 'app' => lang($resource['app'])) + $info;
|
||||
$sel_option_index = $this->get_index($sel_options, 'value', $owner);
|
||||
if($sel_option_index === false)
|
||||
{
|
||||
$sel_options[] = $option;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sel_options[$sel_option_index] = array_merge($sel_options[$sel_option_index], $option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of an array (sel_options) containing the given value
|
||||
*
|
||||
* @param Array $array
|
||||
* @param string $key key we're checking to match value
|
||||
* @param string $value Value we're looking for
|
||||
* @return boolean|int Returns index
|
||||
*/
|
||||
private function get_index(&$array, $key, $value)
|
||||
{
|
||||
foreach($array as $_key => $_value)
|
||||
{
|
||||
if($_value[$key] === $value) return $_key;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Validate input
|
||||
*
|
||||
@ -247,6 +277,10 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist
|
||||
'contact_id' => $contact['id'],
|
||||
'etag' => $contact['etag'] ? $contact['etag'] : 1
|
||||
));
|
||||
if($id < 0)
|
||||
{
|
||||
$value['resources'] = $GLOBALS['egw']->accounts->members($id, true);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
// do nothing
|
||||
|
@ -1024,9 +1024,9 @@ et2_calendar_event.owner_check = function owner_check(event, parent, owner_too)
|
||||
var length = parent_owner.length;
|
||||
for(var i = 0; i < length; i++ )
|
||||
{
|
||||
// Handle grouped resources like mailing lists, they won't match so
|
||||
// Handle groups & grouped resources like mailing lists, they won't match so
|
||||
// we need the list - pull it from sidebox owner
|
||||
if(isNaN(parent_owner[i]) && options && options.find)
|
||||
if((isNaN(parent_owner[i]) || parent_owner[i] < 0) && options && options.find)
|
||||
{
|
||||
var resource = options.find(function(element) {return element.id == parent_owner[i];}) || {};
|
||||
if(resource && resource.resources)
|
||||
@ -1036,14 +1036,6 @@ et2_calendar_event.owner_check = function owner_check(event, parent, owner_too)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (parseInt(parent_owner[i]) < 0)
|
||||
{
|
||||
// Add in groups, if we can get them (this is syncronous)
|
||||
egw.accountData(parent_owner[i],'account_id',true,function(members) {
|
||||
parent_owner = parent_owner.concat(Object.keys(members));
|
||||
});
|
||||
}
|
||||
}
|
||||
var participants = jQuery.extend([],Object.keys(event.participants));
|
||||
for(var i = 0; i < participants.length; i++ )
|
||||
@ -1052,10 +1044,19 @@ et2_calendar_event.owner_check = function owner_check(event, parent, owner_too)
|
||||
// Expand group invitations
|
||||
if (parseInt(id) < 0)
|
||||
{
|
||||
// Add in groups, if we can get them (this is syncronous)
|
||||
egw.accountData(id,'account_id',true,function(members) {
|
||||
participants = participants.concat(Object.keys(members));
|
||||
});
|
||||
// Add in groups, if we can get them from options, great
|
||||
var resource;
|
||||
if(options && options.find && (resource = options.find(function(element) {return element.id === id;})) && resource.resources)
|
||||
{
|
||||
participants = participants.concat(resource.resources);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add in groups, if we can get them (this is asynchronous)
|
||||
egw.accountData(id,'account_id',true,function(members) {
|
||||
participants = participants.concat(Object.keys(members));
|
||||
});
|
||||
}
|
||||
}
|
||||
if(parent.options.owner == id ||
|
||||
parent_owner.indexOf &&
|
||||
|
Loading…
Reference in New Issue
Block a user