Completed
Pull Request — master (#10075)
by
unknown
27:10
created
lib/private/Files/Storage/FailedStorage.php 1 patch
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -34,185 +34,185 @@
 block discarded – undo
34 34
  */
35 35
 class FailedStorage extends Common {
36 36
 
37
-	/** @var \Exception */
38
-	protected $e;
39
-
40
-	/**
41
-	 * @param array $params ['exception' => \Exception]
42
-	 */
43
-	public function __construct($params) {
44
-		$this->e = $params['exception'];
45
-		if (!$this->e) {
46
-			throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor');
47
-		}
48
-	}
49
-
50
-	public function getId() {
51
-		// we can't return anything sane here
52
-		return 'failedstorage';
53
-	}
54
-
55
-	public function mkdir($path) {
56
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
57
-	}
58
-
59
-	public function rmdir($path) {
60
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
61
-	}
62
-
63
-	public function opendir($path) {
64
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
65
-	}
66
-
67
-	public function is_dir($path) {
68
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
69
-	}
70
-
71
-	public function is_file($path) {
72
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
73
-	}
74
-
75
-	public function stat($path) {
76
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
77
-	}
78
-
79
-	public function filetype($path) {
80
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
81
-	}
82
-
83
-	public function filesize($path) {
84
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
85
-	}
86
-
87
-	public function isCreatable($path) {
88
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
89
-	}
90
-
91
-	public function isReadable($path) {
92
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
93
-	}
94
-
95
-	public function isUpdatable($path) {
96
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
97
-	}
98
-
99
-	public function isDeletable($path) {
100
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
101
-	}
102
-
103
-	public function isSharable($path) {
104
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
105
-	}
106
-
107
-	public function getPermissions($path) {
108
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
109
-	}
110
-
111
-	public function file_exists($path) {
112
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
113
-	}
114
-
115
-	public function filemtime($path) {
116
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
117
-	}
118
-
119
-	public function file_get_contents($path) {
120
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
121
-	}
122
-
123
-	public function file_put_contents($path, $data) {
124
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
125
-	}
126
-
127
-	public function unlink($path) {
128
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
129
-	}
130
-
131
-	public function rename($path1, $path2) {
132
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
133
-	}
134
-
135
-	public function copy($path1, $path2) {
136
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
137
-	}
138
-
139
-	public function fopen($path, $mode) {
140
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
141
-	}
142
-
143
-	public function getMimeType($path) {
144
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
145
-	}
146
-
147
-	public function hash($type, $path, $raw = false) {
148
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
149
-	}
150
-
151
-	public function free_space($path) {
152
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
153
-	}
37
+    /** @var \Exception */
38
+    protected $e;
39
+
40
+    /**
41
+     * @param array $params ['exception' => \Exception]
42
+     */
43
+    public function __construct($params) {
44
+        $this->e = $params['exception'];
45
+        if (!$this->e) {
46
+            throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor');
47
+        }
48
+    }
49
+
50
+    public function getId() {
51
+        // we can't return anything sane here
52
+        return 'failedstorage';
53
+    }
54
+
55
+    public function mkdir($path) {
56
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
57
+    }
58
+
59
+    public function rmdir($path) {
60
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
61
+    }
62
+
63
+    public function opendir($path) {
64
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
65
+    }
66
+
67
+    public function is_dir($path) {
68
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
69
+    }
70
+
71
+    public function is_file($path) {
72
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
73
+    }
74
+
75
+    public function stat($path) {
76
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
77
+    }
78
+
79
+    public function filetype($path) {
80
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
81
+    }
82
+
83
+    public function filesize($path) {
84
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
85
+    }
86
+
87
+    public function isCreatable($path) {
88
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
89
+    }
90
+
91
+    public function isReadable($path) {
92
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
93
+    }
94
+
95
+    public function isUpdatable($path) {
96
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
97
+    }
98
+
99
+    public function isDeletable($path) {
100
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
101
+    }
102
+
103
+    public function isSharable($path) {
104
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
105
+    }
106
+
107
+    public function getPermissions($path) {
108
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
109
+    }
110
+
111
+    public function file_exists($path) {
112
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
113
+    }
114
+
115
+    public function filemtime($path) {
116
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
117
+    }
118
+
119
+    public function file_get_contents($path) {
120
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
121
+    }
122
+
123
+    public function file_put_contents($path, $data) {
124
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
125
+    }
126
+
127
+    public function unlink($path) {
128
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
129
+    }
130
+
131
+    public function rename($path1, $path2) {
132
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
133
+    }
134
+
135
+    public function copy($path1, $path2) {
136
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
137
+    }
138
+
139
+    public function fopen($path, $mode) {
140
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
141
+    }
142
+
143
+    public function getMimeType($path) {
144
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
145
+    }
146
+
147
+    public function hash($type, $path, $raw = false) {
148
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
149
+    }
150
+
151
+    public function free_space($path) {
152
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
153
+    }
154 154
 
155
-	public function search($query) {
156
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
157
-	}
155
+    public function search($query) {
156
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
157
+    }
158 158
 
159
-	public function touch($path, $mtime = null) {
160
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
161
-	}
159
+    public function touch($path, $mtime = null) {
160
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
161
+    }
162 162
 
163
-	public function getLocalFile($path) {
164
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
165
-	}
163
+    public function getLocalFile($path) {
164
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
165
+    }
166 166
 
167
-	public function getLocalFolder($path) {
168
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
169
-	}
167
+    public function getLocalFolder($path) {
168
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
169
+    }
170 170
 
171
-	public function hasUpdated($path, $time) {
172
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
173
-	}
171
+    public function hasUpdated($path, $time) {
172
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
173
+    }
174 174
 
175
-	public function getETag($path) {
176
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
177
-	}
175
+    public function getETag($path) {
176
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
177
+    }
178 178
 
179
-	public function getDirectDownload($path) {
180
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
181
-	}
179
+    public function getDirectDownload($path) {
180
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
181
+    }
182 182
 
183
-	public function verifyPath($path, $fileName) {
184
-		return true;
185
-	}
183
+    public function verifyPath($path, $fileName) {
184
+        return true;
185
+    }
186 186
 
187
-	public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
188
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
189
-	}
187
+    public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
188
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
189
+    }
190 190
 
191
-	public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
192
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
193
-	}
191
+    public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
192
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
193
+    }
194 194
 
195
-	public function acquireLock($path, $type, ILockingProvider $provider) {
196
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
197
-	}
195
+    public function acquireLock($path, $type, ILockingProvider $provider) {
196
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
197
+    }
198 198
 
199
-	public function releaseLock($path, $type, ILockingProvider $provider) {
200
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
201
-	}
199
+    public function releaseLock($path, $type, ILockingProvider $provider) {
200
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
201
+    }
202 202
 
203
-	public function changeLock($path, $type, ILockingProvider $provider) {
204
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
205
-	}
203
+    public function changeLock($path, $type, ILockingProvider $provider) {
204
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
205
+    }
206 206
 
207
-	public function getAvailability() {
208
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
209
-	}
207
+    public function getAvailability() {
208
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
209
+    }
210 210
 
211
-	public function setAvailability($isAvailable) {
212
-		throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
213
-	}
211
+    public function setAvailability($isAvailable) {
212
+        throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
213
+    }
214 214
 
215
-	public function getCache($path = '', $storage = null) {
216
-		return new FailedCache();
217
-	}
215
+    public function getCache($path = '', $storage = null) {
216
+        return new FailedCache();
217
+    }
218 218
 }
Please login to merge, or discard this patch.
lib/private/Mail/Mailer.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		$mailer = $this->getInstance();
130 130
 
131 131
 		// Enable logger if debug mode is enabled
132
-		if($debugMode) {
132
+		if ($debugMode) {
133 133
 			$mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
134 134
 			$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
135 135
 		}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		// Debugging logging
140 140
 		$logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
141 141
 		$this->logger->debug($logMessage, ['app' => 'core']);
142
-		if($debugMode && isset($mailLogger)) {
142
+		if ($debugMode && isset($mailLogger)) {
143 143
 			$this->logger->debug($mailLogger->dump(), ['app' => 'core']);
144 144
 		}
145 145
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		}
171 171
 
172 172
 		list($name, $domain) = explode('@', $email, 2);
173
-		$domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46);
173
+		$domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
174 174
 		return $name.'@'.$domain;
175 175
 	}
176 176
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 				break;
241 241
 		}
242 242
 
243
-		return \Swift_SendmailTransport::newInstance($binaryPath . ' -bs');
243
+		return \Swift_SendmailTransport::newInstance($binaryPath.' -bs');
244 244
 	}
245 245
 
246 246
 	/**
Please login to merge, or discard this patch.
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -55,242 +55,242 @@
 block discarded – undo
55 55
  * @package OC\Mail
56 56
  */
57 57
 class Mailer implements IMailer {
58
-	/** @var \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport Cached transport */
59
-	private $instance = null;
60
-	/** @var IConfig */
61
-	private $config;
62
-	/** @var ILogger */
63
-	private $logger;
64
-	/** @var Defaults */
65
-	private $defaults;
66
-	/** @var IURLGenerator */
67
-	private $urlGenerator;
68
-	/** @var IL10N */
69
-	private $l10n;
58
+    /** @var \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport Cached transport */
59
+    private $instance = null;
60
+    /** @var IConfig */
61
+    private $config;
62
+    /** @var ILogger */
63
+    private $logger;
64
+    /** @var Defaults */
65
+    private $defaults;
66
+    /** @var IURLGenerator */
67
+    private $urlGenerator;
68
+    /** @var IL10N */
69
+    private $l10n;
70 70
 
71
-	/**
72
-	 * @param IConfig $config
73
-	 * @param ILogger $logger
74
-	 * @param Defaults $defaults
75
-	 * @param IURLGenerator $urlGenerator
76
-	 * @param IL10N $l10n
77
-	 */
78
-	public function __construct(IConfig $config,
79
-						 ILogger $logger,
80
-						 Defaults $defaults,
81
-						 IURLGenerator $urlGenerator,
82
-						 IL10N $l10n) {
83
-		$this->config = $config;
84
-		$this->logger = $logger;
85
-		$this->defaults = $defaults;
86
-		$this->urlGenerator = $urlGenerator;
87
-		$this->l10n = $l10n;
88
-	}
71
+    /**
72
+     * @param IConfig $config
73
+     * @param ILogger $logger
74
+     * @param Defaults $defaults
75
+     * @param IURLGenerator $urlGenerator
76
+     * @param IL10N $l10n
77
+     */
78
+    public function __construct(IConfig $config,
79
+                            ILogger $logger,
80
+                            Defaults $defaults,
81
+                            IURLGenerator $urlGenerator,
82
+                            IL10N $l10n) {
83
+        $this->config = $config;
84
+        $this->logger = $logger;
85
+        $this->defaults = $defaults;
86
+        $this->urlGenerator = $urlGenerator;
87
+        $this->l10n = $l10n;
88
+    }
89 89
 
90
-	/**
91
-	 * Creates a new message object that can be passed to send()
92
-	 *
93
-	 * @return IMessage
94
-	 */
95
-	public function createMessage(): IMessage {
96
-		$plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false);
97
-		return new Message(new \Swift_Message(), $plainTextOnly);
98
-	}
90
+    /**
91
+     * Creates a new message object that can be passed to send()
92
+     *
93
+     * @return IMessage
94
+     */
95
+    public function createMessage(): IMessage {
96
+        $plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false);
97
+        return new Message(new \Swift_Message(), $plainTextOnly);
98
+    }
99 99
 
100
-	/**
101
-	 * @param string|null $data
102
-	 * @param string|null $filename
103
-	 * @param string|null $contentType
104
-	 * @return IAttachment
105
-	 * @since 13.0.0
106
-	 */
107
-	public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment {
108
-		return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
109
-	}
100
+    /**
101
+     * @param string|null $data
102
+     * @param string|null $filename
103
+     * @param string|null $contentType
104
+     * @return IAttachment
105
+     * @since 13.0.0
106
+     */
107
+    public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment {
108
+        return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
109
+    }
110 110
 
111
-	/**
112
-	 * @param string $path
113
-	 * @param string|null $contentType
114
-	 * @return IAttachment
115
-	 * @since 13.0.0
116
-	 */
117
-	public function createAttachmentFromPath(string $path, $contentType = null): IAttachment {
118
-		return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
119
-	}
111
+    /**
112
+     * @param string $path
113
+     * @param string|null $contentType
114
+     * @return IAttachment
115
+     * @since 13.0.0
116
+     */
117
+    public function createAttachmentFromPath(string $path, $contentType = null): IAttachment {
118
+        return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
119
+    }
120 120
 
121
-	/**
122
-	 * Creates a new email template object
123
-	 *
124
-	 * @param string $emailId
125
-	 * @param array $data
126
-	 * @return IEMailTemplate
127
-	 * @since 12.0.0
128
-	 */
129
-	public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate {
130
-		$class = $this->config->getSystemValue('mail_template_class', '');
121
+    /**
122
+     * Creates a new email template object
123
+     *
124
+     * @param string $emailId
125
+     * @param array $data
126
+     * @return IEMailTemplate
127
+     * @since 12.0.0
128
+     */
129
+    public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate {
130
+        $class = $this->config->getSystemValue('mail_template_class', '');
131 131
 
132
-		if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) {
133
-			return new $class(
134
-				$this->defaults,
135
-				$this->urlGenerator,
136
-				$this->l10n,
137
-				$emailId,
138
-				$data
139
-			);
140
-		}
132
+        if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) {
133
+            return new $class(
134
+                $this->defaults,
135
+                $this->urlGenerator,
136
+                $this->l10n,
137
+                $emailId,
138
+                $data
139
+            );
140
+        }
141 141
 
142
-		return new EMailTemplate(
143
-			$this->defaults,
144
-			$this->urlGenerator,
145
-			$this->l10n,
146
-			$emailId,
147
-			$data
148
-		);
149
-	}
142
+        return new EMailTemplate(
143
+            $this->defaults,
144
+            $this->urlGenerator,
145
+            $this->l10n,
146
+            $emailId,
147
+            $data
148
+        );
149
+    }
150 150
 
151
-	/**
152
-	 * Send the specified message. Also sets the from address to the value defined in config.php
153
-	 * if no-one has been passed.
154
-	 *
155
-	 * @param IMessage|Message $message Message to send
156
-	 * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and
157
-	 * therefore should be considered
158
-	 * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
159
-	 * has been supplied.)
160
-	 */
161
-	public function send(IMessage $message): array {
162
-		$debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
151
+    /**
152
+     * Send the specified message. Also sets the from address to the value defined in config.php
153
+     * if no-one has been passed.
154
+     *
155
+     * @param IMessage|Message $message Message to send
156
+     * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and
157
+     * therefore should be considered
158
+     * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
159
+     * has been supplied.)
160
+     */
161
+    public function send(IMessage $message): array {
162
+        $debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
163 163
 
164
-		if (empty($message->getFrom())) {
165
-			$message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName()) => $this->defaults->getName()]);
166
-		}
164
+        if (empty($message->getFrom())) {
165
+            $message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName()) => $this->defaults->getName()]);
166
+        }
167 167
 
168
-		$failedRecipients = [];
168
+        $failedRecipients = [];
169 169
 
170
-		$mailer = $this->getInstance();
170
+        $mailer = $this->getInstance();
171 171
 
172
-		// Enable logger if debug mode is enabled
173
-		if($debugMode) {
174
-			$mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
175
-			$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
176
-		}
172
+        // Enable logger if debug mode is enabled
173
+        if($debugMode) {
174
+            $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
175
+            $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
176
+        }
177 177
 
178
-		$mailer->send($message->getSwiftMessage(), $failedRecipients);
178
+        $mailer->send($message->getSwiftMessage(), $failedRecipients);
179 179
 
180
-		// Debugging logging
181
-		$logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
182
-		$this->logger->debug($logMessage, ['app' => 'core']);
183
-		if($debugMode && isset($mailLogger)) {
184
-			$this->logger->debug($mailLogger->dump(), ['app' => 'core']);
185
-		}
180
+        // Debugging logging
181
+        $logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
182
+        $this->logger->debug($logMessage, ['app' => 'core']);
183
+        if($debugMode && isset($mailLogger)) {
184
+            $this->logger->debug($mailLogger->dump(), ['app' => 'core']);
185
+        }
186 186
 
187
-		return $failedRecipients;
188
-	}
187
+        return $failedRecipients;
188
+    }
189 189
 
190
-	/**
191
-	 * Checks if an e-mail address is valid
192
-	 *
193
-	 * @param string $email Email address to be validated
194
-	 * @return bool True if the mail address is valid, false otherwise
195
-	 */
196
-	public function validateMailAddress(string $email): bool {
197
-		return \Swift_Validate::email($this->convertEmail($email));
198
-	}
190
+    /**
191
+     * Checks if an e-mail address is valid
192
+     *
193
+     * @param string $email Email address to be validated
194
+     * @return bool True if the mail address is valid, false otherwise
195
+     */
196
+    public function validateMailAddress(string $email): bool {
197
+        return \Swift_Validate::email($this->convertEmail($email));
198
+    }
199 199
 
200
-	/**
201
-	 * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains
202
-	 *
203
-	 * FIXME: Remove this once SwiftMailer supports IDN
204
-	 *
205
-	 * @param string $email
206
-	 * @return string Converted mail address if `idn_to_ascii` exists
207
-	 */
208
-	protected function convertEmail(string $email): string {
209
-		if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46') || strpos($email, '@') === false) {
210
-			return $email;
211
-		}
200
+    /**
201
+     * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains
202
+     *
203
+     * FIXME: Remove this once SwiftMailer supports IDN
204
+     *
205
+     * @param string $email
206
+     * @return string Converted mail address if `idn_to_ascii` exists
207
+     */
208
+    protected function convertEmail(string $email): string {
209
+        if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46') || strpos($email, '@') === false) {
210
+            return $email;
211
+        }
212 212
 
213
-		list($name, $domain) = explode('@', $email, 2);
214
-		$domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46);
215
-		return $name.'@'.$domain;
216
-	}
213
+        list($name, $domain) = explode('@', $email, 2);
214
+        $domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46);
215
+        return $name.'@'.$domain;
216
+    }
217 217
 
218
-	/**
219
-	 * Returns whatever transport is configured within the config
220
-	 *
221
-	 * @return \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport
222
-	 */
223
-	protected function getInstance() {
224
-		if (!is_null($this->instance)) {
225
-			return $this->instance;
226
-		}
218
+    /**
219
+     * Returns whatever transport is configured within the config
220
+     *
221
+     * @return \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport
222
+     */
223
+    protected function getInstance() {
224
+        if (!is_null($this->instance)) {
225
+            return $this->instance;
226
+        }
227 227
 
228
-		switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
229
-			case 'smtp':
230
-				$this->instance = $this->getSmtpInstance();
231
-				break;
232
-			case 'sendmail':
233
-				// FIXME: Move into the return statement but requires proper testing
234
-				//       for SMTP and mail as well. Thus not really doable for a
235
-				//       minor release.
236
-				$this->instance = \Swift_Mailer::newInstance($this->getSendMailInstance());
237
-				break;
238
-			default:
239
-				$this->instance = $this->getMailInstance();
240
-				break;
241
-		}
228
+        switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
229
+            case 'smtp':
230
+                $this->instance = $this->getSmtpInstance();
231
+                break;
232
+            case 'sendmail':
233
+                // FIXME: Move into the return statement but requires proper testing
234
+                //       for SMTP and mail as well. Thus not really doable for a
235
+                //       minor release.
236
+                $this->instance = \Swift_Mailer::newInstance($this->getSendMailInstance());
237
+                break;
238
+            default:
239
+                $this->instance = $this->getMailInstance();
240
+                break;
241
+        }
242 242
 
243
-		return $this->instance;
244
-	}
243
+        return $this->instance;
244
+    }
245 245
 
246
-	/**
247
-	 * Returns the SMTP transport
248
-	 *
249
-	 * @return \Swift_SmtpTransport
250
-	 */
251
-	protected function getSmtpInstance(): \Swift_SmtpTransport {
252
-		$transport = \Swift_SmtpTransport::newInstance();
253
-		$transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
254
-		$transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1'));
255
-		$transport->setPort($this->config->getSystemValue('mail_smtpport', 25));
256
-		if ($this->config->getSystemValue('mail_smtpauth', false)) {
257
-			$transport->setUsername($this->config->getSystemValue('mail_smtpname', ''));
258
-			$transport->setPassword($this->config->getSystemValue('mail_smtppassword', ''));
259
-			$transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN'));
260
-		}
261
-		$smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', '');
262
-		if (!empty($smtpSecurity)) {
263
-			$transport->setEncryption($smtpSecurity);
264
-		}
265
-		$transport->start();
266
-		return $transport;
267
-	}
246
+    /**
247
+     * Returns the SMTP transport
248
+     *
249
+     * @return \Swift_SmtpTransport
250
+     */
251
+    protected function getSmtpInstance(): \Swift_SmtpTransport {
252
+        $transport = \Swift_SmtpTransport::newInstance();
253
+        $transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
254
+        $transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1'));
255
+        $transport->setPort($this->config->getSystemValue('mail_smtpport', 25));
256
+        if ($this->config->getSystemValue('mail_smtpauth', false)) {
257
+            $transport->setUsername($this->config->getSystemValue('mail_smtpname', ''));
258
+            $transport->setPassword($this->config->getSystemValue('mail_smtppassword', ''));
259
+            $transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN'));
260
+        }
261
+        $smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', '');
262
+        if (!empty($smtpSecurity)) {
263
+            $transport->setEncryption($smtpSecurity);
264
+        }
265
+        $transport->start();
266
+        return $transport;
267
+    }
268 268
 
269
-	/**
270
-	 * Returns the sendmail transport
271
-	 *
272
-	 * @return \Swift_SendmailTransport
273
-	 */
274
-	protected function getSendMailInstance(): \Swift_SendmailTransport {
275
-		switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
276
-			case 'qmail':
277
-				$binaryPath = '/var/qmail/bin/sendmail';
278
-				break;
279
-			default:
280
-				$binaryPath = '/usr/sbin/sendmail';
281
-				break;
282
-		}
269
+    /**
270
+     * Returns the sendmail transport
271
+     *
272
+     * @return \Swift_SendmailTransport
273
+     */
274
+    protected function getSendMailInstance(): \Swift_SendmailTransport {
275
+        switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
276
+            case 'qmail':
277
+                $binaryPath = '/var/qmail/bin/sendmail';
278
+                break;
279
+            default:
280
+                $binaryPath = '/usr/sbin/sendmail';
281
+                break;
282
+        }
283 283
 
284
-		return \Swift_SendmailTransport::newInstance($binaryPath . ' -bs');
285
-	}
284
+        return \Swift_SendmailTransport::newInstance($binaryPath . ' -bs');
285
+    }
286 286
 
287
-	/**
288
-	 * Returns the mail transport
289
-	 *
290
-	 * @return \Swift_MailTransport
291
-	 */
292
-	protected function getMailInstance(): \Swift_MailTransport {
293
-		return \Swift_MailTransport::newInstance();
294
-	}
287
+    /**
288
+     * Returns the mail transport
289
+     *
290
+     * @return \Swift_MailTransport
291
+     */
292
+    protected function getMailInstance(): \Swift_MailTransport {
293
+        return \Swift_MailTransport::newInstance();
294
+    }
295 295
 
296 296
 }
Please login to merge, or discard this patch.
lib/private/Route/Route.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -32,128 +32,128 @@
 block discarded – undo
32 32
 use Symfony\Component\Routing\Route as SymfonyRoute;
33 33
 
34 34
 class Route extends SymfonyRoute implements IRoute {
35
-	/**
36
-	 * Specify the method when this route is to be used
37
-	 *
38
-	 * @param string $method HTTP method (uppercase)
39
-	 * @return \OC\Route\Route
40
-	 */
41
-	public function method($method) {
42
-		$this->setMethods($method);
43
-		return $this;
44
-	}
35
+    /**
36
+     * Specify the method when this route is to be used
37
+     *
38
+     * @param string $method HTTP method (uppercase)
39
+     * @return \OC\Route\Route
40
+     */
41
+    public function method($method) {
42
+        $this->setMethods($method);
43
+        return $this;
44
+    }
45 45
 
46
-	/**
47
-	 * Specify POST as the method to use with this route
48
-	 * @return \OC\Route\Route
49
-	 */
50
-	public function post() {
51
-		$this->method('POST');
52
-		return $this;
53
-	}
46
+    /**
47
+     * Specify POST as the method to use with this route
48
+     * @return \OC\Route\Route
49
+     */
50
+    public function post() {
51
+        $this->method('POST');
52
+        return $this;
53
+    }
54 54
 
55
-	/**
56
-	 * Specify GET as the method to use with this route
57
-	 * @return \OC\Route\Route
58
-	 */
59
-	public function get() {
60
-		$this->method('GET');
61
-		return $this;
62
-	}
55
+    /**
56
+     * Specify GET as the method to use with this route
57
+     * @return \OC\Route\Route
58
+     */
59
+    public function get() {
60
+        $this->method('GET');
61
+        return $this;
62
+    }
63 63
 
64
-	/**
65
-	 * Specify PUT as the method to use with this route
66
-	 * @return \OC\Route\Route
67
-	 */
68
-	public function put() {
69
-		$this->method('PUT');
70
-		return $this;
71
-	}
64
+    /**
65
+     * Specify PUT as the method to use with this route
66
+     * @return \OC\Route\Route
67
+     */
68
+    public function put() {
69
+        $this->method('PUT');
70
+        return $this;
71
+    }
72 72
 
73
-	/**
74
-	 * Specify DELETE as the method to use with this route
75
-	 * @return \OC\Route\Route
76
-	 */
77
-	public function delete() {
78
-		$this->method('DELETE');
79
-		return $this;
80
-	}
73
+    /**
74
+     * Specify DELETE as the method to use with this route
75
+     * @return \OC\Route\Route
76
+     */
77
+    public function delete() {
78
+        $this->method('DELETE');
79
+        return $this;
80
+    }
81 81
 
82
-	/**
83
-	 * Specify PATCH as the method to use with this route
84
-	 * @return \OC\Route\Route
85
-	 */
86
-	public function patch() {
87
-		$this->method('PATCH');
88
-		return $this;
89
-	}
82
+    /**
83
+     * Specify PATCH as the method to use with this route
84
+     * @return \OC\Route\Route
85
+     */
86
+    public function patch() {
87
+        $this->method('PATCH');
88
+        return $this;
89
+    }
90 90
 
91
-	/**
92
-	 * Defaults to use for this route
93
-	 *
94
-	 * @param array $defaults The defaults
95
-	 * @return \OC\Route\Route
96
-	 */
97
-	public function defaults($defaults) {
98
-		$action = $this->getDefault('action');
99
-		$this->setDefaults($defaults);
100
-		if (isset($defaults['action'])) {
101
-			$action = $defaults['action'];
102
-		}
103
-		$this->action($action);
104
-		return $this;
105
-	}
91
+    /**
92
+     * Defaults to use for this route
93
+     *
94
+     * @param array $defaults The defaults
95
+     * @return \OC\Route\Route
96
+     */
97
+    public function defaults($defaults) {
98
+        $action = $this->getDefault('action');
99
+        $this->setDefaults($defaults);
100
+        if (isset($defaults['action'])) {
101
+            $action = $defaults['action'];
102
+        }
103
+        $this->action($action);
104
+        return $this;
105
+    }
106 106
 
107
-	/**
108
-	 * Requirements for this route
109
-	 *
110
-	 * @param array $requirements The requirements
111
-	 * @return \OC\Route\Route
112
-	 */
113
-	public function requirements($requirements) {
114
-		$method = $this->getMethods();
115
-		$this->setRequirements($requirements);
116
-		if (isset($requirements['_method'])) {
117
-			$method = $requirements['_method'];
118
-		}
119
-		if ($method) {
120
-			$this->method($method);
121
-		}
122
-		return $this;
123
-	}
107
+    /**
108
+     * Requirements for this route
109
+     *
110
+     * @param array $requirements The requirements
111
+     * @return \OC\Route\Route
112
+     */
113
+    public function requirements($requirements) {
114
+        $method = $this->getMethods();
115
+        $this->setRequirements($requirements);
116
+        if (isset($requirements['_method'])) {
117
+            $method = $requirements['_method'];
118
+        }
119
+        if ($method) {
120
+            $this->method($method);
121
+        }
122
+        return $this;
123
+    }
124 124
 
125
-	/**
126
-	 * The action to execute when this route matches
127
-	 *
128
-	 * @param string|callable $class the class or a callable
129
-	 * @param string $function the function to use with the class
130
-	 * @return \OC\Route\Route
131
-	 *
132
-	 * This function is called with $class set to a callable or
133
-	 * to the class with $function
134
-	 */
135
-	public function action($class, $function = null) {
136
-		$action = array($class, $function);
137
-		if (is_null($function)) {
138
-			$action = $class;
139
-		}
140
-		$this->setDefault('action', $action);
141
-		return $this;
142
-	}
125
+    /**
126
+     * The action to execute when this route matches
127
+     *
128
+     * @param string|callable $class the class or a callable
129
+     * @param string $function the function to use with the class
130
+     * @return \OC\Route\Route
131
+     *
132
+     * This function is called with $class set to a callable or
133
+     * to the class with $function
134
+     */
135
+    public function action($class, $function = null) {
136
+        $action = array($class, $function);
137
+        if (is_null($function)) {
138
+            $action = $class;
139
+        }
140
+        $this->setDefault('action', $action);
141
+        return $this;
142
+    }
143 143
 
144
-	/**
145
-	 * The action to execute when this route matches, includes a file like
146
-	 * it is called directly
147
-	 * @param string $file
148
-	 * @return void
149
-	 */
150
-	public function actionInclude($file) {
151
-		$function = function($param) use ($file) {
152
-			unset($param["_route"]);
153
-			$_GET=array_merge($_GET, $param);
154
-			unset($param);
155
-			require_once "$file";
156
-		} ;
157
-		$this->action($function);
158
-	}
144
+    /**
145
+     * The action to execute when this route matches, includes a file like
146
+     * it is called directly
147
+     * @param string $file
148
+     * @return void
149
+     */
150
+    public function actionInclude($file) {
151
+        $function = function($param) use ($file) {
152
+            unset($param["_route"]);
153
+            $_GET=array_merge($_GET, $param);
154
+            unset($param);
155
+            require_once "$file";
156
+        } ;
157
+        $this->action($function);
158
+    }
159 159
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@
 block discarded – undo
150 150
 	public function actionInclude($file) {
151 151
 		$function = function($param) use ($file) {
152 152
 			unset($param["_route"]);
153
-			$_GET=array_merge($_GET, $param);
153
+			$_GET = array_merge($_GET, $param);
154 154
 			unset($param);
155 155
 			require_once "$file";
156 156
 		} ;
Please login to merge, or discard this patch.
apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -13,74 +13,74 @@
 block discarded – undo
13 13
 use OCP\Share\IManager;
14 14
 
15 15
 class ShareInfoMiddleware extends Middleware {
16
-	/** @var IManager */
17
-	private $shareManager;
16
+    /** @var IManager */
17
+    private $shareManager;
18 18
 
19
-	public function __construct(IManager $shareManager) {
20
-		$this->shareManager = $shareManager;
21
-	}
19
+    public function __construct(IManager $shareManager) {
20
+        $this->shareManager = $shareManager;
21
+    }
22 22
 
23
-	/**
24
-	 * @param Controller $controller
25
-	 * @param string $methodName
26
-	 * @throws S2SException
27
-	 */
28
-	public function beforeController($controller, $methodName) {
29
-		if (!($controller instanceof ShareInfoController)) {
30
-			return;
31
-		}
23
+    /**
24
+     * @param Controller $controller
25
+     * @param string $methodName
26
+     * @throws S2SException
27
+     */
28
+    public function beforeController($controller, $methodName) {
29
+        if (!($controller instanceof ShareInfoController)) {
30
+            return;
31
+        }
32 32
 
33
-		if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
34
-			throw new S2SException();
35
-		}
36
-	}
33
+        if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
34
+            throw new S2SException();
35
+        }
36
+    }
37 37
 
38
-	/**
39
-	 * @param Controller $controller
40
-	 * @param string $methodName
41
-	 * @param \Exception $exception
42
-	 * @throws \Exception
43
-	 * @return Response
44
-	 */
45
-	public function afterException($controller, $methodName, \Exception $exception) {
46
-		if (!($controller instanceof ShareInfoController)) {
47
-			throw $exception;
48
-		}
38
+    /**
39
+     * @param Controller $controller
40
+     * @param string $methodName
41
+     * @param \Exception $exception
42
+     * @throws \Exception
43
+     * @return Response
44
+     */
45
+    public function afterException($controller, $methodName, \Exception $exception) {
46
+        if (!($controller instanceof ShareInfoController)) {
47
+            throw $exception;
48
+        }
49 49
 
50
-		if ($exception instanceof S2SException) {
51
-			return new JSONResponse([], Http::STATUS_NOT_FOUND);
52
-		}
50
+        if ($exception instanceof S2SException) {
51
+            return new JSONResponse([], Http::STATUS_NOT_FOUND);
52
+        }
53 53
 
54
-		throw $exception;
55
-	}
54
+        throw $exception;
55
+    }
56 56
 
57
-	/**
58
-	 * @param Controller $controller
59
-	 * @param string $methodName
60
-	 * @param Response $response
61
-	 * @return Response
62
-	 */
63
-	public function afterController($controller, $methodName, Response $response) {
64
-		if (!($controller instanceof ShareInfoController)) {
65
-			return $response;
66
-		}
57
+    /**
58
+     * @param Controller $controller
59
+     * @param string $methodName
60
+     * @param Response $response
61
+     * @return Response
62
+     */
63
+    public function afterController($controller, $methodName, Response $response) {
64
+        if (!($controller instanceof ShareInfoController)) {
65
+            return $response;
66
+        }
67 67
 
68
-		if (!($response instanceof JSONResponse)) {
69
-			return $response;
70
-		}
68
+        if (!($response instanceof JSONResponse)) {
69
+            return $response;
70
+        }
71 71
 
72
-		$data = $response->getData();
73
-		$status = 'error';
72
+        $data = $response->getData();
73
+        $status = 'error';
74 74
 
75
-		if ($response->getStatus() === Http::STATUS_OK) {
76
-			$status = 'success';
77
-		}
75
+        if ($response->getStatus() === Http::STATUS_OK) {
76
+            $status = 'success';
77
+        }
78 78
 
79
-		$response->setData([
80
-			'data' => $data,
81
-			'status' => $status,
82
-		]);
79
+        $response->setData([
80
+            'data' => $data,
81
+            'status' => $status,
82
+        ]);
83 83
 
84
-		return $response;
85
-	}
84
+        return $response;
85
+    }
86 86
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Controller/ShareInfoController.php 2 patches
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -17,114 +17,114 @@
 block discarded – undo
17 17
 
18 18
 class ShareInfoController extends ApiController {
19 19
 
20
-	/** @var IManager */
21
-	private $shareManager;
22
-
23
-	/**
24
-	 * ShareInfoController constructor.
25
-	 *
26
-	 * @param string $appName
27
-	 * @param IRequest $request
28
-	 * @param IManager $shareManager
29
-	 */
30
-	public function __construct($appName,
31
-								IRequest $request,
32
-								IManager $shareManager) {
33
-		parent::__construct($appName, $request);
34
-
35
-		$this->shareManager = $shareManager;
36
-	}
37
-
38
-	/**
39
-	 * @PublicPage
40
-	 * @NoCSRFRequired
41
-	 *
42
-	 * @param string $t
43
-	 * @param null $password
44
-	 * @param null $dir
45
-	 * @return JSONResponse
46
-	 * @throws ShareNotFound
47
-	 */
48
-	public function info($t, $password = null, $dir = null) {
49
-		try {
50
-			$share = $this->shareManager->getShareByToken($t);
51
-		} catch (ShareNotFound $e) {
52
-			return new JSONResponse([], Http::STATUS_NOT_FOUND);
53
-		}
54
-
55
-		if ($share->getPassword() && !$this->shareManager->checkPassword($share, $password)) {
56
-			return new JSONResponse([], Http::STATUS_FORBIDDEN);
57
-		}
58
-
59
-		if (!($share->getPermissions() & Constants::PERMISSION_READ)) {
60
-			return new JSONResponse([], Http::STATUS_FORBIDDEN);
61
-		}
62
-
63
-		$isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
64
-		if (!$isWritable) {
65
-			$this->addROWrapper();
66
-		}
67
-
68
-		$node = $share->getNode();
69
-
70
-		if ($dir !== null && $node instanceof Folder) {
71
-			try {
72
-				$node = $node->get($dir);
73
-			} catch (NotFoundException $e) {
74
-
75
-			}
76
-		}
77
-
78
-		return new JSONResponse($this->parseNode($node));
79
-	}
80
-
81
-	private function parseNode(Node $node) {
82
-		if ($node instanceof File) {
83
-			return $this->parseFile($node);
84
-		}
85
-		return $this->parseFolder($node);
86
-	}
87
-
88
-	private function parseFile(File $file) {
89
-		return $this->format($file);
90
-	}
91
-
92
-	private function parseFolder(Folder $folder) {
93
-		$data = $this->format($folder);
94
-
95
-		$data['children'] = [];
96
-
97
-		$nodes = $folder->getDirectoryListing();
98
-		foreach ($nodes as $node) {
99
-			$data['children'][] = $this->parseNode($node);
100
-		}
101
-
102
-		return $data;
103
-	}
104
-
105
-	private function format(Node $node) {
106
-		$entry = [];
107
-
108
-		$entry['id'] = $node->getId();
109
-		$entry['parentId'] = $node->getParent()->getId();
110
-		$entry['mtime'] = $node->getMTime();
111
-
112
-		$entry['name'] = $node->getName();
113
-		$entry['permissions'] = $node->getPermissions();
114
-		$entry['mimetype'] = $node->getMimetype();
115
-		$entry['size'] = $node->getSize();
116
-		$entry['type'] = $node->getType();
117
-		$entry['etag'] = $node->getEtag();
118
-
119
-		return $entry;
120
-	}
121
-
122
-	protected function addROWrapper() {
123
-		// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
124
-		$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
125
-		\OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
126
-			return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE));
127
-		});
128
-		\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
129
-	}
20
+    /** @var IManager */
21
+    private $shareManager;
22
+
23
+    /**
24
+     * ShareInfoController constructor.
25
+     *
26
+     * @param string $appName
27
+     * @param IRequest $request
28
+     * @param IManager $shareManager
29
+     */
30
+    public function __construct($appName,
31
+                                IRequest $request,
32
+                                IManager $shareManager) {
33
+        parent::__construct($appName, $request);
34
+
35
+        $this->shareManager = $shareManager;
36
+    }
37
+
38
+    /**
39
+     * @PublicPage
40
+     * @NoCSRFRequired
41
+     *
42
+     * @param string $t
43
+     * @param null $password
44
+     * @param null $dir
45
+     * @return JSONResponse
46
+     * @throws ShareNotFound
47
+     */
48
+    public function info($t, $password = null, $dir = null) {
49
+        try {
50
+            $share = $this->shareManager->getShareByToken($t);
51
+        } catch (ShareNotFound $e) {
52
+            return new JSONResponse([], Http::STATUS_NOT_FOUND);
53
+        }
54
+
55
+        if ($share->getPassword() && !$this->shareManager->checkPassword($share, $password)) {
56
+            return new JSONResponse([], Http::STATUS_FORBIDDEN);
57
+        }
58
+
59
+        if (!($share->getPermissions() & Constants::PERMISSION_READ)) {
60
+            return new JSONResponse([], Http::STATUS_FORBIDDEN);
61
+        }
62
+
63
+        $isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
64
+        if (!$isWritable) {
65
+            $this->addROWrapper();
66
+        }
67
+
68
+        $node = $share->getNode();
69
+
70
+        if ($dir !== null && $node instanceof Folder) {
71
+            try {
72
+                $node = $node->get($dir);
73
+            } catch (NotFoundException $e) {
74
+
75
+            }
76
+        }
77
+
78
+        return new JSONResponse($this->parseNode($node));
79
+    }
80
+
81
+    private function parseNode(Node $node) {
82
+        if ($node instanceof File) {
83
+            return $this->parseFile($node);
84
+        }
85
+        return $this->parseFolder($node);
86
+    }
87
+
88
+    private function parseFile(File $file) {
89
+        return $this->format($file);
90
+    }
91
+
92
+    private function parseFolder(Folder $folder) {
93
+        $data = $this->format($folder);
94
+
95
+        $data['children'] = [];
96
+
97
+        $nodes = $folder->getDirectoryListing();
98
+        foreach ($nodes as $node) {
99
+            $data['children'][] = $this->parseNode($node);
100
+        }
101
+
102
+        return $data;
103
+    }
104
+
105
+    private function format(Node $node) {
106
+        $entry = [];
107
+
108
+        $entry['id'] = $node->getId();
109
+        $entry['parentId'] = $node->getParent()->getId();
110
+        $entry['mtime'] = $node->getMTime();
111
+
112
+        $entry['name'] = $node->getName();
113
+        $entry['permissions'] = $node->getPermissions();
114
+        $entry['mimetype'] = $node->getMimetype();
115
+        $entry['size'] = $node->getSize();
116
+        $entry['type'] = $node->getType();
117
+        $entry['etag'] = $node->getEtag();
118
+
119
+        return $entry;
120
+    }
121
+
122
+    protected function addROWrapper() {
123
+        // FIXME: should not add storage wrappers outside of preSetup, need to find a better way
124
+        $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
125
+        \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
126
+            return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE));
127
+        });
128
+        \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
129
+    }
130 130
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@
 block discarded – undo
122 122
 	protected function addROWrapper() {
123 123
 		// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
124 124
 		$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
125
-		\OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
125
+		\OC\Files\Filesystem::addStorageWrapper('readonly', function($mountPoint, $storage) {
126 126
 			return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE));
127 127
 		});
128 128
 		\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
Please login to merge, or discard this patch.
lib/private/Repair/Owncloud/DropAccountTermsTable.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -29,32 +29,32 @@
 block discarded – undo
29 29
 
30 30
 class DropAccountTermsTable implements IRepairStep {
31 31
 
32
-	/** @var IDBConnection */
33
-	protected $db;
34
-
35
-	/**
36
-	 * @param IDBConnection $db
37
-	 */
38
-	public function __construct(IDBConnection $db) {
39
-		$this->db = $db;
40
-	}
41
-
42
-	/**
43
-	 * @return string
44
-	 */
45
-	public function getName() {
46
-		return 'Drop account terms table when migrating from ownCloud';
47
-	}
48
-
49
-	/**
50
-	 * @param IOutput $output
51
-	 */
52
-	public function run(IOutput $output) {
53
-		if (!$this->db->tableExists('account_terms')) {
54
-			return;
55
-		}
56
-
57
-		$this->db->dropTable('account_terms');
58
-	}
32
+    /** @var IDBConnection */
33
+    protected $db;
34
+
35
+    /**
36
+     * @param IDBConnection $db
37
+     */
38
+    public function __construct(IDBConnection $db) {
39
+        $this->db = $db;
40
+    }
41
+
42
+    /**
43
+     * @return string
44
+     */
45
+    public function getName() {
46
+        return 'Drop account terms table when migrating from ownCloud';
47
+    }
48
+
49
+    /**
50
+     * @param IOutput $output
51
+     */
52
+    public function run(IOutput $output) {
53
+        if (!$this->db->tableExists('account_terms')) {
54
+            return;
55
+        }
56
+
57
+        $this->db->dropTable('account_terms');
58
+    }
59 59
 }
60 60
 
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/ContactsStore.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
 	/**
64 64
 	 * @param IUser $user
65 65
 	 * @param string|null $filter
66
-	 * @return IEntry[]
66
+	 * @return Entry[]
67 67
 	 */
68 68
 	public function getContacts(IUser $user, $filter) {
69 69
 		$allContacts = $this->contactsManager->search($filter ?: '', [
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		if ($excludedGroups) {
118 118
 			$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
119 119
 			$decodedExcludeGroups = json_decode($excludedGroups, true);
120
-			$excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups :  [];
120
+			$excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups : [];
121 121
 
122 122
 			if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
123 123
 				// a group of the current user is excluded -> filter all local users
@@ -133,22 +133,22 @@  discard block
 block discarded – undo
133 133
 			}
134 134
 
135 135
 			// Prevent enumerating local users
136
-			if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
136
+			if ($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
137 137
 				$filterUser = true;
138 138
 
139 139
 				$mailAddresses = $entry->getEMailAddresses();
140
-				foreach($mailAddresses as $mailAddress) {
141
-					if($mailAddress === $filter) {
140
+				foreach ($mailAddresses as $mailAddress) {
141
+					if ($mailAddress === $filter) {
142 142
 						$filterUser = false;
143 143
 						break;
144 144
 					}
145 145
 				}
146 146
 
147
-				if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
147
+				if ($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
148 148
 					$filterUser = false;
149 149
 				}
150 150
 
151
-				if($filterUser) {
151
+				if ($filterUser) {
152 152
 					return false;
153 153
 				}
154 154
 			}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @return IEntry|null
173 173
 	 */
174 174
 	public function findOne(IUser $user, $shareType, $shareWith) {
175
-		switch($shareType) {
175
+		switch ($shareType) {
176 176
 			case 0:
177 177
 			case 6:
178 178
 				$filter = ['UID'];
Please login to merge, or discard this patch.
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -37,221 +37,221 @@
 block discarded – undo
37 37
 
38 38
 class ContactsStore implements IContactsStore {
39 39
 
40
-	/** @var IManager */
41
-	private $contactsManager;
42
-
43
-	/** @var IConfig */
44
-	private $config;
45
-
46
-	/** @var IUserManager */
47
-	private $userManager;
48
-
49
-	/** @var IGroupManager */
50
-	private $groupManager;
51
-
52
-	/**
53
-	 * @param IManager $contactsManager
54
-	 * @param IConfig $config
55
-	 * @param IUserManager $userManager
56
-	 * @param IGroupManager $groupManager
57
-	 */
58
-	public function __construct(IManager $contactsManager,
59
-								IConfig $config,
60
-								IUserManager $userManager,
61
-								IGroupManager $groupManager) {
62
-		$this->contactsManager = $contactsManager;
63
-		$this->config = $config;
64
-		$this->userManager = $userManager;
65
-		$this->groupManager = $groupManager;
66
-	}
67
-
68
-	/**
69
-	 * @param IUser $user
70
-	 * @param string|null $filter
71
-	 * @return IEntry[]
72
-	 */
73
-	public function getContacts(IUser $user, $filter) {
74
-		$allContacts = $this->contactsManager->search($filter ?: '', [
75
-			'FN',
76
-			'EMAIL'
77
-		]);
78
-
79
-		$entries = array_map(function(array $contact) {
80
-			return $this->contactArrayToEntry($contact);
81
-		}, $allContacts);
82
-		return $this->filterContacts(
83
-			$user,
84
-			$entries,
85
-			$filter
86
-		);
87
-	}
88
-
89
-	/**
90
-	 * Filters the contacts. Applies 3 filters:
91
-	 *  1. filter the current user
92
-	 *  2. if the `shareapi_allow_share_dialog_user_enumeration` config option is
93
-	 * enabled it will filter all local users
94
-	 *  3. if the `shareapi_exclude_groups` config option is enabled and the
95
-	 * current user is in an excluded group it will filter all local users.
96
-	 *  4. if the `shareapi_only_share_with_group_members` config option is
97
-	 * enabled it will filter all users which doens't have a common group
98
-	 * with the current user.
99
-	 *
100
-	 * @param IUser $self
101
-	 * @param Entry[] $entries
102
-	 * @param string $filter
103
-	 * @return Entry[] the filtered contacts
104
-	 */
105
-	private function filterContacts(IUser $self,
106
-									array $entries,
107
-									$filter) {
108
-		$disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes';
109
-		$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes';
110
-
111
-		// whether to filter out local users
112
-		$skipLocal = false;
113
-		// whether to filter out all users which doesn't have the same group as the current user
114
-		$ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
115
-
116
-		$selfGroups = $this->groupManager->getUserGroupIds($self);
117
-
118
-		if ($excludedGroups) {
119
-			$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
120
-			$decodedExcludeGroups = json_decode($excludedGroups, true);
121
-			$excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups :  [];
122
-
123
-			if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
124
-				// a group of the current user is excluded -> filter all local users
125
-				$skipLocal = true;
126
-			}
127
-		}
128
-
129
-		$selfUID = $self->getUID();
130
-
131
-		return array_values(array_filter($entries, function(IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) {
132
-			if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) {
133
-				return false;
134
-			}
135
-
136
-			// Prevent enumerating local users
137
-			if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
138
-				$filterUser = true;
139
-
140
-				$mailAddresses = $entry->getEMailAddresses();
141
-				foreach($mailAddresses as $mailAddress) {
142
-					if($mailAddress === $filter) {
143
-						$filterUser = false;
144
-						break;
145
-					}
146
-				}
147
-
148
-				if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
149
-					$filterUser = false;
150
-				}
151
-
152
-				if($filterUser) {
153
-					return false;
154
-				}
155
-			}
156
-
157
-			if ($ownGroupsOnly && $entry->getProperty('isLocalSystemBook') === true) {
158
-				$contactGroups = $this->groupManager->getUserGroupIds($this->userManager->get($entry->getProperty('UID')));
159
-				if (count(array_intersect($contactGroups, $selfGroups)) === 0) {
160
-					// no groups in common, so shouldn't see the contact
161
-					return false;
162
-				}
163
-			}
164
-
165
-			return $entry->getProperty('UID') !== $selfUID;
166
-		}));
167
-	}
168
-
169
-	/**
170
-	 * @param IUser $user
171
-	 * @param integer $shareType
172
-	 * @param string $shareWith
173
-	 * @return IEntry|null
174
-	 */
175
-	public function findOne(IUser $user, $shareType, $shareWith) {
176
-		switch($shareType) {
177
-			case 0:
178
-			case 6:
179
-				$filter = ['UID'];
180
-				break;
181
-			case 4:
182
-				$filter = ['EMAIL'];
183
-				break;
184
-			default:
185
-				return null;
186
-		}
187
-
188
-		$userId = $user->getUID();
189
-		$allContacts = $this->contactsManager->search($shareWith, $filter);
190
-		$contacts = array_filter($allContacts, function($contact) use ($userId) {
191
-			return $contact['UID'] !== $userId;
192
-		});
193
-		$match = null;
194
-
195
-		foreach ($contacts as $contact) {
196
-			if ($shareType === 4 && isset($contact['EMAIL'])) {
197
-				if (in_array($shareWith, $contact['EMAIL'])) {
198
-					$match = $contact;
199
-					break;
200
-				}
201
-			}
202
-			if ($shareType === 0 || $shareType === 6) {
203
-				$isLocal = $contact['isLocalSystemBook'] ?? false;
204
-				if ($contact['UID'] === $shareWith && $isLocal === true) {
205
-					$match = $contact;
206
-					break;
207
-				}
208
-			}
209
-		}
210
-
211
-		if ($match) {
212
-			$match = $this->filterContacts($user, [$this->contactArrayToEntry($match)], $shareWith);
213
-			if (count($match) === 1) {
214
-				$match = $match[0];
215
-			} else {
216
-				$match = null;
217
-			}
218
-
219
-		}
220
-
221
-		return $match;
222
-	}
223
-
224
-	/**
225
-	 * @param array $contact
226
-	 * @return Entry
227
-	 */
228
-	private function contactArrayToEntry(array $contact) {
229
-		$entry = new Entry();
230
-
231
-		if (isset($contact['id'])) {
232
-			$entry->setId($contact['id']);
233
-		}
234
-
235
-		if (isset($contact['FN'])) {
236
-			$entry->setFullName($contact['FN']);
237
-		}
238
-
239
-		$avatarPrefix = "VALUE=uri:";
240
-		if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) {
241
-			$entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix)));
242
-		}
243
-
244
-		if (isset($contact['EMAIL'])) {
245
-			foreach ($contact['EMAIL'] as $email) {
246
-				$entry->addEMailAddress($email);
247
-			}
248
-		}
249
-
250
-		// Attach all other properties to the entry too because some
251
-		// providers might make use of it.
252
-		$entry->setProperties($contact);
253
-
254
-		return $entry;
255
-	}
40
+    /** @var IManager */
41
+    private $contactsManager;
42
+
43
+    /** @var IConfig */
44
+    private $config;
45
+
46
+    /** @var IUserManager */
47
+    private $userManager;
48
+
49
+    /** @var IGroupManager */
50
+    private $groupManager;
51
+
52
+    /**
53
+     * @param IManager $contactsManager
54
+     * @param IConfig $config
55
+     * @param IUserManager $userManager
56
+     * @param IGroupManager $groupManager
57
+     */
58
+    public function __construct(IManager $contactsManager,
59
+                                IConfig $config,
60
+                                IUserManager $userManager,
61
+                                IGroupManager $groupManager) {
62
+        $this->contactsManager = $contactsManager;
63
+        $this->config = $config;
64
+        $this->userManager = $userManager;
65
+        $this->groupManager = $groupManager;
66
+    }
67
+
68
+    /**
69
+     * @param IUser $user
70
+     * @param string|null $filter
71
+     * @return IEntry[]
72
+     */
73
+    public function getContacts(IUser $user, $filter) {
74
+        $allContacts = $this->contactsManager->search($filter ?: '', [
75
+            'FN',
76
+            'EMAIL'
77
+        ]);
78
+
79
+        $entries = array_map(function(array $contact) {
80
+            return $this->contactArrayToEntry($contact);
81
+        }, $allContacts);
82
+        return $this->filterContacts(
83
+            $user,
84
+            $entries,
85
+            $filter
86
+        );
87
+    }
88
+
89
+    /**
90
+     * Filters the contacts. Applies 3 filters:
91
+     *  1. filter the current user
92
+     *  2. if the `shareapi_allow_share_dialog_user_enumeration` config option is
93
+     * enabled it will filter all local users
94
+     *  3. if the `shareapi_exclude_groups` config option is enabled and the
95
+     * current user is in an excluded group it will filter all local users.
96
+     *  4. if the `shareapi_only_share_with_group_members` config option is
97
+     * enabled it will filter all users which doens't have a common group
98
+     * with the current user.
99
+     *
100
+     * @param IUser $self
101
+     * @param Entry[] $entries
102
+     * @param string $filter
103
+     * @return Entry[] the filtered contacts
104
+     */
105
+    private function filterContacts(IUser $self,
106
+                                    array $entries,
107
+                                    $filter) {
108
+        $disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes';
109
+        $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes';
110
+
111
+        // whether to filter out local users
112
+        $skipLocal = false;
113
+        // whether to filter out all users which doesn't have the same group as the current user
114
+        $ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
115
+
116
+        $selfGroups = $this->groupManager->getUserGroupIds($self);
117
+
118
+        if ($excludedGroups) {
119
+            $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
120
+            $decodedExcludeGroups = json_decode($excludedGroups, true);
121
+            $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups :  [];
122
+
123
+            if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
124
+                // a group of the current user is excluded -> filter all local users
125
+                $skipLocal = true;
126
+            }
127
+        }
128
+
129
+        $selfUID = $self->getUID();
130
+
131
+        return array_values(array_filter($entries, function(IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) {
132
+            if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) {
133
+                return false;
134
+            }
135
+
136
+            // Prevent enumerating local users
137
+            if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
138
+                $filterUser = true;
139
+
140
+                $mailAddresses = $entry->getEMailAddresses();
141
+                foreach($mailAddresses as $mailAddress) {
142
+                    if($mailAddress === $filter) {
143
+                        $filterUser = false;
144
+                        break;
145
+                    }
146
+                }
147
+
148
+                if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
149
+                    $filterUser = false;
150
+                }
151
+
152
+                if($filterUser) {
153
+                    return false;
154
+                }
155
+            }
156
+
157
+            if ($ownGroupsOnly && $entry->getProperty('isLocalSystemBook') === true) {
158
+                $contactGroups = $this->groupManager->getUserGroupIds($this->userManager->get($entry->getProperty('UID')));
159
+                if (count(array_intersect($contactGroups, $selfGroups)) === 0) {
160
+                    // no groups in common, so shouldn't see the contact
161
+                    return false;
162
+                }
163
+            }
164
+
165
+            return $entry->getProperty('UID') !== $selfUID;
166
+        }));
167
+    }
168
+
169
+    /**
170
+     * @param IUser $user
171
+     * @param integer $shareType
172
+     * @param string $shareWith
173
+     * @return IEntry|null
174
+     */
175
+    public function findOne(IUser $user, $shareType, $shareWith) {
176
+        switch($shareType) {
177
+            case 0:
178
+            case 6:
179
+                $filter = ['UID'];
180
+                break;
181
+            case 4:
182
+                $filter = ['EMAIL'];
183
+                break;
184
+            default:
185
+                return null;
186
+        }
187
+
188
+        $userId = $user->getUID();
189
+        $allContacts = $this->contactsManager->search($shareWith, $filter);
190
+        $contacts = array_filter($allContacts, function($contact) use ($userId) {
191
+            return $contact['UID'] !== $userId;
192
+        });
193
+        $match = null;
194
+
195
+        foreach ($contacts as $contact) {
196
+            if ($shareType === 4 && isset($contact['EMAIL'])) {
197
+                if (in_array($shareWith, $contact['EMAIL'])) {
198
+                    $match = $contact;
199
+                    break;
200
+                }
201
+            }
202
+            if ($shareType === 0 || $shareType === 6) {
203
+                $isLocal = $contact['isLocalSystemBook'] ?? false;
204
+                if ($contact['UID'] === $shareWith && $isLocal === true) {
205
+                    $match = $contact;
206
+                    break;
207
+                }
208
+            }
209
+        }
210
+
211
+        if ($match) {
212
+            $match = $this->filterContacts($user, [$this->contactArrayToEntry($match)], $shareWith);
213
+            if (count($match) === 1) {
214
+                $match = $match[0];
215
+            } else {
216
+                $match = null;
217
+            }
218
+
219
+        }
220
+
221
+        return $match;
222
+    }
223
+
224
+    /**
225
+     * @param array $contact
226
+     * @return Entry
227
+     */
228
+    private function contactArrayToEntry(array $contact) {
229
+        $entry = new Entry();
230
+
231
+        if (isset($contact['id'])) {
232
+            $entry->setId($contact['id']);
233
+        }
234
+
235
+        if (isset($contact['FN'])) {
236
+            $entry->setFullName($contact['FN']);
237
+        }
238
+
239
+        $avatarPrefix = "VALUE=uri:";
240
+        if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) {
241
+            $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix)));
242
+        }
243
+
244
+        if (isset($contact['EMAIL'])) {
245
+            foreach ($contact['EMAIL'] as $email) {
246
+                $entry->addEMailAddress($email);
247
+            }
248
+        }
249
+
250
+        // Attach all other properties to the entry too because some
251
+        // providers might make use of it.
252
+        $entry->setProperties($contact);
253
+
254
+        return $entry;
255
+    }
256 256
 
257 257
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/ExpireSharesJob.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -29,48 +29,48 @@
 block discarded – undo
29 29
  */
30 30
 class ExpireSharesJob extends TimedJob {
31 31
 
32
-	/**
33
-	 * sets the correct interval for this timed job
34
-	 */
35
-	public function __construct() {
36
-		// Run once a day
37
-		$this->setInterval(24 * 60 * 60);
38
-	}
32
+    /**
33
+     * sets the correct interval for this timed job
34
+     */
35
+    public function __construct() {
36
+        // Run once a day
37
+        $this->setInterval(24 * 60 * 60);
38
+    }
39 39
 
40
-	/**
41
-	 * Makes the background job do its work
42
-	 *
43
-	 * @param array $argument unused argument
44
-	 */
45
-	public function run($argument) {
46
-		$connection = \OC::$server->getDatabaseConnection();
40
+    /**
41
+     * Makes the background job do its work
42
+     *
43
+     * @param array $argument unused argument
44
+     */
45
+    public function run($argument) {
46
+        $connection = \OC::$server->getDatabaseConnection();
47 47
 
48
-		//Current time
49
-		$now = new \DateTime();
50
-		$now = $now->format('Y-m-d H:i:s');
48
+        //Current time
49
+        $now = new \DateTime();
50
+        $now = $now->format('Y-m-d H:i:s');
51 51
 
52
-		/*
52
+        /*
53 53
 		 * Expire file link shares only (for now)
54 54
 		 */
55
-		$qb = $connection->getQueryBuilder();
56
-		$qb->select('id', 'file_source', 'uid_owner', 'item_type')
57
-			->from('share')
58
-			->where(
59
-				$qb->expr()->andX(
60
-					$qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)),
61
-					$qb->expr()->lte('expiration', $qb->expr()->literal($now)),
62
-					$qb->expr()->orX(
63
-						$qb->expr()->eq('item_type', $qb->expr()->literal('file')),
64
-						$qb->expr()->eq('item_type', $qb->expr()->literal('folder'))
65
-					)
66
-				)
67
-			);
55
+        $qb = $connection->getQueryBuilder();
56
+        $qb->select('id', 'file_source', 'uid_owner', 'item_type')
57
+            ->from('share')
58
+            ->where(
59
+                $qb->expr()->andX(
60
+                    $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)),
61
+                    $qb->expr()->lte('expiration', $qb->expr()->literal($now)),
62
+                    $qb->expr()->orX(
63
+                        $qb->expr()->eq('item_type', $qb->expr()->literal('file')),
64
+                        $qb->expr()->eq('item_type', $qb->expr()->literal('folder'))
65
+                    )
66
+                )
67
+            );
68 68
 
69
-		$shares = $qb->execute();
70
-		while($share = $shares->fetch()) {
71
-			\OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']);
72
-		}
73
-		$shares->closeCursor();
74
-	}
69
+        $shares = $qb->execute();
70
+        while($share = $shares->fetch()) {
71
+            \OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']);
72
+        }
73
+        $shares->closeCursor();
74
+    }
75 75
 
76 76
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 			);
68 68
 
69 69
 		$shares = $qb->execute();
70
-		while($share = $shares->fetch()) {
70
+		while ($share = $shares->fetch()) {
71 71
 			\OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']);
72 72
 		}
73 73
 		$shares->closeCursor();
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/InvalidAuth.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@
 block discarded – undo
27 27
  */
28 28
 class InvalidAuth extends AuthMechanism {
29 29
 
30
-	/**
31
-	 * Constructs a new InvalidAuth with the id of the invalid auth
32
-	 * for display purposes
33
-	 *
34
-	 * @param string $invalidId invalid id
35
-	 */
36
-	public function __construct($invalidId) {
37
-		$this
38
-			->setIdentifier($invalidId)
39
-			->setScheme(self::SCHEME_NULL)
40
-			->setText('Unknown auth mechanism backend ' . $invalidId)
41
-		;
42
-	}
30
+    /**
31
+     * Constructs a new InvalidAuth with the id of the invalid auth
32
+     * for display purposes
33
+     *
34
+     * @param string $invalidId invalid id
35
+     */
36
+    public function __construct($invalidId) {
37
+        $this
38
+            ->setIdentifier($invalidId)
39
+            ->setScheme(self::SCHEME_NULL)
40
+            ->setText('Unknown auth mechanism backend ' . $invalidId)
41
+        ;
42
+    }
43 43
 
44 44
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 		$this
38 38
 			->setIdentifier($invalidId)
39 39
 			->setScheme(self::SCHEME_NULL)
40
-			->setText('Unknown auth mechanism backend ' . $invalidId)
40
+			->setText('Unknown auth mechanism backend '.$invalidId)
41 41
 		;
42 42
 	}
43 43
 
Please login to merge, or discard this patch.