Passed
Push — master ( 6578a9...ac4ff6 )
by Christoph
16:15 queued 12s
created
apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -33,104 +33,104 @@
 block discarded – undo
33 33
 use Sabre\DAVACL\IACL;
34 34
 
35 35
 class DeletedCalendarObject implements IACL, ICalendarObject, IRestorable {
36
-	use ACLTrait;
37
-
38
-	/** @var string */
39
-	private $name;
40
-
41
-	/** @var mixed[] */
42
-	private $objectData;
43
-
44
-	/** @var string */
45
-	private $principalUri;
46
-
47
-	/** @var CalDavBackend */
48
-	private $calDavBackend;
49
-
50
-	public function __construct(string $name,
51
-								array $objectData,
52
-								string $principalUri,
53
-								CalDavBackend $calDavBackend) {
54
-		$this->name = $name;
55
-		$this->objectData = $objectData;
56
-		$this->calDavBackend = $calDavBackend;
57
-		$this->principalUri = $principalUri;
58
-	}
59
-
60
-	public function delete() {
61
-		$this->calDavBackend->deleteCalendarObject(
62
-			$this->objectData['calendarid'],
63
-			$this->objectData['uri'],
64
-			CalDavBackend::CALENDAR_TYPE_CALENDAR,
65
-			true
66
-		);
67
-	}
68
-
69
-	public function getName() {
70
-		return $this->name;
71
-	}
72
-
73
-	public function setName($name) {
74
-		throw new Forbidden();
75
-	}
76
-
77
-	public function getLastModified() {
78
-		return 0;
79
-	}
80
-
81
-	public function put($data) {
82
-		throw new Forbidden();
83
-	}
84
-
85
-	public function get() {
86
-		return $this->objectData['calendardata'];
87
-	}
88
-
89
-	public function getContentType() {
90
-		$mime = 'text/calendar; charset=utf-8';
91
-		if (isset($this->objectData['component']) && $this->objectData['component']) {
92
-			$mime .= '; component='.$this->objectData['component'];
93
-		}
94
-
95
-		return $mime;
96
-	}
97
-
98
-	public function getETag() {
99
-		return $this->objectData['etag'];
100
-	}
101
-
102
-	public function getSize() {
103
-		return (int) $this->objectData['size'];
104
-	}
105
-
106
-	public function restore(): void {
107
-		$this->calDavBackend->restoreCalendarObject($this->objectData);
108
-	}
109
-
110
-	public function getDeletedAt(): ?int {
111
-		return $this->objectData['deleted_at'] ? (int) $this->objectData['deleted_at'] : null;
112
-	}
113
-
114
-	public function getCalendarUri(): string {
115
-		return $this->objectData['calendaruri'];
116
-	}
117
-
118
-	public function getACL(): array {
119
-		return [
120
-			[
121
-				'privilege' => '{DAV:}read', // For queries
122
-				'principal' => $this->getOwner(),
123
-				'protected' => true,
124
-			],
125
-			[
126
-				'privilege' => '{DAV:}unbind', // For moving and deletion
127
-				'principal' => '{DAV:}owner',
128
-				'protected' => true,
129
-			],
130
-		];
131
-	}
132
-
133
-	public function getOwner() {
134
-		return $this->principalUri;
135
-	}
36
+    use ACLTrait;
37
+
38
+    /** @var string */
39
+    private $name;
40
+
41
+    /** @var mixed[] */
42
+    private $objectData;
43
+
44
+    /** @var string */
45
+    private $principalUri;
46
+
47
+    /** @var CalDavBackend */
48
+    private $calDavBackend;
49
+
50
+    public function __construct(string $name,
51
+                                array $objectData,
52
+                                string $principalUri,
53
+                                CalDavBackend $calDavBackend) {
54
+        $this->name = $name;
55
+        $this->objectData = $objectData;
56
+        $this->calDavBackend = $calDavBackend;
57
+        $this->principalUri = $principalUri;
58
+    }
59
+
60
+    public function delete() {
61
+        $this->calDavBackend->deleteCalendarObject(
62
+            $this->objectData['calendarid'],
63
+            $this->objectData['uri'],
64
+            CalDavBackend::CALENDAR_TYPE_CALENDAR,
65
+            true
66
+        );
67
+    }
68
+
69
+    public function getName() {
70
+        return $this->name;
71
+    }
72
+
73
+    public function setName($name) {
74
+        throw new Forbidden();
75
+    }
76
+
77
+    public function getLastModified() {
78
+        return 0;
79
+    }
80
+
81
+    public function put($data) {
82
+        throw new Forbidden();
83
+    }
84
+
85
+    public function get() {
86
+        return $this->objectData['calendardata'];
87
+    }
88
+
89
+    public function getContentType() {
90
+        $mime = 'text/calendar; charset=utf-8';
91
+        if (isset($this->objectData['component']) && $this->objectData['component']) {
92
+            $mime .= '; component='.$this->objectData['component'];
93
+        }
94
+
95
+        return $mime;
96
+    }
97
+
98
+    public function getETag() {
99
+        return $this->objectData['etag'];
100
+    }
101
+
102
+    public function getSize() {
103
+        return (int) $this->objectData['size'];
104
+    }
105
+
106
+    public function restore(): void {
107
+        $this->calDavBackend->restoreCalendarObject($this->objectData);
108
+    }
109
+
110
+    public function getDeletedAt(): ?int {
111
+        return $this->objectData['deleted_at'] ? (int) $this->objectData['deleted_at'] : null;
112
+    }
113
+
114
+    public function getCalendarUri(): string {
115
+        return $this->objectData['calendaruri'];
116
+    }
117
+
118
+    public function getACL(): array {
119
+        return [
120
+            [
121
+                'privilege' => '{DAV:}read', // For queries
122
+                'principal' => $this->getOwner(),
123
+                'protected' => true,
124
+            ],
125
+            [
126
+                'privilege' => '{DAV:}unbind', // For moving and deletion
127
+                'principal' => '{DAV:}owner',
128
+                'protected' => true,
129
+            ],
130
+        ];
131
+    }
132
+
133
+    public function getOwner() {
134
+        return $this->principalUri;
135
+    }
136 136
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObjectsCollection.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -36,97 +36,97 @@
 block discarded – undo
36 36
 use function preg_match;
37 37
 
38 38
 class DeletedCalendarObjectsCollection implements ICalendarObjectContainer {
39
-	public const NAME = 'objects';
40
-
41
-	/** @var CalDavBackend */
42
-	protected $caldavBackend;
43
-
44
-	/** @var mixed[] */
45
-	private $principalInfo;
46
-
47
-	public function __construct(CalDavBackend $caldavBackend,
48
-								array $principalInfo) {
49
-		$this->caldavBackend = $caldavBackend;
50
-		$this->principalInfo = $principalInfo;
51
-	}
52
-
53
-	/**
54
-	 * @see \OCA\DAV\CalDAV\Trashbin\DeletedCalendarObjectsCollection::calendarQuery
55
-	 */
56
-	public function getChildren() {
57
-		throw new NotImplemented();
58
-	}
59
-
60
-	public function getChild($name) {
61
-		if (!preg_match("/(\d+)\\.ics/", $name, $matches)) {
62
-			throw new NotFound();
63
-		}
64
-
65
-		$data = $this->caldavBackend->getCalendarObjectById(
66
-			$this->principalInfo['uri'],
67
-			(int) $matches[1],
68
-		);
69
-
70
-		// If the object hasn't been deleted yet then we don't want to find it here
71
-		if ($data === null) {
72
-			throw new NotFound();
73
-		}
74
-		if (!isset($data['deleted_at'])) {
75
-			throw new BadRequest('The calendar object you\'re trying to restore is not marked as deleted');
76
-		}
77
-
78
-		return new DeletedCalendarObject(
79
-			$this->getRelativeObjectPath($data),
80
-			$data,
81
-			$this->principalInfo['uri'],
82
-			$this->caldavBackend
83
-		);
84
-	}
85
-
86
-	public function createFile($name, $data = null) {
87
-		throw new Forbidden();
88
-	}
89
-
90
-	public function createDirectory($name) {
91
-		throw new Forbidden();
92
-	}
93
-
94
-	public function childExists($name) {
95
-		try {
96
-			$this->getChild($name);
97
-		} catch (NotFound $e) {
98
-			return false;
99
-		}
100
-
101
-		return true;
102
-	}
103
-
104
-	public function delete() {
105
-		throw new Forbidden();
106
-	}
107
-
108
-	public function getName(): string {
109
-		return self::NAME;
110
-	}
111
-
112
-	public function setName($name) {
113
-		throw new Forbidden();
114
-	}
115
-
116
-	public function getLastModified(): int {
117
-		return 0;
118
-	}
119
-
120
-	public function calendarQuery(array $filters) {
121
-		return array_map(function (array $calendarObjectInfo) {
122
-			return $this->getRelativeObjectPath($calendarObjectInfo);
123
-		}, $this->caldavBackend->getDeletedCalendarObjectsByPrincipal($this->principalInfo['uri']));
124
-	}
125
-
126
-	private function getRelativeObjectPath(array $calendarInfo): string {
127
-		return implode(
128
-			'.',
129
-			[$calendarInfo['id'], 'ics'],
130
-		);
131
-	}
39
+    public const NAME = 'objects';
40
+
41
+    /** @var CalDavBackend */
42
+    protected $caldavBackend;
43
+
44
+    /** @var mixed[] */
45
+    private $principalInfo;
46
+
47
+    public function __construct(CalDavBackend $caldavBackend,
48
+                                array $principalInfo) {
49
+        $this->caldavBackend = $caldavBackend;
50
+        $this->principalInfo = $principalInfo;
51
+    }
52
+
53
+    /**
54
+     * @see \OCA\DAV\CalDAV\Trashbin\DeletedCalendarObjectsCollection::calendarQuery
55
+     */
56
+    public function getChildren() {
57
+        throw new NotImplemented();
58
+    }
59
+
60
+    public function getChild($name) {
61
+        if (!preg_match("/(\d+)\\.ics/", $name, $matches)) {
62
+            throw new NotFound();
63
+        }
64
+
65
+        $data = $this->caldavBackend->getCalendarObjectById(
66
+            $this->principalInfo['uri'],
67
+            (int) $matches[1],
68
+        );
69
+
70
+        // If the object hasn't been deleted yet then we don't want to find it here
71
+        if ($data === null) {
72
+            throw new NotFound();
73
+        }
74
+        if (!isset($data['deleted_at'])) {
75
+            throw new BadRequest('The calendar object you\'re trying to restore is not marked as deleted');
76
+        }
77
+
78
+        return new DeletedCalendarObject(
79
+            $this->getRelativeObjectPath($data),
80
+            $data,
81
+            $this->principalInfo['uri'],
82
+            $this->caldavBackend
83
+        );
84
+    }
85
+
86
+    public function createFile($name, $data = null) {
87
+        throw new Forbidden();
88
+    }
89
+
90
+    public function createDirectory($name) {
91
+        throw new Forbidden();
92
+    }
93
+
94
+    public function childExists($name) {
95
+        try {
96
+            $this->getChild($name);
97
+        } catch (NotFound $e) {
98
+            return false;
99
+        }
100
+
101
+        return true;
102
+    }
103
+
104
+    public function delete() {
105
+        throw new Forbidden();
106
+    }
107
+
108
+    public function getName(): string {
109
+        return self::NAME;
110
+    }
111
+
112
+    public function setName($name) {
113
+        throw new Forbidden();
114
+    }
115
+
116
+    public function getLastModified(): int {
117
+        return 0;
118
+    }
119
+
120
+    public function calendarQuery(array $filters) {
121
+        return array_map(function (array $calendarObjectInfo) {
122
+            return $this->getRelativeObjectPath($calendarObjectInfo);
123
+        }, $this->caldavBackend->getDeletedCalendarObjectsByPrincipal($this->principalInfo['uri']));
124
+    }
125
+
126
+    private function getRelativeObjectPath(array $calendarInfo): string {
127
+        return implode(
128
+            '.',
129
+            [$calendarInfo['id'], 'ics'],
130
+        );
131
+    }
132 132
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@
 block discarded – undo
118 118
 	}
119 119
 
120 120
 	public function calendarQuery(array $filters) {
121
-		return array_map(function (array $calendarObjectInfo) {
121
+		return array_map(function(array $calendarObjectInfo) {
122 122
 			return $this->getRelativeObjectPath($calendarObjectInfo);
123 123
 		}, $this->caldavBackend->getDeletedCalendarObjectsByPrincipal($this->principalInfo['uri']));
124 124
 	}
Please login to merge, or discard this patch.