From c90fc65566abe719aa345848ffd85d8bbbe5d97b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 22 Oct 2012 15:50:33 +0000 Subject: [PATCH] * Calendar: deny creating of recurring events, if duration of a single recurrence is longer then the recurrence interval --- calendar/inc/class.calendar_rrule.inc.php | 30 +++++++++++++++++++++ calendar/inc/class.calendar_uiforms.inc.php | 6 +++++ calendar/lang/egw_de.lang | 10 ++++--- calendar/lang/egw_en.lang | 10 ++++--- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/calendar/inc/class.calendar_rrule.inc.php b/calendar/inc/class.calendar_rrule.inc.php index 6e5bbad770..788e9d2866 100644 --- a/calendar/inc/class.calendar_rrule.inc.php +++ b/calendar/inc/class.calendar_rrule.inc.php @@ -311,6 +311,36 @@ class calendar_rrule implements Iterator } } + /** + * Get recurrence interval duration in seconds + * + * @param int $type self::(DAILY|WEEKLY|MONTHLY_(M|W)DAY|YEARLY) + * @param int $interval=1 + * @return int + */ + public static function recurrence_interval($type, $interval=1) + { + switch($type) + { + case self::DAILY: + $duration = 24*3600; + break; + case self::WEEKLY: + $duration = 7*24*3600; + break; + case self::MONTHLY_MDAY: + case self::MONTHLY_WDAY: + $duration = 31*24*3600; + break; + case self::YEARLY: + $duration = 366*24*3600; + break; + } + if ($interval > 1) $duration *= $interval; + + return $duration; + } + /** * Get number of days in month of given date * diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 13ddcfae1c..e957c67a85 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -507,6 +507,12 @@ class calendar_uiforms extends calendar_ui $button = ''; break; } + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) + { + $msg = lang('Error: Duration of event longer then recurrence interval!'); + $button = ''; + break; + } if (!$event['participants']) { $msg = lang('Error: no participants selected !!!'); diff --git a/calendar/lang/egw_de.lang b/calendar/lang/egw_de.lang index ecbc6d309b..9b9b5baee1 100644 --- a/calendar/lang/egw_de.lang +++ b/calendar/lang/egw_de.lang @@ -128,10 +128,12 @@ enddate / -time of the meeting, eg. for more then one day calendar de Enddatum u enddate of the export calendar de Enddatum des Exports ends calendar de endet error adding the alarm calendar de Fehler beim Zufügen des Alarms -error: importing the ical calendar de Fehler: beim Importieren des iCal -error: no participants selected !!! calendar de Fehler: keine Teilnehmer ausgewählt !!! -error: ressources reservation in private events is not allowed!!! calendar de Fehler: die Reservierung von Ressourcen für private Termine ist nicht erlaubt !!! -error: saving the event !!! calendar de Fehler: beim Speichern des Termins !!! +error: can't delete original series! calendar de Fehler beim Löschen der bestehenden Serie +error: duration of event longer then recurrence interval! calendar de Fehler: Termindauer ist länger als das Intervall der Wiederholung! +error: importing the ical calendar de Fehler beim Importieren des iCal +error: no participants selected !!! calendar de Fehler: Keine Teilnehmer ausgewählt !!! +error: ressources reservation in private events is not allowed!!! calendar de Fehler: Die Reservierung von Ressourcen für private Termine ist nicht erlaubt !!! +error: saving the event !!! calendar de Fehler beim Speichern des Termins !!! error: starttime has to be before the endtime !!! calendar de Fehler: Startzeit muss vor Endzeit liegen !!! error: the entry has been updated since you opened it for editing! calendar de Fehler: der Eintrag wurde geändert seit Sie ihn zum Bearbeiten geöffnet haben! event copied - the copy can now be edited calendar de Termin kopiert - die Kopie kann jetzt bearbeitet werden diff --git a/calendar/lang/egw_en.lang b/calendar/lang/egw_en.lang index 4becd9aeab..0a69e3aa92 100644 --- a/calendar/lang/egw_en.lang +++ b/calendar/lang/egw_en.lang @@ -120,10 +120,12 @@ enddate / -time of the meeting, eg. for more then one day calendar en End date / enddate of the export calendar en End date of the export ends calendar en ends error adding the alarm calendar en Error adding the alarm -error: importing the ical calendar en Error: importing the iCal -error: no participants selected !!! calendar en Error: no participants selected !!! -error: ressources reservation in private events is not allowed!!! calendar en Error: Resources reservation in private events is not allowed !!! -error: saving the event !!! calendar en Error: saving the event !!! +error: can't delete original series! calendar en Error: Can't delete original series! +error: duration of event longer then recurrence interval! calendar en Error: Duration of event longer then recurrence interval! +error: importing the ical calendar en Error: importing the iCal! +error: no participants selected !!! calendar en Error: no participants selected! +error: ressources reservation in private events is not allowed!!! calendar en Error: Resources reservation in private events is not allowed! +error: saving the event !!! calendar en Error saving the event! error: starttime has to be before the endtime !!! calendar en Error: Start time has to be before the end time !!! error: the entry has been updated since you opened it for editing! calendar en Error: The entry has been updated since you opened it for editing! event copied - the copy can now be edited calendar en Event copied - the copy can now be edited