Passed
Push — master ( c56a27...645109 )
by Christoph
13:24 queued 10s
created
apps/federatedfilesharing/lib/Notifier.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -184,12 +184,12 @@
 block discarded – undo
184 184
 		}
185 185
 
186 186
 		try {
187
-			$this->getDisplayNameFromContact($user . '@http://' . $server);
187
+			$this->getDisplayNameFromContact($user.'@http://'.$server);
188 188
 		} catch (\OutOfBoundsException $e) {
189 189
 		}
190 190
 
191 191
 		try {
192
-			$this->getDisplayNameFromContact($user . '@https://' . $server);
192
+			$this->getDisplayNameFromContact($user.'@https://'.$server);
193 193
 		} catch (\OutOfBoundsException $e) {
194 194
 		}
195 195
 
Please login to merge, or discard this patch.
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -35,229 +35,229 @@
 block discarded – undo
35 35
 use OCP\Notification\INotifier;
36 36
 
37 37
 class Notifier implements INotifier {
38
-	/** @var IFactory */
39
-	protected $factory;
40
-	/** @var IManager */
41
-	protected $contactsManager;
42
-	/** @var IURLGenerator */
43
-	protected $url;
44
-	/** @var array */
45
-	protected $federatedContacts;
46
-	/** @var ICloudIdManager */
47
-	protected $cloudIdManager;
38
+    /** @var IFactory */
39
+    protected $factory;
40
+    /** @var IManager */
41
+    protected $contactsManager;
42
+    /** @var IURLGenerator */
43
+    protected $url;
44
+    /** @var array */
45
+    protected $federatedContacts;
46
+    /** @var ICloudIdManager */
47
+    protected $cloudIdManager;
48 48
 
49
-	/**
50
-	 * @param IFactory $factory
51
-	 * @param IManager $contactsManager
52
-	 * @param IURLGenerator $url
53
-	 * @param ICloudIdManager $cloudIdManager
54
-	 */
55
-	public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) {
56
-		$this->factory = $factory;
57
-		$this->contactsManager = $contactsManager;
58
-		$this->url = $url;
59
-		$this->cloudIdManager = $cloudIdManager;
60
-	}
49
+    /**
50
+     * @param IFactory $factory
51
+     * @param IManager $contactsManager
52
+     * @param IURLGenerator $url
53
+     * @param ICloudIdManager $cloudIdManager
54
+     */
55
+    public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) {
56
+        $this->factory = $factory;
57
+        $this->contactsManager = $contactsManager;
58
+        $this->url = $url;
59
+        $this->cloudIdManager = $cloudIdManager;
60
+    }
61 61
 
62
-	/**
63
-	 * Identifier of the notifier, only use [a-z0-9_]
64
-	 *
65
-	 * @return string
66
-	 * @since 17.0.0
67
-	 */
68
-	public function getID(): string {
69
-		return 'federatedfilesharing';
70
-	}
62
+    /**
63
+     * Identifier of the notifier, only use [a-z0-9_]
64
+     *
65
+     * @return string
66
+     * @since 17.0.0
67
+     */
68
+    public function getID(): string {
69
+        return 'federatedfilesharing';
70
+    }
71 71
 
72
-	/**
73
-	 * Human readable name describing the notifier
74
-	 *
75
-	 * @return string
76
-	 * @since 17.0.0
77
-	 */
78
-	public function getName(): string {
79
-		return $this->factory->get('federatedfilesharing')->t('Federated sharing');
80
-	}
72
+    /**
73
+     * Human readable name describing the notifier
74
+     *
75
+     * @return string
76
+     * @since 17.0.0
77
+     */
78
+    public function getName(): string {
79
+        return $this->factory->get('federatedfilesharing')->t('Federated sharing');
80
+    }
81 81
 
82
-	/**
83
-	 * @param INotification $notification
84
-	 * @param string $languageCode The code of the language that should be used to prepare the notification
85
-	 * @return INotification
86
-	 * @throws \InvalidArgumentException
87
-	 */
88
-	public function prepare(INotification $notification, string $languageCode): INotification {
89
-		if ($notification->getApp() !== 'files_sharing' || $notification->getObjectType() !== 'remote_share') {
90
-			// Not my app => throw
91
-			throw new \InvalidArgumentException();
92
-		}
82
+    /**
83
+     * @param INotification $notification
84
+     * @param string $languageCode The code of the language that should be used to prepare the notification
85
+     * @return INotification
86
+     * @throws \InvalidArgumentException
87
+     */
88
+    public function prepare(INotification $notification, string $languageCode): INotification {
89
+        if ($notification->getApp() !== 'files_sharing' || $notification->getObjectType() !== 'remote_share') {
90
+            // Not my app => throw
91
+            throw new \InvalidArgumentException();
92
+        }
93 93
 
94
-		// Read the language from the notification
95
-		$l = $this->factory->get('files_sharing', $languageCode);
94
+        // Read the language from the notification
95
+        $l = $this->factory->get('files_sharing', $languageCode);
96 96
 
97
-		switch ($notification->getSubject()) {
98
-			// Deal with known subjects
99
-			case 'remote_share':
100
-				$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
97
+        switch ($notification->getSubject()) {
98
+            // Deal with known subjects
99
+            case 'remote_share':
100
+                $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
101 101
 
102
-				$params = $notification->getSubjectParameters();
103
-				if ($params[0] !== $params[1] && $params[1] !== null) {
104
-					$notification->setParsedSubject(
105
-						$l->t('You received "%3$s" as a remote share from %4$s (%1$s) (on behalf of %5$s (%2$s))', $params)
106
-					);
102
+                $params = $notification->getSubjectParameters();
103
+                if ($params[0] !== $params[1] && $params[1] !== null) {
104
+                    $notification->setParsedSubject(
105
+                        $l->t('You received "%3$s" as a remote share from %4$s (%1$s) (on behalf of %5$s (%2$s))', $params)
106
+                    );
107 107
 
108
-					$initiator = $params[0];
109
-					$initiatorDisplay = isset($params[3]) ? $params[3] : null;
110
-					$owner = $params[1];
111
-					$ownerDisplay = isset($params[4]) ? $params[4] : null;
108
+                    $initiator = $params[0];
109
+                    $initiatorDisplay = isset($params[3]) ? $params[3] : null;
110
+                    $owner = $params[1];
111
+                    $ownerDisplay = isset($params[4]) ? $params[4] : null;
112 112
 
113
-					$notification->setRichSubject(
114
-						$l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'),
115
-						[
116
-							'share' => [
117
-								'type' => 'pending-federated-share',
118
-								'id' => $notification->getObjectId(),
119
-								'name' => $params[2],
120
-							],
121
-							'user' => $this->createRemoteUser($initiator, $initiatorDisplay),
122
-							'behalf' => $this->createRemoteUser($owner, $ownerDisplay),
123
-						]
124
-					);
125
-				} else {
126
-					$notification->setParsedSubject(
127
-						$l->t('You received "%3$s" as a remote share from %4$s (%1$s)', $params)
128
-					);
113
+                    $notification->setRichSubject(
114
+                        $l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'),
115
+                        [
116
+                            'share' => [
117
+                                'type' => 'pending-federated-share',
118
+                                'id' => $notification->getObjectId(),
119
+                                'name' => $params[2],
120
+                            ],
121
+                            'user' => $this->createRemoteUser($initiator, $initiatorDisplay),
122
+                            'behalf' => $this->createRemoteUser($owner, $ownerDisplay),
123
+                        ]
124
+                    );
125
+                } else {
126
+                    $notification->setParsedSubject(
127
+                        $l->t('You received "%3$s" as a remote share from %4$s (%1$s)', $params)
128
+                    );
129 129
 
130
-					$owner = $params[0];
131
-					$ownerDisplay = isset($params[3]) ? $params[3] : null;
130
+                    $owner = $params[0];
131
+                    $ownerDisplay = isset($params[3]) ? $params[3] : null;
132 132
 
133
-					$notification->setRichSubject(
134
-						$l->t('You received {share} as a remote share from {user}'),
135
-						[
136
-							'share' => [
137
-								'type' => 'pending-federated-share',
138
-								'id' => $notification->getObjectId(),
139
-								'name' => $params[2],
140
-							],
141
-							'user' => $this->createRemoteUser($owner, $ownerDisplay),
142
-						]
143
-					);
144
-				}
133
+                    $notification->setRichSubject(
134
+                        $l->t('You received {share} as a remote share from {user}'),
135
+                        [
136
+                            'share' => [
137
+                                'type' => 'pending-federated-share',
138
+                                'id' => $notification->getObjectId(),
139
+                                'name' => $params[2],
140
+                            ],
141
+                            'user' => $this->createRemoteUser($owner, $ownerDisplay),
142
+                        ]
143
+                    );
144
+                }
145 145
 
146
-				// Deal with the actions for a known subject
147
-				foreach ($notification->getActions() as $action) {
148
-					switch ($action->getLabel()) {
149
-						case 'accept':
150
-							$action->setParsedLabel(
151
-								(string) $l->t('Accept')
152
-							)
153
-							->setPrimary(true);
154
-							break;
146
+                // Deal with the actions for a known subject
147
+                foreach ($notification->getActions() as $action) {
148
+                    switch ($action->getLabel()) {
149
+                        case 'accept':
150
+                            $action->setParsedLabel(
151
+                                (string) $l->t('Accept')
152
+                            )
153
+                            ->setPrimary(true);
154
+                            break;
155 155
 
156
-						case 'decline':
157
-							$action->setParsedLabel(
158
-								(string) $l->t('Decline')
159
-							);
160
-							break;
161
-					}
156
+                        case 'decline':
157
+                            $action->setParsedLabel(
158
+                                (string) $l->t('Decline')
159
+                            );
160
+                            break;
161
+                    }
162 162
 
163
-					$notification->addParsedAction($action);
164
-				}
165
-				return $notification;
163
+                    $notification->addParsedAction($action);
164
+                }
165
+                return $notification;
166 166
 
167
-			default:
168
-				// Unknown subject => Unknown notification => throw
169
-				throw new \InvalidArgumentException();
170
-		}
171
-	}
167
+            default:
168
+                // Unknown subject => Unknown notification => throw
169
+                throw new \InvalidArgumentException();
170
+        }
171
+    }
172 172
 
173
-	/**
174
-	 * @param string $cloudId
175
-	 * @return array
176
-	 */
177
-	protected function createRemoteUser($cloudId, $displayName = null) {
178
-		try {
179
-			$resolvedId = $this->cloudIdManager->resolveCloudId($cloudId);
180
-			if ($displayName === null) {
181
-				$displayName = $this->getDisplayName($resolvedId);
182
-			}
183
-			$user = $resolvedId->getUser();
184
-			$server = $resolvedId->getRemote();
185
-		} catch (HintException $e) {
186
-			$user = $cloudId;
187
-			$displayName = $cloudId;
188
-			$server = '';
189
-		}
173
+    /**
174
+     * @param string $cloudId
175
+     * @return array
176
+     */
177
+    protected function createRemoteUser($cloudId, $displayName = null) {
178
+        try {
179
+            $resolvedId = $this->cloudIdManager->resolveCloudId($cloudId);
180
+            if ($displayName === null) {
181
+                $displayName = $this->getDisplayName($resolvedId);
182
+            }
183
+            $user = $resolvedId->getUser();
184
+            $server = $resolvedId->getRemote();
185
+        } catch (HintException $e) {
186
+            $user = $cloudId;
187
+            $displayName = $cloudId;
188
+            $server = '';
189
+        }
190 190
 
191
-		return [
192
-			'type' => 'user',
193
-			'id' => $user,
194
-			'name' => $displayName,
195
-			'server' => $server,
196
-		];
197
-	}
191
+        return [
192
+            'type' => 'user',
193
+            'id' => $user,
194
+            'name' => $displayName,
195
+            'server' => $server,
196
+        ];
197
+    }
198 198
 
199
-	/**
200
-	 * Try to find the user in the contacts
201
-	 *
202
-	 * @param ICloudId $cloudId
203
-	 * @return string
204
-	 */
205
-	protected function getDisplayName(ICloudId $cloudId) {
206
-		$server = $cloudId->getRemote();
207
-		$user = $cloudId->getUser();
208
-		if (strpos($server, 'http://') === 0) {
209
-			$server = substr($server, strlen('http://'));
210
-		} else if (strpos($server, 'https://') === 0) {
211
-			$server = substr($server, strlen('https://'));
212
-		}
199
+    /**
200
+     * Try to find the user in the contacts
201
+     *
202
+     * @param ICloudId $cloudId
203
+     * @return string
204
+     */
205
+    protected function getDisplayName(ICloudId $cloudId) {
206
+        $server = $cloudId->getRemote();
207
+        $user = $cloudId->getUser();
208
+        if (strpos($server, 'http://') === 0) {
209
+            $server = substr($server, strlen('http://'));
210
+        } else if (strpos($server, 'https://') === 0) {
211
+            $server = substr($server, strlen('https://'));
212
+        }
213 213
 
214
-		try {
215
-			return $this->getDisplayNameFromContact($cloudId->getId());
216
-		} catch (\OutOfBoundsException $e) {
217
-		}
214
+        try {
215
+            return $this->getDisplayNameFromContact($cloudId->getId());
216
+        } catch (\OutOfBoundsException $e) {
217
+        }
218 218
 
219
-		try {
220
-			$this->getDisplayNameFromContact($user . '@http://' . $server);
221
-		} catch (\OutOfBoundsException $e) {
222
-		}
219
+        try {
220
+            $this->getDisplayNameFromContact($user . '@http://' . $server);
221
+        } catch (\OutOfBoundsException $e) {
222
+        }
223 223
 
224
-		try {
225
-			$this->getDisplayNameFromContact($user . '@https://' . $server);
226
-		} catch (\OutOfBoundsException $e) {
227
-		}
224
+        try {
225
+            $this->getDisplayNameFromContact($user . '@https://' . $server);
226
+        } catch (\OutOfBoundsException $e) {
227
+        }
228 228
 
229
-		return $cloudId->getId();
230
-	}
229
+        return $cloudId->getId();
230
+    }
231 231
 
232
-	/**
233
-	 * Try to find the user in the contacts
234
-	 *
235
-	 * @param string $federatedCloudId
236
-	 * @return string
237
-	 * @throws \OutOfBoundsException when there is no contact for the id
238
-	 */
239
-	protected function getDisplayNameFromContact($federatedCloudId) {
240
-		if (isset($this->federatedContacts[$federatedCloudId])) {
241
-			if ($this->federatedContacts[$federatedCloudId] !== '') {
242
-				return $this->federatedContacts[$federatedCloudId];
243
-			} else {
244
-				throw new \OutOfBoundsException('No contact found for federated cloud id');
245
-			}
246
-		}
232
+    /**
233
+     * Try to find the user in the contacts
234
+     *
235
+     * @param string $federatedCloudId
236
+     * @return string
237
+     * @throws \OutOfBoundsException when there is no contact for the id
238
+     */
239
+    protected function getDisplayNameFromContact($federatedCloudId) {
240
+        if (isset($this->federatedContacts[$federatedCloudId])) {
241
+            if ($this->federatedContacts[$federatedCloudId] !== '') {
242
+                return $this->federatedContacts[$federatedCloudId];
243
+            } else {
244
+                throw new \OutOfBoundsException('No contact found for federated cloud id');
245
+            }
246
+        }
247 247
 
248
-		$addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']);
249
-		foreach ($addressBookEntries as $entry) {
250
-			if (isset($entry['CLOUD'])) {
251
-				foreach ($entry['CLOUD'] as $cloudID) {
252
-					if ($cloudID === $federatedCloudId) {
253
-						$this->federatedContacts[$federatedCloudId] = $entry['FN'];
254
-						return $entry['FN'];
255
-					}
256
-				}
257
-			}
258
-		}
248
+        $addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']);
249
+        foreach ($addressBookEntries as $entry) {
250
+            if (isset($entry['CLOUD'])) {
251
+                foreach ($entry['CLOUD'] as $cloudID) {
252
+                    if ($cloudID === $federatedCloudId) {
253
+                        $this->federatedContacts[$federatedCloudId] = $entry['FN'];
254
+                        return $entry['FN'];
255
+                    }
256
+                }
257
+            }
258
+        }
259 259
 
260
-		$this->federatedContacts[$federatedCloudId] = '';
261
-		throw new \OutOfBoundsException('No contact found for federated cloud id');
262
-	}
260
+        $this->federatedContacts[$federatedCloudId] = '';
261
+        throw new \OutOfBoundsException('No contact found for federated cloud id');
262
+    }
263 263
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		$token = $argument['token'];
106 106
 		$action = $argument['action'];
107 107
 		$data = json_decode($argument['data'], true);
108
-		$try = (int)$argument['try'] + 1;
108
+		$try = (int) $argument['try'] + 1;
109 109
 
110 110
 		$result = $this->notifications->sendUpdateToRemote($remote, $remoteId, $token, $action, $data, $try);
111 111
 		
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				'token' => $argument['token'],
129 129
 				'data' => $argument['data'],
130 130
 				'action' => $argument['action'],
131
-				'try' => (int)$argument['try'] + 1,
131
+				'try' => (int) $argument['try'] + 1,
132 132
 				'lastRun' => time()
133 133
 			]
134 134
 		);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return bool
142 142
 	 */
143 143
 	protected function shouldRun(array $argument) {
144
-		$lastRun = (int)$argument['lastRun'];
144
+		$lastRun = (int) $argument['lastRun'];
145 145
 		return ((time() - $lastRun) > $this->interval);
146 146
 	}
147 147
 
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -45,105 +45,105 @@
 block discarded – undo
45 45
  */
46 46
 class RetryJob extends Job {
47 47
 
48
-	/** @var  bool */
49
-	private $retainJob = true;
50
-
51
-	/** @var Notifications */
52
-	private $notifications;
53
-
54
-	/** @var int max number of attempts to send the request */
55
-	private $maxTry = 20;
56
-
57
-	/** @var int how much time should be between two tries (10 minutes) */
58
-	private $interval = 600;
59
-
60
-	/**
61
-	 * UnShare constructor.
62
-	 *
63
-	 * @param Notifications $notifications
64
-	 */
65
-	public function __construct(Notifications $notifications = null) {
66
-		if ($notifications) {
67
-			$this->notifications = $notifications;
68
-		} else {
69
-			$addressHandler = new AddressHandler(
70
-				\OC::$server->getURLGenerator(),
71
-				\OC::$server->getL10N('federatedfilesharing'),
72
-				\OC::$server->getCloudIdManager()
73
-			);
74
-			$this->notifications = new Notifications(
75
-				$addressHandler,
76
-				\OC::$server->getHTTPClientService(),
77
-				\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
78
-				\OC::$server->getJobList(),
79
-				\OC::$server->getCloudFederationProviderManager(),
80
-				\OC::$server->getCloudFederationFactory()
81
-			);
82
-		}
83
-
84
-	}
85
-
86
-	/**
87
-	 * run the job, then remove it from the jobList
88
-	 *
89
-	 * @param JobList $jobList
90
-	 * @param ILogger|null $logger
91
-	 */
92
-	public function execute($jobList, ILogger $logger = null) {
93
-
94
-		if ($this->shouldRun($this->argument)) {
95
-			parent::execute($jobList, $logger);
96
-			$jobList->remove($this, $this->argument);
97
-			if ($this->retainJob) {
98
-				$this->reAddJob($jobList, $this->argument);
99
-			}
100
-		}
101
-	}
102
-
103
-	protected function run($argument) {
104
-		$remote = $argument['remote'];
105
-		$remoteId = $argument['remoteId'];
106
-		$token = $argument['token'];
107
-		$action = $argument['action'];
108
-		$data = json_decode($argument['data'], true);
109
-		$try = (int)$argument['try'] + 1;
110
-
111
-		$result = $this->notifications->sendUpdateToRemote($remote, $remoteId, $token, $action, $data, $try);
112
-
113
-		if ($result === true || $try > $this->maxTry) {
114
-			$this->retainJob = false;
115
-		}
116
-	}
117
-
118
-	/**
119
-	 * re-add background job with new arguments
120
-	 *
121
-	 * @param IJobList $jobList
122
-	 * @param array $argument
123
-	 */
124
-	protected function reAddJob(IJobList $jobList, array $argument) {
125
-		$jobList->add(RetryJob::class,
126
-			[
127
-				'remote' => $argument['remote'],
128
-				'remoteId' => $argument['remoteId'],
129
-				'token' => $argument['token'],
130
-				'data' => $argument['data'],
131
-				'action' => $argument['action'],
132
-				'try' => (int)$argument['try'] + 1,
133
-				'lastRun' => time()
134
-			]
135
-		);
136
-	}
137
-
138
-	/**
139
-	 * test if it is time for the next run
140
-	 *
141
-	 * @param array $argument
142
-	 * @return bool
143
-	 */
144
-	protected function shouldRun(array $argument) {
145
-		$lastRun = (int)$argument['lastRun'];
146
-		return ((time() - $lastRun) > $this->interval);
147
-	}
48
+    /** @var  bool */
49
+    private $retainJob = true;
50
+
51
+    /** @var Notifications */
52
+    private $notifications;
53
+
54
+    /** @var int max number of attempts to send the request */
55
+    private $maxTry = 20;
56
+
57
+    /** @var int how much time should be between two tries (10 minutes) */
58
+    private $interval = 600;
59
+
60
+    /**
61
+     * UnShare constructor.
62
+     *
63
+     * @param Notifications $notifications
64
+     */
65
+    public function __construct(Notifications $notifications = null) {
66
+        if ($notifications) {
67
+            $this->notifications = $notifications;
68
+        } else {
69
+            $addressHandler = new AddressHandler(
70
+                \OC::$server->getURLGenerator(),
71
+                \OC::$server->getL10N('federatedfilesharing'),
72
+                \OC::$server->getCloudIdManager()
73
+            );
74
+            $this->notifications = new Notifications(
75
+                $addressHandler,
76
+                \OC::$server->getHTTPClientService(),
77
+                \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
78
+                \OC::$server->getJobList(),
79
+                \OC::$server->getCloudFederationProviderManager(),
80
+                \OC::$server->getCloudFederationFactory()
81
+            );
82
+        }
83
+
84
+    }
85
+
86
+    /**
87
+     * run the job, then remove it from the jobList
88
+     *
89
+     * @param JobList $jobList
90
+     * @param ILogger|null $logger
91
+     */
92
+    public function execute($jobList, ILogger $logger = null) {
93
+
94
+        if ($this->shouldRun($this->argument)) {
95
+            parent::execute($jobList, $logger);
96
+            $jobList->remove($this, $this->argument);
97
+            if ($this->retainJob) {
98
+                $this->reAddJob($jobList, $this->argument);
99
+            }
100
+        }
101
+    }
102
+
103
+    protected function run($argument) {
104
+        $remote = $argument['remote'];
105
+        $remoteId = $argument['remoteId'];
106
+        $token = $argument['token'];
107
+        $action = $argument['action'];
108
+        $data = json_decode($argument['data'], true);
109
+        $try = (int)$argument['try'] + 1;
110
+
111
+        $result = $this->notifications->sendUpdateToRemote($remote, $remoteId, $token, $action, $data, $try);
112
+
113
+        if ($result === true || $try > $this->maxTry) {
114
+            $this->retainJob = false;
115
+        }
116
+    }
117
+
118
+    /**
119
+     * re-add background job with new arguments
120
+     *
121
+     * @param IJobList $jobList
122
+     * @param array $argument
123
+     */
124
+    protected function reAddJob(IJobList $jobList, array $argument) {
125
+        $jobList->add(RetryJob::class,
126
+            [
127
+                'remote' => $argument['remote'],
128
+                'remoteId' => $argument['remoteId'],
129
+                'token' => $argument['token'],
130
+                'data' => $argument['data'],
131
+                'action' => $argument['action'],
132
+                'try' => (int)$argument['try'] + 1,
133
+                'lastRun' => time()
134
+            ]
135
+        );
136
+    }
137
+
138
+    /**
139
+     * test if it is time for the next run
140
+     *
141
+     * @param array $argument
142
+     * @return bool
143
+     */
144
+    protected function shouldRun(array $argument) {
145
+        $lastRun = (int)$argument['lastRun'];
146
+        return ((time() - $lastRun) > $this->interval);
147
+    }
148 148
 
149 149
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/TokenHandler.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -33,30 +33,30 @@
 block discarded – undo
33 33
  */
34 34
 class TokenHandler {
35 35
 
36
-	const TOKEN_LENGTH = 15;
37
-
38
-	/** @var ISecureRandom */
39
-	private $secureRandom;
40
-
41
-	/**
42
-	 * TokenHandler constructor.
43
-	 *
44
-	 * @param ISecureRandom $secureRandom
45
-	 */
46
-	public function __construct(ISecureRandom $secureRandom) {
47
-		$this->secureRandom = $secureRandom;
48
-	}
49
-
50
-	/**
51
-	 * generate to token used to authenticate federated shares
52
-	 *
53
-	 * @return string
54
-	 */
55
-	public function generateToken() {
56
-		$token = $this->secureRandom->generate(
57
-			self::TOKEN_LENGTH,
58
-			ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
59
-		return $token;
60
-	}
36
+    const TOKEN_LENGTH = 15;
37
+
38
+    /** @var ISecureRandom */
39
+    private $secureRandom;
40
+
41
+    /**
42
+     * TokenHandler constructor.
43
+     *
44
+     * @param ISecureRandom $secureRandom
45
+     */
46
+    public function __construct(ISecureRandom $secureRandom) {
47
+        $this->secureRandom = $secureRandom;
48
+    }
49
+
50
+    /**
51
+     * generate to token used to authenticate federated shares
52
+     *
53
+     * @return string
54
+     */
55
+    public function generateToken() {
56
+        $token = $this->secureRandom->generate(
57
+            self::TOKEN_LENGTH,
58
+            ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
59
+        return $token;
60
+    }
61 61
 
62 62
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 	public function generateToken() {
56 56
 		$token = $this->secureRandom->generate(
57 57
 			self::TOKEN_LENGTH,
58
-			ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
58
+			ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS);
59 59
 		return $token;
60 60
 	}
61 61
 
Please login to merge, or discard this patch.
apps/federation/templates/settings-admin.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
28 28
 				<?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
29 29
 					<span class="status success"></span>
30 30
 				<?php
31
-				} elseif(
32
-					(int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
33
-					(int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
34
-				) { ?>
31
+                } elseif(
32
+                    (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
33
+                    (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
34
+                ) { ?>
35 35
 					<span class="status indeterminate"></span>
36 36
 				<?php } else {?>
37 37
 					<span class="status error"></span>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@
 block discarded – undo
11 11
 	<p class="settings-hint"><?php p($l->t('Federation allows you to connect with other trusted servers to exchange the user directory. For example this will be used to auto-complete external users for federated sharing.')); ?></p>
12 12
 
13 13
 	<p>
14
-		<input id="autoAddServers" type="checkbox" class="checkbox" <?php if($_['autoAddServers']) p('checked'); ?> />
14
+		<input id="autoAddServers" type="checkbox" class="checkbox" <?php if ($_['autoAddServers']) p('checked'); ?> />
15 15
 		<label for="autoAddServers"><?php p($l->t('Add server automatically once a federated share was created successfully')); ?></label>
16 16
 	</p>
17 17
 
18 18
 	<ul id="listOfTrustedServers">
19
-		<?php foreach($_['trustedServers'] as $trustedServer) { ?>
19
+		<?php foreach ($_['trustedServers'] as $trustedServer) { ?>
20 20
 			<li id="<?php p($trustedServer['id']); ?>">
21
-				<?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
21
+				<?php if ((int) $trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
22 22
 					<span class="status success"></span>
23 23
 				<?php
24
-				} elseif(
25
-					(int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
26
-					(int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
24
+				} elseif (
25
+					(int) $trustedServer['status'] === TrustedServers::STATUS_PENDING ||
26
+					(int) $trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
27 27
 				) { ?>
28 28
 					<span class="status indeterminate"></span>
29 29
 				<?php } else {?>
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,10 @@
 block discarded – undo
11 11
 	<p class="settings-hint"><?php p($l->t('Federation allows you to connect with other trusted servers to exchange the user directory. For example this will be used to auto-complete external users for federated sharing.')); ?></p>
12 12
 
13 13
 	<p>
14
-		<input id="autoAddServers" type="checkbox" class="checkbox" <?php if($_['autoAddServers']) p('checked'); ?> />
14
+		<input id="autoAddServers" type="checkbox" class="checkbox" <?php if($_['autoAddServers']) {
15
+    p('checked');
16
+}
17
+?> />
15 18
 		<label for="autoAddServers"><?php p($l->t('Add server automatically once a federated share was created successfully')); ?></label>
16 19
 	</p>
17 20
 
Please login to merge, or discard this patch.
apps/federation/lib/Settings/Admin.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -29,41 +29,41 @@
 block discarded – undo
29 29
 
30 30
 class Admin implements ISettings {
31 31
 
32
-	/** @var TrustedServers */
33
-	private $trustedServers;
32
+    /** @var TrustedServers */
33
+    private $trustedServers;
34 34
 
35
-	public function __construct(TrustedServers $trustedServers) {
36
-		$this->trustedServers = $trustedServers;
37
-	}
35
+    public function __construct(TrustedServers $trustedServers) {
36
+        $this->trustedServers = $trustedServers;
37
+    }
38 38
 
39
-	/**
40
-	 * @return TemplateResponse
41
-	 */
42
-	public function getForm() {
43
-		$parameters = [
44
-			'trustedServers' => $this->trustedServers->getServers(),
45
-			'autoAddServers' => $this->trustedServers->getAutoAddServers(),
46
-		];
39
+    /**
40
+     * @return TemplateResponse
41
+     */
42
+    public function getForm() {
43
+        $parameters = [
44
+            'trustedServers' => $this->trustedServers->getServers(),
45
+            'autoAddServers' => $this->trustedServers->getAutoAddServers(),
46
+        ];
47 47
 
48
-		return new TemplateResponse('federation', 'settings-admin', $parameters, '');
49
-	}
48
+        return new TemplateResponse('federation', 'settings-admin', $parameters, '');
49
+    }
50 50
 
51
-	/**
52
-	 * @return string the section ID, e.g. 'sharing'
53
-	 */
54
-	public function getSection() {
55
-		return 'sharing';
56
-	}
51
+    /**
52
+     * @return string the section ID, e.g. 'sharing'
53
+     */
54
+    public function getSection() {
55
+        return 'sharing';
56
+    }
57 57
 
58
-	/**
59
-	 * @return int whether the form should be rather on the top or bottom of
60
-	 * the admin section. The forms are arranged in ascending order of the
61
-	 * priority values. It is required to return a value between 0 and 100.
62
-	 *
63
-	 * E.g.: 70
64
-	 */
65
-	public function getPriority() {
66
-		return 30;
67
-	}
58
+    /**
59
+     * @return int whether the form should be rather on the top or bottom of
60
+     * the admin section. The forms are arranged in ascending order of the
61
+     * priority values. It is required to return a value between 0 and 100.
62
+     *
63
+     * E.g.: 70
64
+     */
65
+    public function getPriority() {
66
+        return 30;
67
+    }
68 68
 
69 69
 }
Please login to merge, or discard this patch.
apps/dav/lib/DAV/PublicAuth.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -26,67 +26,67 @@
 block discarded – undo
26 26
 
27 27
 class PublicAuth implements BackendInterface {
28 28
 
29
-	/** @var string[] */
30
-	private $publicURLs;
29
+    /** @var string[] */
30
+    private $publicURLs;
31 31
 
32
-	public function __construct() {
33
-		$this->publicURLs = [
34
-			'public-calendars',
35
-			'principals/system/public'
36
-		];
37
-	}
32
+    public function __construct() {
33
+        $this->publicURLs = [
34
+            'public-calendars',
35
+            'principals/system/public'
36
+        ];
37
+    }
38 38
 
39
-	/**
40
-	 * When this method is called, the backend must check if authentication was
41
-	 * successful.
42
-	 *
43
-	 * The returned value must be one of the following
44
-	 *
45
-	 * [true, "principals/username"]
46
-	 * [false, "reason for failure"]
47
-	 *
48
-	 * If authentication was successful, it's expected that the authentication
49
-	 * backend returns a so-called principal url.
50
-	 *
51
-	 * Examples of a principal url:
52
-	 *
53
-	 * principals/admin
54
-	 * principals/user1
55
-	 * principals/users/joe
56
-	 * principals/uid/123457
57
-	 *
58
-	 * If you don't use WebDAV ACL (RFC3744) we recommend that you simply
59
-	 * return a string such as:
60
-	 *
61
-	 * principals/users/[username]
62
-	 *
63
-	 * @param RequestInterface $request
64
-	 * @param ResponseInterface $response
65
-	 * @return array
66
-	 */
67
-	function check(RequestInterface $request, ResponseInterface $response) {
39
+    /**
40
+     * When this method is called, the backend must check if authentication was
41
+     * successful.
42
+     *
43
+     * The returned value must be one of the following
44
+     *
45
+     * [true, "principals/username"]
46
+     * [false, "reason for failure"]
47
+     *
48
+     * If authentication was successful, it's expected that the authentication
49
+     * backend returns a so-called principal url.
50
+     *
51
+     * Examples of a principal url:
52
+     *
53
+     * principals/admin
54
+     * principals/user1
55
+     * principals/users/joe
56
+     * principals/uid/123457
57
+     *
58
+     * If you don't use WebDAV ACL (RFC3744) we recommend that you simply
59
+     * return a string such as:
60
+     *
61
+     * principals/users/[username]
62
+     *
63
+     * @param RequestInterface $request
64
+     * @param ResponseInterface $response
65
+     * @return array
66
+     */
67
+    function check(RequestInterface $request, ResponseInterface $response) {
68 68
 
69
-		if ($this->isRequestPublic($request)) {
70
-			return [true, "principals/system/public"];
71
-		}
72
-		return [false, "No public access to this resource."];
73
-	}
69
+        if ($this->isRequestPublic($request)) {
70
+            return [true, "principals/system/public"];
71
+        }
72
+        return [false, "No public access to this resource."];
73
+    }
74 74
 
75
-	/**
76
-	 * @inheritdoc
77
-	 */
78
-	function challenge(RequestInterface $request, ResponseInterface $response) {
79
-	}
75
+    /**
76
+     * @inheritdoc
77
+     */
78
+    function challenge(RequestInterface $request, ResponseInterface $response) {
79
+    }
80 80
 
81
-	/**
82
-	 * @param RequestInterface $request
83
-	 * @return bool
84
-	 */
85
-	private function isRequestPublic(RequestInterface $request) {
86
-		$url = $request->getPath();
87
-		$matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) {
88
-			return strpos($url, $publicUrl, 0) === 0;
89
-		});
90
-		return !empty($matchingUrls);
91
-	}
81
+    /**
82
+     * @param RequestInterface $request
83
+     * @return bool
84
+     */
85
+    private function isRequestPublic(RequestInterface $request) {
86
+        $url = $request->getPath();
87
+        $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) {
88
+            return strpos($url, $publicUrl, 0) === 0;
89
+        });
90
+        return !empty($matchingUrls);
91
+    }
92 92
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 	 */
85 85
 	private function isRequestPublic(RequestInterface $request) {
86 86
 		$url = $request->getPath();
87
-		$matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) {
87
+		$matchingUrls = array_filter($this->publicURLs, function($publicUrl) use ($url) {
88 88
 			return strpos($url, $publicUrl, 0) === 0;
89 89
 		});
90 90
 		return !empty($matchingUrls);
Please login to merge, or discard this patch.
apps/dav/lib/DAV/Sharing/Xml/Invite.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -41,130 +41,130 @@
 block discarded – undo
41 41
  */
42 42
 class Invite implements XmlSerializable {
43 43
 
44
-	/**
45
-	 * The list of users a calendar has been shared to.
46
-	 *
47
-	 * @var array
48
-	 */
49
-	protected $users;
50
-
51
-	/**
52
-	 * The organizer contains information about the person who shared the
53
-	 * object.
54
-	 *
55
-	 * @var array|null
56
-	 */
57
-	protected $organizer;
58
-
59
-	/**
60
-	 * Creates the property.
61
-	 *
62
-	 * Users is an array. Each element of the array has the following
63
-	 * properties:
64
-	 *
65
-	 *   * href - Often a mailto: address
66
-	 *   * commonName - Optional, for example a first and lastname for a user.
67
-	 *   * status - One of the SharingPlugin::STATUS_* constants.
68
-	 *   * readOnly - true or false
69
-	 *   * summary - Optional, description of the share
70
-	 *
71
-	 * The organizer key is optional to specify. It's only useful when a
72
-	 * 'sharee' requests the sharing information.
73
-	 *
74
-	 * The organizer may have the following properties:
75
-	 *   * href - Often a mailto: address.
76
-	 *   * commonName - Optional human-readable name.
77
-	 *   * firstName - Optional first name.
78
-	 *   * lastName - Optional last name.
79
-	 *
80
-	 * If you wonder why these two structures are so different, I guess a
81
-	 * valid answer is that the current spec is still a draft.
82
-	 *
83
-	 * @param array $users
84
-	 */
85
-	function __construct(array $users, array $organizer = null) {
86
-
87
-		$this->users = $users;
88
-		$this->organizer = $organizer;
89
-
90
-	}
91
-
92
-	/**
93
-	 * Returns the list of users, as it was passed to the constructor.
94
-	 *
95
-	 * @return array
96
-	 */
97
-	function getValue() {
98
-
99
-		return $this->users;
100
-
101
-	}
102
-
103
-	/**
104
-	 * The xmlSerialize metod is called during xml writing.
105
-	 *
106
-	 * Use the $writer argument to write its own xml serialization.
107
-	 *
108
-	 * An important note: do _not_ create a parent element. Any element
109
-	 * implementing XmlSerializble should only ever write what's considered
110
-	 * its 'inner xml'.
111
-	 *
112
-	 * The parent of the current element is responsible for writing a
113
-	 * containing element.
114
-	 *
115
-	 * This allows serializers to be re-used for different element names.
116
-	 *
117
-	 * If you are opening new elements, you must also close them again.
118
-	 *
119
-	 * @param Writer $writer
120
-	 * @return void
121
-	 */
122
-	function xmlSerialize(Writer $writer) {
123
-
124
-		$cs = '{' . Plugin::NS_OWNCLOUD . '}';
125
-
126
-		if (!is_null($this->organizer)) {
127
-
128
-			$writer->startElement($cs . 'organizer');
129
-			$writer->writeElement('{DAV:}href', $this->organizer['href']);
130
-
131
-			if (isset($this->organizer['commonName']) && $this->organizer['commonName']) {
132
-				$writer->writeElement($cs . 'common-name', $this->organizer['commonName']);
133
-			}
134
-			if (isset($this->organizer['firstName']) && $this->organizer['firstName']) {
135
-				$writer->writeElement($cs . 'first-name', $this->organizer['firstName']);
136
-			}
137
-			if (isset($this->organizer['lastName']) && $this->organizer['lastName']) {
138
-				$writer->writeElement($cs . 'last-name', $this->organizer['lastName']);
139
-			}
140
-			$writer->endElement(); // organizer
141
-
142
-		}
143
-
144
-		foreach ($this->users as $user) {
145
-
146
-			$writer->startElement($cs . 'user');
147
-			$writer->writeElement('{DAV:}href', $user['href']);
148
-			if (isset($user['commonName']) && $user['commonName']) {
149
-				$writer->writeElement($cs . 'common-name', $user['commonName']);
150
-			}
151
-			$writer->writeElement($cs . 'invite-accepted');
152
-
153
-			$writer->startElement($cs . 'access');
154
-			if ($user['readOnly']) {
155
-				$writer->writeElement($cs . 'read');
156
-			} else {
157
-				$writer->writeElement($cs . 'read-write');
158
-			}
159
-			$writer->endElement(); // access
160
-
161
-			if (isset($user['summary']) && $user['summary']) {
162
-				$writer->writeElement($cs . 'summary', $user['summary']);
163
-			}
164
-
165
-			$writer->endElement(); //user
166
-
167
-		}
168
-
169
-	}
44
+    /**
45
+     * The list of users a calendar has been shared to.
46
+     *
47
+     * @var array
48
+     */
49
+    protected $users;
50
+
51
+    /**
52
+     * The organizer contains information about the person who shared the
53
+     * object.
54
+     *
55
+     * @var array|null
56
+     */
57
+    protected $organizer;
58
+
59
+    /**
60
+     * Creates the property.
61
+     *
62
+     * Users is an array. Each element of the array has the following
63
+     * properties:
64
+     *
65
+     *   * href - Often a mailto: address
66
+     *   * commonName - Optional, for example a first and lastname for a user.
67
+     *   * status - One of the SharingPlugin::STATUS_* constants.
68
+     *   * readOnly - true or false
69
+     *   * summary - Optional, description of the share
70
+     *
71
+     * The organizer key is optional to specify. It's only useful when a
72
+     * 'sharee' requests the sharing information.
73
+     *
74
+     * The organizer may have the following properties:
75
+     *   * href - Often a mailto: address.
76
+     *   * commonName - Optional human-readable name.
77
+     *   * firstName - Optional first name.
78
+     *   * lastName - Optional last name.
79
+     *
80
+     * If you wonder why these two structures are so different, I guess a
81
+     * valid answer is that the current spec is still a draft.
82
+     *
83
+     * @param array $users
84
+     */
85
+    function __construct(array $users, array $organizer = null) {
86
+
87
+        $this->users = $users;
88
+        $this->organizer = $organizer;
89
+
90
+    }
91
+
92
+    /**
93
+     * Returns the list of users, as it was passed to the constructor.
94
+     *
95
+     * @return array
96
+     */
97
+    function getValue() {
98
+
99
+        return $this->users;
100
+
101
+    }
102
+
103
+    /**
104
+     * The xmlSerialize metod is called during xml writing.
105
+     *
106
+     * Use the $writer argument to write its own xml serialization.
107
+     *
108
+     * An important note: do _not_ create a parent element. Any element
109
+     * implementing XmlSerializble should only ever write what's considered
110
+     * its 'inner xml'.
111
+     *
112
+     * The parent of the current element is responsible for writing a
113
+     * containing element.
114
+     *
115
+     * This allows serializers to be re-used for different element names.
116
+     *
117
+     * If you are opening new elements, you must also close them again.
118
+     *
119
+     * @param Writer $writer
120
+     * @return void
121
+     */
122
+    function xmlSerialize(Writer $writer) {
123
+
124
+        $cs = '{' . Plugin::NS_OWNCLOUD . '}';
125
+
126
+        if (!is_null($this->organizer)) {
127
+
128
+            $writer->startElement($cs . 'organizer');
129
+            $writer->writeElement('{DAV:}href', $this->organizer['href']);
130
+
131
+            if (isset($this->organizer['commonName']) && $this->organizer['commonName']) {
132
+                $writer->writeElement($cs . 'common-name', $this->organizer['commonName']);
133
+            }
134
+            if (isset($this->organizer['firstName']) && $this->organizer['firstName']) {
135
+                $writer->writeElement($cs . 'first-name', $this->organizer['firstName']);
136
+            }
137
+            if (isset($this->organizer['lastName']) && $this->organizer['lastName']) {
138
+                $writer->writeElement($cs . 'last-name', $this->organizer['lastName']);
139
+            }
140
+            $writer->endElement(); // organizer
141
+
142
+        }
143
+
144
+        foreach ($this->users as $user) {
145
+
146
+            $writer->startElement($cs . 'user');
147
+            $writer->writeElement('{DAV:}href', $user['href']);
148
+            if (isset($user['commonName']) && $user['commonName']) {
149
+                $writer->writeElement($cs . 'common-name', $user['commonName']);
150
+            }
151
+            $writer->writeElement($cs . 'invite-accepted');
152
+
153
+            $writer->startElement($cs . 'access');
154
+            if ($user['readOnly']) {
155
+                $writer->writeElement($cs . 'read');
156
+            } else {
157
+                $writer->writeElement($cs . 'read-write');
158
+            }
159
+            $writer->endElement(); // access
160
+
161
+            if (isset($user['summary']) && $user['summary']) {
162
+                $writer->writeElement($cs . 'summary', $user['summary']);
163
+            }
164
+
165
+            $writer->endElement(); //user
166
+
167
+        }
168
+
169
+    }
170 170
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	function xmlSerialize(Writer $writer) {
123 123
 
124
-		$cs = '{' . Plugin::NS_OWNCLOUD . '}';
124
+		$cs = '{'.Plugin::NS_OWNCLOUD.'}';
125 125
 
126 126
 		if (!is_null($this->organizer)) {
127 127
 
128
-			$writer->startElement($cs . 'organizer');
128
+			$writer->startElement($cs.'organizer');
129 129
 			$writer->writeElement('{DAV:}href', $this->organizer['href']);
130 130
 
131 131
 			if (isset($this->organizer['commonName']) && $this->organizer['commonName']) {
132
-				$writer->writeElement($cs . 'common-name', $this->organizer['commonName']);
132
+				$writer->writeElement($cs.'common-name', $this->organizer['commonName']);
133 133
 			}
134 134
 			if (isset($this->organizer['firstName']) && $this->organizer['firstName']) {
135
-				$writer->writeElement($cs . 'first-name', $this->organizer['firstName']);
135
+				$writer->writeElement($cs.'first-name', $this->organizer['firstName']);
136 136
 			}
137 137
 			if (isset($this->organizer['lastName']) && $this->organizer['lastName']) {
138
-				$writer->writeElement($cs . 'last-name', $this->organizer['lastName']);
138
+				$writer->writeElement($cs.'last-name', $this->organizer['lastName']);
139 139
 			}
140 140
 			$writer->endElement(); // organizer
141 141
 
@@ -143,23 +143,23 @@  discard block
 block discarded – undo
143 143
 
144 144
 		foreach ($this->users as $user) {
145 145
 
146
-			$writer->startElement($cs . 'user');
146
+			$writer->startElement($cs.'user');
147 147
 			$writer->writeElement('{DAV:}href', $user['href']);
148 148
 			if (isset($user['commonName']) && $user['commonName']) {
149
-				$writer->writeElement($cs . 'common-name', $user['commonName']);
149
+				$writer->writeElement($cs.'common-name', $user['commonName']);
150 150
 			}
151
-			$writer->writeElement($cs . 'invite-accepted');
151
+			$writer->writeElement($cs.'invite-accepted');
152 152
 
153
-			$writer->startElement($cs . 'access');
153
+			$writer->startElement($cs.'access');
154 154
 			if ($user['readOnly']) {
155
-				$writer->writeElement($cs . 'read');
155
+				$writer->writeElement($cs.'read');
156 156
 			} else {
157
-				$writer->writeElement($cs . 'read-write');
157
+				$writer->writeElement($cs.'read-write');
158 158
 			}
159 159
 			$writer->endElement(); // access
160 160
 
161 161
 			if (isset($user['summary']) && $user['summary']) {
162
-				$writer->writeElement($cs . 'summary', $user['summary']);
162
+				$writer->writeElement($cs.'summary', $user['summary']);
163 163
 			}
164 164
 
165 165
 			$writer->endElement(); //user
Please login to merge, or discard this patch.
apps/dav/lib/DAV/Sharing/Plugin.php 3 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,8 +119,9 @@
 block discarded – undo
119 119
 
120 120
 		// Only handling xml
121 121
 		$contentType = $request->getHeader('Content-Type');
122
-		if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false)
123
-			return;
122
+		if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) {
123
+					return;
124
+		}
124 125
 
125 126
 		// Making sure the node exists
126 127
 		try {
Please login to merge, or discard this patch.
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -38,167 +38,167 @@
 block discarded – undo
38 38
 
39 39
 class Plugin extends ServerPlugin {
40 40
 
41
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
42
-	const NS_NEXTCLOUD = 'http://nextcloud.com/ns';
43
-
44
-	/** @var Auth */
45
-	private $auth;
46
-
47
-	/** @var IRequest */
48
-	private $request;
49
-
50
-	/**
51
-	 * Plugin constructor.
52
-	 *
53
-	 * @param Auth $authBackEnd
54
-	 * @param IRequest $request
55
-	 */
56
-	public function __construct(Auth $authBackEnd, IRequest $request) {
57
-		$this->auth = $authBackEnd;
58
-		$this->request = $request;
59
-	}
60
-
61
-	/**
62
-	 * Reference to SabreDAV server object.
63
-	 *
64
-	 * @var \Sabre\DAV\Server
65
-	 */
66
-	protected $server;
67
-
68
-	/**
69
-	 * This method should return a list of server-features.
70
-	 *
71
-	 * This is for example 'versioning' and is added to the DAV: header
72
-	 * in an OPTIONS response.
73
-	 *
74
-	 * @return string[]
75
-	 */
76
-	function getFeatures() {
77
-		return ['oc-resource-sharing'];
78
-	}
79
-
80
-	/**
81
-	 * Returns a plugin name.
82
-	 *
83
-	 * Using this name other plugins will be able to access other plugins
84
-	 * using Sabre\DAV\Server::getPlugin
85
-	 *
86
-	 * @return string
87
-	 */
88
-	function getPluginName() {
89
-		return 'oc-resource-sharing';
90
-	}
91
-
92
-	/**
93
-	 * This initializes the plugin.
94
-	 *
95
-	 * This function is called by Sabre\DAV\Server, after
96
-	 * addPlugin is called.
97
-	 *
98
-	 * This method should set up the required event subscriptions.
99
-	 *
100
-	 * @param Server $server
101
-	 * @return void
102
-	 */
103
-	function initialize(Server $server) {
104
-		$this->server = $server;
105
-		$this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}share'] = ShareRequest::class;
106
-		$this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}invite'] = Invite::class;
107
-
108
-		$this->server->on('method:POST', [$this, 'httpPost']);
109
-		$this->server->on('propFind',    [$this, 'propFind']);
110
-	}
111
-
112
-	/**
113
-	 * We intercept this to handle POST requests on a dav resource.
114
-	 *
115
-	 * @param RequestInterface $request
116
-	 * @param ResponseInterface $response
117
-	 * @return null|false
118
-	 */
119
-	function httpPost(RequestInterface $request, ResponseInterface $response) {
120
-
121
-		$path = $request->getPath();
122
-
123
-		// Only handling xml
124
-		$contentType = $request->getHeader('Content-Type');
125
-		if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false)
126
-			return;
127
-
128
-		// Making sure the node exists
129
-		try {
130
-			$node = $this->server->tree->getNodeForPath($path);
131
-		} catch (NotFound $e) {
132
-			return;
133
-		}
134
-
135
-		$requestBody = $request->getBodyAsString();
136
-
137
-		// If this request handler could not deal with this POST request, it
138
-		// will return 'null' and other plugins get a chance to handle the
139
-		// request.
140
-		//
141
-		// However, we already requested the full body. This is a problem,
142
-		// because a body can only be read once. This is why we preemptively
143
-		// re-populated the request body with the existing data.
144
-		$request->setBody($requestBody);
145
-
146
-		$message = $this->server->xml->parse($requestBody, $request->getUrl(), $documentType);
147
-
148
-		switch ($documentType) {
149
-
150
-			// Dealing with the 'share' document, which modified invitees on a
151
-			// calendar.
152
-			case '{' . self::NS_OWNCLOUD . '}share' :
153
-
154
-				// We can only deal with IShareableCalendar objects
155
-				if (!$node instanceof IShareable) {
156
-					return;
157
-				}
158
-
159
-				$this->server->transactionType = 'post-oc-resource-share';
160
-
161
-				// Getting ACL info
162
-				$acl = $this->server->getPlugin('acl');
163
-
164
-				// If there's no ACL support, we allow everything
165
-				if ($acl) {
166
-					/** @var \Sabre\DAVACL\Plugin $acl */
167
-					$acl->checkPrivileges($path, '{DAV:}write');
168
-				}
169
-
170
-				$node->updateShares($message->set, $message->remove);
171
-
172
-				$response->setStatus(200);
173
-				// Adding this because sending a response body may cause issues,
174
-				// and I wanted some type of indicator the response was handled.
175
-				$response->setHeader('X-Sabre-Status', 'everything-went-well');
176
-
177
-				// Breaking the event chain
178
-				return false;
179
-		}
180
-	}
181
-
182
-	/**
183
-	 * This event is triggered when properties are requested for a certain
184
-	 * node.
185
-	 *
186
-	 * This allows us to inject any properties early.
187
-	 *
188
-	 * @param PropFind $propFind
189
-	 * @param INode $node
190
-	 * @return void
191
-	 */
192
-	function propFind(PropFind $propFind, INode $node) {
193
-		if ($node instanceof IShareable) {
194
-
195
-			$propFind->handle('{' . Plugin::NS_OWNCLOUD . '}invite', function () use ($node) {
196
-				return new Invite(
197
-					$node->getShares()
198
-				);
199
-			});
200
-
201
-		}
202
-	}
41
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
42
+    const NS_NEXTCLOUD = 'http://nextcloud.com/ns';
43
+
44
+    /** @var Auth */
45
+    private $auth;
46
+
47
+    /** @var IRequest */
48
+    private $request;
49
+
50
+    /**
51
+     * Plugin constructor.
52
+     *
53
+     * @param Auth $authBackEnd
54
+     * @param IRequest $request
55
+     */
56
+    public function __construct(Auth $authBackEnd, IRequest $request) {
57
+        $this->auth = $authBackEnd;
58
+        $this->request = $request;
59
+    }
60
+
61
+    /**
62
+     * Reference to SabreDAV server object.
63
+     *
64
+     * @var \Sabre\DAV\Server
65
+     */
66
+    protected $server;
67
+
68
+    /**
69
+     * This method should return a list of server-features.
70
+     *
71
+     * This is for example 'versioning' and is added to the DAV: header
72
+     * in an OPTIONS response.
73
+     *
74
+     * @return string[]
75
+     */
76
+    function getFeatures() {
77
+        return ['oc-resource-sharing'];
78
+    }
79
+
80
+    /**
81
+     * Returns a plugin name.
82
+     *
83
+     * Using this name other plugins will be able to access other plugins
84
+     * using Sabre\DAV\Server::getPlugin
85
+     *
86
+     * @return string
87
+     */
88
+    function getPluginName() {
89
+        return 'oc-resource-sharing';
90
+    }
91
+
92
+    /**
93
+     * This initializes the plugin.
94
+     *
95
+     * This function is called by Sabre\DAV\Server, after
96
+     * addPlugin is called.
97
+     *
98
+     * This method should set up the required event subscriptions.
99
+     *
100
+     * @param Server $server
101
+     * @return void
102
+     */
103
+    function initialize(Server $server) {
104
+        $this->server = $server;
105
+        $this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}share'] = ShareRequest::class;
106
+        $this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}invite'] = Invite::class;
107
+
108
+        $this->server->on('method:POST', [$this, 'httpPost']);
109
+        $this->server->on('propFind',    [$this, 'propFind']);
110
+    }
111
+
112
+    /**
113
+     * We intercept this to handle POST requests on a dav resource.
114
+     *
115
+     * @param RequestInterface $request
116
+     * @param ResponseInterface $response
117
+     * @return null|false
118
+     */
119
+    function httpPost(RequestInterface $request, ResponseInterface $response) {
120
+
121
+        $path = $request->getPath();
122
+
123
+        // Only handling xml
124
+        $contentType = $request->getHeader('Content-Type');
125
+        if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false)
126
+            return;
127
+
128
+        // Making sure the node exists
129
+        try {
130
+            $node = $this->server->tree->getNodeForPath($path);
131
+        } catch (NotFound $e) {
132
+            return;
133
+        }
134
+
135
+        $requestBody = $request->getBodyAsString();
136
+
137
+        // If this request handler could not deal with this POST request, it
138
+        // will return 'null' and other plugins get a chance to handle the
139
+        // request.
140
+        //
141
+        // However, we already requested the full body. This is a problem,
142
+        // because a body can only be read once. This is why we preemptively
143
+        // re-populated the request body with the existing data.
144
+        $request->setBody($requestBody);
145
+
146
+        $message = $this->server->xml->parse($requestBody, $request->getUrl(), $documentType);
147
+
148
+        switch ($documentType) {
149
+
150
+            // Dealing with the 'share' document, which modified invitees on a
151
+            // calendar.
152
+            case '{' . self::NS_OWNCLOUD . '}share' :
153
+
154
+                // We can only deal with IShareableCalendar objects
155
+                if (!$node instanceof IShareable) {
156
+                    return;
157
+                }
158
+
159
+                $this->server->transactionType = 'post-oc-resource-share';
160
+
161
+                // Getting ACL info
162
+                $acl = $this->server->getPlugin('acl');
163
+
164
+                // If there's no ACL support, we allow everything
165
+                if ($acl) {
166
+                    /** @var \Sabre\DAVACL\Plugin $acl */
167
+                    $acl->checkPrivileges($path, '{DAV:}write');
168
+                }
169
+
170
+                $node->updateShares($message->set, $message->remove);
171
+
172
+                $response->setStatus(200);
173
+                // Adding this because sending a response body may cause issues,
174
+                // and I wanted some type of indicator the response was handled.
175
+                $response->setHeader('X-Sabre-Status', 'everything-went-well');
176
+
177
+                // Breaking the event chain
178
+                return false;
179
+        }
180
+    }
181
+
182
+    /**
183
+     * This event is triggered when properties are requested for a certain
184
+     * node.
185
+     *
186
+     * This allows us to inject any properties early.
187
+     *
188
+     * @param PropFind $propFind
189
+     * @param INode $node
190
+     * @return void
191
+     */
192
+    function propFind(PropFind $propFind, INode $node) {
193
+        if ($node instanceof IShareable) {
194
+
195
+            $propFind->handle('{' . Plugin::NS_OWNCLOUD . '}invite', function () use ($node) {
196
+                return new Invite(
197
+                    $node->getShares()
198
+                );
199
+            });
200
+
201
+        }
202
+    }
203 203
 
204 204
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	function initialize(Server $server) {
104 104
 		$this->server = $server;
105
-		$this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}share'] = ShareRequest::class;
106
-		$this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}invite'] = Invite::class;
105
+		$this->server->xml->elementMap['{'.Plugin::NS_OWNCLOUD.'}share'] = ShareRequest::class;
106
+		$this->server->xml->elementMap['{'.Plugin::NS_OWNCLOUD.'}invite'] = Invite::class;
107 107
 
108 108
 		$this->server->on('method:POST', [$this, 'httpPost']);
109
-		$this->server->on('propFind',    [$this, 'propFind']);
109
+		$this->server->on('propFind', [$this, 'propFind']);
110 110
 	}
111 111
 
112 112
 	/**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 			// Dealing with the 'share' document, which modified invitees on a
151 151
 			// calendar.
152
-			case '{' . self::NS_OWNCLOUD . '}share' :
152
+			case '{'.self::NS_OWNCLOUD.'}share' :
153 153
 
154 154
 				// We can only deal with IShareableCalendar objects
155 155
 				if (!$node instanceof IShareable) {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	function propFind(PropFind $propFind, INode $node) {
193 193
 		if ($node instanceof IShareable) {
194 194
 
195
-			$propFind->handle('{' . Plugin::NS_OWNCLOUD . '}invite', function () use ($node) {
195
+			$propFind->handle('{'.Plugin::NS_OWNCLOUD.'}invite', function() use ($node) {
196 196
 				return new Invite(
197 197
 					$node->getShares()
198 198
 				);
Please login to merge, or discard this patch.
apps/dav/lib/Comments/EntityTypeCollection.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -43,85 +43,85 @@
 block discarded – undo
43 43
  */
44 44
 class EntityTypeCollection extends RootCollection {
45 45
 
46
-	/** @var ILogger */
47
-	protected $logger;
46
+    /** @var ILogger */
47
+    protected $logger;
48 48
 
49
-	/** @var IUserManager */
50
-	protected $userManager;
49
+    /** @var IUserManager */
50
+    protected $userManager;
51 51
 
52
-	/** @var \Closure */
53
-	protected $childExistsFunction;
52
+    /** @var \Closure */
53
+    protected $childExistsFunction;
54 54
 
55
-	/**
56
-	 * @param string $name
57
-	 * @param ICommentsManager $commentsManager
58
-	 * @param IUserManager $userManager
59
-	 * @param IUserSession $userSession
60
-	 * @param ILogger $logger
61
-	 * @param \Closure $childExistsFunction
62
-	 */
63
-	public function __construct(
64
-		$name,
65
-		ICommentsManager $commentsManager,
66
-		IUserManager $userManager,
67
-		IUserSession $userSession,
68
-		ILogger $logger,
69
-		\Closure $childExistsFunction
70
-	) {
71
-		$name = trim($name);
72
-		if(empty($name) || !is_string($name)) {
73
-			throw new \InvalidArgumentException('"name" parameter must be non-empty string');
74
-		}
75
-		$this->name = $name;
76
-		$this->commentsManager = $commentsManager;
77
-		$this->logger = $logger;
78
-		$this->userManager = $userManager;
79
-		$this->userSession = $userSession;
80
-		$this->childExistsFunction = $childExistsFunction;
81
-	}
55
+    /**
56
+     * @param string $name
57
+     * @param ICommentsManager $commentsManager
58
+     * @param IUserManager $userManager
59
+     * @param IUserSession $userSession
60
+     * @param ILogger $logger
61
+     * @param \Closure $childExistsFunction
62
+     */
63
+    public function __construct(
64
+        $name,
65
+        ICommentsManager $commentsManager,
66
+        IUserManager $userManager,
67
+        IUserSession $userSession,
68
+        ILogger $logger,
69
+        \Closure $childExistsFunction
70
+    ) {
71
+        $name = trim($name);
72
+        if(empty($name) || !is_string($name)) {
73
+            throw new \InvalidArgumentException('"name" parameter must be non-empty string');
74
+        }
75
+        $this->name = $name;
76
+        $this->commentsManager = $commentsManager;
77
+        $this->logger = $logger;
78
+        $this->userManager = $userManager;
79
+        $this->userSession = $userSession;
80
+        $this->childExistsFunction = $childExistsFunction;
81
+    }
82 82
 
83
-	/**
84
-	 * Returns a specific child node, referenced by its name
85
-	 *
86
-	 * This method must throw Sabre\DAV\Exception\NotFound if the node does not
87
-	 * exist.
88
-	 *
89
-	 * @param string $name
90
-	 * @return \Sabre\DAV\INode
91
-	 * @throws NotFound
92
-	 */
93
-	function getChild($name) {
94
-		if(!$this->childExists($name)) {
95
-			throw new NotFound('Entity does not exist or is not available');
96
-		}
97
-		return new EntityCollection(
98
-			$name,
99
-			$this->name,
100
-			$this->commentsManager,
101
-			$this->userManager,
102
-			$this->userSession,
103
-			$this->logger
104
-		);
105
-	}
83
+    /**
84
+     * Returns a specific child node, referenced by its name
85
+     *
86
+     * This method must throw Sabre\DAV\Exception\NotFound if the node does not
87
+     * exist.
88
+     *
89
+     * @param string $name
90
+     * @return \Sabre\DAV\INode
91
+     * @throws NotFound
92
+     */
93
+    function getChild($name) {
94
+        if(!$this->childExists($name)) {
95
+            throw new NotFound('Entity does not exist or is not available');
96
+        }
97
+        return new EntityCollection(
98
+            $name,
99
+            $this->name,
100
+            $this->commentsManager,
101
+            $this->userManager,
102
+            $this->userSession,
103
+            $this->logger
104
+        );
105
+    }
106 106
 
107
-	/**
108
-	 * Returns an array with all the child nodes
109
-	 *
110
-	 * @return \Sabre\DAV\INode[]
111
-	 * @throws MethodNotAllowed
112
-	 */
113
-	function getChildren() {
114
-		throw new MethodNotAllowed('No permission to list folder contents');
115
-	}
107
+    /**
108
+     * Returns an array with all the child nodes
109
+     *
110
+     * @return \Sabre\DAV\INode[]
111
+     * @throws MethodNotAllowed
112
+     */
113
+    function getChildren() {
114
+        throw new MethodNotAllowed('No permission to list folder contents');
115
+    }
116 116
 
117
-	/**
118
-	 * Checks if a child-node with the specified name exists
119
-	 *
120
-	 * @param string $name
121
-	 * @return bool
122
-	 */
123
-	function childExists($name) {
124
-		return call_user_func($this->childExistsFunction, $name);
125
-	}
117
+    /**
118
+     * Checks if a child-node with the specified name exists
119
+     *
120
+     * @param string $name
121
+     * @return bool
122
+     */
123
+    function childExists($name) {
124
+        return call_user_func($this->childExistsFunction, $name);
125
+    }
126 126
 
127 127
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		\Closure $childExistsFunction
70 70
 	) {
71 71
 		$name = trim($name);
72
-		if(empty($name) || !is_string($name)) {
72
+		if (empty($name) || !is_string($name)) {
73 73
 			throw new \InvalidArgumentException('"name" parameter must be non-empty string');
74 74
 		}
75 75
 		$this->name = $name;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @throws NotFound
92 92
 	 */
93 93
 	function getChild($name) {
94
-		if(!$this->childExists($name)) {
94
+		if (!$this->childExists($name)) {
95 95
 			throw new NotFound('Entity does not exist or is not available');
96 96
 		}
97 97
 		return new EntityCollection(
Please login to merge, or discard this patch.