Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
9dd7ca26
Commit
9dd7ca26
authored
12 years ago
by
Georg Ehrke
Browse files
Options
Downloads
Patches
Plain Diff
some changes and more doc for OC_Calendar_Export class
parent
9a4709e6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/calendar/lib/export.php
+55
-19
55 additions, 19 deletions
apps/calendar/lib/export.php
with
55 additions
and
19 deletions
apps/calendar/lib/export.php
+
55
−
19
View file @
9dd7ca26
...
...
@@ -6,9 +6,12 @@
* See the COPYING-README file.
*/
/*
* This class does export
* This class does export
and converts all times to UTC
*/
class
OC_Calendar_Export
{
/*
* @brief Use one of these constants as second parameter if you call OC_Calendar_Export::export()
*/
const
CALENDAR
=
'calendar'
;
const
EVENT
=
'event'
;
...
...
@@ -20,38 +23,71 @@ class OC_Calendar_Export{
*/
public
static
function
export
(
$id
,
$type
){
if
(
$type
==
self
::
EVENT
){
$data
=
OC_Calendar_App
::
getEventObject
(
$_GET
[
'eventid'
],
false
);
$return
=
$data
[
'calendardata'
];
$return
=
self
::
event
(
$id
);
}
else
{
$return
=
self
::
calendar
(
$id
);
}
return
$return
;
return
self
::
fixLineBreaks
(
$return
)
;
}
/*
* @brief export a calendar and convert all times to UTC
* @brief export
s
a calendar and convert all times to UTC
* @param integer $id id of the calendar
* @return string
*/
private
static
function
calendar
(
$id
){
$events
=
OC_Calendar_Object
::
all
(
$id
);
$return
=
"BEGIN:VCALENDAR
\n
VERSION:2.0
\n
PRODID:ownCloud Calendar
\n
"
;
$return
=
"BEGIN:VCALENDAR
\n
VERSION:2.0
\n
PRODID:ownCloud Calendar
"
.
OCP\App
::
getAppVersion
(
'calendar'
)
.
"
\n
"
;
foreach
(
$events
as
$event
){
$return
.
=
self
::
generateEvent
(
$event
);
}
$return
.
=
"END:VCALENDAR"
;
return
$return
;
}
/*
* @brief exports an event and convert all times to UTC
* @param integer $id id of the event
* @return string
*/
private
static
function
event
(
$id
){
$event
=
OC_Calendar_Object
::
find
(
$id
);
$return
=
"BEGIN:VCALENDAR
\n
VERSION:2.0
\n
PRODID:ownCloud Calendar "
.
OCP\App
::
getAppVersion
(
'calendar'
)
.
"
\n
"
;
$return
.
=
self
::
generateEvent
(
$event
);
$return
.
=
"END:VCALENDAR"
;
return
$return
;
}
/*
* @brief generates the VEVENT with UTC dates
* @param array $event
* @return string
*/
private
static
function
generateEvent
(
$event
){
$object
=
OC_VObject
::
parse
(
$event
[
'calendardata'
]);
$dtstart
=
$object
->
VEVENT
->
DTSTART
;
$start_dt
=
$dtstart
->
getDateTime
();
$dtend
=
OC_Calendar_Object
::
getDTEndFromVEvent
(
$object
->
VEVENT
);
$end_dt
=
$dtend
->
getDateTime
();
if
(
$dtstart
->
getDateType
()
!==
Sabre_VObject_Element_DateTime
::
DATE
){
$object
->
VEVENT
->
DTSTART
->
offsetUnset
(
'VALUE'
);
$object
->
VEVENT
->
DTEND
->
offsetUnset
(
'VALUE'
);
$start_dt
->
setTimezone
(
new
DateTimeZone
(
'UTC'
));
$end_dt
->
setTimezone
(
new
DateTimeZone
(
'UTC'
));
$object
->
VEVENT
->
setDateTime
(
'DTSTART'
,
$start_dt
,
Sabre_VObject_Property_DateTime
::
UTC
);
$object
->
VEVENT
->
setDateTime
(
'DTEND'
,
$end_dt
,
Sabre_VObject_Property_DateTime
::
UTC
);
}
$
return
.
=
$object
->
VEVENT
->
serialize
();
return
$object
->
VEVENT
->
serialize
();
}
$return
.
=
"END:VCALENDAR"
;
$return
=
str_replace
(
"
\r\n
"
,
"
\n
"
,
$return
);
$return
=
str_replace
(
"
\r
"
,
"
\n
"
,
$return
);
$return
=
str_replace
(
"
\n
"
,
"
\r\n
"
,
$return
);
return
$return
;
/*
* @brief fixes new line breaks
* (fixes problems with Apple iCal)
* @param string $string to fix
* @return string
*/
private
static
function
fixLineBreaks
(
$string
){
$string
=
str_replace
(
"
\r\n
"
,
"
\n
"
,
$string
);
$string
=
str_replace
(
"
\r
"
,
"
\n
"
,
$string
);
$string
=
str_replace
(
"
\n
"
,
"
\r\n
"
,
$string
);
return
$string
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment