mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-12 08:58:30 +01:00
bocalendar_update::email_update_requested() allowing eSync to check if calendar will send a notification according to preferences
This commit is contained in:
parent
d896ff64f8
commit
037ccb85a6
@ -509,7 +509,7 @@ class calendar_boupdate extends calendar_bo
|
|||||||
* @param string $role we treat CHAIR like event owners
|
* @param string $role we treat CHAIR like event owners
|
||||||
* @return boolean true = update requested, false otherwise
|
* @return boolean true = update requested, false otherwise
|
||||||
*/
|
*/
|
||||||
function update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event,$role)
|
public static function update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event,$role)
|
||||||
{
|
{
|
||||||
if ($msg_type == MSG_ALARM)
|
if ($msg_type == MSG_ALARM)
|
||||||
{
|
{
|
||||||
@ -533,8 +533,8 @@ class calendar_boupdate extends calendar_bo
|
|||||||
case 'time_change_4h':
|
case 'time_change_4h':
|
||||||
case 'time_change':
|
case 'time_change':
|
||||||
default:
|
default:
|
||||||
$diff = max(abs($this->date2ts($old_event['start'])-$this->date2ts($new_event['start'])),
|
$diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])),
|
||||||
abs($this->date2ts($old_event['end'])-$this->date2ts($new_event['end'])));
|
abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end'])));
|
||||||
$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
|
$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
|
||||||
if ($msg_type == MSG_MODIFIED && $diff > $check)
|
if ($msg_type == MSG_MODIFIED && $diff > $check)
|
||||||
{
|
{
|
||||||
@ -558,6 +558,55 @@ class calendar_boupdate extends calendar_bo
|
|||||||
return $want_update > 0;
|
return $want_update > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check calendar prefs, if a given user (integer account_id) or email (user or externals) should get notified
|
||||||
|
*
|
||||||
|
* @param int|string $user_or_email
|
||||||
|
* @param string $ical_method='REQUEST'
|
||||||
|
* @param string $role='REQ-PARTICIPANT'
|
||||||
|
* @return boolean true if user requested to be notified, false if not
|
||||||
|
*/
|
||||||
|
static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT')
|
||||||
|
{
|
||||||
|
// check if email is from a user
|
||||||
|
if (is_numeric($user_or_email))
|
||||||
|
{
|
||||||
|
$account_id = $user_or_email;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$account_id = $GLOBALS['egw']->account->name2id($user_or_email, 'account_email');
|
||||||
|
}
|
||||||
|
if ($account_id)
|
||||||
|
{
|
||||||
|
$prefs = new preferences($account_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$prefs = array(
|
||||||
|
'calendar' => array(
|
||||||
|
'receive_updates' => $GLOBALS['egw_info']['user']['preferences']['calendar']['notify_externals'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
switch($ical_method)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 'REQUEST':
|
||||||
|
$msg_type = MSG_ADDED;
|
||||||
|
break;
|
||||||
|
case 'REPLY':
|
||||||
|
$msg_type = MSG_ACCEPTED;
|
||||||
|
break;
|
||||||
|
case 'CANCEL':
|
||||||
|
$msg_type = MSG_DELETED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$ret = self::update_requested($acount_id, $prefs, $msg_type, array(), array(), $role);
|
||||||
|
//error_log(__METHOD__."('$user_or_email', '$ical_method', '$role') account_id=$account_id --> updated_requested returned ".array2string($ret));
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sends update-messages to certain participants of an event
|
* sends update-messages to certain participants of an event
|
||||||
*
|
*
|
||||||
@ -750,7 +799,7 @@ class calendar_boupdate extends calendar_bo
|
|||||||
$part_prefs['calendar']['update_format'] = 'ical'; // use ical format
|
$part_prefs['calendar']['update_format'] = 'ical'; // use ical format
|
||||||
$details['to-fullname'] = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid;
|
$details['to-fullname'] = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid;
|
||||||
}
|
}
|
||||||
if (!$this->update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event,$role))
|
if (!self::update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event,$role))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user