diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php
index 2c81539d2e..4783fcca89 100644
--- a/apps/calendar/ajax/editeventform.php
+++ b/apps/calendar/ajax/editeventform.php
@@ -40,7 +40,6 @@ switch($dtstart->getDateType()) {
$summary = $vevent->getAsString('SUMMARY');
$location = $vevent->getAsString('LOCATION');
$categories = $vevent->getAsArray('CATEGORIES');
-$repeat = $vevent->getAsString('CATEGORY');
$description = $vevent->getAsString('DESCRIPTION');
foreach($categories as $category){
if (!in_array($category, $category_options)){
@@ -53,10 +52,150 @@ if ($last_modified){
}else{
$lastmodified = 0;
}
+if($data['repeating'] == 1){
+ $rrule = explode(';', $vevent->getAsString('RRULE'));
+ $rrulearr = array();
+ foreach($rrule as $rule){
+ list($attr, $val) = explode('=', $rule);
+ $rrulearr[$attr] = $val;
+ }
+ if(!isset($rrulearr['INTERVAL']) || $rrulearr['INTERVAL'] == ''){
+ $rrulearr['INTERVAL'] = 1;
+ }
+ if(array_key_exists('BYDAY', $rrulearr)){
+ if(substr_count($rrulearr['BYDAY'], ',') == 0){
+ if(strlen($rrulearr['BYDAY']) == 2){
+ $repeat['weekdays'] = array($rrulearr['BYDAY']);
+ }elseif(strlen($rrulearr['BYDAY']) == 3){
+ $repeat['weekofmonth'] = substr($rrulearr['BYDAY'] , 0, 1);
+ $repeat['weekdays'] = array(substr($rrulearr['BYDAY'] , 1, 2));
+ }elseif(strlen($rrulearr['BYDAY']) == 4){
+ $repeat['weekofmonth'] = substr($rrulearr['BYDAY'] , 0, 2);
+ $repeat['weekdays'] = array(substr($rrulearr['BYDAY'] , 2, 2));
+ }
+ }else{
+ $byday_days = explode(',', $rrulearr['BYDAY']);
+ foreach($byday_days as $byday_day){
+ if(strlen($byday_day) == 2){
+ $repeat['weekdays'][] = $byday_day;
+ }elseif(strlen($rrulearr['BYDAY']) == 3){
+ $repeat['weekofmonth'] = substr($byday_day , 0, 1);
+ $repeat['weekdays'][] = substr($byday_day , 1, 2);
+ }elseif(strlen($rrulearr['BYDAY']) == 4){
+ $repeat['byweekno'] = substr($byday_day , 0, 2);
+ $repeat['weekdays'][] = substr($byday_day , 2, 2);
+ }
+ }
+ }
+ }
+ if(array_key_exists('BYMONTHDAY', $rrulearr)){
+ if(substr_count($rrulearr['BYMONTHDAY'], ',') == 0){
+ $repeat['bymonthday'][] = $rrulearr['BYMONTHDAY'];
+ }else{
+ $bymonthdays = explode(',', $rrulearr['BYMONTHDAY']);
+ foreach($bymonthdays as $bymonthday){
+ $repeat['bymonthday'][] = $bymonthday;
+ }
+ }
+ }
+ if(array_key_exists('BYYEARDAY', $rrulearr)){
+ if(substr_count($rrulearr['BYYEARDAY'], ',') == 0){
+ $repeat['byyearday'][] = $rrulearr['BYYEARDAY'];
+ }else{
+ $byyeardays = explode(',', $rrulearr['BYYEARDAY']);
+ foreach($byyeardays as $yearday){
+ $repeat['byyearday'][] = $yearday;
+ }
+ }
+ }
+ if(array_key_exists('BYWEEKNO', $rrulearr)){
+ if(substr_count($rrulearr['BYWEEKNO'], ',') == 0){
+ $repeat['byweekno'][] = (string) $rrulearr['BYWEEKNO'];
+ }else{
+ $byweekno = explode(',', $rrulearr['BYWEEKNO']);
+ foreach($byweekno as $weekno){
+ $repeat['byweekno'][] = (string) $weekno;
+ }
+ }
+ }
+ if(array_key_exists('BYMONTH', $rrulearr)){
+ $months = OC_Calendar_App::getByMonthOptions();
+ if(substr_count($rrulearr['BYMONTH'], ',') == 0){
+ $repeat['bymonth'][] = $months[$month];
+ }else{
+ $bymonth = explode(',', $rrulearr['BYMONTH']);
+ foreach($bymonth as $month){
+ $repeat['bymonth'][] = $months[$month];
+ }
+ }
+ }
+ switch($rrulearr['FREQ']){
+ case 'DAILY':
+ $repeat['repeat'] = 'daily';
+ break;
+ case 'WEEKLY':
+ if($rrulearr['INTERVAL'] % 2 == 0){
+ $repeat['repeat'] = 'biweekly';
+ $rrulearr['INTERVAL'] = $rrulearr['INTERVAL'] / 2;
+ }elseif($rrulearr['BYDAY'] == 'MO,TU,WE,TH,FR'){
+ $repeat['repeat'] = 'weekday';
+ }else{
+ $repeat['repeat'] = 'weekly';
+ }
+ break;
+ case 'MONTHLY':
+ $repeat['repeat'] = 'monthly';
+ if(array_key_exists('BYDAY', $rrulearr)){
+ $repeat['month'] = 'weekday';
+ }else{
+ $repeat['month'] = 'monthday';
+ }
+ break;
+ case 'YEARLY':
+ $repeat['repeat'] = 'yearly';
+ if(array_key_exists('BYMONTH', $rrulearr)){
+ $repeat['year'] = 'bydaymonth';
+ }elseif(array_key_exists('BYWEEKNO', $rrulearr)){
+ $repeat['year'] = 'byweekno';
+ }else{
+ $repeat['year'] = 'byyearday';
+ }
+ }
+ $repeat['interval'] = $rrulearr['INTERVAL'];
+ if(array_key_exists('COUNT', $rrulearr)){
+ $end = 'count';
+ $count = $rrulearr['COUNT'];
+ }elseif(array_key_exists('UNTIL', $rrulearr)){
+ $end = 'date';
+ $endbydate_day = substr($rrulearr['UNTIL'], 6, 2);
+ $endbydate_month = substr($rrulearr['UNTIL'], 4, 2);
+ $endbydate_year = substr($rrulearr['UNTIL'], 0, 4);
+ $endbydate = $endbydate_day . $endbydate_month . $endbydate_year;
+ }else{
+ $end = 'never';
+ }
+ if(array_key_exists('weekdays', $repeat)){
+ $repeat_weekdays_ = array();
+ $days = OC_Calendar_App::getWeeklyOptions();
+ foreach($repeat['weekdays'] as $weekday){
+ $repeat_weekdays_[] = $days[$weekday];
+ }
+ $repeat['weekdays'] = $repeat_weekdays_;
+ }
+}
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
+$repeat_end_options = OC_Calendar_App::getEndOptions();
+$repeat_month_options = OC_Calendar_App::getMonthOptions();
+$repeat_year_options = OC_Calendar_App::getYearOptions();
+$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions();
+$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth();
+$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions();
+$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions();
+$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
+$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
$tmpl = new OC_Template('calendar', 'part.editevent');
$tmpl->assign('id', $id);
@@ -64,6 +203,15 @@ $tmpl->assign('lastmodified', $lastmodified);
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
$tmpl->assign('repeat_options', $repeat_options);
+$tmpl->assign('repeat_month_options', $repeat_month_options);
+$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
+$tmpl->assign('repeat_end_options', $repeat_end_options);
+$tmpl->assign('repeat_year_options', $repeat_year_options);
+$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options);
+$tmpl->assign('repeat_bymonth_options', $repeat_bymonth_options);
+$tmpl->assign('repeat_byweekno_options', $repeat_byweekno_options);
+$tmpl->assign('repeat_bymonthday_options', $repeat_bymonthday_options);
+$tmpl->assign('repeat_weekofmonth_options', $repeat_weekofmonth_options);
$tmpl->assign('title', $summary);
$tmpl->assign('location', $location);
@@ -74,8 +222,22 @@ $tmpl->assign('startdate', $startdate);
$tmpl->assign('starttime', $starttime);
$tmpl->assign('enddate', $enddate);
$tmpl->assign('endtime', $endtime);
-$tmpl->assign('repeat', $repeat);
$tmpl->assign('description', $description);
+
+$tmpl->assign('repeat', $repeat['repeat']);
+$tmpl->assign('repeat_month', $repeat['month']);
+$tmpl->assign('repeat_weekdays', $repeat['weekdays']);
+$tmpl->assign('repeat_interval', $repeat['interval']);
+$tmpl->assign('repeat_end', $repeat['end']);
+$tmpl->assign('repeat_count', $repeat['count']);
+$tmpl->assign('repeat_weekofmonth', $repeat['weekofmonth']);
+$tmpl->assign('repeat_date', $repeat['date']);
+$tmpl->assign('repeat_year', $repeat['year']);
+$tmpl->assign('repeat_byyearday', $repeat['byyearday']);
+$tmpl->assign('repeat_bymonthday', $repeat['bymonthday']);
+$tmpl->assign('repeat_bymonth', $repeat['bymonth']);
+$tmpl->assign('repeat_byweekno', $repeat['byweekno']);
$tmpl->printpage();
+
?>
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php
index 6de1f8ca30..1812407dd6 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/neweventform.php
@@ -32,14 +32,43 @@ $end->setTimezone(new DateTimeZone($timezone));
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
+$repeat_end_options = OC_Calendar_App::getEndOptions();
+$repeat_month_options = OC_Calendar_App::getMonthOptions();
+$repeat_year_options = OC_Calendar_App::getYearOptions();
+$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions();
+$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth();
+$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions();
+$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions();
+$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
+$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
$tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
+$tmpl->assign('repeat_options', $repeat_options);
+$tmpl->assign('repeat_month_options', $repeat_month_options);
+$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
+$tmpl->assign('repeat_end_options', $repeat_end_options);
+$tmpl->assign('repeat_year_options', $repeat_year_options);
+$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options);
+$tmpl->assign('repeat_bymonth_options', $repeat_bymonth_options);
+$tmpl->assign('repeat_byweekno_options', $repeat_byweekno_options);
+$tmpl->assign('repeat_bymonthday_options', $repeat_bymonthday_options);
+$tmpl->assign('repeat_weekofmonth_options', $repeat_weekofmonth_options);
+
$tmpl->assign('startdate', $start->format('d-m-Y'));
$tmpl->assign('starttime', $start->format('H:i'));
$tmpl->assign('enddate', $end->format('d-m-Y'));
$tmpl->assign('endtime', $end->format('H:i'));
$tmpl->assign('allday', $allday);
+$tmpl->assign('repeat', 'doesnotrepeat');
+$tmpl->assign('repeat_month', 'monthday');
+$tmpl->assign('repeat_weekdays', array());
+$tmpl->assign('repeat_interval', 1);
+$tmpl->assign('repeat_end', 'never');
+$tmpl->assign('repeat_count', '10');
+$tmpl->assign('repeat_weekofmonth', 'auto');
+$tmpl->assign('repeat_date', '');
+$tmpl->assign('repeat_year', 'byyearday');
$tmpl->printpage();
?>
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index c3644b5370..93dddf516f 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -25,6 +25,19 @@ Calendar={
minWidth:'auto',
classes: 'category',
});
+ Calendar.UI.repeat('init');
+ $('#end').change(function(){
+ Calendar.UI.repeat('end');
+ });
+ $('#repeat').change(function(){
+ Calendar.UI.repeat('repeat');
+ });
+ $('#advanced_year').change(function(){
+ Calendar.UI.repeat('year');
+ });
+ $('#advanced_month').change(function(){
+ Calendar.UI.repeat('month');
+ });
$('#event').dialog({
width : 500,
close : function(event, ui) {
@@ -132,9 +145,16 @@ Calendar={
});
},
showadvancedoptions:function(){
- $("#advanced_options").css("display", "block");
+ $("#advanced_options").slideDown('slow');
$("#advanced_options_button").css("display", "none");
},
+ showadvancedoptionsforrepeating:function(){
+ if($("#advanced_options_repeating").is(":hidden")){
+ $('#advanced_options_repeating').slideDown('slow');
+ }else{
+ $('#advanced_options_repeating').slideUp('slow');
+ }
+ },
getEventPopupText:function(event){
if (event.allDay){
var timespan = $.fullCalendar.formatDates(event.start, event.end, 'ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}', {monthNamesShort: monthNamesShort, monthNames: monthNames, dayNames: dayNames, dayNamesShort: dayNamesShort}); //t('calendar', "ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}")
@@ -205,6 +225,107 @@ Calendar={
event.preventDefault();
}
},
+ repeat:function(task){
+ if(task=='init'){
+ $('#byweekno').multiselect({
+ header: false,
+ noneSelectedText: $('#advanced_byweekno').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ $('#weeklyoptions').multiselect({
+ header: false,
+ noneSelectedText: $('#weeklyoptions').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ $('input[name="bydate"]').datepicker({
+ dateFormat : 'dd-mm-yy'
+ });
+ $('#byyearday').multiselect({
+ header: false,
+ noneSelectedText: $('#byyearday').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ $('#bymonth').multiselect({
+ header: false,
+ noneSelectedText: $('#bymonth').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ $('#bymonthday').multiselect({
+ header: false,
+ noneSelectedText: $('#bymonthday').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ Calendar.UI.repeat('end');
+ Calendar.UI.repeat('repeat');
+ Calendar.UI.repeat('month');
+ Calendar.UI.repeat('year');
+ }
+ if(task == 'end'){
+ $('#byoccurrences').css('display', 'none');
+ $('#bydate').css('display', 'none');
+ if($('#end option:selected').val() == 'count'){
+ $('#byoccurrences').css('display', 'block');
+ }
+ if($('#end option:selected').val() == 'date'){
+ $('#bydate').css('display', 'block');
+ }
+ }
+ if(task == 'repeat'){
+ $('#advanced_month').css('display', 'none');
+ $('#advanced_weekday').css('display', 'none');
+ $('#advanced_weekofmonth').css('display', 'none');
+ $('#advanced_byyearday').css('display', 'none');
+ $('#advanced_bymonth').css('display', 'none');
+ $('#advanced_byweekno').css('display', 'none');
+ $('#advanced_year').css('display', 'none');
+ $('#advanced_bymonthday').css('display', 'none');
+ if($('#repeat option:selected').val() == 'monthly'){
+ $('#advanced_month').css('display', 'block');
+ }
+ if($('#repeat option:selected').val() == 'weekly'){
+ $('#advanced_weekday').css('display', 'block');
+ }
+ if($('#repeat option:selected').val() == 'yearly'){
+ $('#advanced_year').css('display', 'block');
+ $('#advanced_byyearday').css('display', 'block');
+ }
+ if($('#repeat option:selected').val() == 'doesnotrepeat'){
+ $('#advanced_options_repeating').slideUp('slow');
+ }
+ }
+ if(task == 'month'){
+ $('#advanced_weekday').css('display', 'none');
+ $('#advanced_weekofmonth').css('display', 'none');
+ if($('#advanced_month_select option:selected').val() == 'weekday'){
+ $('#advanced_weekday').css('display', 'block');
+ $('#advanced_weekofmonth').css('display', 'block');
+ }
+ }
+ if(task == 'year'){
+ $('#advanced_weekday').css('display', 'none');
+ $('#advanced_byyearday').css('display', 'none');
+ $('#advanced_bymonth').css('display', 'none');
+ $('#advanced_byweekno').css('display', 'none');
+ $('#advanced_bymonthday').css('display', 'none');
+ if($('#advanced_year option:selected').val() == 'byyearday'){
+ $('#advanced_byyearday').css('display', 'block');
+ }
+ if($('#advanced_year option:selected').val() == 'byweekno'){
+ $('#advanced_byweekno').css('display', 'block');
+
+ }
+ if($('#advanced_year option:selected').val() == 'bydaymonth'){
+ $('#advanced_bymonth').css('display', 'block');
+ $('#advanced_bymonthday').css('display', 'block');
+ $('#advanced_weekday').css('display', 'block');
+ }
+ }
+ },
Calendar:{
overview:function(){
if($('#choosecalendar_dialog').dialog('isOpen') == true){
diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php
index b023d531aa..6e92cf67c5 100644
--- a/apps/calendar/lib/app.php
+++ b/apps/calendar/lib/app.php
@@ -75,8 +75,43 @@ class OC_Calendar_App{
);
}
- public static function getRepeatOptions()
- {
- OC_Calendar_Object::getRepeatOptions(self::$l10n);
+ public static function getRepeatOptions(){
+ return OC_Calendar_Object::getRepeatOptions(self::$l10n);
+ }
+
+ public static function getEndOptions(){
+ return OC_Calendar_Object::getEndOptions(self::$l10n);
+ }
+
+ public static function getMonthOptions(){
+ return OC_Calendar_Object::getMonthOptions(self::$l10n);
+ }
+
+ public static function getWeeklyOptions(){
+ return OC_Calendar_Object::getWeeklyOptions(self::$l10n);
+ }
+
+ public static function getYearOptions(){
+ return OC_Calendar_Object::getYearOptions(self::$l10n);
+ }
+
+ public static function getByYearDayOptions(){
+ return OC_Calendar_Object::getByYearDayOptions();
+ }
+
+ public static function getByMonthOptions(){
+ return OC_Calendar_Object::getByMonthOptions(self::$l10n);
+ }
+
+ public static function getByWeekNoOptions(){
+ return OC_Calendar_Object::getByWeekNoOptions();
+ }
+
+ public static function getByMonthDayOptions(){
+ return OC_Calendar_Object::getByMonthDayOptions();
+ }
+
+ public static function getWeekofMonth(){
+ return OC_Calendar_Object::getWeekofMonth(self::$l10n);
}
}
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index 58fe60611c..c5ae760d00 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -356,9 +356,98 @@ class OC_Calendar_Object{
'weekday' => $l10n->t('Every Weekday'),
'biweekly' => $l10n->t('Bi-Weekly'),
'monthly' => $l10n->t('Monthly'),
- 'yearly' => $l10n->t('Yearly'),
+ 'yearly' => $l10n->t('Yearly')
);
}
+
+ public static function getEndOptions($l10n)
+ {
+ return array(
+ 'never' => $l10n->t('never'),
+ 'count' => $l10n->t('by occurrences'),
+ 'date' => $l10n->t('by date')
+ );
+ }
+
+ public static function getMonthOptions($l10n)
+ {
+ return array(
+ 'monthday' => $l10n->t('by monthday'),
+ 'weekday' => $l10n->t('by weekday')
+ );
+ }
+
+ public static function getWeeklyOptions($l10n)
+ {
+ return array(
+ 'MO' => $l10n->t('Monday'),
+ 'TU' => $l10n->t('Tuesday'),
+ 'WE' => $l10n->t('Wednesday'),
+ 'TH' => $l10n->t('Thursday'),
+ 'FR' => $l10n->t('Friday'),
+ 'SA' => $l10n->t('Saturday'),
+ 'SU' => $l10n->t('Sunday')
+ );
+ }
+
+ public static function getWeekofMonth($l10n)
+ {
+ return array(
+ 'auto' => $l10n->t('events week of month'),
+ '1' => $l10n->t('first'),
+ '2' => $l10n->t('second'),
+ '3' => $l10n->t('third'),
+ '4' => $l10n->t('fourth'),
+ '5' => $l10n->t('fifth'),
+ '-1' => $l10n->t('last')
+ );
+ }
+
+ public static function getByYearDayOptions(){
+ $return = array();
+ foreach(range(1,366) as $num){
+ $return[(string) $num] = (string) $num;
+ }
+ return $return;
+ }
+
+ public static function getByMonthDayOptions(){
+ $return = array();
+ foreach(range(1,31) as $num){
+ $return[(string) $num] = (string) $num;
+ }
+ return $return;
+ }
+
+ public static function getByMonthOptions($l10n){
+ return array(
+ '1' => $l10n->t('January'),
+ '2' => $l10n->t('February'),
+ '3' => $l10n->t('March'),
+ '4' => $l10n->t('April'),
+ '5' => $l10n->t('May'),
+ '6' => $l10n->t('June'),
+ '7' => $l10n->t('July'),
+ '8' => $l10n->t('August'),
+ '9' => $l10n->t('September'),
+ '10' => $l10n->t('October'),
+ '11' => $l10n->t('November'),
+ '12' => $l10n->t('December')
+ );
+ }
+
+ public static function getYearOptions($l10n){
+ return array(
+ 'byyearday' => $l10n->t('by yearday(s)'),
+ 'byweekno' => $l10n->t('by weeknumber(s)'),
+ 'bydaymonth' => $l10n->t('by day and month')
+ );
+ }
+
+ public static function getByWeekNoOptions(){
+ return range(1, 52);
+ }
+
public static function validateRequest($request)
{
$errnum = 0;
@@ -397,7 +486,91 @@ class OC_Calendar_Object{
$errarr['to'] = 'true';
$errnum++;
}
- ;
+ if($request['repeat'] != 'doesnotrepeat'){
+ if(is_nan($request['interval']) && $request['interval'] != ''){
+ $errarr['interval'] = 'true';
+ $ernum++;
+ }
+ if(array_key_exists('repeat', $request) && !array_key_exists($request['repeat'], self::getRepeatOptions(OC_Calendar_App::$l10n))){
+ $errarr['repeat'] = 'true';
+ $ernum++;
+ }
+ if(array_key_exists('advanced_month_select', $request) && !array_key_exists($request['advanced_month_select'], self::getMonthOptions(OC_Calendar_App::$l10n))){
+ $errarr['advanced_month_select'] = 'true';
+ $errnum++;
+ }
+ if(array_key_exists('advanced_year_select', $request) && !array_key_exists($request['advanced_year_select'], self::getYearOptions(OC_Calendar_App::$l10n))){
+ $errarr['advanced_year_select'] = 'true';
+ $errnum++;
+ }
+ if(array_key_exists('weekofmonthoptions', $request) && !array_key_exists($request['weekofmonthoptions'], self::getWeekofMonth(OC_Calendar_App::$l10n))){
+ $errarr['weekofmonthoptions'] = 'true';
+ $errnum++;
+ }
+ if($request['end'] != 'never'){
+ if(!array_key_exists($request['end'], self::getEndOptions(OC_Calendar_App::$l10n))){
+ $errarr['end'] = 'true';
+ $errnum++;
+ }
+ if($request['end'] == 'count' && is_nan($request['byoccurrences'])){
+ $errarr['byoccurrences'] = 'true';
+ $errnum++;
+ }
+ if($request['end'] == 'date'){
+ list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']);
+ if(!checkdate($bydate_month, $bydate_day, $bydate_year)){
+ $errarr['bydate'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('weeklyoptions', $request)){
+ foreach($request['weeklyoptions'] as $option){
+ if(!in_array($option, self::getWeeklyOptions(OC_Calendar_App::$l10n))){
+ $errarr['weeklyoptions'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('byyearday', $request)){
+ foreach($request['byyearday'] as $option){
+ if(!array_key_exists($option, self::getByYearDayOptions())){
+ $errarr['byyearday'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('weekofmonthoptions', $request)){
+ if(is_nan((double)$request['weekofmonthoptions'])){
+ $errarr['weekofmonthoptions'] = 'true';
+ $errnum++;
+ }
+ }
+ if(array_key_exists('bymonth', $request)){
+ foreach($request['bymonth'] as $option){
+ if(!in_array($option, self::getByMonthOptions(OC_Calendar_App::$l10n))){
+ $errarr['bymonth'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('byweekno', $request)){
+ foreach($request['byweekno'] as $option){
+ if(!array_key_exists($option, self::getByWeekNoOptions())){
+ $errarr['byweekno'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('bymonthday', $request)){
+ foreach($request['bymonthday'] as $option){
+ if(!array_key_exists($option, self::getByMonthDayOptions())){
+ $errarr['bymonthday'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ }
if(!$allday && self::checkTime(urldecode($request['totime']))) {
$errarr['totime'] = 'true';
$errnum++;
@@ -468,27 +641,146 @@ class OC_Calendar_Object{
$fromtime = $request['fromtime'];
$totime = $request['totime'];
}
- $description = $request["description"];
- //$repeat = $request["repeat"];
- /*switch($request["repeatfreq"]){
- case "DAILY":
- $repeatfreq = "DAILY";
- case "WEEKLY":
- $repeatfreq = "WEEKLY";
- case "WEEKDAY":
- $repeatfreq = "DAILY;BYDAY=MO,TU,WE,TH,FR"; //load weeksdayss from userconfig when weekdays are choosable
- case "":
- $repeatfreq = "";
- case "":
- $repeatfreq = "";
- case "":
- $repeatfreq = "";
- default:
- $repeat = "false";
- }*/
- $repeat = "false";
-
$vevent = $vcalendar->VEVENT;
+ $description = $request["description"];
+ $repeat = $request["repeat"];
+ if($repeat != 'doesnotrepeat'){
+ $rrule = '';
+ $interval = $request['interval'];
+ $end = $request['end'];
+ $byoccurrences = $request['byoccurrences'];
+ switch($repeat){
+ case 'daily':
+ $rrule .= 'FREQ=DAILY';
+ break;
+ case 'weekly':
+ $rrule .= 'FREQ=WEEKLY';
+ if(array_key_exists('weeklyoptions', $request)){
+ $byday = '';
+ $daystrings = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
+ foreach($request['weeklyoptions'] as $days){
+ if($byday == ''){
+ $byday .= $daystrings[$days];
+ }else{
+ $byday .= ',' .$daystrings[$days];
+ }
+ }
+ $rrule .= ';BYDAY=' . $byday;
+ }
+ break;
+ case 'weekday':
+ $rrule .= 'FREQ=DAILY';
+ $rrule .= ';BYDAY=MO,TU,WE,TH,FR';
+ break;
+ case 'biweekly':
+ $rrule .= 'FREQ=WEEKLY';
+ $interval = $interval * 2;
+ break;
+ case 'monthly':
+ $rrule .= 'FREQ=MONTHLY';
+ if($request['advanced_month_select'] == 'monthday'){
+ break;
+ }elseif($request['advanced_month_select'] == 'weekday'){
+ if($request['weekofmonthoptions'] == 'auto'){
+ $weekofmonth = floor($request['weekofmonthoptions']/7);
+ }else{
+ $weekofmonth = $request['weekofmonthoptions'];
+ }
+ $days = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
+ $byday = '';
+ foreach($request['weeklyoptions'] as $day){
+ if($byday == ''){
+ $byday .= $weekofmonth . $days[$day];
+ }else{
+ $byday .= ',' . $weekofmonth . $days[$day];
+ }
+ }
+ $rrule .= ';BYDAY=' . $byday;
+ }
+ break;
+ case 'yearly':
+ $rrule .= 'FREQ=YEARLY';
+ if($request['advanced_year_select'] == 'byyearday'){
+ $byyearday = '';
+ foreach($request['byyearday'] as $yearday){
+ if($byyearday == ''){
+ $byyearday = $yearday;
+ }else{
+ $byyearday .= ',' . $yearday;
+ }
+ }
+ $rrule .= ';BYYEARDAY=' . $byyearday;
+ }elseif($request['advanced_year_select'] == 'byweekno'){
+ list($_day, $_month, $_year) = explode('-', $from);
+ $rrule .= ';BYDAY=' . strtoupper(substr(date('l', mktime(0,0,0, $_month, $_day, $_year)), 0, 2));
+ $byweekno = '';
+ foreach($request['byweekno'] as $weekno){
+ if($byweekno == ''){
+ $byweekno = $weekno;
+ }else{
+ $byweekno .= ',' . $weekno;
+ }
+ }
+ $rrule .= ';BYWEEKNO=' . $byweekno;
+ }elseif($request['advanced_year_select'] == 'bydaymonth'){
+ if(array_key_exists('weeklyoptions', $request)){
+ $days = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
+ $byday = '';
+ foreach($request['weeklyoptions'] as $day){
+ if($byday == ''){
+ $byday .= $days[$day];
+ }else{
+ $byday .= ',' . $days[$day];
+ }
+ }
+ $rrule .= ';BYDAY=' . $byday;
+ }
+ if(array_key_exists('bymonth', $request)){
+ $monthes = array_flip(self::getByMonthOptions(OC_Calendar_App::$l10n));
+ $bymonth = '';
+ foreach($request['bymonth'] as $month){
+ if($bymonth == ''){
+ $bymonth .= $monthes[$month];
+ }else{
+ $bymonth .= ',' . $monthes[$month];
+ }
+ }
+ $rrule .= ';BYMONTH=' . $bymonth;
+
+ }
+ if(array_key_exists('bymonthday', $request)){
+ $bymonthday = '';
+ foreach($request['bymonthday'] as $monthday){
+ if($bymonthday == ''){
+ $bymonthday .= $monthday;
+ }else{
+ $bymonthday .= ',' . $monthday;
+ }
+ }
+ $rrule .= ';BYMONTHDAY=' . $bymonthday;
+
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ if($interval != ''){
+ $rrule .= ';INTERVAL=' . $interval;
+ }
+ if($end == 'count'){
+ $rrule .= ';COUNT=' . $byoccurrences;
+ }
+ if($end == 'date'){
+ list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']);
+ $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day;
+ }
+ $vevent->setString('RRULE', $rrule);
+ $repeat = "true";
+ }else{
+ $repeat = "false";
+ }
+
$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
@@ -521,4 +813,4 @@ class OC_Calendar_Object{
return $vcalendar;
}
-}
+}
\ No newline at end of file
diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php
index dfa5fb8c78..1f2073f4bc 100644
--- a/apps/calendar/templates/part.eventform.php
+++ b/apps/calendar/templates/part.eventform.php
@@ -2,92 +2,221 @@
t("Title");?>: |
- " value="" maxlength="100" name="title"/>
+ " value="" maxlength="100" name="title"/>
|
-
+
t("Category");?>: |
- |
+
+
t("Calendar");?>: |
- |
+
+
-
-
-
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+ t('and the events day of year.'); ?>
+ |
+
+
+
+
+ |
+
+ t('and the events day of month.'); ?>
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+ t('and the events week of year.'); ?>
+ |
+
+
+
+
+
+
+
+
+
+ t("Description");?>: |
+
+
+ |
+
+