forked from extern/egroupware
When adding a mailing list as participant, immediately expand it to contacts
This commit is contained in:
parent
918548665d
commit
fada2d433e
@ -362,6 +362,45 @@ class calendar_bo
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates the contacts in a contact list, and returns the list of contact IDs
|
||||
*
|
||||
* This is used to enable mailing lists as owner/participant
|
||||
*
|
||||
* @param string $id Mailing list participant ID, which is the mailing list
|
||||
* ID prefixed with 'l'
|
||||
* @param boolean $ignore_acl = false Flag to skip ACL checks
|
||||
* @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function enum_mailing_list($id, $ignore_acl= false, $use_freebusy = true)
|
||||
{
|
||||
$contact_list = array();
|
||||
$contacts = new Api\Contacts();
|
||||
if($contacts->check_list((int)substr($id,1), ACL::READ))
|
||||
{
|
||||
$options = array('list' => substr($id,1));
|
||||
$lists = $contacts->search('',true,'','','',false,'AND',false,$options);
|
||||
if(!$lists)
|
||||
{
|
||||
return $contact_list;
|
||||
}
|
||||
foreach($lists as &$contact)
|
||||
{
|
||||
$contact = 'c'.$contact['id'];
|
||||
if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
|
||||
{
|
||||
if ($contact && !in_array($contact,$contact_list)) // already added?
|
||||
{
|
||||
$contact_list[] = $contact;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $contact_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add group-members as participants with status 'G'
|
||||
*
|
||||
@ -413,29 +452,13 @@ class calendar_bo
|
||||
// Handle email lists
|
||||
if(!is_numeric($user) && $user[0] == 'l')
|
||||
{
|
||||
$contacts = new Api\Contacts();
|
||||
if($contacts->check_list((int)substr($user,1), ACL::READ))
|
||||
{
|
||||
$users[] = $user;
|
||||
|
||||
$options = array('list' => substr($user,1));
|
||||
$lists = $contacts->search('',true,'','','',false,'AND',false,$options);
|
||||
if(!$lists)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach($lists as &$contact)
|
||||
{
|
||||
$contact = 'c'.$contact['id'];
|
||||
if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
|
||||
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))
|
||||
|
@ -839,28 +839,6 @@ 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']);
|
||||
|
@ -158,6 +158,16 @@ class calendar_uiforms extends calendar_ui
|
||||
}
|
||||
elseif (is_array($this->bo->resources[$uid[0]]))
|
||||
{
|
||||
// Expand mailing lists
|
||||
if($uid[0] == 'l')
|
||||
{
|
||||
foreach($this->bo->enum_mailing_list($uid) as $contact)
|
||||
{
|
||||
$participants[$contact] = $participant_types['c'][substr($contact,1)] =
|
||||
calendar_so::combine_status('U',1,'REQ-PARTICIPANT');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// if contact is a user, use the user instead (as the GUI)
|
||||
if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id')))
|
||||
{
|
||||
@ -419,6 +429,16 @@ class calendar_uiforms extends calendar_ui
|
||||
ExecMethod($this->bo->resources[$type]['new_status'],$id) :
|
||||
($uid == $this->bo->user ? 'A' : 'U');
|
||||
|
||||
// Expand mailing lists
|
||||
if($type == 'l')
|
||||
{
|
||||
foreach($this->bo->enum_mailing_list($participant) as $contact)
|
||||
{
|
||||
$event['participants'][$contact] = $event['participant_types']['c'][substr($contact,1)] =
|
||||
calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ($status)
|
||||
{
|
||||
$res_info = $this->bo->resource_info($uid);
|
||||
|
Loading…
Reference in New Issue
Block a user