Skip to content

Commit

Permalink
fixes for vobject categories
Browse files Browse the repository at this point in the history
  • Loading branch information
libasys committed Sep 13, 2015
1 parent 5e1ff55 commit 344f7f6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions controller/calendarsettingscontroller.php
Expand Up @@ -188,6 +188,7 @@ public function getUserSettingsCalendar() {
$myCalendars[$calendar['id']]=[
'id'=> $calendar['id'],
'name'=>$calendar['displayname'],
'uri' => $calendar['uri'],
'issubscribe' => (int) $calendar['issubscribe'],
'permissions' => (int) $calendar['permissions'],
];
Expand Down
5 changes: 3 additions & 2 deletions controller/eventcontroller.php
Expand Up @@ -290,9 +290,9 @@ public function addCategorieToEvent() {
if(!array_key_exists($category, $aCatNew)){
$sCatNew.= ','.$category;
}
$vevent->setString('CATEGORIES', $sCatNew);
$vevent->CATEGORIES = $sCatNew;
}else{
$vevent->setString('CATEGORIES', $category);
$vevent->CATEGORIES = $category;
}

$vevent->setDateTime('LAST-MODIFIED', 'now');
Expand Down Expand Up @@ -1694,6 +1694,7 @@ public function generateEventOutput(array $event, $start, $end, $list = false) {
$isEventShared = $event['shared'];
}


$lastmodified = ($last_modified) ? $last_modified -> getDateTime() -> format('U') : 0;
$staticoutput = array(
'id' => (int)$event['id'],
Expand Down
6 changes: 4 additions & 2 deletions controller/exportcontroller.php
Expand Up @@ -49,6 +49,8 @@ public function __construct($appName, IRequest $request, $userId, $l10n, IConfig
$this->configInfo = $settings;
}



/**
*@PublicPage
* @NoCSRFRequired
Expand All @@ -62,7 +64,7 @@ public function exportEvents(){
if (isset($token)) {

$linkItem = \OCP\Share::getShareByToken($token, false);
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
if (is_array($linkItem) && isset($linkItem['uid_owner']) && !isset($linkItem['share_with'])) {
$rootLinkItem = \OCP\Share::resolveReShare($linkItem);

if (isset($rootLinkItem['uid_owner'])) {
Expand Down Expand Up @@ -113,7 +115,7 @@ public function exportEvents(){
$calendarEvents = Export::export($calid, Export::CALENDAR);

$response = new DataDownloadResponse($calendarEvents, $name, 'text/calendar');

$response->addHeader('last-modified',$calendar['lastmodifieddate']);
return $response;

}
Expand Down
35 changes: 34 additions & 1 deletion lib/connector/calendarconnector.php
Expand Up @@ -91,7 +91,23 @@ public function addObject($calendarId, $objectUri, $calendarData, $bLogActivity

$object = $objectParser -> parse($calendarData);
list($type, $startdate, $enddate, $summary, $repeating, $uid, $isAlarm, $relatedTo) = $objectParser -> extractData($object);


//Thunderbird fix multiple categories
$vevent = $object->VEVENT;
if(isset($vevent->CATEGORIES) && count($vevent->CATEGORIES) > 1){
$sCat ='';
foreach($vevent->CATEGORIES as $key => $val){
if($sCat === ''){
$sCat .= $val;
}else{
$sCat .= ','.$val;
}
}
unset($vevent->CATEGORIES);
$vevent->CATEGORIES = $sCat;
$calendarData = $object->serialize();
}

$eventDB = new EventDAO($this -> db, $this -> userId, null);
$object_id = $eventDB -> add($calendarId, $type, $startdate, $enddate, $repeating, $summary, $calendarData, $objectUri, time(), $isAlarm, $uid, $relatedTo, 0, $this -> userId);

Expand Down Expand Up @@ -151,6 +167,23 @@ public function updateObject($cid, $uri, $data, $bLogActivity = true) {
}
$object = $objectParser -> parse($data);
list($type, $startdate, $enddate, $summary, $repeating, $uid, $isAlarm, $relatedTo) = $objectParser -> extractData($object);

//Thunderbird fix
$vevent = $object->VEVENT;
if(isset($vevent->CATEGORIES) && count($vevent->CATEGORIES) > 1){
$sCat ='';
foreach($vevent->CATEGORIES as $key => $val){
if($sCat === ''){
$sCat .= $val;
}else{
$sCat .= ','.$val;
}
}
unset($vevent->CATEGORIES);
$vevent->CATEGORIES = $sCat;
$data = $object->serialize();
}


$eventDB = new EventDAO($this -> db, $this -> userId, null);
$eventDB -> update($type, $startdate, $enddate, $repeating, $summary, $data, time(), $isAlarm, $uid, $relatedTo, $oldobject['id']);
Expand Down

0 comments on commit 344f7f6

Please sign in to comment.