Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only VEVENT for birthday calendar and default order to 1 #28011

Merged
merged 2 commits into from Jul 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -19,44 +19,26 @@
*
*/

namespace OCA\DAV\Migration;
namespace OCA\DAV\Migrations;

use OCA\DAV\CalDAV\BirthdayService;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\Migration\ISimpleMigration;

class FixBirthdayCalendarComponent implements IRepairStep {

/** @var IDBConnection */
private $connection;

/**
* FixBirthdayCalendarComponent constructor.
*
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}

/**
* @inheritdoc
*/
public function getName() {
return 'Fix component of birthday calendars';
}
/**
* Fix the calendar components of the system contact birthday calendar
*/
class Version20170526100342 implements ISimpleMigration {

/**
* @inheritdoc
*/
public function run(IOutput $output) {
$query = $this->connection->getQueryBuilder();
public function run(IOutput $out) {
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$updated = $query->update('calendars')
->set('components', $query->createNamedParameter('VEVENT'))
->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
->set('calendarorder', $query->createNamedParameter('100'))
->where($query->expr()->eq(
'uri',
$query->createNamedParameter('contact_birthdays')))
->execute();

$output->info("$updated birthday calendars updated.");
$out->info("$updated birthday calendars updated.");
}
}
7 changes: 1 addition & 6 deletions apps/dav/appinfo/info.xml
Expand Up @@ -5,7 +5,7 @@
<description>ownCloud WebDAV endpoint</description>
<licence>AGPL</licence>
<author>owncloud.org</author>
<version>0.2.9</version>
<version>0.3.0</version>
<default_enable/>
<use-migrations>true</use-migrations>
<types>
Expand All @@ -21,11 +21,6 @@
<background-jobs>
<job>OCA\DAV\CardDAV\SyncJob</job>
</background-jobs>
<repair-steps>
<post-migration>
<step>OCA\DAV\Migration\FixBirthdayCalendarComponent</step>
</post-migration>
</repair-steps>
<commands>
<command>OCA\DAV\Command\CreateAddressBook</command>
<command>OCA\DAV\Command\CreateCalendar</command>
Expand Down
4 changes: 3 additions & 1 deletion apps/dav/lib/CalDAV/BirthdayService.php
Expand Up @@ -25,6 +25,7 @@
use Exception;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\DAV\GroupPrincipalBackend;
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\DateTimeParser;
Expand Down Expand Up @@ -106,7 +107,8 @@ public function ensureCalendarExists($principal) {
$this->calDavBackEnd->createCalendar($principal, self::BIRTHDAY_CALENDAR_URI, [
'{DAV:}displayname' => 'Contact birthdays',
'{http://apple.com/ns/ical/}calendar-color' => '#FFFFCA',
'components' => 'VEVENT',
'{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VEVENT']),
'{http://apple.com/ns/ical/}calendar-order' => 100
]);

return $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI);
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Expand Up @@ -532,7 +532,7 @@ public function getCalendarById($calendarId) {
*
* @param string $principalUri
* @param string $calendarUri
* @param array $properties
* @param array $properties (keys must be CalDAV properties not db names)
* @return int
* @throws DAV\Exception
*/
Expand All @@ -544,7 +544,7 @@ function createCalendar($principalUri, $calendarUri, array $properties) {
'synctoken' => 1,
'transparent' => 0,
'components' => 'VEVENT,VTODO',
'displayname' => $calendarUri
'displayname' => $calendarUri,
];

// Default value
Expand Down
4 changes: 3 additions & 1 deletion apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
Expand Up @@ -26,6 +26,7 @@
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\DAV\GroupPrincipalBackend;
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Reader;
use Test\TestCase;
Expand Down Expand Up @@ -199,7 +200,8 @@ public function testBirthdayCalendarHasComponentEvent() {
->with('principal001', 'contact_birthdays', [
'{DAV:}displayname' => 'Contact birthdays',
'{http://apple.com/ns/ical/}calendar-color' => '#FFFFCA',
'components' => 'VEVENT',
'{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VEVENT']),
'{http://apple.com/ns/ical/}calendar-order' => 100
]);
$this->service->ensureCalendarExists('principal001');
}
Expand Down