diff options
Diffstat (limited to 'apps/calendar')
41 files changed, 1160 insertions, 428 deletions
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php index 72882496ab6..ada2e44547b 100644 --- a/apps/calendar/ajax/activation.php +++ b/apps/calendar/ajax/activation.php @@ -7,13 +7,12 @@ */ require_once ("../../../lib/base.php"); -if(!OC_USER::isLoggedIn()) { - die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); -} +OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $calendarid = $_POST['calendarid']; +$calendar = OC_Calendar_App::getCalendar($calendarid);//access check OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); -$calendar = OC_Calendar_Calendar::findCalendar($calendarid); +$calendar = OC_Calendar_App::getCalendar($calendarid); OC_JSON::success(array( 'active' => $calendar['active'], 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), diff --git a/apps/calendar/ajax/choosecalendar.php b/apps/calendar/ajax/choosecalendar.php index 0935a4c42ad..9281c8edbdc 100644 --- a/apps/calendar/ajax/choosecalendar.php +++ b/apps/calendar/ajax/choosecalendar.php @@ -8,9 +8,7 @@ require_once('../../../lib/base.php'); $l10n = new OC_L10N('calendar'); -if(!OC_USER::isLoggedIn()) { - die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); -} +OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $output = new OC_TEMPLATE("calendar", "part.choosecalendar"); $output -> printpage(); diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/createcalendar.php index 325a5ec35bc..f8b5974f54c 100644 --- a/apps/calendar/ajax/createcalendar.php +++ b/apps/calendar/ajax/createcalendar.php @@ -8,8 +8,6 @@ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); @@ -17,7 +15,8 @@ OC_JSON::checkAppEnabled('calendar'); $userid = OC_User::getUser(); $calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']); OC_Calendar_Calendar::setCalendarActive($calendarid, 1); -$calendar = OC_Calendar_Calendar::findCalendar($calendarid); + +$calendar = OC_Calendar_Calendar::find($calendarid); $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); OC_JSON::success(array( diff --git a/apps/calendar/ajax/daysofweekend.php b/apps/calendar/ajax/daysofweekend.php deleted file mode 100755 index 606d13b1e1c..00000000000 --- a/apps/calendar/ajax/daysofweekend.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -require_once('../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}'); -?> diff --git a/apps/calendar/ajax/deletecalendar.php b/apps/calendar/ajax/deletecalendar.php index e8ffe0d0598..901cbbfcb08 100644 --- a/apps/calendar/ajax/deletecalendar.php +++ b/apps/calendar/ajax/deletecalendar.php @@ -7,19 +7,11 @@ */ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - -if(!OC_USER::isLoggedIn()) { - die('<script type="text/javascript">document.location = oc_webroot;</script>'); -} +OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $cal = $_POST["calendarid"]; -$calendar = OC_Calendar_Calendar::findCalendar($cal); -if($calendar["userid"] != OC_User::getUser()){ - OC_JSON::error(array('error'=>'permission_denied')); - exit; -} +$calendar = OC_Calendar_App::getCalendar($cal); $del = OC_Calendar_Calendar::deleteCalendar($cal); if($del == true){ OC_JSON::success(); diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/deleteevent.php index 9e3c7dd87dd..b25a5af1a29 100644 --- a/apps/calendar/ajax/deleteevent.php +++ b/apps/calendar/ajax/deleteevent.php @@ -9,23 +9,11 @@ require_once('../../../lib/base.php'); $l10n = new OC_L10N('calendar'); -if(!OC_USER::isLoggedIn()) { - die('<script type="text/javascript">document.location = oc_webroot;</script>'); -} +OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $id = $_POST['id']; -$data = OC_Calendar_Object::find($id); -if (!$data) -{ - OC_JSON::error(); - exit; -} -$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']); -if($calendar['userid'] != OC_User::getUser()){ - OC_JSON::error(); - exit; -} +$event_object = OC_Calendar_App::getEventObject($id); $result = OC_Calendar_Object::delete($id); OC_JSON::success(); ?> diff --git a/apps/calendar/ajax/duration.php b/apps/calendar/ajax/duration.php deleted file mode 100644 index cdc41388abd..00000000000 --- a/apps/calendar/ajax/duration.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -require_once('../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60"); -OC_JSON::encodedPrint(array("duration" => $duration)); -?> diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php index d23e5287868..7aeb5bbe305 100644 --- a/apps/calendar/ajax/editcalendar.php +++ b/apps/calendar/ajax/editcalendar.php @@ -7,13 +7,11 @@ */ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); -if(!OC_USER::isLoggedIn()) { - die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); -} +OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); + $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); -$calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']); +$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']); $tmpl = new OC_Template("calendar", "part.editcalendar"); $tmpl->assign('new', false); $tmpl->assign('calendarcolor_options', $calendarcolor_options); diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php index e3c84520481..5a487da1758 100644 --- a/apps/calendar/ajax/editevent.php +++ b/apps/calendar/ajax/editevent.php @@ -7,12 +7,7 @@ */ require_once('../../../lib/base.php'); - -$l10n = new OC_L10N('calendar'); - -if(!OC_USER::isLoggedIn()) { - die('<script type="text/javascript">document.location = oc_webroot;</script>'); -} +OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $errarr = OC_Calendar_Object::validateRequest($_POST); @@ -23,26 +18,12 @@ if($errarr){ }else{ $id = $_POST['id']; $cal = $_POST['calendar']; - $data = OC_Calendar_Object::find($id); - if (!$data) - { - OC_JSON::error(); - exit; - } - $calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']); - if($calendar['userid'] != OC_User::getUser()){ - OC_JSON::error(); - exit; - } + $data = OC_Calendar_App::getEventObject($id); $vcalendar = OC_VObject::parse($data['calendardata']); - $last_modified = $vcalendar->VEVENT->__get('LAST-MODIFIED'); - if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){ - OC_JSON::error(array('modified'=>true)); - exit; - } - + OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']); OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar); + $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); if ($data['calendarid'] != $cal) { OC_Calendar_Object::moveToCalendar($id, $cal); diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php index c91f136e898..95cae39c1c2 100644 --- a/apps/calendar/ajax/editeventform.php +++ b/apps/calendar/ajax/editeventform.php @@ -8,26 +8,16 @@ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } OC_JSON::checkAppEnabled('calendar'); -$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); -$category_options = OC_Calendar_Object::getCategoryOptions($l10n); -$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n); - $id = $_GET['id']; -$data = OC_Calendar_Object::find($id); -$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']); -if($calendar['userid'] != OC_User::getUser()){ - echo $l10n->t('Wrong calendar'); - exit; -} +$data = OC_Calendar_App::getEventObject($id); $object = OC_VObject::parse($data['calendardata']); $vevent = $object->VEVENT; + $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); switch($dtstart->getDateType()) { @@ -52,7 +42,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)){ @@ -65,6 +54,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($byday_day) == 3){ + $repeat['weekofmonth'] = substr($byday_day , 0, 1); + $repeat['weekdays'][] = substr($byday_day , 1, 2); + }elseif(strlen($byday_day) == 4){ + $repeat['weekofmonth'] = 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)){ + $repeat['end'] = 'count'; + $repeat['count'] = $rrulearr['COUNT']; + }elseif(array_key_exists('UNTIL', $rrulearr)){ + $repeat['end'] = 'date'; + $endbydate_day = substr($rrulearr['UNTIL'], 6, 2); + $endbydate_month = substr($rrulearr['UNTIL'], 4, 2); + $endbydate_year = substr($rrulearr['UNTIL'], 0, 4); + $repeat['date'] = $endbydate_day . '-' . $endbydate_month . '-' . $endbydate_year; + }else{ + $repeat['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); @@ -72,6 +205,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); @@ -82,8 +224,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/events.php b/apps/calendar/ajax/events.php index 1430432b8a3..998991c2fb4 100644 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -58,7 +58,7 @@ foreach($events as $event){ } if($return_event['allDay'] == true){ $return_event['start'] = $result->format('Y-m-d'); - $return_event['end'] = date('Y-m-d', $result->format('U') + $duration--); + $return_event['end'] = date('Y-m-d', $result->format('U') + --$duration); }else{ $return_event['start'] = $result->format('Y-m-d H:i:s'); $return_event['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration); diff --git a/apps/calendar/ajax/firstdayofweek.php b/apps/calendar/ajax/firstdayofweek.php deleted file mode 100755 index eff82cece1d..00000000000 --- a/apps/calendar/ajax/firstdayofweek.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -require_once('../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -$firstdayofweek = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); -OC_JSON::encodedPrint(array("firstdayofweek" => $firstdayofweek)); -?>
\ No newline at end of file diff --git a/apps/calendar/ajax/gettimezonedetection.php b/apps/calendar/ajax/gettimezonedetection.php new file mode 100644 index 00000000000..ae58370712d --- /dev/null +++ b/apps/calendar/ajax/gettimezonedetection.php @@ -0,0 +1,11 @@ +<?php +/** + * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once ("../../../lib/base.php"); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); +OC_JSON::success(array('detection' => OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection')));
\ No newline at end of file diff --git a/apps/calendar/ajax/guesstimezone.php b/apps/calendar/ajax/guesstimezone.php index a3594498b0f..41aea26985f 100755 --- a/apps/calendar/ajax/guesstimezone.php +++ b/apps/calendar/ajax/guesstimezone.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. @@ -24,11 +24,20 @@ OC_JSON::checkAppEnabled('calendar'); $l = new OC_L10N('calendar'); $lat = $_GET['lat']; $long = $_GET['long']; +if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'position') == $lat . '-' . $long && OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone') != null){ + OC_JSON::success(); + exit; +} +OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'position', $lat . '-' . $long); $geolocation = file_get_contents('http://ws.geonames.org/timezone?lat=' . $lat . '&lng=' . $long); //Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License $geoxml = simplexml_load_string($geolocation); $geoarray = make_array_out_of_xml($geoxml); -if(isset($geoarray['timezone']['timezoneId']) && $geoarray['timezone']['timezoneId'] != ''){ +if($geoarray['timezone']['timezoneId'] == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){ + OC_JSON::success(); + exit; +} +if(in_array($geoarray['timezone']['timezoneId'], DateTimeZone::listIdentifiers())){ OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']); $message = array('message'=> $l->t('New Timezone:') . $geoarray['timezone']['timezoneId']); OC_JSON::success($message); @@ -36,4 +45,4 @@ if(isset($geoarray['timezone']['timezoneId']) && $geoarray['timezone']['timezone OC_JSON::error(); } -?>
\ No newline at end of file +?> diff --git a/apps/calendar/ajax/importdialog.php b/apps/calendar/ajax/importdialog.php index 232b4ba5807..983a3d95a84 100644 --- a/apps/calendar/ajax/importdialog.php +++ b/apps/calendar/ajax/importdialog.php @@ -11,7 +11,7 @@ require_once('../../../lib/base.php'); $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { - die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); + die('<script type="text/javascript">document.location = oc_webroot;</script>'); } OC_JSON::checkAppEnabled('calendar'); diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php index 51fafdfeb97..f2256d4eee6 100644 --- a/apps/calendar/ajax/moveevent.php +++ b/apps/calendar/ajax/moveevent.php @@ -5,31 +5,20 @@ * later. * See the COPYING-README file. */ -error_reporting(E_ALL); require_once('../../../lib/base.php'); OC_JSON::checkLoggedIn(); -$data = OC_Calendar_Object::find($_POST["id"]); -$calendarid = $data["calendarid"]; -$cal = $calendarid; + $id = $_POST['id']; -$calendar = OC_Calendar_Calendar::findCalendar($calendarid); -if(OC_User::getUser() != $calendar['userid']){ - OC_JSON::error(); - exit; -} + +$vcalendar = OC_Calendar_App::getVCalendar($id); +$vevent = $vcalendar->VEVENT; + $allday = $_POST['allDay']; $delta = new DateInterval('P0D'); $delta->d = $_POST['dayDelta']; $delta->i = $_POST['minuteDelta']; -$vcalendar = OC_VObject::parse($data['calendardata']); -$vevent = $vcalendar->VEVENT; - -$last_modified = $vevent->__get('LAST-MODIFIED'); -if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){ - OC_JSON::error(); - exit; -} +OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']); $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); @@ -50,4 +39,5 @@ $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); -OC_JSON::success(array('lastmodified'=>(int)$now->format('U'))); +$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); +OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/newcalendar.php b/apps/calendar/ajax/newcalendar.php index a7935c95672..af3ba4fbbea 100644 --- a/apps/calendar/ajax/newcalendar.php +++ b/apps/calendar/ajax/newcalendar.php @@ -8,9 +8,7 @@ require_once('../../../lib/base.php'); $l10n = new OC_L10N('calendar'); -if(!OC_USER::isLoggedIn()) { - die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); -} +OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = array( diff --git a/apps/calendar/ajax/newevent.php b/apps/calendar/ajax/newevent.php index 1a696cf7780..c7c4d29943a 100644 --- a/apps/calendar/ajax/newevent.php +++ b/apps/calendar/ajax/newevent.php @@ -10,9 +10,7 @@ require_once('../../../lib/base.php'); $l10n = new OC_L10N('calendar'); -if(!OC_USER::isLoggedIn()) { - die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); -} +OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $errarr = OC_Calendar_Object::validateRequest($_POST); diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php index 68423adb344..3870c879b0e 100644 --- a/apps/calendar/ajax/neweventform.php +++ b/apps/calendar/ajax/neweventform.php @@ -8,8 +8,6 @@ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } @@ -34,16 +32,45 @@ $start->setTimezone(new DateTimeZone($timezone)); $end->setTimezone(new DateTimeZone($timezone)); $calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); -$category_options = OC_Calendar_Object::getCategoryOptions($l10n); -$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n); +$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', 'bydate'); $tmpl->printpage(); ?> diff --git a/apps/calendar/ajax/resizeevent.php b/apps/calendar/ajax/resizeevent.php index 28a185411e0..68347906529 100644 --- a/apps/calendar/ajax/resizeevent.php +++ b/apps/calendar/ajax/resizeevent.php @@ -5,45 +5,28 @@ * later. * See the COPYING-README file. */ -error_reporting(E_ALL); require_once('../../../lib/base.php'); OC_JSON::checkLoggedIn(); -$data = OC_Calendar_Object::find($_POST["id"]); -$calendarid = $data["calendarid"]; -$cal = $calendarid; + $id = $_POST['id']; -$calendar = OC_Calendar_Calendar::findCalendar($calendarid); -if(OC_User::getUser() != $calendar['userid']){ - OC_JSON::error(); - exit; -} + +$vcalendar = OC_Calendar_App::getVCalendar($id); +$vevent = $vcalendar->VEVENT; $delta = new DateInterval('P0D'); $delta->d = $_POST['dayDelta']; $delta->i = $_POST['minuteDelta']; -$vcalendar = OC_Calendar_Object::parse($data['calendardata']); -$vevent = $vcalendar->VEVENT; - -$last_modified = $vevent->__get('LAST-MODIFIED'); -if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){ - OC_JSON::error(); - exit; -} +OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']); $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); $end_type = $dtend->getDateType(); $dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type); unset($vevent->DURATION); -$now = new DateTime(); -$last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED'); -$last_modified->setDateTime($now, Sabre_VObject_Element_DateTime::UTC); -$vevent->__set('LAST-MODIFIED', $last_modified); - -$dtstamp = new Sabre_VObject_Element_DateTime('DTSTAMP'); -$dtstamp->setDateTime($now, Sabre_VObject_Element_DateTime::UTC); -$vevent->DTSTAMP = $dtstamp; +$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); +$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); -OC_JSON::success(array('lastmodified'=>$now->format('U'))); +$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); +OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/setdaysofweekend.php b/apps/calendar/ajax/setdaysofweekend.php deleted file mode 100755 index b5ef5f8573f..00000000000 --- a/apps/calendar/ajax/setdaysofweekend.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -require_once('../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -$weekenddays = array("Monday"=>"false", "Tuesday"=>"false", "Wednesday"=>"false", "Thursday"=>"false", "Friday"=>"false", "Saturday"=>"false", "Sunday"=>"false"); -for($i = 0;$i < count($_POST["weekend"]); $i++){ - switch ($_POST["weekend"][$i]){ - case "Monday": - case "Tuesday": - case "Wednesday": - case "Thursday": - case "Friday": - case "Saturday": - case "Sunday": - break; - default: - OC_JSON::error(); - exit; - } - $weekenddays[$_POST["weekend"][$i]] = "true"; -} -$setValue = json_encode($weekenddays); -OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'weekend', $setValue); -OC_JSON::success(); -?> diff --git a/apps/calendar/ajax/setduration.php b/apps/calendar/ajax/setduration.php deleted file mode 100644 index a75c8faea42..00000000000 --- a/apps/calendar/ajax/setduration.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -require_once('../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -if(isset($_POST["duration"])){ - OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'duration', $_POST["duration"]); - OC_JSON::success(); -}else{ - OC_JSON::error(); -} -?> - diff --git a/apps/calendar/ajax/setfirstdayofweek.php b/apps/calendar/ajax/setfirstdayofweek.php deleted file mode 100755 index 571b95af0e3..00000000000 --- a/apps/calendar/ajax/setfirstdayofweek.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -require_once('../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -if(isset($_POST["firstdayofweek"])){ - OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstdayofweek', $_POST["firstdayofweek"]); - OC_JSON::success(); -}else{ - OC_JSON::error(); -} -?> diff --git a/apps/calendar/ajax/timezonedetection.php b/apps/calendar/ajax/timezonedetection.php new file mode 100644 index 00000000000..77e4c4f6ebe --- /dev/null +++ b/apps/calendar/ajax/timezonedetection.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once ("../../../lib/base.php"); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); +if($_POST['timezonedetection'] == 'on'){ + OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'true'); +}else{ + OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'false'); +} +OC_JSON::success(); + diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php index e99ca16e22a..14f560da5a3 100644 --- a/apps/calendar/ajax/updatecalendar.php +++ b/apps/calendar/ajax/updatecalendar.php @@ -8,16 +8,16 @@ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $calendarid = $_POST['id']; +$calendar = OC_Calendar_App::getCalendar($calendarid);//access check OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], null, null, null, $_POST['color']); OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); -$calendar = OC_Calendar_Calendar::findCalendar($calendarid); + +$calendar = OC_Calendar_App::getCalendar($calendarid); $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); OC_JSON::success(array( diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index 5675e624dda..267a74bf29a 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -1,25 +1,23 @@ <?php -$l=new OC_L10N('calendar'); -OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php'; -OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php'; -OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php'; -OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php'; -OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'deleteUser'); - -OC_Util::addScript('calendar','loader'); - -OC_App::register( array( - 'order' => 10, - 'id' => 'calendar', - 'name' => 'Calendar' )); - -OC_App::addNavigationEntry( array( - 'id' => 'calendar_index', - 'order' => 10, - 'href' => OC_Helper::linkTo( 'calendar', 'index.php' ), - 'icon' => OC_Helper::imagePath( 'calendar', 'icon.png' ), - 'name' => $l->t('Calendar'))); - -OC_App::registerPersonal('calendar', 'settings'); - -require_once('apps/calendar/lib/search.php');
\ No newline at end of file +if(version_compare(PHP_VERSION, '5.3.0', '>')){ + $l=new OC_L10N('calendar'); + OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php'; + OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php'; + OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php'; + OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php'; + OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php'; + OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'deleteUser'); + OC_Util::addScript('calendar','loader'); + OC_App::register( array( + 'order' => 10, + 'id' => 'calendar', + 'name' => 'Calendar' )); + OC_App::addNavigationEntry( array( + 'id' => 'calendar_index', + 'order' => 10, + 'href' => OC_Helper::linkTo( 'calendar', 'index.php' ), + 'icon' => OC_Helper::imagePath( 'calendar', 'icon.png' ), + 'name' => $l->t('Calendar'))); + OC_App::registerPersonal('calendar', 'settings'); + require_once('apps/calendar/lib/search.php'); +} diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css index 0204f2fc12f..6555c25a767 100644 --- a/apps/calendar/css/style.css +++ b/apps/calendar/css/style.css @@ -17,6 +17,8 @@ #editentry_dialog {display: none;} #parsingfail_dialog{display: none;} +#loading { display: none; left: 40%; position: fixed; top: 4.4em; z-index: 100; } + #calendar_holder {position: relative;bottom: 0; right: 0; left: 0; top: 3em;} .fc-content{padding:2px 4px;} #listview {margin: 0; padding: 10px; background: #EEEEEE;} diff --git a/apps/calendar/export.php b/apps/calendar/export.php index 3e93a1ad618..ce1a4aa046f 100644 --- a/apps/calendar/export.php +++ b/apps/calendar/export.php @@ -6,33 +6,25 @@ * See the COPYING-README file. */ -require_once ("../../lib/base.php"); +require_once ('../../lib/base.php'); OC_Util::checkLoggedIn(); OC_Util::checkAppEnabled('calendar'); -$cal = isset($_GET["calid"]) ? $_GET["calid"] : NULL; -$event = isset($_GET["eventid"]) ? $_GET["eventid"] : NULL; +$cal = isset($_GET['calid']) ? $_GET['calid'] : NULL; +$event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL; if(isset($cal)){ - $calendar = OC_Calendar_Calendar::findCalendar($cal); - if($calendar["userid"] != OC_User::getUser()){ - OC_JSON::error(); - exit; - } + $calendar = OC_Calendar_App::getCalendar($cal); $calobjects = OC_Calendar_Object::all($cal); - header("Content-Type: text/Calendar"); - header("Content-Disposition: inline; filename=calendar.ics"); - for($i = 0;$i <= count($calobjects); $i++){ - echo $calobjects[$i]["calendardata"] . "\n"; + header('Content-Type: text/Calendar'); + header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics'); + foreach($calobjects as $calobject){ + echo $calobject['calendardata'] . '\n'; } }elseif(isset($event)){ - $data = OC_Calendar_Object::find($_GET["eventid"]); - $calendarid = $data["calendarid"]; - $calendar = OC_Calendar_Calendar::findCalendar($calendarid); - if($calendar["userid"] != OC_User::getUser()){ - OC_JSON::error(); - exit; - } - header("Content-Type: text/Calendar"); - header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics"); - echo $data["calendardata"]; + $data = OC_Calendar_App::getEventObject($_GET['eventid']); + $calendarid = $data['calendarid']; + $calendar = OC_Calendar_App::getCalendar($calendarid); + header('Content-Type: text/Calendar'); + header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics'); + echo $data['calendardata']; } ?> diff --git a/apps/calendar/import.php b/apps/calendar/import.php index 211791f551b..759726b8d10 100644 --- a/apps/calendar/import.php +++ b/apps/calendar/import.php @@ -12,11 +12,7 @@ OC_Util::checkAppEnabled('calendar'); if($_GET["import"] == "existing"){ $calid = $_GET["calid"]; - $calendar = OC_Calendar_Calendar::findCalendar($calid); - if($calendar['userid'] != OC_User::getUser()){ - OC_JSON::error(); - exit; - } + $calendar = OC_Calendar_App::getCalendar($calid); if($_GET["path"] != ""){ $filename = $_GET["path"] . "/" . $_GET["file"]; }else{ @@ -47,4 +43,4 @@ for($i = 1;$i < count($vcalendar);$i++){ OC_Calendar_Object::add($calid, $vcalendar[$i]); } OC_JSON::success(); -?>
\ No newline at end of file +?> diff --git a/apps/calendar/index.php b/apps/calendar/index.php index 3313750d52e..e8e214c0b75 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -32,7 +32,7 @@ if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'mont OC_Util::addScript('3rdparty/fullcalendar', 'fullcalendar'); OC_Util::addStyle('3rdparty/fullcalendar', 'fullcalendar'); -if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null){ +if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null || OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection') == 'true'){ OC_UTIL::addScript('calendar', 'geo'); } OC_Util::addScript('calendar', 'calendar'); @@ -42,4 +42,7 @@ OC_Util::addStyle('', 'jquery.multiselect'); OC_App::setActiveNavigationEntry('calendar_index'); $tmpl = new OC_Template('calendar', 'calendar', 'user'); $tmpl->assign('eventSources', $eventSources); -$tmpl->printPage();
\ No newline at end of file +if(array_key_exists('showevent', $_GET)){ + $tmpl->assign('showevent', $_GET['showevent']); +} +$tmpl->printPage(); diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index c3644b53704..ae586661ccc 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -8,7 +8,15 @@ Calendar={ UI:{ + loading: function(isLoading){ + if (isLoading){ + $('#loading').show(); + }else{ + $('#loading').hide(); + } + }, startEventDialog:function(){ + Calendar.UI.loading(false); $('.tipsy').remove(); $('#calendar_holder').fullCalendar('unselect'); Calendar.UI.lockTime(); @@ -25,6 +33,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) { @@ -41,6 +62,7 @@ Calendar={ // TODO: save event $('#event').dialog('destroy').remove(); }else{ + Calendar.UI.loading(true); $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog); } }, @@ -50,13 +72,16 @@ Calendar={ // TODO: save event $('#event').dialog('destroy').remove(); }else{ + Calendar.UI.loading(true); $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'editeventform.php') + '?id=' + id, Calendar.UI.startEventDialog); } }, submitDeleteEventForm:function(url){ var post = $( '#event_form' ).serialize(); $('#errorbox').empty(); + Calendar.UI.loading(true); $.post(url, post, function(data){ + Calendar.UI.loading(false); if(data.status == 'success'){ $('#calendar_holder').fullCalendar('removeEvents', $('#event_form input[name=id]').val()); $('#event').dialog('destroy').remove(); @@ -69,8 +94,10 @@ Calendar={ validateEventForm:function(url){ var post = $( "#event_form" ).serialize(); $("#errorbox").empty(); + Calendar.UI.loading(true); $.post(url, post, function(data){ + Calendar.UI.loading(false); if(data.status == "error"){ var output = missing_field + ": <br />"; if(data.title == "true"){ @@ -107,8 +134,10 @@ Calendar={ }, moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){ $('.tipsy').remove(); + Calendar.UI.loading(true); $.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified}, function(data) { + Calendar.UI.loading(false); if (data.status == 'success'){ event.lastmodified = data.lastmodified; console.log("Event moved successfully"); @@ -120,8 +149,10 @@ Calendar={ }, resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){ $('.tipsy').remove(); + Calendar.UI.loading(true); $.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified}, function(data) { + Calendar.UI.loading(false); if (data.status == 'success'){ event.lastmodified = data.lastmodified; console.log("Event resized successfully"); @@ -132,9 +163,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,11 +243,114 @@ 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('month'); + Calendar.UI.repeat('year'); + Calendar.UI.repeat('repeat'); + } + 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'); + Calendar.UI.repeat('month'); + } + if($('#repeat option:selected').val() == 'weekly'){ + $('#advanced_weekday').css('display', 'block'); + } + if($('#repeat option:selected').val() == 'yearly'){ + $('#advanced_year').css('display', 'block'); + Calendar.UI.repeat('year'); + } + 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_select option:selected').val() == 'byyearday'){ + //$('#advanced_byyearday').css('display', 'block'); + } + if($('#advanced_year_select option:selected').val() == 'byweekno'){ + $('#advanced_byweekno').css('display', 'block'); + } + if($('#advanced_year_select 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){ $('#choosecalendar_dialog').dialog('moveToTop'); }else{ + Calendar.UI.loading(true); $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'choosecalendar.php'), function(){ $('#choosecalendar_dialog').dialog({ width : 600, @@ -217,13 +358,16 @@ Calendar={ $(this).dialog('destroy').remove(); } }); + Calendar.UI.loading(false); }); } }, activation:function(checkbox, calendarid) { + Calendar.UI.loading(true); $.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 }, function(data) { + Calendar.UI.loading(false); if (data.status == 'success'){ checkbox.checked = data.active == 1; if (data.active == 1){ @@ -520,6 +664,7 @@ $(document).ready(function(){ } }); }, + loading: Calendar.UI.loading, eventSources: eventSources }); $('#oneweekview_radio').click(function(){ diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js index acea17c0269..ae6a971e938 100755 --- a/apps/calendar/js/geo.js +++ b/apps/calendar/js/geo.js @@ -8,8 +8,9 @@ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { $.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''), function(data){ - if (data.status == 'success'){ + if (data.status == 'success' && typeof(data.message) != 'undefined'){ $('#notification').html(data.message); + $('#notification').attr('title', 'CC BY 3.0 by Geonames.org'); $('#notification').slideDown(); window.setTimeout(function(){$('#notification').slideUp();}, 5000); }else{ diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index 6c00be06b39..73300885565 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -1,63 +1,35 @@ $(document).ready(function(){ - $("#timezone").change( function(){ + $('#timezone').change( function(){ OC.msg.startSaving('#calendar .msg') // Serialize the data - var post = $( "#timezone" ).serialize(); + var post = $( '#timezone' ).serialize(); $.post( OC.filePath('calendar', 'ajax', 'settimezone.php'), post, function(data){ //OC.msg.finishedSaving('#calendar .msg', data); }); return false; }); - $("#timezone").chosen(); - $("#firstdayofweek").change( function(){ - var data = $("#firstdayofweek").serialize(); - $.post( OC.filePath('calendar', 'ajax', 'setfirstdayofweek.php'), data, function(data){ - if(data == "error"){ - console.log("saving first day of week failed"); - } - }); - }); - $.getJSON(OC.filePath('calendar', 'ajax', 'firstdayofweek.php'), function(jsondata, status) { - $("#select_" + jsondata.firstdayofweek).attr('selected',true); - $("#firstdayofweek").chosen(); - }); - $.getJSON(OC.filePath('calendar', 'ajax', 'daysofweekend.php'), function(jsondata, status) { - for(day in jsondata){ - if(jsondata[day] == "true"){ - $("#selectweekend_" + day).attr('selected',true); - } - } - $("#weekend").chosen(); - }); - $("#timeformat").change( function(){ - var data = $("#timeformat").serialize(); + $('#timezone').chosen(); + $('#timeformat').change( function(){ + var data = $('#timeformat').serialize(); $.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){ - if(data == "error"){ - console.log("saving timeformat failed"); + if(data == 'error'){ + console.log('saving timeformat failed'); } }); }); - $.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) { - $("#" + jsondata.timeformat).attr('selected',true); - $("#timeformat").chosen(); - }); - $("#duration").blur( function(){ - var data = $("#duration").val(); - $.post( OC.filePath('calendar', 'ajax', 'setduration.php'), {duration: data}, function(data){ - if(data == "error"){ - console.log("saving duration failed"); - } + $('#timezonedetection').change( function(){ + var post = $('#timezonedetection').serialize(); + $.post( OC.filePath('calendar', 'ajax', 'timezonedetection.php'), post, function(data){ + }); }); - $.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) { - $("#duration").val(jsondata.duration); + $.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) { + $('#' + jsondata.timeformat).attr('selected',true); + $('#timeformat').chosen(); }); - $("#weekend").change( function(){ - var data = $("#weekend").serialize(); - $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ - if(data == "error"){ - console.log("saving days of weekend failed"); - } - }); + $.getJSON(OC.filePath('calendar', 'ajax', 'gettimezonedetection.php'), function(jsondata, status){ + if(jsondata.detection == 'true'){ + $('#timezonedetection').attr('checked', 'checked'); + } }); }); diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php new file mode 100644 index 00000000000..6e92cf67c5c --- /dev/null +++ b/apps/calendar/lib/app.php @@ -0,0 +1,117 @@ +<?php +/** + * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +/** + * This class manages our app actions + */ +OC_Calendar_App::$l10n = new OC_L10N('calendar'); +class OC_Calendar_App{ + public static $l10n; + + public static function getCalendar($id){ + $calendar = OC_Calendar_Calendar::find( $id ); + if( $calendar === false || $calendar['userid'] != OC_User::getUser()){ + OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); + exit(); + } + return $calendar; + } + + public static function getEventObject($id){ + $event_object = OC_Calendar_Object::find( $id ); + if( $event_object === false ){ + OC_JSON::error(); + exit(); + } + + self::getCalendar( $event_object['calendarid'] );//access check + return $event_object; + } + + public static function getVCalendar($id){ + $event_object = self::getEventObject( $id ); + + $vcalendar = OC_VObject::parse($event_object['calendardata']); + // Check if the vcalendar is valid + if(is_null($vcalendar)){ + OC_JSON::error(); + exit(); + } + return $vcalendar; + } + + public static function isNotModified($vevent, $lastmodified) + { + $last_modified = $vevent->__get('LAST-MODIFIED'); + if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')){ + OC_JSON::error(array('modified'=>true)); + exit; + } + } + + public static function getCategoryOptions() + { + return array( + self::$l10n->t('Birthday'), + self::$l10n->t('Business'), + self::$l10n->t('Call'), + self::$l10n->t('Clients'), + self::$l10n->t('Deliverer'), + self::$l10n->t('Holidays'), + self::$l10n->t('Ideas'), + self::$l10n->t('Journey'), + self::$l10n->t('Jubilee'), + self::$l10n->t('Meeting'), + self::$l10n->t('Other'), + self::$l10n->t('Personal'), + self::$l10n->t('Projects'), + self::$l10n->t('Questions'), + self::$l10n->t('Work'), + ); + } + + 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/calendar.php b/apps/calendar/lib/calendar.php index 3db4398096e..ea60526a5bd 100644 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -82,7 +82,7 @@ class OC_Calendar_Calendar{ * @param integer $id * @return associative array */ - public static function findCalendar($id){ + public static function find($id){ $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' ); $result = $stmt->execute(array($id)); @@ -148,7 +148,7 @@ class OC_Calendar_Calendar{ */ public static function editCalendar($id,$name=null,$components=null,$timezone=null,$order=null,$color=null){ // Need these ones for checking uri - $calendar = self::findCalendar($id); + $calendar = self::find($id); // Keep old stuff if(is_null($name)) $name = $calendar['name']; diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 1c145003511..cbb1badf802 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -356,9 +356,99 @@ 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( + 'bydate' => $l10n->t('by events date'), + '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; @@ -367,7 +457,7 @@ class OC_Calendar_Object{ $errarr['title'] = 'true'; $errnum++; } - $calendar = OC_Calendar_Calendar::findCalendar($request['calendar']); + $calendar = OC_Calendar_Calendar::find($request['calendar']); if($calendar['userid'] != OC_User::getUser()){ $errarr['cal'] = 'true'; $errnum++; @@ -397,7 +487,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 +642,148 @@ 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=WEEKLY'; + $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'){ + list($_day, $_month, $_year) = explode('-', $from); + $weekofmonth = floor($_day/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'] == 'bydate'){ + + }elseif($request['advanced_year_select'] == 'byyearday'){ + list($_day, $_month, $_year) = explode('-', $from); + $byyearday = date('z', mktime(0,0,0, $_month, $_day, $_year)) + 1; + if(array_key_exists('byyearday', $request)){ + foreach($request['byyearday'] as $yearday){ + $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 +816,4 @@ class OC_Calendar_Object{ return $vcalendar; } -} +}
\ No newline at end of file diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php index 41faf49a519..425c93c7338 100644 --- a/apps/calendar/lib/search.php +++ b/apps/calendar/lib/search.php @@ -12,15 +12,36 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ }else{ $searchquery[] = $query; } + $user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $l = new OC_l10n('calendar'); foreach($calendars as $calendar){ $objects = OC_Calendar_Object::all($calendar['id']); foreach($objects as $object){ - if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){//$name,$text,$link,$type - $results[]=new OC_Search_Result($object['summary'],'','#','Cal.'); + if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){ + $calendardata = OC_VObject::parse($object['calendardata']); + $vevent = $calendardata->VEVENT; + $dtstart = $vevent->DTSTART; + $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); + $start_dt = $dtstart->getDateTime(); + $start_dt->setTimezone(new DateTimeZone($user_timezone)); + $end_dt = $dtend->getDateTime(); + $end_dt->setTimezone(new DateTimeZone($user_timezone)); + if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ + $end_dt->modify('-1 sec'); + if($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')){ + $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y'); + }else{ + $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y'); + } + }else{ + $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i'); + } + $link = OC_Helper::linkTo('apps/calendar', 'index.php?showevent='.urlencode($object['id'])); + $results[]=new OC_Search_Result($object['summary'],$info, $link,$l->t('Cal.'));//$name,$text,$link,$type } } } return $results; } } -new OC_Search_Provider_Calendar();
\ No newline at end of file +new OC_Search_Provider_Calendar(); diff --git a/apps/calendar/resettimezone.php b/apps/calendar/resettimezone.php new file mode 100644 index 00000000000..1ef9591ae39 --- /dev/null +++ b/apps/calendar/resettimezone.php @@ -0,0 +1,4 @@ +<?php +require_once ("../../lib/base.php"); +OC_Preferences::deleteKey(OC_USER::getUser(), 'calendar', 'timezone'); +?>
\ No newline at end of file diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 2003b7efc49..92c1b8a778a 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -18,7 +18,18 @@ var missing_field_startsbeforeends = '<?php echo $l->t('The event ends before it starts') ?>'; var missing_field_dberror = '<?php echo $l->t('There was a database fail') ?>'; var totalurl = '<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?>/calendars'; + $(document).ready(function() { + <?php + if(array_key_exists('showevent', $_)){ + $data = OC_Calendar_App::getEventObject($_['showevent']); + $date = substr($data['startdate'], 0, 10); + list($year, $month, $day) = explode('-', $date); + echo '$(\'#calendar_holder\').fullCalendar(\'gotoDate\', ' . $year . ', ' . --$month . ', ' . $day . ');'; + } + ?> + }); </script> + <div id="loading"><img src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></div> <div id="controls"> <div> <form> 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"> <?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"> - - <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"> + + <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"> - - <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"> + + <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> diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index 56fb55d235c..fc8e0e061d9 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -27,7 +27,7 @@ $continent=$ex[0]; echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>'; endforeach;?> - </select></td></tr> + </select><input type="checkbox" name="timezonedetection" id="timezonedetection"><label for="timezonedetection"><?php echo $l->t('Check always for changes of the timezone'); ?></label></td></tr> <tr><td><label for="timeformat" class="bold"><?php echo $l->t('Timeformat');?></label></td><td> <select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat"> |