forked from extern/egroupware
* Calendar: automatic cancel alarms from removed or rejected participants
This commit is contained in:
parent
012e2e4763
commit
fe2438cc53
@ -1134,6 +1134,18 @@ class calendar_boupdate extends calendar_bo
|
||||
{
|
||||
// recalculate alarms to also cope with moved events (beside server time adjustment)
|
||||
$event['alarm'][$id]['time'] = $event['start'] - $alarm['offset'];
|
||||
|
||||
// remove alarms belonging to not longer existing or rejected participants
|
||||
if ($alarm['owner'] && isset($event['participants']))
|
||||
{
|
||||
$status = $event['participants'][$alarm['owner']];
|
||||
if (!isset($status) || calendar_so::split_status($status) === 'R')
|
||||
{
|
||||
unset($event['alarm'][$id]);
|
||||
$this->so->delete_alarm($id);
|
||||
error_log(__LINE__.': '.__METHOD__."(".array2string($event).") deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// update all existing alarm times, in case alarm got moved and alarms are not include in $event
|
||||
@ -1144,7 +1156,19 @@ class calendar_boupdate extends calendar_bo
|
||||
if (!isset($event['alarm'][$id]))
|
||||
{
|
||||
$alarm['time'] = $event['start'] - $alarm['offset'];
|
||||
// remove (not store) alarms belonging to not longer existing or rejected participants
|
||||
$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
|
||||
$old_event['participants'][$alarm['owner']];
|
||||
if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R')
|
||||
{
|
||||
$this->so->save_alarm($event['id'], $alarm, $this->now);
|
||||
error_log(__LINE__.': '.__METHOD__."() so->save_alarm($event[id], ".array2string($alarm).", $this->now)");
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->so->delete_alarm($id);
|
||||
error_log(__LINE__.': '.__METHOD__."(".array2string($event).") deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1388,6 +1412,17 @@ class calendar_boupdate extends calendar_bo
|
||||
is_numeric($uid)?$uid:substr($uid,1),$status,
|
||||
$recur_date?$this->date2ts($recur_date,true):0,$role)))
|
||||
{
|
||||
if ($status == 'R') // remove alarms belonging to rejected participants
|
||||
{
|
||||
foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
|
||||
{
|
||||
if ((string)$alarm['owner'] === (string)$uid)
|
||||
{
|
||||
$this->so->delete_alarm($id);
|
||||
error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($updateTS)
|
||||
{
|
||||
$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now);
|
||||
|
@ -1029,7 +1029,7 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
|
||||
$old_min = $old_duration = 0;
|
||||
|
||||
//error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag)");
|
||||
//error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace());
|
||||
|
||||
$cal_id = (int) $event['id'];
|
||||
unset($event['id']);
|
||||
@ -1480,10 +1480,11 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
* splits the combined status, quantity and role
|
||||
*
|
||||
* @param string &$status I: combined value, O: status letter: U, T, A, R
|
||||
* @param int &$quantity only O: quantity
|
||||
* @param string &$role only O: role
|
||||
* @param int &$quantity=null only O: quantity
|
||||
* @param string &$role=null only O: role
|
||||
* @return string status U, T, A or R, same as $status parameter on return
|
||||
*/
|
||||
static function split_status(&$status,&$quantity,&$role)
|
||||
static function split_status(&$status,&$quantity=null,&$role=null)
|
||||
{
|
||||
$quantity = 1;
|
||||
$role = 'REQ-PARTICIPANT';
|
||||
@ -1498,6 +1499,7 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
{
|
||||
$status = 'U';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1927,8 +1929,7 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
*/
|
||||
function save_alarm($cal_id, $alarm, $update_modified=true)
|
||||
{
|
||||
//echo "<p>save_alarm(cal_id=$cal_id, alarm="; print_r($alarm); echo ")</p>\n";
|
||||
//error_log(__METHOD__."(.$cal_id,$now,".array2string($alarm).')');
|
||||
//error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace());
|
||||
if (!($id = $alarm['id']))
|
||||
{
|
||||
$alarms = $this->read_alarms($cal_id); // find a free alarm#
|
||||
@ -1971,6 +1972,7 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
*/
|
||||
private function delete_alarms($cal_id)
|
||||
{
|
||||
//error_log(__METHOD__."($cal_id) ".function_backtrace());
|
||||
$alarms = $this->read_alarms($cal_id);
|
||||
|
||||
foreach($alarms as $id => $alarm)
|
||||
@ -1991,6 +1993,7 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
*/
|
||||
function delete_alarm($id)
|
||||
{
|
||||
//error_log(__METHOD__."('$id') ".function_backtrace());
|
||||
// update the modification information of the related event
|
||||
list(,$cal_id) = explode(':',$id);
|
||||
if ($cal_id)
|
||||
|
@ -430,6 +430,17 @@ class calendar_uiforms extends calendar_ui
|
||||
$js = "opener.location.search += (opener.location.search?'&msg=':'?msg=')+'".
|
||||
addslashes($msg)."';";
|
||||
}
|
||||
if ($status == 'R' && $event['alarm'])
|
||||
{
|
||||
// remove from bo->set_status deleted alarms of rejected users from UI too
|
||||
foreach($event['alarm'] as $alarm_id => $alarm)
|
||||
{
|
||||
if ((string)$alarm['owner'] === (string)$uid)
|
||||
{
|
||||
unset($event['alarm'][$alarm_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($uid && $status != 'G')
|
||||
|
@ -5,6 +5,7 @@
|
||||
%1 records imported calendar de %1 Datensätze importiert
|
||||
%1 records read (not yet imported, you may go back and uncheck test import) calendar de %1 Datensätze gelesen (noch nicht importiert, Sie können zurück gehen und Test Import ausschalten)
|
||||
%1 weeks calendar de %1 Wochen
|
||||
%s the event calendar de %s dem Termin
|
||||
(%1 events in %2 seconds) calendar de (%1 Termine in %2 Sekunden
|
||||
, exceptions preserved calendar de und Ausnahmen erhalten
|
||||
, stati of participants reset calendar de , Status der Teilnehmer zurückgesetzt
|
||||
|
@ -5,6 +5,7 @@
|
||||
%1 records imported calendar en %1 records imported.
|
||||
%1 records read (not yet imported, you may go back and uncheck test import) calendar en %1 records read. Not yet imported, go back and uncheck Test import.
|
||||
%1 weeks calendar en %1 weeks
|
||||
%s the event calendar en %s the event
|
||||
(%1 events in %2 seconds) calendar en (%1 events in %2 seconds)
|
||||
, exceptions preserved calendar en , exceptions preserved
|
||||
, stati of participants reset calendar en , status of participants reset
|
||||
|
Loading…
Reference in New Issue
Block a user