Skip to content

Commit

Permalink
First version of the framework
Browse files Browse the repository at this point in the history
  • Loading branch information
brainformatik committed Jan 10, 2017
1 parent 7dd179a commit 5c27db1
Show file tree
Hide file tree
Showing 411 changed files with 37,806 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ignore composer files
vendor/
composer.lock
composer.phar

#ignore thumbnails created by windows
Thumbs.db

#Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.dll
*.lib
*.sbr
.idea
.svn
.git

# Folder view configuration files
.DS_Store
Desktop.ini
60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,59 @@
# caldav-framework
# CalDAV Framework

## Description

This framework abstracts all VCALENDAR entities. In addition it automatically adds required timezone information for dates. You can simply work with PHP DateTime and DateTimeZone objects.

After creating an event or a todo and setting all required values, you can create the vcalendar output or save the entry directly.

## Example usage

```php
require_once('autoload.php');

try {
$client = new \Brainformatik\CalDAV\Connection\Client([
'baseUri' => 'http://some-url' // set caldav server url
]);

$calendar = new \Brainformatik\CalDAV\Entity\Calendar($client, 'http://url-to-calendar');

$event = $calendar->addEvent();
$event->setUid('unique-id123415');
$event->setSummary('This is the summary');
$event->setDescription('This is the description which can be very long and should be folded at some point if the implementation is working correctly.');
$event->setComment('This is the comment you can use for something.');
$event->setLocation('Meeting room 1');
$event->setPriority(9);
$event->addResources(['BEAMER', 'Flipchart']);
$event->setStatus(\Brainformatik\CalDAV\Enum\EventStatus::CONFIRMED);
$event->setDateEnd(new DateTime('2016-01-01 14:00:10', new DateTimeZone('America/New_York')));
$event->setDateStart(new DateTime('2015-12-12', new DateTimeZone('America/New_York')));
$event->setRecurrenceId(new DateTime('2015-12-12', new DateTimeZone('America/New_York')), [
'RANGE' => 'THISANDFUTURE',
'VALUE' => 'DATE'
]);

$duration = new \Brainformatik\CalDAV\Type\Duration();
$duration->setHour(10)->setMinute(30);

$event->setDuration($duration);
$event->setTransparency(\Brainformatik\CalDAV\Enum\EventTransparency::TRANSPARENT);
$event->addExceptionDates([
new DateTime('2015-12-12 12:00:00', new DateTimeZone('America/New_York')),
new DateTime('2015-12-13 12:00:00', new DateTimeZone('America/New_York')),
new DateTime('2015-12-14 12:00:00', new DateTimeZone('Europe/Berlin'))
]);

$event->setDateCreated(new DateTime('2016-10-08 09:32:00', new DateTimeZone('UTC')));
$event->setDateLastModified(new DateTime('2016-10-08 09:32:00', new DateTimeZone('UTC')));

// to get the icalendar output
echo $calendar->serialize();

// to save the event to the calendar
$calendar->save('filename.ics');
} catch (\Exception $e) {
echo $e->getMessage();
}
```
20 changes: 20 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

if (file_exists('vendor/autoload.php')) {
require_once('vendor/autoload.php');
}

spl_autoload_register(function ($className) {
$prefix = 'Brainformatik\\CalDAV\\';
$baseDir = __DIR__ . '/src/';

$length = strlen($prefix);
if (strncmp($prefix, $className, $length) !== 0) {
return;
}

$file = $baseDir . str_replace('\\', '/', substr($className, $length)) . '.php';
if (file_exists($file)) {
require $file;
}
});
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "brainformatik/caldav",
"type": "library",
"description": "Brainformatik CalDAV Framework",
"keywords": ["brainformatik", "caldav", "crm", "vtiger"],
"homepage": "https://www.brainformatik.com",
"license": "MIT",
"authors": [
{
"name": "Brainformatik GmbH",
"email": "info@brainformatik.com",
"homepage": "https://www.brainformatik.com"
}
],
"require": {
"php": ">=5.6",
"ext-curl": "*",
"sabre/vobject": "4.1.2",
"sabre/dav" : "3.2.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7.0"
},
"autoload": {
"psr-4": {
"Brainformatik\\CalDAV\\": "src/"
}
}
}
19 changes: 19 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Brainformatik CalDAV Framework Test Suite">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
15 changes: 15 additions & 0 deletions resource/zoneinfo/Africa/Abidjan.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BEGIN:VCALENDAR
PRODID:-//My Organization//NONSGML My Product//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Africa/Abidjan
X-LIC-LOCATION:Africa/Abidjan
BEGIN:STANDARD
TZOFFSETFROM:-001608
TZOFFSETTO:+0000
TZNAME:GMT
DTSTART:19120101T000000
RDATE:19120101T000000
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
73 changes: 73 additions & 0 deletions resource/zoneinfo/Africa/Accra.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
BEGIN:VCALENDAR
PRODID:-//My Organization//NONSGML My Product//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Africa/Accra
X-LIC-LOCATION:Africa/Accra
BEGIN:STANDARD
TZOFFSETFROM:-000052
TZOFFSETTO:+0000
TZNAME:GMT
DTSTART:19180101T000000
RDATE:19180101T000000
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0000
TZOFFSETTO:+0020
TZNAME:GHST
DTSTART:19200901T000000
RDATE:19200901T000000
RDATE:19210901T000000
RDATE:19220901T000000
RDATE:19230901T000000
RDATE:19240901T000000
RDATE:19250901T000000
RDATE:19260901T000000
RDATE:19270901T000000
RDATE:19280901T000000
RDATE:19290901T000000
RDATE:19300901T000000
RDATE:19310901T000000
RDATE:19320901T000000
RDATE:19330901T000000
RDATE:19340901T000000
RDATE:19350901T000000
RDATE:19360901T000000
RDATE:19370901T000000
RDATE:19380901T000000
RDATE:19390901T000000
RDATE:19400901T000000
RDATE:19410901T000000
RDATE:19420901T000000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0020
TZOFFSETTO:+0000
TZNAME:GMT
DTSTART:19201231T000000
RDATE:19201231T000000
RDATE:19211231T000000
RDATE:19221231T000000
RDATE:19231231T000000
RDATE:19241231T000000
RDATE:19251231T000000
RDATE:19261231T000000
RDATE:19271231T000000
RDATE:19281231T000000
RDATE:19291231T000000
RDATE:19301231T000000
RDATE:19311231T000000
RDATE:19321231T000000
RDATE:19331231T000000
RDATE:19341231T000000
RDATE:19351231T000000
RDATE:19361231T000000
RDATE:19371231T000000
RDATE:19381231T000000
RDATE:19391231T000000
RDATE:19401231T000000
RDATE:19411231T000000
RDATE:19421231T000000
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
36 changes: 36 additions & 0 deletions resource/zoneinfo/Africa/Addis_Ababa.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
BEGIN:VCALENDAR
PRODID:-//My Organization//NONSGML My Product//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Africa/Addis_Ababa
X-LIC-LOCATION:Africa/Addis_Ababa
BEGIN:STANDARD
TZOFFSETFROM:+022716
TZOFFSETTO:+0300
TZNAME:EAT
DTSTART:19280701T000000
RDATE:19280701T000000
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+0300
TZOFFSETTO:+0230
TZNAME:BEAT
DTSTART:19300101T000000
RDATE:19300101T000000
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+0230
TZOFFSETTO:+0245
TZNAME:BEAUT
DTSTART:19400101T000000
RDATE:19400101T000000
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+0245
TZOFFSETTO:+0300
TZNAME:EAT
DTSTART:19600101T000000
RDATE:19600101T000000
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
90 changes: 90 additions & 0 deletions resource/zoneinfo/Africa/Algiers.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
BEGIN:VCALENDAR
PRODID:-//My Organization//NONSGML My Product//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Africa/Algiers
X-LIC-LOCATION:Africa/Algiers
BEGIN:STANDARD
TZOFFSETFROM:+001212
TZOFFSETTO:+000921
TZNAME:PMT
DTSTART:18910315T000100
RDATE:18910315T000100
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+000921
TZOFFSETTO:+0000
TZNAME:WET
DTSTART:19110311T000000
RDATE:19110311T000000
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
TZNAME:WEST
DTSTART:19160614T230000
RDATE:19160614T230000
RDATE:19170324T230000
RDATE:19180309T230000
RDATE:19190301T230000
RDATE:19200214T230000
RDATE:19210314T230000
RDATE:19390911T230000
RDATE:19710425T230000
RDATE:19770506T000000
RDATE:19800425T000000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
TZNAME:WET
DTSTART:19161002T000000
RDATE:19161002T000000
RDATE:19171008T000000
RDATE:19181007T000000
RDATE:19191006T000000
RDATE:19201024T000000
RDATE:19210622T000000
RDATE:19391119T010000
RDATE:19461007T000000
RDATE:19630414T000000
RDATE:19710927T000000
RDATE:19791026T000000
RDATE:19801031T020000
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19400225T020000
RDATE:19400225T020000
RDATE:19560129T000000
RDATE:19810501T000000
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19440403T020000
RDATE:19440403T020000
RDATE:19450402T020000
RDATE:19780324T010000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19441008T020000
RDATE:19441008T020000
RDATE:19450916T010000
RDATE:19780922T030000
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+0100
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19771021T000000
RDATE:19771021T000000
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
Loading

0 comments on commit 5c27db1

Please sign in to comment.