diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-02-25 16:54:27 +0100 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-02-25 16:54:27 +0100 |
commit | bfb67286c85806fdd4293b60936d5cdedee2e702 (patch) | |
tree | 7136c53adb6c7196c84b2b2295a781e697fa42a9 /apps/calendar | |
parent | 9460c9e907f1dd80e4978e23911975bc775e7260 (diff) | |
parent | 3cf81cadd5535b0516d73fe3de8ee91f330b4a6f (diff) | |
download | nextcloud-server-bfb67286c85806fdd4293b60936d5cdedee2e702.tar.gz nextcloud-server-bfb67286c85806fdd4293b60936d5cdedee2e702.zip |
fix merge conflicts
Diffstat (limited to 'apps/calendar')
-rw-r--r-- | apps/calendar/ajax/changeview.php | 2 | ||||
-rwxr-xr-x | apps/calendar/ajax/events.php | 30 | ||||
-rw-r--r-- | apps/calendar/appinfo/update.php | 17 | ||||
-rw-r--r-- | apps/calendar/js/calendar.js | 7 | ||||
-rw-r--r-- | apps/calendar/lib/app.php | 4 | ||||
-rw-r--r-- | apps/calendar/lib/calendar.php | 25 | ||||
-rw-r--r-- | apps/calendar/lib/object.php | 1 | ||||
-rw-r--r-- | apps/calendar/lib/search.php | 2 | ||||
-rwxr-xr-x | apps/calendar/templates/calendar.php | 2 | ||||
-rw-r--r-- | apps/calendar/templates/part.eventform.php | 7 | ||||
-rw-r--r-- | apps/calendar/templates/settings.php | 2 |
11 files changed, 67 insertions, 32 deletions
diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php index 034c7129cab..76e29cbe265 100644 --- a/apps/calendar/ajax/changeview.php +++ b/apps/calendar/ajax/changeview.php @@ -21,4 +21,4 @@ switch($view){ } OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'currentview', $view); OC_JSON::success(); -?>
\ No newline at end of file +?> diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index 1747b2ac1a8..687b8e38d44 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -1,10 +1,11 @@ <?php /** - * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> + * 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'); require_once('../../../3rdparty/when/When.php'); @@ -13,6 +14,7 @@ OC_JSON::checkAppEnabled('calendar'); $start = DateTime::createFromFormat('U', $_GET['start']); $end = DateTime::createFromFormat('U', $_GET['end']); + if($_GET['calendar_id'] == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){ $calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r'); $events = array(); @@ -27,17 +29,21 @@ if($_GET['calendar_id'] == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){ exit; } $events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end); + OC_Response::enableCaching(0); + OC_Response::setETagHeader($calendar['ctag']); } -$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end); +$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $return = array(); - foreach($events as $event){ $object = OC_VObject::parse($event['calendardata']); $vevent = $object->VEVENT; + + $return_event = OC_Calendar_App::prepareForOutput($event, $vevent); + $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); - $return_event = array(); $start_dt = $dtstart->getDateTime(); $end_dt = $dtend->getDateTime(); if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ @@ -50,9 +56,12 @@ foreach($events as $event){ if($event['repeating'] == 1){ $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U'); $r = new When(); - $r->recur((string) $start_dt->format('Ymd\THis'))->rrule((string) $vevent->RRULE); + $r->recur($start_dt)->rrule((string) $vevent->RRULE); while($result = $r->next()){ - if($result->format('U') > $_GET['end']){ + if($result < $start){ + continue; + } + if($result > $end){ break; } if($return_event['allDay'] == true){ @@ -62,21 +71,18 @@ foreach($events as $event){ $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); } - $return[] = OC_Calendar_App::prepareForOutput($event, $vevent, $return_event); + $return[] = $return_event; } }else{ - $return_event = array(); - if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ - $return_event['allDay'] = true; + if($return_event['allDay'] == true){ $return_event['start'] = $start_dt->format('Y-m-d'); $end_dt->modify('-1 sec'); $return_event['end'] = $end_dt->format('Y-m-d'); }else{ $return_event['start'] = $start_dt->format('Y-m-d H:i:s'); $return_event['end'] = $end_dt->format('Y-m-d H:i:s'); - $return_event['allDay'] = false; } - $return[] = OC_Calendar_App::prepareForOutput($event, $vevent, $return_event); + $return[] = $return_event; } } OC_JSON::encodedPrint($return); diff --git a/apps/calendar/appinfo/update.php b/apps/calendar/appinfo/update.php new file mode 100644 index 00000000000..375816a403e --- /dev/null +++ b/apps/calendar/appinfo/update.php @@ -0,0 +1,17 @@ +<?php + +$installedVersion=OC_Appconfig::getValue('calendar', 'installed_version'); +if (version_compare($installedVersion, '0.2.1', '<')) { + $stmt = OC_DB::prepare( 'SELECT id, calendarcolor FROM *PREFIX*calendar_calendars WHERE calendarcolor IS NOT NULL' ); + $result = $stmt->execute(); + while( $row = $result->fetchRow()) { + $id = $row['id']; + $color = $row['calendarcolor']; + if ($color[0] == '#' || strlen($color) < 6) { + continue; + } + $color = '#' .$color; + $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET calendarcolor=? WHERE id=?' ); + $r = $stmt->execute(array($color,$id)); + } +} diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index cd4a82a71b3..c6a66770747 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -479,7 +479,7 @@ Calendar={ colors[i].label = $(elm).text(); }); for (var i in colors) { - picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: #' + colors[i].color + ';"></span>'); + picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: ' + colors[i].color + ';"></span>'); } picker.delegate(".calendar-colorpicker-color", "click", function() { $(obj).val($(this).attr('rel')); @@ -792,7 +792,10 @@ $(document).ready(function(){ allDayText: allDayText, viewDisplay: function(view) { $('#datecontrol_date').html(view.title); - $.get(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view.name); + if (view.name != defaultView) { + $.get(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view.name); + defaultView = view.name; + } Calendar.UI.setViewActive(view.name); if (view.name == 'agendaWeek') { $('#calendar_holder').fullCalendar('option', 'aspectRatio', 0.1); diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 27129e77e35..516c04f038a 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -115,7 +115,8 @@ class OC_Calendar_App{ return OC_Calendar_Object::getWeekofMonth(self::$l10n); } - public static function prepareForOutput($event, $vevent, $return_event){ + public static function prepareForOutput($event, $vevent){ + $return_event = array(); $return_event['id'] = (int)$event['id']; $return_event['title'] = htmlspecialchars($event['summary']); $return_event['description'] = isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):''; @@ -127,6 +128,5 @@ class OC_Calendar_App{ } $return_event['lastmodified'] = (int)$lastmodified; return $return_event; - } } diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 5e272991f20..277539af97d 100644 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -96,7 +96,7 @@ class OC_Calendar_Calendar{ * @param string $components Default: "VEVENT,VTODO,VJOURNAL" * @param string $timezone Default: null * @param integer $order Default: 1 - * @param string $color Default: null + * @param string $color Default: null, format: '#RRGGBB(AA)' * @return insertid */ public static function addCalendar($userid,$name,$components='VEVENT,VTODO,VJOURNAL',$timezone=null,$order=0,$color=null){ @@ -122,7 +122,7 @@ class OC_Calendar_Calendar{ * @param string $components * @param string $timezone * @param integer $order - * @param string $color + * @param string $color format: '#RRGGBB(AA)' * @return insertid */ public static function addCalendarFromDAVData($principaluri,$uri,$name,$components,$timezone,$order,$color){ @@ -141,7 +141,7 @@ class OC_Calendar_Calendar{ * @param string $components Default: null * @param string $timezone Default: null * @param integer $order Default: null - * @param string $color Default: null + * @param string $color Default: null, format: '#RRGGBB(AA)' * @return boolean * * Values not null will be set @@ -230,22 +230,23 @@ class OC_Calendar_Calendar{ } public static function getCalendarColorOptions(){ return array( - 'ff0000', // "Red" - 'b3dc6c', // "Green" - 'ffff00', // "Yellow" - '808000', // "Olive" - 'ffa500', // "Orange" - 'ff7f50', // "Coral" - 'ee82ee', // "Violet" - '9fc6e7', // "light blue" + '#ff0000', // "Red" + '#b3dc6c', // "Green" + '#ffff00', // "Yellow" + '#808000', // "Olive" + '#ffa500', // "Orange" + '#ff7f50', // "Coral" + '#ee82ee', // "Violet" + '#9fc6e7', // "light blue" ); } public static function getEventSourceInfo($calendar){ return array( 'url' => 'ajax/events.php?calendar_id='.$calendar['id'], - 'backgroundColor' => '#'.$calendar['calendarcolor'], + 'backgroundColor' => $calendar['calendarcolor'], 'borderColor' => '#888', 'textColor' => 'black', + 'cache' => true, ); } } diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index a7ee5bd1081..5a3410ea5dc 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -194,6 +194,7 @@ class OC_Calendar_Object{ public static function deleteFromDAVData($cid,$uri){ $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri=?' ); $stmt->execute(array($cid,$uri)); + OC_Calendar_Calendar::touchCalendar($cid); return true; } diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php index 425c93c7338..0016751a66a 100644 --- a/apps/calendar/lib/search.php +++ b/apps/calendar/lib/search.php @@ -36,7 +36,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ }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'])); + $link = OC_Helper::linkTo('calendar', 'index.php').'?showevent='.urlencode($object['id']); $results[]=new OC_Search_Result($object['summary'],$info, $link,$l->t('Cal.'));//$name,$text,$link,$type } } diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 2d5cdea4d74..eb82d0d02ad 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -18,7 +18,7 @@ var missing_field_totime = '<?php echo addslashes($l->t('To Time')) ?>'; var missing_field_startsbeforeends = '<?php echo addslashes($l->t('The event ends before it starts')) ?>'; var missing_field_dberror = '<?php echo addslashes($l->t('There was a database fail')) ?>'; - var totalurl = '<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?>/calendars'; + var totalurl = '<?php echo OC_Helper::linkToAbsolute('calendar', 'caldav.php'); ?>/calendars'; $(document).ready(function() { <?php if(array_key_exists('showevent', $_)){ diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 2abfe94ba03..b67f8c02c39 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -25,6 +25,7 @@ ?> </select> </td> + <?php if(count($_['calendar_options']) > 1) { ?> <th width="75px"> <?php echo $l->t("Calendar");?>:</th> <td> <select style="width:140px;" name="calendar"> @@ -34,6 +35,12 @@ ?> </select> </td> + <?php } else { ?> + <th width="75px"> </th> + <td> + <input type="hidden" name="calendar" value="<?php echo $_['calendar_options'][0]['id'] ?>"> + </td> + <?php } ?> </tr> </table> <hr> diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index e174378d02d..979634874e4 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -40,6 +40,6 @@ </table> <?php echo $l->t('Calendar CalDAV syncing address:');?> - <?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br /> + <?php echo OC_Helper::linkToAbsolute('calendar', 'caldav.php'); ?><br /> </fieldset> </form> |