Completed
Pull Request — master (#4212)
by Individual IT
13:52
created
apps/encryption/lib/HookManager.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -28,38 +28,38 @@
 block discarded – undo
28 28
 
29 29
 class HookManager {
30 30
 
31
-	private $hookInstances = [];
31
+    private $hookInstances = [];
32 32
 
33
-	/**
34
-	 * @param array|IHook $instances
35
-	 *        - This accepts either a single instance of IHook or an array of instances of IHook
36
-	 * @return bool
37
-	 */
38
-	public function registerHook($instances) {
39
-		if (is_array($instances)) {
40
-			foreach ($instances as $instance) {
41
-				if (!$instance instanceof IHook) {
42
-					return false;
43
-				}
44
-				$this->hookInstances[] = $instance;
45
-			}
33
+    /**
34
+     * @param array|IHook $instances
35
+     *        - This accepts either a single instance of IHook or an array of instances of IHook
36
+     * @return bool
37
+     */
38
+    public function registerHook($instances) {
39
+        if (is_array($instances)) {
40
+            foreach ($instances as $instance) {
41
+                if (!$instance instanceof IHook) {
42
+                    return false;
43
+                }
44
+                $this->hookInstances[] = $instance;
45
+            }
46 46
 
47
-		} elseif ($instances instanceof IHook) {
48
-			$this->hookInstances[] = $instances;
49
-		}
50
-		return true;
51
-	}
47
+        } elseif ($instances instanceof IHook) {
48
+            $this->hookInstances[] = $instances;
49
+        }
50
+        return true;
51
+    }
52 52
 
53
-	public function fireHooks() {
54
-		foreach ($this->hookInstances as $instance) {
55
-			/**
56
-			 * Fire off the add hooks method of each instance stored in cache
57
-			 *
58
-			 * @var $instance IHook
59
-			 */
60
-			$instance->addHooks();
61
-		}
53
+    public function fireHooks() {
54
+        foreach ($this->hookInstances as $instance) {
55
+            /**
56
+             * Fire off the add hooks method of each instance stored in cache
57
+             *
58
+             * @var $instance IHook
59
+             */
60
+            $instance->addHooks();
61
+        }
62 62
 
63
-	}
63
+    }
64 64
 
65 65
 }
Please login to merge, or discard this patch.
apps/encryption/appinfo/routes.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -26,36 +26,36 @@
 block discarded – undo
26 26
 
27 27
 (new Application())->registerRoutes($this, array('routes' => array(
28 28
 
29
-	[
30
-		'name' => 'Recovery#adminRecovery',
31
-		'url' => '/ajax/adminRecovery',
32
-		'verb' => 'POST'
33
-	],
34
-	[
35
-		'name' => 'Settings#updatePrivateKeyPassword',
36
-		'url' => '/ajax/updatePrivateKeyPassword',
37
-		'verb' => 'POST'
38
-	],
39
-	[
40
-		'name' => 'Settings#setEncryptHomeStorage',
41
-		'url' => '/ajax/setEncryptHomeStorage',
42
-		'verb' => 'POST'
43
-	],
44
-	[
45
-		'name' => 'Recovery#changeRecoveryPassword',
46
-		'url' => '/ajax/changeRecoveryPassword',
47
-		'verb' => 'POST'
48
-	],
49
-	[
50
-		'name' => 'Recovery#userSetRecovery',
51
-		'url' => '/ajax/userSetRecovery',
52
-		'verb' => 'POST'
53
-	],
54
-	[
55
-		'name' => 'Status#getStatus',
56
-		'url' => '/ajax/getStatus',
57
-		'verb' => 'GET'
58
-	]
29
+    [
30
+        'name' => 'Recovery#adminRecovery',
31
+        'url' => '/ajax/adminRecovery',
32
+        'verb' => 'POST'
33
+    ],
34
+    [
35
+        'name' => 'Settings#updatePrivateKeyPassword',
36
+        'url' => '/ajax/updatePrivateKeyPassword',
37
+        'verb' => 'POST'
38
+    ],
39
+    [
40
+        'name' => 'Settings#setEncryptHomeStorage',
41
+        'url' => '/ajax/setEncryptHomeStorage',
42
+        'verb' => 'POST'
43
+    ],
44
+    [
45
+        'name' => 'Recovery#changeRecoveryPassword',
46
+        'url' => '/ajax/changeRecoveryPassword',
47
+        'verb' => 'POST'
48
+    ],
49
+    [
50
+        'name' => 'Recovery#userSetRecovery',
51
+        'url' => '/ajax/userSetRecovery',
52
+        'verb' => 'POST'
53
+    ],
54
+    [
55
+        'name' => 'Status#getStatus',
56
+        'url' => '/ajax/getStatus',
57
+        'verb' => 'GET'
58
+    ]
59 59
 
60 60
 
61 61
 )));
Please login to merge, or discard this patch.
apps/encryption/appinfo/app.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 
30 30
 $app = new Application([], $encryptionSystemReady);
31 31
 if ($encryptionSystemReady) {
32
-	$app->registerEncryptionModule();
33
-	$app->registerHooks();
34
-	$app->registerSettings();
32
+    $app->registerEncryptionModule();
33
+    $app->registerHooks();
34
+    $app->registerSettings();
35 35
 }
Please login to merge, or discard this patch.
apps/encryption/settings/settings-personal.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -27,26 +27,26 @@  discard block
 block discarded – undo
27 27
 
28 28
 $template = new OCP\Template('encryption', 'settings-personal');
29 29
 $crypt = new \OCA\Encryption\Crypto\Crypt(
30
-	\OC::$server->getLogger(),
31
-	$userSession,
32
-	\OC::$server->getConfig(),
33
-	\OC::$server->getL10N('encryption'));
30
+    \OC::$server->getLogger(),
31
+    $userSession,
32
+    \OC::$server->getConfig(),
33
+    \OC::$server->getL10N('encryption'));
34 34
 
35 35
 $util = new \OCA\Encryption\Util(
36
-	new \OC\Files\View(),
37
-	$crypt,
38
-	\OC::$server->getLogger(),
39
-	$userSession,
40
-	\OC::$server->getConfig(),
41
-	\OC::$server->getUserManager());
36
+    new \OC\Files\View(),
37
+    $crypt,
38
+    \OC::$server->getLogger(),
39
+    $userSession,
40
+    \OC::$server->getConfig(),
41
+    \OC::$server->getUserManager());
42 42
 
43 43
 $keyManager = new \OCA\Encryption\KeyManager(
44
-	\OC::$server->getEncryptionKeyStorage(),
45
-	$crypt,
46
-	\OC::$server->getConfig(),
47
-	$userSession,
48
-	$session,
49
-	\OC::$server->getLogger(), $util);
44
+    \OC::$server->getEncryptionKeyStorage(),
45
+    $crypt,
46
+    \OC::$server->getConfig(),
47
+    $userSession,
48
+    $session,
49
+    \OC::$server->getLogger(), $util);
50 50
 
51 51
 $user = $userSession->getUser()->getUID();
52 52
 
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 $result = false;
65 65
 
66 66
 if ($recoveryAdminEnabled || !$privateKeySet) {
67
-	$template->assign('recoveryEnabled', $recoveryAdminEnabled);
68
-	$template->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
69
-	$template->assign('privateKeySet', $privateKeySet);
70
-	$template->assign('initialized', $initialized);
67
+    $template->assign('recoveryEnabled', $recoveryAdminEnabled);
68
+    $template->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
69
+    $template->assign('privateKeySet', $privateKeySet);
70
+    $template->assign('initialized', $initialized);
71 71
 
72
-	$result = $template->fetchPage();
72
+    $result = $template->fetchPage();
73 73
 }
74 74
 
75 75
 return $result;
Please login to merge, or discard this patch.
apps/comments/lib/Activity/Provider.php 1 patch
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -34,209 +34,209 @@
 block discarded – undo
34 34
 
35 35
 class Provider implements IProvider {
36 36
 
37
-	/** @var IFactory */
38
-	protected $languageFactory;
39
-
40
-	/** @var IL10N */
41
-	protected $l;
42
-
43
-	/** @var IURLGenerator */
44
-	protected $url;
45
-
46
-	/** @var ICommentsManager */
47
-	protected $commentsManager;
48
-
49
-	/** @var IUserManager */
50
-	protected $userManager;
51
-
52
-	/** @var IManager */
53
-	protected $activityManager;
54
-
55
-	/** @var string[] */
56
-	protected $displayNames = [];
57
-
58
-	/**
59
-	 * @param IFactory $languageFactory
60
-	 * @param IURLGenerator $url
61
-	 * @param ICommentsManager $commentsManager
62
-	 * @param IUserManager $userManager
63
-	 * @param IManager $activityManager
64
-	 */
65
-	public function __construct(IFactory $languageFactory, IURLGenerator $url, ICommentsManager $commentsManager, IUserManager $userManager, IManager $activityManager) {
66
-		$this->languageFactory = $languageFactory;
67
-		$this->url = $url;
68
-		$this->commentsManager = $commentsManager;
69
-		$this->userManager = $userManager;
70
-		$this->activityManager = $activityManager;
71
-	}
72
-
73
-	/**
74
-	 * @param string $language
75
-	 * @param IEvent $event
76
-	 * @param IEvent|null $previousEvent
77
-	 * @return IEvent
78
-	 * @throws \InvalidArgumentException
79
-	 * @since 11.0.0
80
-	 */
81
-	public function parse($language, IEvent $event, IEvent $previousEvent = null) {
82
-		if ($event->getApp() !== 'comments') {
83
-			throw new \InvalidArgumentException();
84
-		}
85
-
86
-		$this->l = $this->languageFactory->get('comments', $language);
87
-
88
-		if ($event->getSubject() === 'add_comment_subject') {
89
-			$this->parseMessage($event);
90
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg')));
91
-
92
-			if ($this->activityManager->isFormattingFilteredObject()) {
93
-				try {
94
-					return $this->parseShortVersion($event);
95
-				} catch (\InvalidArgumentException $e) {
96
-					// Ignore and simply use the long version...
97
-				}
98
-			}
99
-
100
-			return $this->parseLongVersion($event);
101
-		} else {
102
-			throw new \InvalidArgumentException();
103
-		}
104
-	}
105
-
106
-	/**
107
-	 * @param IEvent $event
108
-	 * @return IEvent
109
-	 * @throws \InvalidArgumentException
110
-	 */
111
-	protected function parseShortVersion(IEvent $event) {
112
-		$subjectParameters = $event->getSubjectParameters();
113
-
114
-		if ($event->getSubject() === 'add_comment_subject') {
115
-			if ($subjectParameters[0] === $this->activityManager->getCurrentUserId()) {
116
-				$event->setParsedSubject($this->l->t('You commented'))
117
-					->setRichSubject($this->l->t('You commented'), []);
118
-			} else {
119
-				$author = $this->generateUserParameter($subjectParameters[0]);
120
-				$event->setParsedSubject($this->l->t('%1$s commented', [$author['name']]))
121
-					->setRichSubject($this->l->t('{author} commented'), [
122
-						'author' => $author,
123
-					]);
124
-			}
125
-		} else {
126
-			throw new \InvalidArgumentException();
127
-		}
128
-
129
-		return $event;
130
-	}
131
-
132
-	/**
133
-	 * @param IEvent $event
134
-	 * @return IEvent
135
-	 * @throws \InvalidArgumentException
136
-	 */
137
-	protected function parseLongVersion(IEvent $event) {
138
-		$subjectParameters = $event->getSubjectParameters();
139
-
140
-		if ($event->getSubject() === 'add_comment_subject') {
141
-			if ($subjectParameters[0] === $this->activityManager->getCurrentUserId()) {
142
-				$event->setParsedSubject($this->l->t('You commented on %1$s', [
143
-						trim($subjectParameters[1], '/'),
144
-					]))
145
-					->setRichSubject($this->l->t('You commented on {file}'), [
146
-						'file' => $this->generateFileParameter($event->getObjectId(), $subjectParameters[1]),
147
-					]);
148
-			} else {
149
-				$author = $this->generateUserParameter($subjectParameters[0]);
150
-				$event->setParsedSubject($this->l->t('%1$s commented on %2$s', [
151
-						$author['name'],
152
-						trim($subjectParameters[1], '/'),
153
-					]))
154
-					->setRichSubject($this->l->t('{author} commented on {file}'), [
155
-						'author' => $author,
156
-						'file' => $this->generateFileParameter($event->getObjectId(), $subjectParameters[1]),
157
-					]);
158
-			}
159
-		} else {
160
-			throw new \InvalidArgumentException();
161
-		}
162
-
163
-		return $event;
164
-	}
165
-
166
-	/**
167
-	 * @param IEvent $event
168
-	 */
169
-	protected function parseMessage(IEvent $event) {
170
-		$messageParameters = $event->getMessageParameters();
171
-		try {
172
-			$comment = $this->commentsManager->get((int) $messageParameters[0]);
173
-			$message = $comment->getMessage();
174
-			$message = str_replace("\n", '<br />', str_replace(['<', '>'], ['&lt;', '&gt;'], $message));
175
-
176
-			$mentionCount = 1;
177
-			$mentions = [];
178
-			foreach ($comment->getMentions() as $mention) {
179
-				if ($mention['type'] !== 'user') {
180
-					continue;
181
-				}
182
-
183
-				$message = preg_replace(
184
-					'/(^|\s)(' . '@' . $mention['id'] . ')(\b)/',
185
-					//'${1}' . $this->regexSafeUser($mention['id'], $displayName) . '${3}',
186
-					'${1}' . '{mention' . $mentionCount . '}' . '${3}',
187
-					$message
188
-				);
189
-				$mentions['mention' . $mentionCount] = $this->generateUserParameter($mention['id']);
190
-				$mentionCount++;
191
-			}
192
-
193
-			$event->setParsedMessage($comment->getMessage())
194
-				->setRichMessage($message, $mentions);
195
-		} catch (NotFoundException $e) {
196
-		}
197
-	}
198
-
199
-	/**
200
-	 * @param int $id
201
-	 * @param string $path
202
-	 * @return array
203
-	 */
204
-	protected function generateFileParameter($id, $path) {
205
-		return [
206
-			'type' => 'file',
207
-			'id' => $id,
208
-			'name' => basename($path),
209
-			'path' => trim($path, '/'),
210
-			'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
211
-		];
212
-	}
213
-
214
-	/**
215
-	 * @param string $uid
216
-	 * @return array
217
-	 */
218
-	protected function generateUserParameter($uid) {
219
-		if (!isset($this->displayNames[$uid])) {
220
-			$this->displayNames[$uid] = $this->getDisplayName($uid);
221
-		}
222
-
223
-		return [
224
-			'type' => 'user',
225
-			'id' => $uid,
226
-			'name' => $this->displayNames[$uid],
227
-		];
228
-	}
229
-
230
-	/**
231
-	 * @param string $uid
232
-	 * @return string
233
-	 */
234
-	protected function getDisplayName($uid) {
235
-		$user = $this->userManager->get($uid);
236
-		if ($user instanceof IUser) {
237
-			return $user->getDisplayName();
238
-		} else {
239
-			return $uid;
240
-		}
241
-	}
37
+    /** @var IFactory */
38
+    protected $languageFactory;
39
+
40
+    /** @var IL10N */
41
+    protected $l;
42
+
43
+    /** @var IURLGenerator */
44
+    protected $url;
45
+
46
+    /** @var ICommentsManager */
47
+    protected $commentsManager;
48
+
49
+    /** @var IUserManager */
50
+    protected $userManager;
51
+
52
+    /** @var IManager */
53
+    protected $activityManager;
54
+
55
+    /** @var string[] */
56
+    protected $displayNames = [];
57
+
58
+    /**
59
+     * @param IFactory $languageFactory
60
+     * @param IURLGenerator $url
61
+     * @param ICommentsManager $commentsManager
62
+     * @param IUserManager $userManager
63
+     * @param IManager $activityManager
64
+     */
65
+    public function __construct(IFactory $languageFactory, IURLGenerator $url, ICommentsManager $commentsManager, IUserManager $userManager, IManager $activityManager) {
66
+        $this->languageFactory = $languageFactory;
67
+        $this->url = $url;
68
+        $this->commentsManager = $commentsManager;
69
+        $this->userManager = $userManager;
70
+        $this->activityManager = $activityManager;
71
+    }
72
+
73
+    /**
74
+     * @param string $language
75
+     * @param IEvent $event
76
+     * @param IEvent|null $previousEvent
77
+     * @return IEvent
78
+     * @throws \InvalidArgumentException
79
+     * @since 11.0.0
80
+     */
81
+    public function parse($language, IEvent $event, IEvent $previousEvent = null) {
82
+        if ($event->getApp() !== 'comments') {
83
+            throw new \InvalidArgumentException();
84
+        }
85
+
86
+        $this->l = $this->languageFactory->get('comments', $language);
87
+
88
+        if ($event->getSubject() === 'add_comment_subject') {
89
+            $this->parseMessage($event);
90
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg')));
91
+
92
+            if ($this->activityManager->isFormattingFilteredObject()) {
93
+                try {
94
+                    return $this->parseShortVersion($event);
95
+                } catch (\InvalidArgumentException $e) {
96
+                    // Ignore and simply use the long version...
97
+                }
98
+            }
99
+
100
+            return $this->parseLongVersion($event);
101
+        } else {
102
+            throw new \InvalidArgumentException();
103
+        }
104
+    }
105
+
106
+    /**
107
+     * @param IEvent $event
108
+     * @return IEvent
109
+     * @throws \InvalidArgumentException
110
+     */
111
+    protected function parseShortVersion(IEvent $event) {
112
+        $subjectParameters = $event->getSubjectParameters();
113
+
114
+        if ($event->getSubject() === 'add_comment_subject') {
115
+            if ($subjectParameters[0] === $this->activityManager->getCurrentUserId()) {
116
+                $event->setParsedSubject($this->l->t('You commented'))
117
+                    ->setRichSubject($this->l->t('You commented'), []);
118
+            } else {
119
+                $author = $this->generateUserParameter($subjectParameters[0]);
120
+                $event->setParsedSubject($this->l->t('%1$s commented', [$author['name']]))
121
+                    ->setRichSubject($this->l->t('{author} commented'), [
122
+                        'author' => $author,
123
+                    ]);
124
+            }
125
+        } else {
126
+            throw new \InvalidArgumentException();
127
+        }
128
+
129
+        return $event;
130
+    }
131
+
132
+    /**
133
+     * @param IEvent $event
134
+     * @return IEvent
135
+     * @throws \InvalidArgumentException
136
+     */
137
+    protected function parseLongVersion(IEvent $event) {
138
+        $subjectParameters = $event->getSubjectParameters();
139
+
140
+        if ($event->getSubject() === 'add_comment_subject') {
141
+            if ($subjectParameters[0] === $this->activityManager->getCurrentUserId()) {
142
+                $event->setParsedSubject($this->l->t('You commented on %1$s', [
143
+                        trim($subjectParameters[1], '/'),
144
+                    ]))
145
+                    ->setRichSubject($this->l->t('You commented on {file}'), [
146
+                        'file' => $this->generateFileParameter($event->getObjectId(), $subjectParameters[1]),
147
+                    ]);
148
+            } else {
149
+                $author = $this->generateUserParameter($subjectParameters[0]);
150
+                $event->setParsedSubject($this->l->t('%1$s commented on %2$s', [
151
+                        $author['name'],
152
+                        trim($subjectParameters[1], '/'),
153
+                    ]))
154
+                    ->setRichSubject($this->l->t('{author} commented on {file}'), [
155
+                        'author' => $author,
156
+                        'file' => $this->generateFileParameter($event->getObjectId(), $subjectParameters[1]),
157
+                    ]);
158
+            }
159
+        } else {
160
+            throw new \InvalidArgumentException();
161
+        }
162
+
163
+        return $event;
164
+    }
165
+
166
+    /**
167
+     * @param IEvent $event
168
+     */
169
+    protected function parseMessage(IEvent $event) {
170
+        $messageParameters = $event->getMessageParameters();
171
+        try {
172
+            $comment = $this->commentsManager->get((int) $messageParameters[0]);
173
+            $message = $comment->getMessage();
174
+            $message = str_replace("\n", '<br />', str_replace(['<', '>'], ['&lt;', '&gt;'], $message));
175
+
176
+            $mentionCount = 1;
177
+            $mentions = [];
178
+            foreach ($comment->getMentions() as $mention) {
179
+                if ($mention['type'] !== 'user') {
180
+                    continue;
181
+                }
182
+
183
+                $message = preg_replace(
184
+                    '/(^|\s)(' . '@' . $mention['id'] . ')(\b)/',
185
+                    //'${1}' . $this->regexSafeUser($mention['id'], $displayName) . '${3}',
186
+                    '${1}' . '{mention' . $mentionCount . '}' . '${3}',
187
+                    $message
188
+                );
189
+                $mentions['mention' . $mentionCount] = $this->generateUserParameter($mention['id']);
190
+                $mentionCount++;
191
+            }
192
+
193
+            $event->setParsedMessage($comment->getMessage())
194
+                ->setRichMessage($message, $mentions);
195
+        } catch (NotFoundException $e) {
196
+        }
197
+    }
198
+
199
+    /**
200
+     * @param int $id
201
+     * @param string $path
202
+     * @return array
203
+     */
204
+    protected function generateFileParameter($id, $path) {
205
+        return [
206
+            'type' => 'file',
207
+            'id' => $id,
208
+            'name' => basename($path),
209
+            'path' => trim($path, '/'),
210
+            'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
211
+        ];
212
+    }
213
+
214
+    /**
215
+     * @param string $uid
216
+     * @return array
217
+     */
218
+    protected function generateUserParameter($uid) {
219
+        if (!isset($this->displayNames[$uid])) {
220
+            $this->displayNames[$uid] = $this->getDisplayName($uid);
221
+        }
222
+
223
+        return [
224
+            'type' => 'user',
225
+            'id' => $uid,
226
+            'name' => $this->displayNames[$uid],
227
+        ];
228
+    }
229
+
230
+    /**
231
+     * @param string $uid
232
+     * @return string
233
+     */
234
+    protected function getDisplayName($uid) {
235
+        $user = $this->userManager->get($uid);
236
+        if ($user instanceof IUser) {
237
+            return $user->getDisplayName();
238
+        } else {
239
+            return $uid;
240
+        }
241
+    }
242 242
 }
Please login to merge, or discard this patch.
apps/comments/lib/Activity/Setting.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -27,72 +27,72 @@
 block discarded – undo
27 27
 
28 28
 class Setting implements ISetting {
29 29
 
30
-	/** @var IL10N */
31
-	protected $l;
30
+    /** @var IL10N */
31
+    protected $l;
32 32
 
33
-	/**
34
-	 * @param IL10N $l
35
-	 */
36
-	public function __construct(IL10N $l) {
37
-		$this->l = $l;
38
-	}
33
+    /**
34
+     * @param IL10N $l
35
+     */
36
+    public function __construct(IL10N $l) {
37
+        $this->l = $l;
38
+    }
39 39
 
40
-	/**
41
-	 * @return string Lowercase a-z and underscore only identifier
42
-	 * @since 11.0.0
43
-	 */
44
-	public function getIdentifier() {
45
-		return 'comments';
46
-	}
40
+    /**
41
+     * @return string Lowercase a-z and underscore only identifier
42
+     * @since 11.0.0
43
+     */
44
+    public function getIdentifier() {
45
+        return 'comments';
46
+    }
47 47
 
48
-	/**
49
-	 * @return string A translated string
50
-	 * @since 11.0.0
51
-	 */
52
-	public function getName() {
53
-		return $this->l->t('<strong>Comments</strong> for files');
54
-	}
48
+    /**
49
+     * @return string A translated string
50
+     * @since 11.0.0
51
+     */
52
+    public function getName() {
53
+        return $this->l->t('<strong>Comments</strong> for files');
54
+    }
55 55
 
56
-	/**
57
-	 * @return int whether the filter should be rather on the top or bottom of
58
-	 * the admin section. The filters are arranged in ascending order of the
59
-	 * priority values. It is required to return a value between 0 and 100.
60
-	 * @since 11.0.0
61
-	 */
62
-	public function getPriority() {
63
-		return 50;
64
-	}
56
+    /**
57
+     * @return int whether the filter should be rather on the top or bottom of
58
+     * the admin section. The filters are arranged in ascending order of the
59
+     * priority values. It is required to return a value between 0 and 100.
60
+     * @since 11.0.0
61
+     */
62
+    public function getPriority() {
63
+        return 50;
64
+    }
65 65
 
66
-	/**
67
-	 * @return bool True when the option can be changed for the stream
68
-	 * @since 11.0.0
69
-	 */
70
-	public function canChangeStream() {
71
-		return true;
72
-	}
66
+    /**
67
+     * @return bool True when the option can be changed for the stream
68
+     * @since 11.0.0
69
+     */
70
+    public function canChangeStream() {
71
+        return true;
72
+    }
73 73
 
74
-	/**
75
-	 * @return bool True when the option can be changed for the stream
76
-	 * @since 11.0.0
77
-	 */
78
-	public function isDefaultEnabledStream() {
79
-		return true;
80
-	}
74
+    /**
75
+     * @return bool True when the option can be changed for the stream
76
+     * @since 11.0.0
77
+     */
78
+    public function isDefaultEnabledStream() {
79
+        return true;
80
+    }
81 81
 
82
-	/**
83
-	 * @return bool True when the option can be changed for the mail
84
-	 * @since 11.0.0
85
-	 */
86
-	public function canChangeMail() {
87
-		return true;
88
-	}
82
+    /**
83
+     * @return bool True when the option can be changed for the mail
84
+     * @since 11.0.0
85
+     */
86
+    public function canChangeMail() {
87
+        return true;
88
+    }
89 89
 
90
-	/**
91
-	 * @return bool True when the option can be changed for the stream
92
-	 * @since 11.0.0
93
-	 */
94
-	public function isDefaultEnabledMail() {
95
-		return false;
96
-	}
90
+    /**
91
+     * @return bool True when the option can be changed for the stream
92
+     * @since 11.0.0
93
+     */
94
+    public function isDefaultEnabledMail() {
95
+        return false;
96
+    }
97 97
 }
98 98
 
Please login to merge, or discard this patch.
apps/comments/lib/Activity/Listener.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -33,97 +33,97 @@
 block discarded – undo
33 33
 use OCP\Share;
34 34
 
35 35
 class Listener {
36
-	/** @var IManager */
37
-	protected $activityManager;
38
-	/** @var IUserSession */
39
-	protected $session;
40
-	/** @var \OCP\App\IAppManager */
41
-	protected $appManager;
42
-	/** @var \OCP\Files\Config\IMountProviderCollection */
43
-	protected $mountCollection;
44
-	/** @var \OCP\Files\IRootFolder */
45
-	protected $rootFolder;
36
+    /** @var IManager */
37
+    protected $activityManager;
38
+    /** @var IUserSession */
39
+    protected $session;
40
+    /** @var \OCP\App\IAppManager */
41
+    protected $appManager;
42
+    /** @var \OCP\Files\Config\IMountProviderCollection */
43
+    protected $mountCollection;
44
+    /** @var \OCP\Files\IRootFolder */
45
+    protected $rootFolder;
46 46
 
47
-	/**
48
-	 * Listener constructor.
49
-	 *
50
-	 * @param IManager $activityManager
51
-	 * @param IUserSession $session
52
-	 * @param IAppManager $appManager
53
-	 * @param IMountProviderCollection $mountCollection
54
-	 * @param IRootFolder $rootFolder
55
-	 */
56
-	public function __construct(IManager $activityManager,
57
-								IUserSession $session,
58
-								IAppManager $appManager,
59
-								IMountProviderCollection $mountCollection,
60
-								IRootFolder $rootFolder) {
61
-		$this->activityManager = $activityManager;
62
-		$this->session = $session;
63
-		$this->appManager = $appManager;
64
-		$this->mountCollection = $mountCollection;
65
-		$this->rootFolder = $rootFolder;
66
-	}
47
+    /**
48
+     * Listener constructor.
49
+     *
50
+     * @param IManager $activityManager
51
+     * @param IUserSession $session
52
+     * @param IAppManager $appManager
53
+     * @param IMountProviderCollection $mountCollection
54
+     * @param IRootFolder $rootFolder
55
+     */
56
+    public function __construct(IManager $activityManager,
57
+                                IUserSession $session,
58
+                                IAppManager $appManager,
59
+                                IMountProviderCollection $mountCollection,
60
+                                IRootFolder $rootFolder) {
61
+        $this->activityManager = $activityManager;
62
+        $this->session = $session;
63
+        $this->appManager = $appManager;
64
+        $this->mountCollection = $mountCollection;
65
+        $this->rootFolder = $rootFolder;
66
+    }
67 67
 
68
-	/**
69
-	 * @param CommentsEvent $event
70
-	 */
71
-	public function commentEvent(CommentsEvent $event) {
72
-		if ($event->getComment()->getObjectType() !== 'files'
73
-			|| !in_array($event->getEvent(), [CommentsEvent::EVENT_ADD])
74
-			|| !$this->appManager->isInstalled('activity')) {
75
-			// Comment not for file, not adding a comment or no activity-app enabled (save the energy)
76
-			return;
77
-		}
68
+    /**
69
+     * @param CommentsEvent $event
70
+     */
71
+    public function commentEvent(CommentsEvent $event) {
72
+        if ($event->getComment()->getObjectType() !== 'files'
73
+            || !in_array($event->getEvent(), [CommentsEvent::EVENT_ADD])
74
+            || !$this->appManager->isInstalled('activity')) {
75
+            // Comment not for file, not adding a comment or no activity-app enabled (save the energy)
76
+            return;
77
+        }
78 78
 
79
-		// Get all mount point owners
80
-		$cache = $this->mountCollection->getMountCache();
81
-		$mounts = $cache->getMountsForFileId($event->getComment()->getObjectId());
82
-		if (empty($mounts)) {
83
-			return;
84
-		}
79
+        // Get all mount point owners
80
+        $cache = $this->mountCollection->getMountCache();
81
+        $mounts = $cache->getMountsForFileId($event->getComment()->getObjectId());
82
+        if (empty($mounts)) {
83
+            return;
84
+        }
85 85
 
86
-		$users = [];
87
-		foreach ($mounts as $mount) {
88
-			$owner = $mount->getUser()->getUID();
89
-			$ownerFolder = $this->rootFolder->getUserFolder($owner);
90
-			$nodes = $ownerFolder->getById($event->getComment()->getObjectId());
91
-			if (!empty($nodes)) {
92
-				/** @var Node $node */
93
-				$node = array_shift($nodes);
94
-				$path = $node->getPath();
95
-				if (strpos($path, '/' . $owner . '/files/') === 0) {
96
-					$path = substr($path, strlen('/' . $owner . '/files'));
97
-				}
98
-				// Get all users that have access to the mount point
99
-				$users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
100
-			}
101
-		}
86
+        $users = [];
87
+        foreach ($mounts as $mount) {
88
+            $owner = $mount->getUser()->getUID();
89
+            $ownerFolder = $this->rootFolder->getUserFolder($owner);
90
+            $nodes = $ownerFolder->getById($event->getComment()->getObjectId());
91
+            if (!empty($nodes)) {
92
+                /** @var Node $node */
93
+                $node = array_shift($nodes);
94
+                $path = $node->getPath();
95
+                if (strpos($path, '/' . $owner . '/files/') === 0) {
96
+                    $path = substr($path, strlen('/' . $owner . '/files'));
97
+                }
98
+                // Get all users that have access to the mount point
99
+                $users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
100
+            }
101
+        }
102 102
 
103
-		$actor = $this->session->getUser();
104
-		if ($actor instanceof IUser) {
105
-			$actor = $actor->getUID();
106
-		} else {
107
-			$actor = '';
108
-		}
103
+        $actor = $this->session->getUser();
104
+        if ($actor instanceof IUser) {
105
+            $actor = $actor->getUID();
106
+        } else {
107
+            $actor = '';
108
+        }
109 109
 
110
-		$activity = $this->activityManager->generateEvent();
111
-		$activity->setApp('comments')
112
-			->setType('comments')
113
-			->setAuthor($actor)
114
-			->setObject($event->getComment()->getObjectType(), (int) $event->getComment()->getObjectId())
115
-			->setMessage('add_comment_message', [
116
-				$event->getComment()->getId(),
117
-			]);
110
+        $activity = $this->activityManager->generateEvent();
111
+        $activity->setApp('comments')
112
+            ->setType('comments')
113
+            ->setAuthor($actor)
114
+            ->setObject($event->getComment()->getObjectType(), (int) $event->getComment()->getObjectId())
115
+            ->setMessage('add_comment_message', [
116
+                $event->getComment()->getId(),
117
+            ]);
118 118
 
119
-		foreach ($users as $user => $path) {
120
-			$activity->setAffectedUser($user);
119
+        foreach ($users as $user => $path) {
120
+            $activity->setAffectedUser($user);
121 121
 
122
-			$activity->setSubject('add_comment_subject', [
123
-				$actor,
124
-				$path,
125
-			]);
126
-			$this->activityManager->publish($activity);
127
-		}
128
-	}
122
+            $activity->setSubject('add_comment_subject', [
123
+                $actor,
124
+                $path,
125
+            ]);
126
+            $this->activityManager->publish($activity);
127
+        }
128
+    }
129 129
 }
Please login to merge, or discard this patch.
apps/comments/lib/Activity/Filter.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -28,63 +28,63 @@
 block discarded – undo
28 28
 
29 29
 class Filter implements IFilter {
30 30
 
31
-	/** @var IL10N */
32
-	protected $l;
31
+    /** @var IL10N */
32
+    protected $l;
33 33
 
34
-	/** @var IURLGenerator */
35
-	protected $url;
34
+    /** @var IURLGenerator */
35
+    protected $url;
36 36
 
37
-	public function __construct(IL10N $l, IURLGenerator $url) {
38
-		$this->l = $l;
39
-		$this->url = $url;
40
-	}
37
+    public function __construct(IL10N $l, IURLGenerator $url) {
38
+        $this->l = $l;
39
+        $this->url = $url;
40
+    }
41 41
 
42
-	/**
43
-	 * @return string Lowercase a-z only identifier
44
-	 * @since 11.0.0
45
-	 */
46
-	public function getIdentifier() {
47
-		return 'comments';
48
-	}
42
+    /**
43
+     * @return string Lowercase a-z only identifier
44
+     * @since 11.0.0
45
+     */
46
+    public function getIdentifier() {
47
+        return 'comments';
48
+    }
49 49
 
50
-	/**
51
-	 * @return string A translated string
52
-	 * @since 11.0.0
53
-	 */
54
-	public function getName() {
55
-		return $this->l->t('Comments');
56
-	}
50
+    /**
51
+     * @return string A translated string
52
+     * @since 11.0.0
53
+     */
54
+    public function getName() {
55
+        return $this->l->t('Comments');
56
+    }
57 57
 
58
-	/**
59
-	 * @return int
60
-	 * @since 11.0.0
61
-	 */
62
-	public function getPriority() {
63
-		return 40;
64
-	}
58
+    /**
59
+     * @return int
60
+     * @since 11.0.0
61
+     */
62
+    public function getPriority() {
63
+        return 40;
64
+    }
65 65
 
66
-	/**
67
-	 * @return string Full URL to an icon, empty string when none is given
68
-	 * @since 11.0.0
69
-	 */
70
-	public function getIcon() {
71
-		return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg'));
72
-	}
66
+    /**
67
+     * @return string Full URL to an icon, empty string when none is given
68
+     * @since 11.0.0
69
+     */
70
+    public function getIcon() {
71
+        return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg'));
72
+    }
73 73
 
74
-	/**
75
-	 * @param string[] $types
76
-	 * @return string[] An array of allowed apps from which activities should be displayed
77
-	 * @since 11.0.0
78
-	 */
79
-	public function filterTypes(array $types) {
80
-		return $types;
81
-	}
74
+    /**
75
+     * @param string[] $types
76
+     * @return string[] An array of allowed apps from which activities should be displayed
77
+     * @since 11.0.0
78
+     */
79
+    public function filterTypes(array $types) {
80
+        return $types;
81
+    }
82 82
 
83
-	/**
84
-	 * @return string[] An array of allowed apps from which activities should be displayed
85
-	 * @since 11.0.0
86
-	 */
87
-	public function allowedApps() {
88
-		return ['comments'];
89
-	}
83
+    /**
84
+     * @return string[] An array of allowed apps from which activities should be displayed
85
+     * @since 11.0.0
86
+     */
87
+    public function allowedApps() {
88
+        return ['comments'];
89
+    }
90 90
 }
Please login to merge, or discard this patch.
apps/comments/lib/Notification/Listener.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -27,93 +27,93 @@
 block discarded – undo
27 27
 use OCP\Notification\IManager;
28 28
 
29 29
 class Listener {
30
-	/** @var IManager */
31
-	protected $notificationManager;
30
+    /** @var IManager */
31
+    protected $notificationManager;
32 32
 
33
-	/** @var IUserManager */
34
-	protected $userManager;
33
+    /** @var IUserManager */
34
+    protected $userManager;
35 35
 
36
-	/**
37
-	 * Listener constructor.
38
-	 *
39
-	 * @param IManager $notificationManager
40
-	 * @param IUserManager $userManager
41
-	 */
42
-	public function __construct(
43
-		IManager $notificationManager,
44
-		IUserManager $userManager
45
-	) {
36
+    /**
37
+     * Listener constructor.
38
+     *
39
+     * @param IManager $notificationManager
40
+     * @param IUserManager $userManager
41
+     */
42
+    public function __construct(
43
+        IManager $notificationManager,
44
+        IUserManager $userManager
45
+    ) {
46 46
 
47
-		$this->notificationManager = $notificationManager;
48
-		$this->userManager = $userManager;
49
-	}
47
+        $this->notificationManager = $notificationManager;
48
+        $this->userManager = $userManager;
49
+    }
50 50
 
51
-	/**
52
-	 * @param CommentsEvent $event
53
-	 */
54
-	public function evaluate(CommentsEvent $event) {
55
-		$comment = $event->getComment();
51
+    /**
52
+     * @param CommentsEvent $event
53
+     */
54
+    public function evaluate(CommentsEvent $event) {
55
+        $comment = $event->getComment();
56 56
 
57
-		$mentions = $this->extractMentions($comment->getMentions());
58
-		if(empty($mentions)) {
59
-			// no one to notify
60
-			return;
61
-		}
57
+        $mentions = $this->extractMentions($comment->getMentions());
58
+        if(empty($mentions)) {
59
+            // no one to notify
60
+            return;
61
+        }
62 62
 
63
-		$notification = $this->instantiateNotification($comment);
63
+        $notification = $this->instantiateNotification($comment);
64 64
 
65
-		foreach($mentions as $uid) {
66
-			if( ($comment->getActorType() === 'users' && $uid === $comment->getActorId())
67
-				|| !$this->userManager->userExists($uid)
68
-			) {
69
-				// do not notify unknown users or yourself
70
-				continue;
71
-			}
65
+        foreach($mentions as $uid) {
66
+            if( ($comment->getActorType() === 'users' && $uid === $comment->getActorId())
67
+                || !$this->userManager->userExists($uid)
68
+            ) {
69
+                // do not notify unknown users or yourself
70
+                continue;
71
+            }
72 72
 
73
-			$notification->setUser($uid);
74
-			if(    $event->getEvent() === CommentsEvent::EVENT_DELETE
75
-				|| $event->getEvent() === CommentsEvent::EVENT_PRE_UPDATE)
76
-			{
77
-				$this->notificationManager->markProcessed($notification);
78
-			} else {
79
-				$this->notificationManager->notify($notification);
80
-			}
81
-		}
82
-	}
73
+            $notification->setUser($uid);
74
+            if(    $event->getEvent() === CommentsEvent::EVENT_DELETE
75
+                || $event->getEvent() === CommentsEvent::EVENT_PRE_UPDATE)
76
+            {
77
+                $this->notificationManager->markProcessed($notification);
78
+            } else {
79
+                $this->notificationManager->notify($notification);
80
+            }
81
+        }
82
+    }
83 83
 
84
-	/**
85
-	 * creates a notification instance and fills it with comment data
86
-	 *
87
-	 * @param IComment $comment
88
-	 * @return \OCP\Notification\INotification
89
-	 */
90
-	public function instantiateNotification(IComment $comment) {
91
-		$notification = $this->notificationManager->createNotification();
92
-		$notification
93
-			->setApp('comments')
94
-			->setObject('comment', $comment->getId())
95
-			->setSubject('mention', [ $comment->getObjectType(), $comment->getObjectId() ])
96
-			->setDateTime($comment->getCreationDateTime());
84
+    /**
85
+     * creates a notification instance and fills it with comment data
86
+     *
87
+     * @param IComment $comment
88
+     * @return \OCP\Notification\INotification
89
+     */
90
+    public function instantiateNotification(IComment $comment) {
91
+        $notification = $this->notificationManager->createNotification();
92
+        $notification
93
+            ->setApp('comments')
94
+            ->setObject('comment', $comment->getId())
95
+            ->setSubject('mention', [ $comment->getObjectType(), $comment->getObjectId() ])
96
+            ->setDateTime($comment->getCreationDateTime());
97 97
 
98
-		return $notification;
99
-	}
98
+        return $notification;
99
+    }
100 100
 
101
-	/**
102
-	 * flattens the mention array returned from comments to a list of user ids.
103
-	 *
104
-	 * @param array $mentions
105
-	 * @return string[] containing the mentions, e.g. ['alice', 'bob']
106
-	 */
107
-	public function extractMentions(array $mentions) {
108
-		if(empty($mentions)) {
109
-			return [];
110
-		}
111
-		$uids = [];
112
-		foreach($mentions as $mention) {
113
-			if($mention['type'] === 'user') {
114
-				$uids[] = $mention['id'];
115
-			}
116
-		}
117
-		return $uids;
118
-	}
101
+    /**
102
+     * flattens the mention array returned from comments to a list of user ids.
103
+     *
104
+     * @param array $mentions
105
+     * @return string[] containing the mentions, e.g. ['alice', 'bob']
106
+     */
107
+    public function extractMentions(array $mentions) {
108
+        if(empty($mentions)) {
109
+            return [];
110
+        }
111
+        $uids = [];
112
+        foreach($mentions as $mention) {
113
+            if($mention['type'] === 'user') {
114
+                $uids[] = $mention['id'];
115
+            }
116
+        }
117
+        return $uids;
118
+    }
119 119
 }
Please login to merge, or discard this patch.