Passed
Push — master ( 873501...d2df81 )
by Maxence
14:59 queued 12s
created
apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @return boolean
107 107
 	 */
108 108
 	public function httpGet(RequestInterface $request, ResponseInterface $response):bool {
109
-		if ($request->getPath() !== 'provisioning/' . AppleProvisioningNode::FILENAME) {
109
+		if ($request->getPath() !== 'provisioning/'.AppleProvisioningNode::FILENAME) {
110 110
 			return true;
111 111
 		}
112 112
 
@@ -144,19 +144,19 @@  discard block
 block discarded – undo
144 144
 		$carddavUUID = call_user_func($this->uuidClosure);
145 145
 		$profileUUID = call_user_func($this->uuidClosure);
146 146
 
147
-		$caldavIdentifier = $reverseDomain . '.' . $caldavUUID;
148
-		$carddavIdentifier = $reverseDomain . '.' . $carddavUUID;
149
-		$profileIdentifier = $reverseDomain . '.' . $profileUUID;
147
+		$caldavIdentifier = $reverseDomain.'.'.$caldavUUID;
148
+		$carddavIdentifier = $reverseDomain.'.'.$carddavUUID;
149
+		$profileIdentifier = $reverseDomain.'.'.$profileUUID;
150 150
 
151 151
 		$caldavDescription = $this->l10n->t('Configures a CalDAV account');
152
-		$caldavDisplayname = $description . ' CalDAV';
152
+		$caldavDisplayname = $description.' CalDAV';
153 153
 		$carddavDescription = $this->l10n->t('Configures a CardDAV account');
154
-		$carddavDisplayname = $description . ' CardDAV';
154
+		$carddavDisplayname = $description.' CardDAV';
155 155
 
156
-		$filename = $userId . '-' . AppleProvisioningNode::FILENAME;
156
+		$filename = $userId.'-'.AppleProvisioningNode::FILENAME;
157 157
 
158 158
 		$xmlSkeleton = $this->getTemplate();
159
-		$body = vsprintf($xmlSkeleton, array_map(function ($v) {
159
+		$body = vsprintf($xmlSkeleton, array_map(function($v) {
160 160
 			return \htmlspecialchars($v, ENT_XML1, 'UTF-8');
161 161
 		}, [
162 162
 			$description,
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		));
183 183
 
184 184
 		$response->setStatus(200);
185
-		$response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
185
+		$response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"');
186 186
 		$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
187 187
 		$response->setBody($body);
188 188
 
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -36,162 +36,162 @@  discard block
 block discarded – undo
36 36
 use Sabre\HTTP\ResponseInterface;
37 37
 
38 38
 class AppleProvisioningPlugin extends ServerPlugin {
39
-	/**
40
-	 * @var Server
41
-	 */
42
-	protected $server;
39
+    /**
40
+     * @var Server
41
+     */
42
+    protected $server;
43 43
 
44
-	/**
45
-	 * @var IURLGenerator
46
-	 */
47
-	protected $urlGenerator;
44
+    /**
45
+     * @var IURLGenerator
46
+     */
47
+    protected $urlGenerator;
48 48
 
49
-	/**
50
-	 * @var IUserSession
51
-	 */
52
-	protected $userSession;
49
+    /**
50
+     * @var IUserSession
51
+     */
52
+    protected $userSession;
53 53
 
54
-	/**
55
-	 * @var \OC_Defaults
56
-	 */
57
-	protected $themingDefaults;
54
+    /**
55
+     * @var \OC_Defaults
56
+     */
57
+    protected $themingDefaults;
58 58
 
59
-	/**
60
-	 * @var IRequest
61
-	 */
62
-	protected $request;
59
+    /**
60
+     * @var IRequest
61
+     */
62
+    protected $request;
63 63
 
64
-	/**
65
-	 * @var IL10N
66
-	 */
67
-	protected $l10n;
64
+    /**
65
+     * @var IL10N
66
+     */
67
+    protected $l10n;
68 68
 
69
-	/**
70
-	 * @var \Closure
71
-	 */
72
-	protected $uuidClosure;
69
+    /**
70
+     * @var \Closure
71
+     */
72
+    protected $uuidClosure;
73 73
 
74
-	/**
75
-	 * AppleProvisioningPlugin constructor.
76
-	 */
77
-	public function __construct(
78
-		IUserSession $userSession,
79
-		IURLGenerator $urlGenerator,
80
-		\OC_Defaults $themingDefaults,
81
-		IRequest $request,
82
-		IL10N $l10n,
83
-		\Closure $uuidClosure
84
-	) {
85
-		$this->userSession = $userSession;
86
-		$this->urlGenerator = $urlGenerator;
87
-		$this->themingDefaults = $themingDefaults;
88
-		$this->request = $request;
89
-		$this->l10n = $l10n;
90
-		$this->uuidClosure = $uuidClosure;
91
-	}
74
+    /**
75
+     * AppleProvisioningPlugin constructor.
76
+     */
77
+    public function __construct(
78
+        IUserSession $userSession,
79
+        IURLGenerator $urlGenerator,
80
+        \OC_Defaults $themingDefaults,
81
+        IRequest $request,
82
+        IL10N $l10n,
83
+        \Closure $uuidClosure
84
+    ) {
85
+        $this->userSession = $userSession;
86
+        $this->urlGenerator = $urlGenerator;
87
+        $this->themingDefaults = $themingDefaults;
88
+        $this->request = $request;
89
+        $this->l10n = $l10n;
90
+        $this->uuidClosure = $uuidClosure;
91
+    }
92 92
 
93
-	/**
94
-	 * @param Server $server
95
-	 */
96
-	public function initialize(Server $server) {
97
-		$this->server = $server;
98
-		$this->server->on('method:GET', [$this, 'httpGet'], 90);
99
-	}
93
+    /**
94
+     * @param Server $server
95
+     */
96
+    public function initialize(Server $server) {
97
+        $this->server = $server;
98
+        $this->server->on('method:GET', [$this, 'httpGet'], 90);
99
+    }
100 100
 
101
-	/**
102
-	 * @param RequestInterface $request
103
-	 * @param ResponseInterface $response
104
-	 * @return boolean
105
-	 */
106
-	public function httpGet(RequestInterface $request, ResponseInterface $response):bool {
107
-		if ($request->getPath() !== 'provisioning/' . AppleProvisioningNode::FILENAME) {
108
-			return true;
109
-		}
101
+    /**
102
+     * @param RequestInterface $request
103
+     * @param ResponseInterface $response
104
+     * @return boolean
105
+     */
106
+    public function httpGet(RequestInterface $request, ResponseInterface $response):bool {
107
+        if ($request->getPath() !== 'provisioning/' . AppleProvisioningNode::FILENAME) {
108
+            return true;
109
+        }
110 110
 
111
-		$user = $this->userSession->getUser();
112
-		if (!$user) {
113
-			return true;
114
-		}
111
+        $user = $this->userSession->getUser();
112
+        if (!$user) {
113
+            return true;
114
+        }
115 115
 
116
-		$serverProtocol = $this->request->getServerProtocol();
117
-		$useSSL = ($serverProtocol === 'https');
116
+        $serverProtocol = $this->request->getServerProtocol();
117
+        $useSSL = ($serverProtocol === 'https');
118 118
 
119
-		if (!$useSSL) {
120
-			$response->setStatus(200);
121
-			$response->setHeader('Content-Type', 'text/plain; charset=utf-8');
122
-			$response->setBody($this->l10n->t('Your %s needs to be configured to use HTTPS in order to use CalDAV and CardDAV with iOS/macOS.', [$this->themingDefaults->getName()]));
119
+        if (!$useSSL) {
120
+            $response->setStatus(200);
121
+            $response->setHeader('Content-Type', 'text/plain; charset=utf-8');
122
+            $response->setBody($this->l10n->t('Your %s needs to be configured to use HTTPS in order to use CalDAV and CardDAV with iOS/macOS.', [$this->themingDefaults->getName()]));
123 123
 
124
-			return false;
125
-		}
124
+            return false;
125
+        }
126 126
 
127
-		$absoluteURL = $this->urlGenerator->getBaseUrl();
128
-		$parsedUrl = parse_url($absoluteURL);
129
-		if (isset($parsedUrl['port'])) {
130
-			$serverPort = $parsedUrl['port'];
131
-		} else {
132
-			$serverPort = 443;
133
-		}
134
-		$server_url = $parsedUrl['host'];
127
+        $absoluteURL = $this->urlGenerator->getBaseUrl();
128
+        $parsedUrl = parse_url($absoluteURL);
129
+        if (isset($parsedUrl['port'])) {
130
+            $serverPort = $parsedUrl['port'];
131
+        } else {
132
+            $serverPort = 443;
133
+        }
134
+        $server_url = $parsedUrl['host'];
135 135
 
136
-		$description = $this->themingDefaults->getName();
137
-		$userId = $user->getUID();
136
+        $description = $this->themingDefaults->getName();
137
+        $userId = $user->getUID();
138 138
 
139
-		$reverseDomain = implode('.', array_reverse(explode('.', $parsedUrl['host'])));
139
+        $reverseDomain = implode('.', array_reverse(explode('.', $parsedUrl['host'])));
140 140
 
141
-		$caldavUUID = call_user_func($this->uuidClosure);
142
-		$carddavUUID = call_user_func($this->uuidClosure);
143
-		$profileUUID = call_user_func($this->uuidClosure);
141
+        $caldavUUID = call_user_func($this->uuidClosure);
142
+        $carddavUUID = call_user_func($this->uuidClosure);
143
+        $profileUUID = call_user_func($this->uuidClosure);
144 144
 
145
-		$caldavIdentifier = $reverseDomain . '.' . $caldavUUID;
146
-		$carddavIdentifier = $reverseDomain . '.' . $carddavUUID;
147
-		$profileIdentifier = $reverseDomain . '.' . $profileUUID;
145
+        $caldavIdentifier = $reverseDomain . '.' . $caldavUUID;
146
+        $carddavIdentifier = $reverseDomain . '.' . $carddavUUID;
147
+        $profileIdentifier = $reverseDomain . '.' . $profileUUID;
148 148
 
149
-		$caldavDescription = $this->l10n->t('Configures a CalDAV account');
150
-		$caldavDisplayname = $description . ' CalDAV';
151
-		$carddavDescription = $this->l10n->t('Configures a CardDAV account');
152
-		$carddavDisplayname = $description . ' CardDAV';
149
+        $caldavDescription = $this->l10n->t('Configures a CalDAV account');
150
+        $caldavDisplayname = $description . ' CalDAV';
151
+        $carddavDescription = $this->l10n->t('Configures a CardDAV account');
152
+        $carddavDisplayname = $description . ' CardDAV';
153 153
 
154
-		$filename = $userId . '-' . AppleProvisioningNode::FILENAME;
154
+        $filename = $userId . '-' . AppleProvisioningNode::FILENAME;
155 155
 
156
-		$xmlSkeleton = $this->getTemplate();
157
-		$body = vsprintf($xmlSkeleton, array_map(function ($v) {
158
-			return \htmlspecialchars($v, ENT_XML1, 'UTF-8');
159
-		}, [
160
-			$description,
161
-			$server_url,
162
-			$userId,
163
-			$serverPort,
164
-			$caldavDescription,
165
-			$caldavDisplayname,
166
-			$caldavIdentifier,
167
-			$caldavUUID,
168
-			$description,
169
-			$server_url,
170
-			$userId,
171
-			$serverPort,
172
-			$carddavDescription,
173
-			$carddavDisplayname,
174
-			$carddavIdentifier,
175
-			$carddavUUID,
176
-			$description,
177
-			$profileIdentifier,
178
-			$profileUUID
179
-		]
180
-		));
156
+        $xmlSkeleton = $this->getTemplate();
157
+        $body = vsprintf($xmlSkeleton, array_map(function ($v) {
158
+            return \htmlspecialchars($v, ENT_XML1, 'UTF-8');
159
+        }, [
160
+            $description,
161
+            $server_url,
162
+            $userId,
163
+            $serverPort,
164
+            $caldavDescription,
165
+            $caldavDisplayname,
166
+            $caldavIdentifier,
167
+            $caldavUUID,
168
+            $description,
169
+            $server_url,
170
+            $userId,
171
+            $serverPort,
172
+            $carddavDescription,
173
+            $carddavDisplayname,
174
+            $carddavIdentifier,
175
+            $carddavUUID,
176
+            $description,
177
+            $profileIdentifier,
178
+            $profileUUID
179
+        ]
180
+        ));
181 181
 
182
-		$response->setStatus(200);
183
-		$response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
184
-		$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
185
-		$response->setBody($body);
182
+        $response->setStatus(200);
183
+        $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
184
+        $response->setHeader('Content-Type', 'application/xml; charset=utf-8');
185
+        $response->setBody($body);
186 186
 
187
-		return false;
188
-	}
187
+        return false;
188
+    }
189 189
 
190
-	/**
191
-	 * @return string
192
-	 */
193
-	private function getTemplate():string {
194
-		return <<<EOF
190
+    /**
191
+     * @return string
192
+     */
193
+    private function getTemplate():string {
194
+        return <<<EOF
195 195
 <?xml version="1.0" encoding="UTF-8"?>
196 196
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
197 197
 <plist version="1.0">
@@ -263,5 +263,5 @@  discard block
 block discarded – undo
263 263
 </plist>
264 264
 
265 265
 EOF;
266
-	}
266
+    }
267 267
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Integration/ExternalCalendar.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -33,99 +33,99 @@
 block discarded – undo
33 33
  */
34 34
 abstract class ExternalCalendar implements CalDAV\ICalendar, DAV\IProperties {
35 35
 
36
-	/** @var string */
37
-	private const PREFIX = 'app-generated';
36
+    /** @var string */
37
+    private const PREFIX = 'app-generated';
38 38
 
39
-	/**
40
-	 * @var string
41
-	 *
42
-	 * Double dash is a valid delimiter,
43
-	 * because it will always split the calendarURIs correctly:
44
-	 * - our prefix contains only one dash and won't be split
45
-	 * - appIds are not allowed to contain dashes as per spec:
46
-	 * > must contain only lowercase ASCII characters and underscore
47
-	 * - explode has a limit of three, so even if the app-generated
48
-	 *   calendar uri has double dashes, it won't be split
49
-	 */
50
-	private const DELIMITER = '--';
39
+    /**
40
+     * @var string
41
+     *
42
+     * Double dash is a valid delimiter,
43
+     * because it will always split the calendarURIs correctly:
44
+     * - our prefix contains only one dash and won't be split
45
+     * - appIds are not allowed to contain dashes as per spec:
46
+     * > must contain only lowercase ASCII characters and underscore
47
+     * - explode has a limit of three, so even if the app-generated
48
+     *   calendar uri has double dashes, it won't be split
49
+     */
50
+    private const DELIMITER = '--';
51 51
 
52
-	/** @var string */
53
-	private $appId;
52
+    /** @var string */
53
+    private $appId;
54 54
 
55
-	/** @var string */
56
-	private $calendarUri;
55
+    /** @var string */
56
+    private $calendarUri;
57 57
 
58
-	/**
59
-	 * ExternalCalendar constructor.
60
-	 *
61
-	 * @param string $appId
62
-	 * @param string $calendarUri
63
-	 */
64
-	public function __construct(string $appId, string $calendarUri) {
65
-		$this->appId = $appId;
66
-		$this->calendarUri = $calendarUri;
67
-	}
58
+    /**
59
+     * ExternalCalendar constructor.
60
+     *
61
+     * @param string $appId
62
+     * @param string $calendarUri
63
+     */
64
+    public function __construct(string $appId, string $calendarUri) {
65
+        $this->appId = $appId;
66
+        $this->calendarUri = $calendarUri;
67
+    }
68 68
 
69
-	/**
70
-	 * @inheritDoc
71
-	 */
72
-	final public function getName() {
73
-		return implode(self::DELIMITER, [
74
-			self::PREFIX,
75
-			$this->appId,
76
-			$this->calendarUri,
77
-		]);
78
-	}
69
+    /**
70
+     * @inheritDoc
71
+     */
72
+    final public function getName() {
73
+        return implode(self::DELIMITER, [
74
+            self::PREFIX,
75
+            $this->appId,
76
+            $this->calendarUri,
77
+        ]);
78
+    }
79 79
 
80
-	/**
81
-	 * @inheritDoc
82
-	 */
83
-	final public function setName($name) {
84
-		throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported');
85
-	}
80
+    /**
81
+     * @inheritDoc
82
+     */
83
+    final public function setName($name) {
84
+        throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported');
85
+    }
86 86
 
87
-	/**
88
-	 * @inheritDoc
89
-	 */
90
-	final public function createDirectory($name) {
91
-		throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
92
-	}
87
+    /**
88
+     * @inheritDoc
89
+     */
90
+    final public function createDirectory($name) {
91
+        throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
92
+    }
93 93
 
94
-	/**
95
-	 * Checks whether the calendar uri is app-generated
96
-	 *
97
-	 * @param string $calendarUri
98
-	 * @return bool
99
-	 */
100
-	public static function isAppGeneratedCalendar(string $calendarUri):bool {
101
-		return strpos($calendarUri, self::PREFIX) === 0 && substr_count($calendarUri, self::DELIMITER) >= 2;
102
-	}
94
+    /**
95
+     * Checks whether the calendar uri is app-generated
96
+     *
97
+     * @param string $calendarUri
98
+     * @return bool
99
+     */
100
+    public static function isAppGeneratedCalendar(string $calendarUri):bool {
101
+        return strpos($calendarUri, self::PREFIX) === 0 && substr_count($calendarUri, self::DELIMITER) >= 2;
102
+    }
103 103
 
104
-	/**
105
-	 * Splits an app-generated calendar-uri into appId and calendarUri
106
-	 *
107
-	 * @param string $calendarUri
108
-	 * @return array
109
-	 */
110
-	public static function splitAppGeneratedCalendarUri(string $calendarUri):array {
111
-		$array = array_slice(explode(self::DELIMITER, $calendarUri, 3), 1);
112
-		// Check the array has expected amount of elements
113
-		// and none of them is an empty string
114
-		if (\count($array) !== 2 || \in_array('', $array, true)) {
115
-			throw new \InvalidArgumentException('Provided calendar uri was not app-generated');
116
-		}
104
+    /**
105
+     * Splits an app-generated calendar-uri into appId and calendarUri
106
+     *
107
+     * @param string $calendarUri
108
+     * @return array
109
+     */
110
+    public static function splitAppGeneratedCalendarUri(string $calendarUri):array {
111
+        $array = array_slice(explode(self::DELIMITER, $calendarUri, 3), 1);
112
+        // Check the array has expected amount of elements
113
+        // and none of them is an empty string
114
+        if (\count($array) !== 2 || \in_array('', $array, true)) {
115
+            throw new \InvalidArgumentException('Provided calendar uri was not app-generated');
116
+        }
117 117
 
118
-		return $array;
119
-	}
118
+        return $array;
119
+    }
120 120
 
121
-	/**
122
-	 * Checks whether a calendar-name, the user wants to create, violates
123
-	 * the reserved name for calendar uris
124
-	 *
125
-	 * @param string $calendarUri
126
-	 * @return bool
127
-	 */
128
-	public static function doesViolateReservedName(string $calendarUri):bool {
129
-		return strpos($calendarUri, self::PREFIX) === 0;
130
-	}
121
+    /**
122
+     * Checks whether a calendar-name, the user wants to create, violates
123
+     * the reserved name for calendar uris
124
+     *
125
+     * @param string $calendarUri
126
+     * @return bool
127
+     */
128
+    public static function doesViolateReservedName(string $calendarUri):bool {
129
+        return strpos($calendarUri, self::PREFIX) === 0;
130
+    }
131 131
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/CachedSubscription.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 			],
61 61
 			[
62 62
 				'privilege' => '{DAV:}read',
63
-				'principal' => $this->getOwner() . '/calendar-proxy-write',
63
+				'principal' => $this->getOwner().'/calendar-proxy-write',
64 64
 				'protected' => true,
65 65
 			],
66 66
 			[
67 67
 				'privilege' => '{DAV:}read',
68
-				'principal' => $this->getOwner() . '/calendar-proxy-read',
68
+				'principal' => $this->getOwner().'/calendar-proxy-read',
69 69
 				'protected' => true,
70 70
 			],
71 71
 			[
72
-				'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
72
+				'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy',
73 73
 				'principal' => '{DAV:}authenticated',
74 74
 				'protected' => true,
75 75
 			],
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 
90 90
 			[
91 91
 				'privilege' => '{DAV:}read',
92
-				'principal' => $this->getOwner() . '/calendar-proxy-write',
92
+				'principal' => $this->getOwner().'/calendar-proxy-write',
93 93
 				'protected' => true,
94 94
 			],
95 95
 			[
96 96
 				'privilege' => '{DAV:}read',
97
-				'principal' => $this->getOwner() . '/calendar-proxy-read',
97
+				'principal' => $this->getOwner().'/calendar-proxy-read',
98 98
 				'protected' => true,
99 99
 			],
100 100
 
Please login to merge, or discard this patch.
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -42,171 +42,171 @@
 block discarded – undo
42 42
  */
43 43
 class CachedSubscription extends \Sabre\CalDAV\Calendar {
44 44
 
45
-	/**
46
-	 * @return string
47
-	 */
48
-	public function getPrincipalURI():string {
49
-		return $this->calendarInfo['principaluri'];
50
-	}
51
-
52
-	/**
53
-	 * @return array
54
-	 */
55
-	public function getACL() {
56
-		return [
57
-			[
58
-				'privilege' => '{DAV:}read',
59
-				'principal' => $this->getOwner(),
60
-				'protected' => true,
61
-			],
62
-			[
63
-				'privilege' => '{DAV:}read',
64
-				'principal' => $this->getOwner() . '/calendar-proxy-write',
65
-				'protected' => true,
66
-			],
67
-			[
68
-				'privilege' => '{DAV:}read',
69
-				'principal' => $this->getOwner() . '/calendar-proxy-read',
70
-				'protected' => true,
71
-			],
72
-			[
73
-				'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
74
-				'principal' => '{DAV:}authenticated',
75
-				'protected' => true,
76
-			],
77
-		];
78
-	}
79
-
80
-	/**
81
-	 * @return array
82
-	 */
83
-	public function getChildACL() {
84
-		return [
85
-			[
86
-				'privilege' => '{DAV:}read',
87
-				'principal' => $this->getOwner(),
88
-				'protected' => true,
89
-			],
90
-
91
-			[
92
-				'privilege' => '{DAV:}read',
93
-				'principal' => $this->getOwner() . '/calendar-proxy-write',
94
-				'protected' => true,
95
-			],
96
-			[
97
-				'privilege' => '{DAV:}read',
98
-				'principal' => $this->getOwner() . '/calendar-proxy-read',
99
-				'protected' => true,
100
-			],
101
-
102
-		];
103
-	}
104
-
105
-	/**
106
-	 * @return null|string
107
-	 */
108
-	public function getOwner() {
109
-		if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
110
-			return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'];
111
-		}
112
-		return parent::getOwner();
113
-	}
45
+    /**
46
+     * @return string
47
+     */
48
+    public function getPrincipalURI():string {
49
+        return $this->calendarInfo['principaluri'];
50
+    }
51
+
52
+    /**
53
+     * @return array
54
+     */
55
+    public function getACL() {
56
+        return [
57
+            [
58
+                'privilege' => '{DAV:}read',
59
+                'principal' => $this->getOwner(),
60
+                'protected' => true,
61
+            ],
62
+            [
63
+                'privilege' => '{DAV:}read',
64
+                'principal' => $this->getOwner() . '/calendar-proxy-write',
65
+                'protected' => true,
66
+            ],
67
+            [
68
+                'privilege' => '{DAV:}read',
69
+                'principal' => $this->getOwner() . '/calendar-proxy-read',
70
+                'protected' => true,
71
+            ],
72
+            [
73
+                'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
74
+                'principal' => '{DAV:}authenticated',
75
+                'protected' => true,
76
+            ],
77
+        ];
78
+    }
79
+
80
+    /**
81
+     * @return array
82
+     */
83
+    public function getChildACL() {
84
+        return [
85
+            [
86
+                'privilege' => '{DAV:}read',
87
+                'principal' => $this->getOwner(),
88
+                'protected' => true,
89
+            ],
90
+
91
+            [
92
+                'privilege' => '{DAV:}read',
93
+                'principal' => $this->getOwner() . '/calendar-proxy-write',
94
+                'protected' => true,
95
+            ],
96
+            [
97
+                'privilege' => '{DAV:}read',
98
+                'principal' => $this->getOwner() . '/calendar-proxy-read',
99
+                'protected' => true,
100
+            ],
101
+
102
+        ];
103
+    }
104
+
105
+    /**
106
+     * @return null|string
107
+     */
108
+    public function getOwner() {
109
+        if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
110
+            return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'];
111
+        }
112
+        return parent::getOwner();
113
+    }
114 114
 
115 115
 	
116
-	public function delete() {
117
-		$this->caldavBackend->deleteSubscription($this->calendarInfo['id']);
118
-	}
119
-
120
-	/**
121
-	 * @param PropPatch $propPatch
122
-	 */
123
-	public function propPatch(PropPatch $propPatch) {
124
-		$this->caldavBackend->updateSubscription($this->calendarInfo['id'], $propPatch);
125
-	}
126
-
127
-	/**
128
-	 * @param string $name
129
-	 * @return CalendarObject|\Sabre\CalDAV\ICalendarObject
130
-	 * @throws NotFound
131
-	 */
132
-	public function getChild($name) {
133
-		$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
134
-		if (!$obj) {
135
-			throw new NotFound('Calendar object not found');
136
-		}
137
-
138
-		$obj['acl'] = $this->getChildACL();
139
-		return new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
140
-	}
141
-
142
-	/**
143
-	 * @return INode[]
144
-	 */
145
-	public function getChildren(): array {
146
-		$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
147
-
148
-		$children = [];
149
-		foreach ($objs as $obj) {
150
-			$children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
151
-		}
152
-
153
-		return $children;
154
-	}
155
-
156
-	/**
157
-	 * @param array $paths
158
-	 * @return array
159
-	 */
160
-	public function getMultipleChildren(array $paths):array {
161
-		$objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
162
-
163
-		$children = [];
164
-		foreach ($objs as $obj) {
165
-			$children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
166
-		}
167
-
168
-		return $children;
169
-	}
170
-
171
-	/**
172
-	 * @param string $name
173
-	 * @param null|resource|string $calendarData
174
-	 * @return null|string
175
-	 * @throws MethodNotAllowed
176
-	 */
177
-	public function createFile($name, $calendarData = null) {
178
-		throw new MethodNotAllowed('Creating objects in cached subscription is not allowed');
179
-	}
180
-
181
-	/**
182
-	 * @param string $name
183
-	 * @return bool
184
-	 */
185
-	public function childExists($name):bool {
186
-		$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
187
-		if (!$obj) {
188
-			return false;
189
-		}
190
-
191
-		return true;
192
-	}
193
-
194
-	/**
195
-	 * @param array $filters
196
-	 * @return array
197
-	 */
198
-	public function calendarQuery(array $filters):array {
199
-		return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
200
-	}
201
-
202
-	/**
203
-	 * @inheritDoc
204
-	 */
205
-	public function getChanges($syncToken, $syncLevel, $limit = null) {
206
-		if (!$syncToken && $limit) {
207
-			throw new UnsupportedLimitOnInitialSyncException();
208
-		}
209
-
210
-		return parent::getChanges($syncToken, $syncLevel, $limit);
211
-	}
116
+    public function delete() {
117
+        $this->caldavBackend->deleteSubscription($this->calendarInfo['id']);
118
+    }
119
+
120
+    /**
121
+     * @param PropPatch $propPatch
122
+     */
123
+    public function propPatch(PropPatch $propPatch) {
124
+        $this->caldavBackend->updateSubscription($this->calendarInfo['id'], $propPatch);
125
+    }
126
+
127
+    /**
128
+     * @param string $name
129
+     * @return CalendarObject|\Sabre\CalDAV\ICalendarObject
130
+     * @throws NotFound
131
+     */
132
+    public function getChild($name) {
133
+        $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
134
+        if (!$obj) {
135
+            throw new NotFound('Calendar object not found');
136
+        }
137
+
138
+        $obj['acl'] = $this->getChildACL();
139
+        return new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
140
+    }
141
+
142
+    /**
143
+     * @return INode[]
144
+     */
145
+    public function getChildren(): array {
146
+        $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
147
+
148
+        $children = [];
149
+        foreach ($objs as $obj) {
150
+            $children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
151
+        }
152
+
153
+        return $children;
154
+    }
155
+
156
+    /**
157
+     * @param array $paths
158
+     * @return array
159
+     */
160
+    public function getMultipleChildren(array $paths):array {
161
+        $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
162
+
163
+        $children = [];
164
+        foreach ($objs as $obj) {
165
+            $children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
166
+        }
167
+
168
+        return $children;
169
+    }
170
+
171
+    /**
172
+     * @param string $name
173
+     * @param null|resource|string $calendarData
174
+     * @return null|string
175
+     * @throws MethodNotAllowed
176
+     */
177
+    public function createFile($name, $calendarData = null) {
178
+        throw new MethodNotAllowed('Creating objects in cached subscription is not allowed');
179
+    }
180
+
181
+    /**
182
+     * @param string $name
183
+     * @return bool
184
+     */
185
+    public function childExists($name):bool {
186
+        $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
187
+        if (!$obj) {
188
+            return false;
189
+        }
190
+
191
+        return true;
192
+    }
193
+
194
+    /**
195
+     * @param array $filters
196
+     * @return array
197
+     */
198
+    public function calendarQuery(array $filters):array {
199
+        return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
200
+    }
201
+
202
+    /**
203
+     * @inheritDoc
204
+     */
205
+    public function getChanges($syncToken, $syncLevel, $limit = null) {
206
+        if (!$syncToken && $limit) {
207
+            throw new UnsupportedLimitOnInitialSyncException();
208
+        }
209
+
210
+        return parent::getChanges($syncToken, $syncLevel, $limit);
211
+    }
212 212
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/ListCalendars.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			}
78 78
 
79 79
 			$readOnly = false;
80
-			$readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
80
+			$readOnlyIndex = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
81 81
 			if (isset($calendar[$readOnlyIndex])) {
82 82
 				$readOnly = $calendar[$readOnlyIndex];
83 83
 			}
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 			$calendarTableData[] = [
86 86
 				$calendar['uri'],
87 87
 				$calendar['{DAV:}displayname'],
88
-				$calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'],
89
-				$calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'],
88
+				$calendar['{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal'],
89
+				$calendar['{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname'],
90 90
 				$readOnly ? ' x ' : ' ✓ ',
91 91
 			];
92 92
 		}
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -37,70 +37,70 @@
 block discarded – undo
37 37
 
38 38
 class ListCalendars extends Command {
39 39
 
40
-	/** @var IUserManager */
41
-	protected $userManager;
40
+    /** @var IUserManager */
41
+    protected $userManager;
42 42
 
43
-	/** @var CalDavBackend */
44
-	private $caldav;
43
+    /** @var CalDavBackend */
44
+    private $caldav;
45 45
 
46
-	/**
47
-	 * @param IUserManager $userManager
48
-	 * @param CalDavBackend $caldav
49
-	 */
50
-	public function __construct(IUserManager $userManager, CalDavBackend $caldav) {
51
-		parent::__construct();
52
-		$this->userManager = $userManager;
53
-		$this->caldav = $caldav;
54
-	}
46
+    /**
47
+     * @param IUserManager $userManager
48
+     * @param CalDavBackend $caldav
49
+     */
50
+    public function __construct(IUserManager $userManager, CalDavBackend $caldav) {
51
+        parent::__construct();
52
+        $this->userManager = $userManager;
53
+        $this->caldav = $caldav;
54
+    }
55 55
 
56
-	protected function configure() {
57
-		$this
58
-			->setName('dav:list-calendars')
59
-			->setDescription('List all calendars of a user')
60
-			->addArgument('uid',
61
-				InputArgument::REQUIRED,
62
-				'User for whom all calendars will be listed');
63
-	}
56
+    protected function configure() {
57
+        $this
58
+            ->setName('dav:list-calendars')
59
+            ->setDescription('List all calendars of a user')
60
+            ->addArgument('uid',
61
+                InputArgument::REQUIRED,
62
+                'User for whom all calendars will be listed');
63
+    }
64 64
 
65
-	protected function execute(InputInterface $input, OutputInterface $output): int {
66
-		$user = $input->getArgument('uid');
67
-		if (!$this->userManager->userExists($user)) {
68
-			throw new \InvalidArgumentException("User <$user> is unknown.");
69
-		}
65
+    protected function execute(InputInterface $input, OutputInterface $output): int {
66
+        $user = $input->getArgument('uid');
67
+        if (!$this->userManager->userExists($user)) {
68
+            throw new \InvalidArgumentException("User <$user> is unknown.");
69
+        }
70 70
 
71
-		$calendars = $this->caldav->getCalendarsForUser("principals/users/$user");
71
+        $calendars = $this->caldav->getCalendarsForUser("principals/users/$user");
72 72
 
73
-		$calendarTableData = [];
74
-		foreach ($calendars as $calendar) {
75
-			// skip birthday calendar
76
-			if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) {
77
-				continue;
78
-			}
73
+        $calendarTableData = [];
74
+        foreach ($calendars as $calendar) {
75
+            // skip birthday calendar
76
+            if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) {
77
+                continue;
78
+            }
79 79
 
80
-			$readOnly = false;
81
-			$readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
82
-			if (isset($calendar[$readOnlyIndex])) {
83
-				$readOnly = $calendar[$readOnlyIndex];
84
-			}
80
+            $readOnly = false;
81
+            $readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
82
+            if (isset($calendar[$readOnlyIndex])) {
83
+                $readOnly = $calendar[$readOnlyIndex];
84
+            }
85 85
 
86
-			$calendarTableData[] = [
87
-				$calendar['uri'],
88
-				$calendar['{DAV:}displayname'],
89
-				$calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'],
90
-				$calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'],
91
-				$readOnly ? ' x ' : ' ✓ ',
92
-			];
93
-		}
86
+            $calendarTableData[] = [
87
+                $calendar['uri'],
88
+                $calendar['{DAV:}displayname'],
89
+                $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'],
90
+                $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'],
91
+                $readOnly ? ' x ' : ' ✓ ',
92
+            ];
93
+        }
94 94
 
95
-		if (count($calendarTableData) > 0) {
96
-			$table = new Table($output);
97
-			$table->setHeaders(['uri', 'displayname', 'owner\'s userid', 'owner\'s displayname', 'writable'])
98
-				->setRows($calendarTableData);
95
+        if (count($calendarTableData) > 0) {
96
+            $table = new Table($output);
97
+            $table->setHeaders(['uri', 'displayname', 'owner\'s userid', 'owner\'s displayname', 'writable'])
98
+                ->setRows($calendarTableData);
99 99
 
100
-			$table->render();
101
-		} else {
102
-			$output->writeln("<info>User <$user> has no calendars</info>");
103
-		}
104
-		return 0;
105
-	}
100
+            $table->render();
101
+        } else {
102
+            $output->writeln("<info>User <$user> has no calendars</info>");
103
+        }
104
+        return 0;
105
+    }
106 106
 }
Please login to merge, or discard this patch.
apps/dav/lib/Comments/CommentsPlugin.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
93 93
 
94
-		$this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value) {
94
+		$this->server->xml->classMap['DateTime'] = function(Writer $writer, \DateTime $value) {
95 95
 			$writer->write(\Sabre\HTTP\toDate($value));
96 96
 		};
97 97
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		// having their own comments marked as unread
126 126
 		$node->setReadMarker(null);
127 127
 
128
-		$url = rtrim($request->getUrl(), '/') . '/' . urlencode($comment->getId());
128
+		$url = rtrim($request->getUrl(), '/').'/'.urlencode($comment->getId());
129 129
 
130 130
 		$response->setHeader('Content-Location', $url);
131 131
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 			$this::REPORT_PARAM_OFFSET,
168 168
 			$this::REPORT_PARAM_TIMESTAMP
169 169
 		];
170
-		$ns = '{' . $this::NS_OWNCLOUD . '}';
170
+		$ns = '{'.$this::NS_OWNCLOUD.'}';
171 171
 		foreach ($report as $parameter) {
172 172
 			if (!in_array($parameter['name'], $acceptableParameters) || empty($parameter['value'])) {
173 173
 				continue;
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$responses = [];
185 185
 		foreach ($results as $node) {
186
-			$nodePath = $this->server->getRequestUri() . '/' . $node->comment->getId();
186
+			$nodePath = $this->server->getRequestUri().'/'.$node->comment->getId();
187 187
 			$resultSet = $this->server->getPropertiesForPath($nodePath, CommentNode::getPropertyNames());
188 188
 			if (isset($resultSet[0]) && isset($resultSet[0][200])) {
189 189
 				$responses[] = new Response(
190
-					$this->server->getBaseUri() . $nodePath,
190
+					$this->server->getBaseUri().$nodePath,
191 191
 					[200 => $resultSet[0][200]],
192 192
 					200
193 193
 				);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 			}
235 235
 		}
236 236
 		if (is_null($actorId)) {
237
-			throw new BadRequest('Invalid actor "' .  $actorType .'"');
237
+			throw new BadRequest('Invalid actor "'.$actorType.'"');
238 238
 		}
239 239
 
240 240
 		try {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 			throw new BadRequest('Invalid input values', 0, $e);
248 248
 		} catch (\OCP\Comments\MessageTooLongException $e) {
249 249
 			$msg = 'Message exceeds allowed character limit of ';
250
-			throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0,	$e);
250
+			throw new BadRequest($msg.\OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e);
251 251
 		}
252 252
 	}
253 253
 }
Please login to merge, or discard this patch.
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -44,210 +44,210 @@
 block discarded – undo
44 44
  * Sabre plugin to handle comments:
45 45
  */
46 46
 class CommentsPlugin extends ServerPlugin {
47
-	// namespace
48
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
49
-
50
-	public const REPORT_NAME = '{http://owncloud.org/ns}filter-comments';
51
-	public const REPORT_PARAM_LIMIT = '{http://owncloud.org/ns}limit';
52
-	public const REPORT_PARAM_OFFSET = '{http://owncloud.org/ns}offset';
53
-	public const REPORT_PARAM_TIMESTAMP = '{http://owncloud.org/ns}datetime';
54
-
55
-	/** @var ICommentsManager  */
56
-	protected $commentsManager;
57
-
58
-	/** @var \Sabre\DAV\Server $server */
59
-	private $server;
60
-
61
-	/** @var  \OCP\IUserSession */
62
-	protected $userSession;
63
-
64
-	/**
65
-	 * Comments plugin
66
-	 *
67
-	 * @param ICommentsManager $commentsManager
68
-	 * @param IUserSession $userSession
69
-	 */
70
-	public function __construct(ICommentsManager $commentsManager, IUserSession $userSession) {
71
-		$this->commentsManager = $commentsManager;
72
-		$this->userSession = $userSession;
73
-	}
74
-
75
-	/**
76
-	 * This initializes the plugin.
77
-	 *
78
-	 * This function is called by Sabre\DAV\Server, after
79
-	 * addPlugin is called.
80
-	 *
81
-	 * This method should set up the required event subscriptions.
82
-	 *
83
-	 * @param Server $server
84
-	 * @return void
85
-	 */
86
-	public function initialize(Server $server) {
87
-		$this->server = $server;
88
-		if (strpos($this->server->getRequestUri(), 'comments/') !== 0) {
89
-			return;
90
-		}
91
-
92
-		$this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
93
-
94
-		$this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value) {
95
-			$writer->write(\Sabre\HTTP\toDate($value));
96
-		};
97
-
98
-		$this->server->on('report', [$this, 'onReport']);
99
-		$this->server->on('method:POST', [$this, 'httpPost']);
100
-	}
101
-
102
-	/**
103
-	 * POST operation on Comments collections
104
-	 *
105
-	 * @param RequestInterface $request request object
106
-	 * @param ResponseInterface $response response object
107
-	 * @return null|false
108
-	 */
109
-	public function httpPost(RequestInterface $request, ResponseInterface $response) {
110
-		$path = $request->getPath();
111
-		$node = $this->server->tree->getNodeForPath($path);
112
-		if (!$node instanceof EntityCollection) {
113
-			return null;
114
-		}
115
-
116
-		$data = $request->getBodyAsString();
117
-		$comment = $this->createComment(
118
-			$node->getName(),
119
-			$node->getId(),
120
-			$data,
121
-			$request->getHeader('Content-Type')
122
-		);
123
-
124
-		// update read marker for the current user/poster to avoid
125
-		// having their own comments marked as unread
126
-		$node->setReadMarker(null);
127
-
128
-		$url = rtrim($request->getUrl(), '/') . '/' . urlencode($comment->getId());
129
-
130
-		$response->setHeader('Content-Location', $url);
131
-
132
-		// created
133
-		$response->setStatus(201);
134
-		return false;
135
-	}
136
-
137
-	/**
138
-	 * Returns a list of reports this plugin supports.
139
-	 *
140
-	 * This will be used in the {DAV:}supported-report-set property.
141
-	 *
142
-	 * @param string $uri
143
-	 * @return array
144
-	 */
145
-	public function getSupportedReportSet($uri) {
146
-		return [self::REPORT_NAME];
147
-	}
148
-
149
-	/**
150
-	 * REPORT operations to look for comments
151
-	 *
152
-	 * @param string $reportName
153
-	 * @param array $report
154
-	 * @param string $uri
155
-	 * @return bool
156
-	 * @throws NotFound
157
-	 * @throws ReportNotSupported
158
-	 */
159
-	public function onReport($reportName, $report, $uri) {
160
-		$node = $this->server->tree->getNodeForPath($uri);
161
-		if (!$node instanceof EntityCollection || $reportName !== self::REPORT_NAME) {
162
-			throw new ReportNotSupported();
163
-		}
164
-		$args = ['limit' => 0, 'offset' => 0, 'datetime' => null];
165
-		$acceptableParameters = [
166
-			$this::REPORT_PARAM_LIMIT,
167
-			$this::REPORT_PARAM_OFFSET,
168
-			$this::REPORT_PARAM_TIMESTAMP
169
-		];
170
-		$ns = '{' . $this::NS_OWNCLOUD . '}';
171
-		foreach ($report as $parameter) {
172
-			if (!in_array($parameter['name'], $acceptableParameters) || empty($parameter['value'])) {
173
-				continue;
174
-			}
175
-			$args[str_replace($ns, '', $parameter['name'])] = $parameter['value'];
176
-		}
177
-
178
-		if (!is_null($args['datetime'])) {
179
-			$args['datetime'] = new \DateTime($args['datetime']);
180
-		}
181
-
182
-		$results = $node->findChildren($args['limit'], $args['offset'], $args['datetime']);
183
-
184
-		$responses = [];
185
-		foreach ($results as $node) {
186
-			$nodePath = $this->server->getRequestUri() . '/' . $node->comment->getId();
187
-			$resultSet = $this->server->getPropertiesForPath($nodePath, CommentNode::getPropertyNames());
188
-			if (isset($resultSet[0]) && isset($resultSet[0][200])) {
189
-				$responses[] = new Response(
190
-					$this->server->getBaseUri() . $nodePath,
191
-					[200 => $resultSet[0][200]],
192
-					200
193
-				);
194
-			}
195
-		}
196
-
197
-		$xml = $this->server->xml->write(
198
-			'{DAV:}multistatus',
199
-			new MultiStatus($responses)
200
-		);
201
-
202
-		$this->server->httpResponse->setStatus(207);
203
-		$this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
204
-		$this->server->httpResponse->setBody($xml);
205
-
206
-		return false;
207
-	}
208
-
209
-	/**
210
-	 * Creates a new comment
211
-	 *
212
-	 * @param string $objectType e.g. "files"
213
-	 * @param string $objectId e.g. the file id
214
-	 * @param string $data JSON encoded string containing the properties of the tag to create
215
-	 * @param string $contentType content type of the data
216
-	 * @return IComment newly created comment
217
-	 *
218
-	 * @throws BadRequest if a field was missing
219
-	 * @throws UnsupportedMediaType if the content type is not supported
220
-	 */
221
-	private function createComment($objectType, $objectId, $data, $contentType = 'application/json') {
222
-		if (explode(';', $contentType)[0] === 'application/json') {
223
-			$data = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
224
-		} else {
225
-			throw new UnsupportedMediaType();
226
-		}
227
-
228
-		$actorType = $data['actorType'];
229
-		$actorId = null;
230
-		if ($actorType === 'users') {
231
-			$user = $this->userSession->getUser();
232
-			if (!is_null($user)) {
233
-				$actorId = $user->getUID();
234
-			}
235
-		}
236
-		if (is_null($actorId)) {
237
-			throw new BadRequest('Invalid actor "' .  $actorType .'"');
238
-		}
239
-
240
-		try {
241
-			$comment = $this->commentsManager->create($actorType, $actorId, $objectType, $objectId);
242
-			$comment->setMessage($data['message']);
243
-			$comment->setVerb($data['verb']);
244
-			$this->commentsManager->save($comment);
245
-			return $comment;
246
-		} catch (\InvalidArgumentException $e) {
247
-			throw new BadRequest('Invalid input values', 0, $e);
248
-		} catch (\OCP\Comments\MessageTooLongException $e) {
249
-			$msg = 'Message exceeds allowed character limit of ';
250
-			throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0,	$e);
251
-		}
252
-	}
47
+    // namespace
48
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
49
+
50
+    public const REPORT_NAME = '{http://owncloud.org/ns}filter-comments';
51
+    public const REPORT_PARAM_LIMIT = '{http://owncloud.org/ns}limit';
52
+    public const REPORT_PARAM_OFFSET = '{http://owncloud.org/ns}offset';
53
+    public const REPORT_PARAM_TIMESTAMP = '{http://owncloud.org/ns}datetime';
54
+
55
+    /** @var ICommentsManager  */
56
+    protected $commentsManager;
57
+
58
+    /** @var \Sabre\DAV\Server $server */
59
+    private $server;
60
+
61
+    /** @var  \OCP\IUserSession */
62
+    protected $userSession;
63
+
64
+    /**
65
+     * Comments plugin
66
+     *
67
+     * @param ICommentsManager $commentsManager
68
+     * @param IUserSession $userSession
69
+     */
70
+    public function __construct(ICommentsManager $commentsManager, IUserSession $userSession) {
71
+        $this->commentsManager = $commentsManager;
72
+        $this->userSession = $userSession;
73
+    }
74
+
75
+    /**
76
+     * This initializes the plugin.
77
+     *
78
+     * This function is called by Sabre\DAV\Server, after
79
+     * addPlugin is called.
80
+     *
81
+     * This method should set up the required event subscriptions.
82
+     *
83
+     * @param Server $server
84
+     * @return void
85
+     */
86
+    public function initialize(Server $server) {
87
+        $this->server = $server;
88
+        if (strpos($this->server->getRequestUri(), 'comments/') !== 0) {
89
+            return;
90
+        }
91
+
92
+        $this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
93
+
94
+        $this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value) {
95
+            $writer->write(\Sabre\HTTP\toDate($value));
96
+        };
97
+
98
+        $this->server->on('report', [$this, 'onReport']);
99
+        $this->server->on('method:POST', [$this, 'httpPost']);
100
+    }
101
+
102
+    /**
103
+     * POST operation on Comments collections
104
+     *
105
+     * @param RequestInterface $request request object
106
+     * @param ResponseInterface $response response object
107
+     * @return null|false
108
+     */
109
+    public function httpPost(RequestInterface $request, ResponseInterface $response) {
110
+        $path = $request->getPath();
111
+        $node = $this->server->tree->getNodeForPath($path);
112
+        if (!$node instanceof EntityCollection) {
113
+            return null;
114
+        }
115
+
116
+        $data = $request->getBodyAsString();
117
+        $comment = $this->createComment(
118
+            $node->getName(),
119
+            $node->getId(),
120
+            $data,
121
+            $request->getHeader('Content-Type')
122
+        );
123
+
124
+        // update read marker for the current user/poster to avoid
125
+        // having their own comments marked as unread
126
+        $node->setReadMarker(null);
127
+
128
+        $url = rtrim($request->getUrl(), '/') . '/' . urlencode($comment->getId());
129
+
130
+        $response->setHeader('Content-Location', $url);
131
+
132
+        // created
133
+        $response->setStatus(201);
134
+        return false;
135
+    }
136
+
137
+    /**
138
+     * Returns a list of reports this plugin supports.
139
+     *
140
+     * This will be used in the {DAV:}supported-report-set property.
141
+     *
142
+     * @param string $uri
143
+     * @return array
144
+     */
145
+    public function getSupportedReportSet($uri) {
146
+        return [self::REPORT_NAME];
147
+    }
148
+
149
+    /**
150
+     * REPORT operations to look for comments
151
+     *
152
+     * @param string $reportName
153
+     * @param array $report
154
+     * @param string $uri
155
+     * @return bool
156
+     * @throws NotFound
157
+     * @throws ReportNotSupported
158
+     */
159
+    public function onReport($reportName, $report, $uri) {
160
+        $node = $this->server->tree->getNodeForPath($uri);
161
+        if (!$node instanceof EntityCollection || $reportName !== self::REPORT_NAME) {
162
+            throw new ReportNotSupported();
163
+        }
164
+        $args = ['limit' => 0, 'offset' => 0, 'datetime' => null];
165
+        $acceptableParameters = [
166
+            $this::REPORT_PARAM_LIMIT,
167
+            $this::REPORT_PARAM_OFFSET,
168
+            $this::REPORT_PARAM_TIMESTAMP
169
+        ];
170
+        $ns = '{' . $this::NS_OWNCLOUD . '}';
171
+        foreach ($report as $parameter) {
172
+            if (!in_array($parameter['name'], $acceptableParameters) || empty($parameter['value'])) {
173
+                continue;
174
+            }
175
+            $args[str_replace($ns, '', $parameter['name'])] = $parameter['value'];
176
+        }
177
+
178
+        if (!is_null($args['datetime'])) {
179
+            $args['datetime'] = new \DateTime($args['datetime']);
180
+        }
181
+
182
+        $results = $node->findChildren($args['limit'], $args['offset'], $args['datetime']);
183
+
184
+        $responses = [];
185
+        foreach ($results as $node) {
186
+            $nodePath = $this->server->getRequestUri() . '/' . $node->comment->getId();
187
+            $resultSet = $this->server->getPropertiesForPath($nodePath, CommentNode::getPropertyNames());
188
+            if (isset($resultSet[0]) && isset($resultSet[0][200])) {
189
+                $responses[] = new Response(
190
+                    $this->server->getBaseUri() . $nodePath,
191
+                    [200 => $resultSet[0][200]],
192
+                    200
193
+                );
194
+            }
195
+        }
196
+
197
+        $xml = $this->server->xml->write(
198
+            '{DAV:}multistatus',
199
+            new MultiStatus($responses)
200
+        );
201
+
202
+        $this->server->httpResponse->setStatus(207);
203
+        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
204
+        $this->server->httpResponse->setBody($xml);
205
+
206
+        return false;
207
+    }
208
+
209
+    /**
210
+     * Creates a new comment
211
+     *
212
+     * @param string $objectType e.g. "files"
213
+     * @param string $objectId e.g. the file id
214
+     * @param string $data JSON encoded string containing the properties of the tag to create
215
+     * @param string $contentType content type of the data
216
+     * @return IComment newly created comment
217
+     *
218
+     * @throws BadRequest if a field was missing
219
+     * @throws UnsupportedMediaType if the content type is not supported
220
+     */
221
+    private function createComment($objectType, $objectId, $data, $contentType = 'application/json') {
222
+        if (explode(';', $contentType)[0] === 'application/json') {
223
+            $data = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
224
+        } else {
225
+            throw new UnsupportedMediaType();
226
+        }
227
+
228
+        $actorType = $data['actorType'];
229
+        $actorId = null;
230
+        if ($actorType === 'users') {
231
+            $user = $this->userSession->getUser();
232
+            if (!is_null($user)) {
233
+                $actorId = $user->getUID();
234
+            }
235
+        }
236
+        if (is_null($actorId)) {
237
+            throw new BadRequest('Invalid actor "' .  $actorType .'"');
238
+        }
239
+
240
+        try {
241
+            $comment = $this->commentsManager->create($actorType, $actorId, $objectType, $objectId);
242
+            $comment->setMessage($data['message']);
243
+            $comment->setVerb($data['verb']);
244
+            $this->commentsManager->save($comment);
245
+            return $comment;
246
+        } catch (\InvalidArgumentException $e) {
247
+            throw new BadRequest('Invalid input values', 0, $e);
248
+        } catch (\OCP\Comments\MessageTooLongException $e) {
249
+            $msg = 'Message exceeds allowed character limit of ';
250
+            throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0,	$e);
251
+        }
252
+    }
253 253
 }
Please login to merge, or discard this patch.
apps/dav/lib/Files/BrowserErrorPagePlugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
 
100 100
 		$templateName = 'exception';
101 101
 		if ($httpCode === 403 || $httpCode === 404) {
102
-			$templateName = (string)$httpCode;
102
+			$templateName = (string) $httpCode;
103 103
 		}
104 104
 
105 105
 		$content = new OC_Template('core', $templateName, 'guest');
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -34,86 +34,86 @@
 block discarded – undo
34 34
 use Sabre\DAV\ServerPlugin;
35 35
 
36 36
 class BrowserErrorPagePlugin extends ServerPlugin {
37
-	/** @var Server */
38
-	private $server;
37
+    /** @var Server */
38
+    private $server;
39 39
 
40
-	/**
41
-	 * This initializes the plugin.
42
-	 *
43
-	 * This function is called by Sabre\DAV\Server, after
44
-	 * addPlugin is called.
45
-	 *
46
-	 * This method should set up the required event subscriptions.
47
-	 *
48
-	 * @param Server $server
49
-	 * @return void
50
-	 */
51
-	public function initialize(Server $server) {
52
-		$this->server = $server;
53
-		$server->on('exception', [$this, 'logException'], 1000);
54
-	}
40
+    /**
41
+     * This initializes the plugin.
42
+     *
43
+     * This function is called by Sabre\DAV\Server, after
44
+     * addPlugin is called.
45
+     *
46
+     * This method should set up the required event subscriptions.
47
+     *
48
+     * @param Server $server
49
+     * @return void
50
+     */
51
+    public function initialize(Server $server) {
52
+        $this->server = $server;
53
+        $server->on('exception', [$this, 'logException'], 1000);
54
+    }
55 55
 
56
-	/**
57
-	 * @param IRequest $request
58
-	 * @return bool
59
-	 */
60
-	public static function isBrowserRequest(IRequest $request) {
61
-		if ($request->getMethod() !== 'GET') {
62
-			return false;
63
-		}
64
-		return $request->isUserAgent([
65
-			Request::USER_AGENT_IE,
66
-			Request::USER_AGENT_MS_EDGE,
67
-			Request::USER_AGENT_CHROME,
68
-			Request::USER_AGENT_FIREFOX,
69
-			Request::USER_AGENT_SAFARI,
70
-		]);
71
-	}
56
+    /**
57
+     * @param IRequest $request
58
+     * @return bool
59
+     */
60
+    public static function isBrowserRequest(IRequest $request) {
61
+        if ($request->getMethod() !== 'GET') {
62
+            return false;
63
+        }
64
+        return $request->isUserAgent([
65
+            Request::USER_AGENT_IE,
66
+            Request::USER_AGENT_MS_EDGE,
67
+            Request::USER_AGENT_CHROME,
68
+            Request::USER_AGENT_FIREFOX,
69
+            Request::USER_AGENT_SAFARI,
70
+        ]);
71
+    }
72 72
 
73
-	/**
74
-	 * @param \Exception $ex
75
-	 */
76
-	public function logException(\Exception $ex) {
77
-		if ($ex instanceof Exception) {
78
-			$httpCode = $ex->getHTTPCode();
79
-			$headers = $ex->getHTTPHeaders($this->server);
80
-		} else {
81
-			$httpCode = 500;
82
-			$headers = [];
83
-		}
84
-		$this->server->httpResponse->addHeaders($headers);
85
-		$this->server->httpResponse->setStatus($httpCode);
86
-		$body = $this->generateBody($httpCode);
87
-		$this->server->httpResponse->setBody($body);
88
-		$csp = new ContentSecurityPolicy();
89
-		$this->server->httpResponse->addHeader('Content-Security-Policy', $csp->buildPolicy());
90
-		$this->sendResponse();
91
-	}
73
+    /**
74
+     * @param \Exception $ex
75
+     */
76
+    public function logException(\Exception $ex) {
77
+        if ($ex instanceof Exception) {
78
+            $httpCode = $ex->getHTTPCode();
79
+            $headers = $ex->getHTTPHeaders($this->server);
80
+        } else {
81
+            $httpCode = 500;
82
+            $headers = [];
83
+        }
84
+        $this->server->httpResponse->addHeaders($headers);
85
+        $this->server->httpResponse->setStatus($httpCode);
86
+        $body = $this->generateBody($httpCode);
87
+        $this->server->httpResponse->setBody($body);
88
+        $csp = new ContentSecurityPolicy();
89
+        $this->server->httpResponse->addHeader('Content-Security-Policy', $csp->buildPolicy());
90
+        $this->sendResponse();
91
+    }
92 92
 
93
-	/**
94
-	 * @codeCoverageIgnore
95
-	 * @return bool|string
96
-	 */
97
-	public function generateBody(int $httpCode) {
98
-		$request = \OC::$server->getRequest();
93
+    /**
94
+     * @codeCoverageIgnore
95
+     * @return bool|string
96
+     */
97
+    public function generateBody(int $httpCode) {
98
+        $request = \OC::$server->getRequest();
99 99
 
100
-		$templateName = 'exception';
101
-		if ($httpCode === 403 || $httpCode === 404) {
102
-			$templateName = (string)$httpCode;
103
-		}
100
+        $templateName = 'exception';
101
+        if ($httpCode === 403 || $httpCode === 404) {
102
+            $templateName = (string)$httpCode;
103
+        }
104 104
 
105
-		$content = new OC_Template('core', $templateName, 'guest');
106
-		$content->assign('title', $this->server->httpResponse->getStatusText());
107
-		$content->assign('remoteAddr', $request->getRemoteAddress());
108
-		$content->assign('requestID', $request->getId());
109
-		return $content->fetchPage();
110
-	}
105
+        $content = new OC_Template('core', $templateName, 'guest');
106
+        $content->assign('title', $this->server->httpResponse->getStatusText());
107
+        $content->assign('remoteAddr', $request->getRemoteAddress());
108
+        $content->assign('requestID', $request->getId());
109
+        return $content->fetchPage();
110
+    }
111 111
 
112
-	/**
113
-	 * @codeCoverageIgnore
114
-	 */
115
-	public function sendResponse() {
116
-		$this->server->sapi->sendResponse($this->server->httpResponse);
117
-		exit();
118
-	}
112
+    /**
113
+     * @codeCoverageIgnore
114
+     */
115
+    public function sendResponse() {
116
+        $this->server->sapi->sendResponse($this->server->httpResponse);
117
+        exit();
118
+    }
119 119
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -34,52 +34,52 @@
 block discarded – undo
34 34
 
35 35
 class RefreshWebcalJobRegistrar implements IRepairStep {
36 36
 
37
-	/** @var IDBConnection */
38
-	private $connection;
37
+    /** @var IDBConnection */
38
+    private $connection;
39 39
 
40
-	/** @var IJobList */
41
-	private $jobList;
40
+    /** @var IJobList */
41
+    private $jobList;
42 42
 
43
-	/**
44
-	 * FixBirthdayCalendarComponent constructor.
45
-	 *
46
-	 * @param IDBConnection $connection
47
-	 * @param IJobList $jobList
48
-	 */
49
-	public function __construct(IDBConnection $connection, IJobList $jobList) {
50
-		$this->connection = $connection;
51
-		$this->jobList = $jobList;
52
-	}
43
+    /**
44
+     * FixBirthdayCalendarComponent constructor.
45
+     *
46
+     * @param IDBConnection $connection
47
+     * @param IJobList $jobList
48
+     */
49
+    public function __construct(IDBConnection $connection, IJobList $jobList) {
50
+        $this->connection = $connection;
51
+        $this->jobList = $jobList;
52
+    }
53 53
 
54
-	/**
55
-	 * @inheritdoc
56
-	 */
57
-	public function getName() {
58
-		return 'Registering background jobs to update cache for webcal calendars';
59
-	}
54
+    /**
55
+     * @inheritdoc
56
+     */
57
+    public function getName() {
58
+        return 'Registering background jobs to update cache for webcal calendars';
59
+    }
60 60
 
61
-	/**
62
-	 * @inheritdoc
63
-	 */
64
-	public function run(IOutput $output) {
65
-		$query = $this->connection->getQueryBuilder();
66
-		$query->select(['principaluri', 'uri'])
67
-			->from('calendarsubscriptions');
68
-		$stmt = $query->execute();
61
+    /**
62
+     * @inheritdoc
63
+     */
64
+    public function run(IOutput $output) {
65
+        $query = $this->connection->getQueryBuilder();
66
+        $query->select(['principaluri', 'uri'])
67
+            ->from('calendarsubscriptions');
68
+        $stmt = $query->execute();
69 69
 
70
-		$count = 0;
71
-		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
72
-			$args = [
73
-				'principaluri' => $row['principaluri'],
74
-				'uri' => $row['uri'],
75
-			];
70
+        $count = 0;
71
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
72
+            $args = [
73
+                'principaluri' => $row['principaluri'],
74
+                'uri' => $row['uri'],
75
+            ];
76 76
 
77
-			if (!$this->jobList->has(RefreshWebcalJob::class, $args)) {
78
-				$this->jobList->add(RefreshWebcalJob::class, $args);
79
-				$count++;
80
-			}
81
-		}
77
+            if (!$this->jobList->has(RefreshWebcalJob::class, $args)) {
78
+                $this->jobList->add(RefreshWebcalJob::class, $args);
79
+                $count++;
80
+            }
81
+        }
82 82
 
83
-		$output->info("Added $count background jobs to update webcal calendars");
84
-	}
83
+        $output->info("Added $count background jobs to update webcal calendars");
84
+    }
85 85
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Helper/ScopeContext.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -28,51 +28,51 @@
 block discarded – undo
28 28
 use OCP\WorkflowEngine\IManager;
29 29
 
30 30
 class ScopeContext {
31
-	/** @var int */
32
-	private $scope;
33
-	/** @var string */
34
-	private $scopeId;
35
-	/** @var string */
36
-	private $hash;
31
+    /** @var int */
32
+    private $scope;
33
+    /** @var string */
34
+    private $scopeId;
35
+    /** @var string */
36
+    private $hash;
37 37
 
38
-	public function __construct(int $scope, string $scopeId = null) {
39
-		$this->scope = $this->evaluateScope($scope);
40
-		$this->scopeId = $this->evaluateScopeId($scopeId);
41
-	}
38
+    public function __construct(int $scope, string $scopeId = null) {
39
+        $this->scope = $this->evaluateScope($scope);
40
+        $this->scopeId = $this->evaluateScopeId($scopeId);
41
+    }
42 42
 
43
-	private function evaluateScope(int $scope): int {
44
-		if (in_array($scope, [IManager::SCOPE_ADMIN, IManager::SCOPE_USER], true)) {
45
-			return $scope;
46
-		}
47
-		throw new \InvalidArgumentException('Invalid scope');
48
-	}
43
+    private function evaluateScope(int $scope): int {
44
+        if (in_array($scope, [IManager::SCOPE_ADMIN, IManager::SCOPE_USER], true)) {
45
+            return $scope;
46
+        }
47
+        throw new \InvalidArgumentException('Invalid scope');
48
+    }
49 49
 
50
-	private function evaluateScopeId(string $scopeId = null): string {
51
-		if ($this->scope === IManager::SCOPE_USER
52
-			&& trim((string)$scopeId) === '') {
53
-			throw new \InvalidArgumentException('user scope requires a user id');
54
-		}
55
-		return trim((string)$scopeId);
56
-	}
50
+    private function evaluateScopeId(string $scopeId = null): string {
51
+        if ($this->scope === IManager::SCOPE_USER
52
+            && trim((string)$scopeId) === '') {
53
+            throw new \InvalidArgumentException('user scope requires a user id');
54
+        }
55
+        return trim((string)$scopeId);
56
+    }
57 57
 
58
-	/**
59
-	 * @return int
60
-	 */
61
-	public function getScope(): int {
62
-		return $this->scope;
63
-	}
58
+    /**
59
+     * @return int
60
+     */
61
+    public function getScope(): int {
62
+        return $this->scope;
63
+    }
64 64
 
65
-	/**
66
-	 * @return string
67
-	 */
68
-	public function getScopeId(): string {
69
-		return $this->scopeId;
70
-	}
65
+    /**
66
+     * @return string
67
+     */
68
+    public function getScopeId(): string {
69
+        return $this->scopeId;
70
+    }
71 71
 
72
-	public function getHash(): string {
73
-		if ($this->hash === null) {
74
-			$this->hash = \hash('sha256', $this->getScope() . '::' . $this->getScopeId());
75
-		}
76
-		return $this->hash;
77
-	}
72
+    public function getHash(): string {
73
+        if ($this->hash === null) {
74
+            $this->hash = \hash('sha256', $this->getScope() . '::' . $this->getScopeId());
75
+        }
76
+        return $this->hash;
77
+    }
78 78
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 
50 50
 	private function evaluateScopeId(string $scopeId = null): string {
51 51
 		if ($this->scope === IManager::SCOPE_USER
52
-			&& trim((string)$scopeId) === '') {
52
+			&& trim((string) $scopeId) === '') {
53 53
 			throw new \InvalidArgumentException('user scope requires a user id');
54 54
 		}
55
-		return trim((string)$scopeId);
55
+		return trim((string) $scopeId);
56 56
 	}
57 57
 
58 58
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
 	public function getHash(): string {
73 73
 		if ($this->hash === null) {
74
-			$this->hash = \hash('sha256', $this->getScope() . '::' . $this->getScopeId());
74
+			$this->hash = \hash('sha256', $this->getScope().'::'.$this->getScopeId());
75 75
 		}
76 76
 		return $this->hash;
77 77
 	}
Please login to merge, or discard this patch.
apps/workflowengine/lib/Helper/LogContext.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -30,67 +30,67 @@
 block discarded – undo
30 30
 use OCP\WorkflowEngine\IOperation;
31 31
 
32 32
 class LogContext {
33
-	/** @var array */
34
-	protected $details;
33
+    /** @var array */
34
+    protected $details;
35 35
 
36
-	public function setDescription(string $description): LogContext {
37
-		$this->details['message'] = $description;
38
-		return $this;
39
-	}
36
+    public function setDescription(string $description): LogContext {
37
+        $this->details['message'] = $description;
38
+        return $this;
39
+    }
40 40
 
41
-	public function setScopes(array $scopes): LogContext {
42
-		$this->details['scopes'] = [];
43
-		foreach ($scopes as $scope) {
44
-			if ($scope instanceof ScopeContext) {
45
-				switch ($scope->getScope()) {
46
-					case IManager::SCOPE_ADMIN:
47
-						$this->details['scopes'][] = ['scope' => 'admin'];
48
-						break;
49
-					case IManager::SCOPE_USER:
50
-						$this->details['scopes'][] = [
51
-							'scope' => 'user',
52
-							'uid' => $scope->getScopeId(),
53
-						];
54
-						break;
55
-					default:
56
-						continue 2;
57
-				}
58
-			}
59
-		}
60
-		return $this;
61
-	}
41
+    public function setScopes(array $scopes): LogContext {
42
+        $this->details['scopes'] = [];
43
+        foreach ($scopes as $scope) {
44
+            if ($scope instanceof ScopeContext) {
45
+                switch ($scope->getScope()) {
46
+                    case IManager::SCOPE_ADMIN:
47
+                        $this->details['scopes'][] = ['scope' => 'admin'];
48
+                        break;
49
+                    case IManager::SCOPE_USER:
50
+                        $this->details['scopes'][] = [
51
+                            'scope' => 'user',
52
+                            'uid' => $scope->getScopeId(),
53
+                        ];
54
+                        break;
55
+                    default:
56
+                        continue 2;
57
+                }
58
+            }
59
+        }
60
+        return $this;
61
+    }
62 62
 
63
-	public function setOperation(?IOperation $operation): LogContext {
64
-		if ($operation instanceof IOperation) {
65
-			$this->details['operation'] = [
66
-				'class' => get_class($operation),
67
-				'name' => $operation->getDisplayName(),
68
-			];
69
-		}
70
-		return $this;
71
-	}
63
+    public function setOperation(?IOperation $operation): LogContext {
64
+        if ($operation instanceof IOperation) {
65
+            $this->details['operation'] = [
66
+                'class' => get_class($operation),
67
+                'name' => $operation->getDisplayName(),
68
+            ];
69
+        }
70
+        return $this;
71
+    }
72 72
 
73
-	public function setEntity(?IEntity $entity): LogContext {
74
-		if ($entity instanceof IEntity) {
75
-			$this->details['entity'] = [
76
-				'class' => get_class($entity),
77
-				'name' => $entity->getName(),
78
-			];
79
-		}
80
-		return $this;
81
-	}
73
+    public function setEntity(?IEntity $entity): LogContext {
74
+        if ($entity instanceof IEntity) {
75
+            $this->details['entity'] = [
76
+                'class' => get_class($entity),
77
+                'name' => $entity->getName(),
78
+            ];
79
+        }
80
+        return $this;
81
+    }
82 82
 
83
-	public function setConfiguration(array $configuration): LogContext {
84
-		$this->details['configuration'] = $configuration;
85
-		return $this;
86
-	}
83
+    public function setConfiguration(array $configuration): LogContext {
84
+        $this->details['configuration'] = $configuration;
85
+        return $this;
86
+    }
87 87
 
88
-	public function setEventName(string $eventName): LogContext {
89
-		$this->details['eventName'] = $eventName;
90
-		return $this;
91
-	}
88
+    public function setEventName(string $eventName): LogContext {
89
+        $this->details['eventName'] = $eventName;
90
+        return $this;
91
+    }
92 92
 
93
-	public function getDetails(): array {
94
-		return $this->details;
95
-	}
93
+    public function getDetails(): array {
94
+        return $this->details;
95
+    }
96 96
 }
Please login to merge, or discard this patch.