Passed
Push — master ( 7e8ddc...b908db )
by Christoph
14:53 queued 12s
created
apps/dav/lib/CalDAV/Trashbin/Plugin.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -39,70 +39,70 @@
 block discarded – undo
39 39
 use function implode;
40 40
 
41 41
 class Plugin extends ServerPlugin {
42
-	public const PROPERTY_DELETED_AT = '{http://nextcloud.com/ns}deleted-at';
43
-
44
-	/** @var bool */
45
-	private $disableTrashbin;
46
-
47
-	/** @var Server */
48
-	private $server;
49
-
50
-	public function __construct(IRequest $request) {
51
-		$this->disableTrashbin = $request->getHeader('X-NC-CalDAV-No-Trashbin') === '1';
52
-	}
53
-
54
-	public function initialize(Server $server): void {
55
-		$this->server = $server;
56
-		$server->on('beforeMethod:*', [$this, 'beforeMethod']);
57
-		$server->on('propFind', Closure::fromCallable([$this, 'propFind']));
58
-	}
59
-
60
-	public function beforeMethod(RequestInterface $request, ResponseInterface $response): void {
61
-		if (!$this->disableTrashbin) {
62
-			return;
63
-		}
64
-
65
-		$path = $request->getPath();
66
-		$pathParts = explode('/', ltrim($path, '/'));
67
-		if (\count($pathParts) < 3) {
68
-			// We are looking for a path like calendars/username/calendarname
69
-			return;
70
-		}
71
-
72
-		// $calendarPath will look like calendars/username/calendarname
73
-		$calendarPath = implode(
74
-			'/',
75
-			array_slice($pathParts, 0, 3)
76
-		);
77
-		try {
78
-			$calendar = $this->server->tree->getNodeForPath($calendarPath);
79
-			if (!($calendar instanceof Calendar)) {
80
-				// This is odd
81
-				return;
82
-			}
83
-
84
-			/** @var Calendar $calendar */
85
-			$calendar->disableTrashbin();
86
-		} catch (NotFound $ex) {
87
-			return;
88
-		}
89
-	}
90
-
91
-	private function propFind(
92
-		PropFind $propFind,
93
-		INode $node): void {
94
-		if ($node instanceof DeletedCalendarObject) {
95
-			$propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) {
96
-				return $node->getDeletedAt();
97
-			});
98
-		}
99
-	}
100
-
101
-	public function getFeatures(): array {
102
-		return ['nc-calendar-trashbin'];
103
-	}
104
-
105
-	public function getPluginName(): string {
106
-		return 'nc-calendar-trashbin';
107
-	}
42
+    public const PROPERTY_DELETED_AT = '{http://nextcloud.com/ns}deleted-at';
43
+
44
+    /** @var bool */
45
+    private $disableTrashbin;
46
+
47
+    /** @var Server */
48
+    private $server;
49
+
50
+    public function __construct(IRequest $request) {
51
+        $this->disableTrashbin = $request->getHeader('X-NC-CalDAV-No-Trashbin') === '1';
52
+    }
53
+
54
+    public function initialize(Server $server): void {
55
+        $this->server = $server;
56
+        $server->on('beforeMethod:*', [$this, 'beforeMethod']);
57
+        $server->on('propFind', Closure::fromCallable([$this, 'propFind']));
58
+    }
59
+
60
+    public function beforeMethod(RequestInterface $request, ResponseInterface $response): void {
61
+        if (!$this->disableTrashbin) {
62
+            return;
63
+        }
64
+
65
+        $path = $request->getPath();
66
+        $pathParts = explode('/', ltrim($path, '/'));
67
+        if (\count($pathParts) < 3) {
68
+            // We are looking for a path like calendars/username/calendarname
69
+            return;
70
+        }
71
+
72
+        // $calendarPath will look like calendars/username/calendarname
73
+        $calendarPath = implode(
74
+            '/',
75
+            array_slice($pathParts, 0, 3)
76
+        );
77
+        try {
78
+            $calendar = $this->server->tree->getNodeForPath($calendarPath);
79
+            if (!($calendar instanceof Calendar)) {
80
+                // This is odd
81
+                return;
82
+            }
83
+
84
+            /** @var Calendar $calendar */
85
+            $calendar->disableTrashbin();
86
+        } catch (NotFound $ex) {
87
+            return;
88
+        }
89
+    }
90
+
91
+    private function propFind(
92
+        PropFind $propFind,
93
+        INode $node): void {
94
+        if ($node instanceof DeletedCalendarObject) {
95
+            $propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) {
96
+                return $node->getDeletedAt();
97
+            });
98
+        }
99
+    }
100
+
101
+    public function getFeatures(): array {
102
+        return ['nc-calendar-trashbin'];
103
+    }
104
+
105
+    public function getPluginName(): string {
106
+        return 'nc-calendar-trashbin';
107
+    }
108 108
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
 		PropFind $propFind,
93 93
 		INode $node): void {
94 94
 		if ($node instanceof DeletedCalendarObject) {
95
-			$propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) {
95
+			$propFind->handle(self::PROPERTY_DELETED_AT, function() use ($node) {
96 96
 				return $node->getDeletedAt();
97 97
 			});
98 98
 		}
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -32,69 +32,69 @@
 block discarded – undo
32 32
 
33 33
 class DeletedCalendarObject implements ICalendarObject, IRestorable {
34 34
 
35
-	/** @var string */
36
-	private $name;
37
-
38
-	/** @var mixed[] */
39
-	private $objectData;
40
-
41
-	/** @var CalDavBackend */
42
-	private $calDavBackend;
43
-
44
-	public function __construct(string $name,
45
-								array $objectData,
46
-								CalDavBackend $calDavBackend) {
47
-		$this->name = $name;
48
-		$this->objectData = $objectData;
49
-		$this->calDavBackend = $calDavBackend;
50
-	}
51
-
52
-	public function delete() {
53
-		throw new Forbidden();
54
-	}
55
-
56
-	public function getName() {
57
-		return $this->name;
58
-	}
59
-
60
-	public function setName($name) {
61
-		throw new Forbidden();
62
-	}
63
-
64
-	public function getLastModified() {
65
-		return 0;
66
-	}
67
-
68
-	public function put($data) {
69
-		throw new Forbidden();
70
-	}
71
-
72
-	public function get() {
73
-		return $this->objectData['calendardata'];
74
-	}
75
-
76
-	public function getContentType() {
77
-		$mime = 'text/calendar; charset=utf-8';
78
-		if (isset($this->objectData['component']) && $this->objectData['component']) {
79
-			$mime .= '; component='.$this->objectData['component'];
80
-		}
81
-
82
-		return $mime;
83
-	}
84
-
85
-	public function getETag() {
86
-		return $this->objectData['etag'];
87
-	}
88
-
89
-	public function getSize() {
90
-		return (int) $this->objectData['size'];
91
-	}
92
-
93
-	public function restore(): void {
94
-		$this->calDavBackend->restoreCalendarObject($this->objectData);
95
-	}
96
-
97
-	public function getDeletedAt(): ?int {
98
-		return $this->objectData['deleted_at'] ? (int) $this->objectData['deleted_at'] : null;
99
-	}
35
+    /** @var string */
36
+    private $name;
37
+
38
+    /** @var mixed[] */
39
+    private $objectData;
40
+
41
+    /** @var CalDavBackend */
42
+    private $calDavBackend;
43
+
44
+    public function __construct(string $name,
45
+                                array $objectData,
46
+                                CalDavBackend $calDavBackend) {
47
+        $this->name = $name;
48
+        $this->objectData = $objectData;
49
+        $this->calDavBackend = $calDavBackend;
50
+    }
51
+
52
+    public function delete() {
53
+        throw new Forbidden();
54
+    }
55
+
56
+    public function getName() {
57
+        return $this->name;
58
+    }
59
+
60
+    public function setName($name) {
61
+        throw new Forbidden();
62
+    }
63
+
64
+    public function getLastModified() {
65
+        return 0;
66
+    }
67
+
68
+    public function put($data) {
69
+        throw new Forbidden();
70
+    }
71
+
72
+    public function get() {
73
+        return $this->objectData['calendardata'];
74
+    }
75
+
76
+    public function getContentType() {
77
+        $mime = 'text/calendar; charset=utf-8';
78
+        if (isset($this->objectData['component']) && $this->objectData['component']) {
79
+            $mime .= '; component='.$this->objectData['component'];
80
+        }
81
+
82
+        return $mime;
83
+    }
84
+
85
+    public function getETag() {
86
+        return $this->objectData['etag'];
87
+    }
88
+
89
+    public function getSize() {
90
+        return (int) $this->objectData['size'];
91
+    }
92
+
93
+    public function restore(): void {
94
+        $this->calDavBackend->restoreCalendarObject($this->objectData);
95
+    }
96
+
97
+    public function getDeletedAt(): ?int {
98
+        return $this->objectData['deleted_at'] ? (int) $this->objectData['deleted_at'] : null;
99
+    }
100 100
 }
Please login to merge, or discard this patch.