summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-05-31 17:16:28 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-06-09 11:09:14 +0200
commit082f456b8b835efc3fa37af7e1628da8d5781331 (patch)
tree9db3aee4f5b04f04cacfc91a647cfc1c61b9ef2b /apps/dav/lib
parent369c3b5d7e6d3bae4fae87338cfd3d90f0c72810 (diff)
downloadnextcloud-server-082f456b8b835efc3fa37af7e1628da8d5781331.tar.gz
nextcloud-server-082f456b8b835efc3fa37af7e1628da8d5781331.zip
Added unit testing for the migration step
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php14
-rw-r--r--apps/dav/lib/Migration/Classification.php2
2 files changed, 12 insertions, 4 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 30cfae39fa4..1950b87df34 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -489,7 +489,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
*/
function getCalendarObjects($calendarId) {
$query = $this->db->getQueryBuilder();
- $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'componenttype'])
+ $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'componenttype', 'classification'])
->from('calendarobjects')
->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)));
$stmt = $query->execute();
@@ -504,6 +504,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'calendarid' => $row['calendarid'],
'size' => (int)$row['size'],
'component' => strtolower($row['componenttype']),
+ 'classification'=> $row['classification']
];
}
@@ -529,7 +530,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
function getCalendarObject($calendarId, $objectUri) {
$query = $this->db->getQueryBuilder();
- $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype'])
+ $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
->from('calendarobjects')
->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)));
@@ -547,6 +548,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'size' => (int)$row['size'],
'calendardata' => $this->readBlob($row['calendardata']),
'component' => strtolower($row['componenttype']),
+ 'classification'=> $row['classification']
];
}
@@ -564,7 +566,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
*/
function getMultipleCalendarObjects($calendarId, array $uris) {
$query = $this->db->getQueryBuilder();
- $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype'])
+ $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
->from('calendarobjects')
->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
->andWhere($query->expr()->in('uri', $query->createParameter('uri')))
@@ -584,6 +586,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'size' => (int)$row['size'],
'calendardata' => $this->readBlob($row['calendardata']),
'component' => strtolower($row['componenttype']),
+ 'classification' => $row['classification']
];
}
@@ -679,6 +682,11 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
* @param int $classification
*/
public function setClassification($calendarObjectId, $classification) {
+ if (!in_array($classification, [
+ self::CLASSIFICATION_PUBLIC, self::CLASSIFICATION_PRIVATE, self::CLASSIFICATION_CONFIDENTIAL
+ ])) {
+ throw new \InvalidArgumentException();
+ }
$query = $this->db->getQueryBuilder();
$query->update('calendarobjects')
->set('classification', $query->createNamedParameter($classification))
diff --git a/apps/dav/lib/Migration/Classification.php b/apps/dav/lib/Migration/Classification.php
index 13ceca6fea6..b793f790af5 100644
--- a/apps/dav/lib/Migration/Classification.php
+++ b/apps/dav/lib/Migration/Classification.php
@@ -55,7 +55,7 @@ class Classification implements IRepairStep {
foreach ($calendars as $calendar) {
$objects = $this->calDavBackend->getCalendarObjects($calendar['id']);
foreach ($objects as $object) {
- $calObject = $this->calDavBackend->getCalendarObject($calendar['id'], $object['id']);
+ $calObject = $this->calDavBackend->getCalendarObject($calendar['id'], $object['uri']);
$classification = $this->extractClassification($calObject['calendardata']);
$this->calDavBackend->setClassification($object['id'], $classification);
}