summaryrefslogtreecommitdiffstats
path: root/apps/calendar
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2011-12-25 23:19:49 +0100
committerGeorg Ehrke <dev@georgswebsite.de>2011-12-25 23:19:49 +0100
commit9eef57faed0f6c8f1481a3bcb38df24605e12384 (patch)
tree1050928e02736deb86b194332d4732352bb8b449 /apps/calendar
parent8ee53708ae708f7765f13f7dee34c68a4f95a6e1 (diff)
downloadnextcloud-server-9eef57faed0f6c8f1481a3bcb38df24605e12384.tar.gz
nextcloud-server-9eef57faed0f6c8f1481a3bcb38df24605e12384.zip
make repeating events editable
Diffstat (limited to 'apps/calendar')
-rw-r--r--apps/calendar/ajax/editeventform.php166
-rw-r--r--apps/calendar/ajax/neweventform.php29
-rw-r--r--apps/calendar/js/calendar.js123
-rw-r--r--apps/calendar/lib/app.php41
-rw-r--r--apps/calendar/lib/object.php336
-rw-r--r--apps/calendar/templates/part.eventform.php251
6 files changed, 857 insertions, 89 deletions
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php
index 2c81539d2e0..4783fcca897 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 6de1f8ca307..1812407dd6e 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 c3644b53704..93dddf516f9 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 b023d531aa5..6e92cf67c5c 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 58fe60611ce..c5ae760d00f 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'];
}
+ $vevent = $vcalendar->VEVENT;
$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";
+ $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 = $vcalendar->VEVENT;
$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 dfa5fb8c78a..1f2073f4bc7 100644
--- a/apps/calendar/templates/part.eventform.php
+++ b/apps/calendar/templates/part.eventform.php
@@ -2,92 +2,221 @@
<tr>
<th width="75px"><?php echo $l->t("Title");?>:</th>
<td>
- <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Title of the Event");?>" value="<?php echo isset($_['title']) ? $_['title'] : '' ?>" maxlength="100" name="title"/>
+ <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Title of the Event");?>" value="<?php echo isset($_['title']) ? $_['title'] : '' ?>" maxlength="100" name="title"/>
</td>
</tr>
</table>
- <table>
+ <table width="100%">
<tr>
<th width="75px"><?php echo $l->t("Category");?>:</th>
<td>
- <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>">
- <?php
- if (!isset($_['categories'])) {$_['categories'] = array();}
- echo html_select_options($_['category_options'], $_['categories'], array('combine'=>true));
- ?>
- </select></td>
+ <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>">
+ <?php
+ if (!isset($_['categories'])) {$_['categories'] = array();}
+ echo html_select_options($_['category_options'], $_['categories'], array('combine'=>true));
+ ?>
+ </select>
+ </td>
<th width="75px">&nbsp;&nbsp;&nbsp;<?php echo $l->t("Calendar");?>:</th>
<td>
- <select style="width:140px;" name="calendar">
- <?php
- if (!isset($_['calendar'])) {$_['calendar'] = false;}
- echo html_select_options($_['calendar_options'], $_['calendar'], array('value'=>'id', 'label'=>'displayname'));
- ?>
- </select></td>
+ <select style="width:140px;" name="calendar">
+ <?php
+ if (!isset($_['calendar'])) {$_['calendar'] = false;}
+ echo html_select_options($_['calendar_options'], $_['calendar'], array('value'=>'id', 'label'=>'displayname'));
+ ?>
+ </select>
+ </td>
</tr>
</table>
<hr>
- <table>
+ <table width="100%">
<tr>
<th width="75px"></th>
<td>
- <input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="allday_checkbox" name="allday">
- <label for="allday_checkbox"><?php echo $l->t("All Day Event");?></label></td>
+ <input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="allday_checkbox" name="allday">
+ <label for="allday_checkbox"><?php echo $l->t("All Day Event");?></label>
+ </td>
</tr>
<tr>
-
<th width="75px"><?php echo $l->t("From");?>:</th>
<td>
- <input type="text" value="<?php echo $_['startdate'];?>" name="from" id="from">
- &nbsp;&nbsp;
- <input type="time" value="<?php echo $_['starttime'];?>" name="fromtime" id="fromtime">
- </td><!--use jquery-->
+ <input type="text" value="<?php echo $_['startdate'];?>" name="from" id="from">
+ &nbsp;&nbsp;
+ <input type="time" value="<?php echo $_['starttime'];?>" name="fromtime" id="fromtime">
+ </td>
</tr>
<tr>
<th width="75px"><?php echo $l->t("To");?>:</th>
<td>
- <input type="text" value="<?php echo $_['enddate'];?>" name="to" id="to">
- &nbsp;&nbsp;
- <input type="time" value="<?php echo $_['endtime'];?>" name="totime" id="totime">
- </td><!--use jquery-->
+ <input type="text" value="<?php echo $_['enddate'];?>" name="to" id="to">
+ &nbsp;&nbsp;
+ <input type="time" value="<?php echo $_['endtime'];?>" name="totime" id="totime">
+ </td>
</tr>
</table>
<input type="button" class="submit" value="<?php echo $l->t("Advanced options"); ?>" onclick="Calendar.UI.showadvancedoptions();" id="advanced_options_button">
<div id="advanced_options" style="display: none;">
- <!--
- <table>
- <tr>
- <th width="75px"><?php echo $l->t("Repeat");?>:</th>
- <td>
- <select name="repeat" style="width:350px;">
- <?php
- if (isset($_['repeat_options'])) {
+ <table style="width:100%">
+ <tr>
+ <th width="75px"><?php echo $l->t("Repeat");?>:</th>
+ <td>
+ <select id="repeat" name="repeat">
+ <?php
echo html_select_options($_['repeat_options'], $_['repeat']);
- }
- ?>
- </select></td>
- </tr>-->
- </table>
- <hr>
- <table><!--
- <tr>
- <th width="75px"><?php echo $l->t("Attendees");?>:</th>
- <td style="height: 50px;"></td>
- </tr>
- </table>
- <hr>-->
- <table>
- <tr>
- <th width="85px"><?php echo $l->t("Location");?>:</th>
- <td>
- <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo isset($_['location']) ? $_['location'] : '' ?>" maxlength="100" name="location" />
- </td>
- </tr>
- </table>
- <table>
- <tr>
- <th width="85px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th>
- <td><textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo isset($_['description']) ? $_['description'] : '' ?></textarea></td>
- </tr>
- </table>
+ ?>
+ </select></td>
+ <td><input type="button" style="float:right;" class="submit" value="<?php echo $l->t("Advanced"); ?>" onclick="Calendar.UI.showadvancedoptionsforrepeating();" id="advanced_options_button"></td>
+ </tr>
+ </table>
+ <div id="advanced_options_repeating" style="display:none;">
+ <table style="width:100%">
+ <tr id="advanced_month" style="display:none;">
+ <th width="75px"></th>
+ <td>
+ <select id="advanced_month_select" name="advanced_month_select">
+ <?php
+ echo html_select_options($_['repeat_month_options'], $_['repeat_month']);
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_year" style="display:none;">
+ <th width="75px"></th>
+ <td>
+ <select id="advanced_year_select" name="advanced_year_select">
+ <?php
+ echo html_select_options($_['repeat_year_options'], $_['repeat_year']);
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_weekofmonth" style="display:none;">
+ <th width="75px"></th>
+ <td id="weekofmonthcheckbox">
+ <select id="weekofmonthoptions" name="weekofmonthoptions">
+ <?php
+ echo html_select_options($_['repeat_weekofmonth_options'], $_['repeat_weekofmonth']);
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_weekday" style="display:none;">
+ <th width="75px"></th>
+ <td id="weeklycheckbox">
+ <select id="weeklyoptions" name="weeklyoptions[]" multiple="multiple" title="<?php echo $l->t("Select weekdays") ?>">
+ <?php
+ if (!isset($_['weekdays'])) {$_['weekdays'] = array();}
+ echo html_select_options($_['repeat_weekly_options'], $_['repeat_weekdays'], array('combine'=>true));
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_byyearday" style="display:none;">
+ <th width="75px"></th>
+ <td id="byyeardaycheckbox">
+ <select id="byyearday" name="byyearday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>">
+ <?php
+ if (!isset($_['repeat_byyearday'])) {$_['repeat_byyearday'] = array();}
+ echo html_select_options($_['repeat_byyearday_options'], $_['repeat_byyearday'], array('combine'=>true));
+ ?>
+ </select><?php echo $l->t('and the events day of year.'); ?>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_bymonthday" style="display:none;">
+ <th width="75px"></th>
+ <td id="bymonthdaycheckbox">
+ <select id="bymonthday" name="bymonthday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>">
+ <?php
+ if (!isset($_['repeat_bymonthday'])) {$_['repeat_bymonthday'] = array();}
+ echo html_select_options($_['repeat_bymonthday_options'], $_['repeat_bymonthday'], array('combine'=>true));
+ ?>
+ </select><?php echo $l->t('and the events day of month.'); ?>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_bymonth" style="display:none;">
+ <th width="75px"></th>
+ <td id="bymonthcheckbox">
+ <select id="bymonth" name="bymonth[]" multiple="multiple" title="<?php echo $l->t("Select months") ?>">
+ <?php
+ if (!isset($_['repeat_bymonth'])) {$_['repeat_bymonth'] = array();}
+ echo html_select_options($_['repeat_bymonth_options'], $_['repeat_bymonth'], array('combine'=>true));
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_byweekno" style="display:none;">
+ <th width="75px"></th>
+ <td id="bymonthcheckbox">
+ <select id="byweekno" name="byweekno[]" multiple="multiple" title="<?php echo $l->t("Select weeks") ?>">
+ <?php
+ if (!isset($_['repeat_byweekno'])) {$_['repeat_byweekno'] = array();}
+ echo html_select_options($_['repeat_byweekno_options'], $_['repeat_byweekno'], array('combine'=>true));
+ ?>
+ </select><?php echo $l->t('and the events week of year.'); ?>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr>
+ <th width="75px"><?php echo $l->t('Interval'); ?>:</th>
+ <td>
+ <input style="width:350px;" type="number" min="1" size="4" max="1000" value="<?php echo isset($_['repeat_interval']) ? $_['repeat_interval'] : '1'; ?>" name="interval">
+ </td>
+ </tr>
+ <tr>
+ <th width="75px"><?php echo $l->t('End'); ?>:</th>
+ <td>
+ <select id="end" name="end">
+ <?php
+ echo html_select_options($_['repeat_end_options'], $_['repeat_end']);
+ ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th></th>
+ <td id="byoccurrences" style="display:none;">
+ <input type="number" min="1" max="99999" id="until_count" name="byoccurrences" value="<?php echo $_['repeat_count']; ?>"><?php echo $l->t('occurrences'); ?>
+ </td>
+ </tr>
+ <tr>
+ <th></th>
+ <td id="bydate" style="display:none;">
+ <input type="text" name="bydate" value="<?php echo $_['repeat_date']; ?>">
+ </td>
+ </tr>
+ </table>
+ </div>
+ <hr>
+ <!-- support for attendees will be added in following versions -->
+ <table>
+ <tr>
+ <th width="85px"><?php echo $l->t("Location");?>:</th>
+ <td>
+ <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo isset($_['location']) ? $_['location'] : '' ?>" maxlength="100" name="location" />
+ </td>
+ </tr>
+ </table>
+ <table>
+ <tr>
+ <th width="85px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th>
+ <td>
+ <textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo isset($_['description']) ? $_['description'] : '' ?></textarea>
+ </td>
+ </tr>
+ </table>
</div>