1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @license GNU AGPL version 3 or any later version |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as |
9
|
|
|
* published by the Free Software Foundation, either version 3 of the |
10
|
|
|
* License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\Activity\Filter; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
use OCP\Activity\IFilter; |
26
|
|
|
use OCP\IL10N; |
27
|
|
|
use OCP\IURLGenerator; |
28
|
|
|
|
29
|
|
View Code Duplication |
class ByFilter implements IFilter { |
|
|
|
|
30
|
|
|
|
31
|
|
|
/** @var IL10N */ |
32
|
|
|
protected $l; |
33
|
|
|
|
34
|
|
|
/** @var IURLGenerator */ |
35
|
|
|
protected $url; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param IL10N $l |
39
|
|
|
* @param IURLGenerator $url |
40
|
|
|
*/ |
41
|
|
|
public function __construct(IL10N $l, IURLGenerator $url) { |
42
|
|
|
$this->l = $l; |
43
|
|
|
$this->url = $url; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return string Lowercase a-z only identifier |
48
|
|
|
* @since 9.2.0 |
49
|
|
|
*/ |
50
|
|
|
public function getIdentifier() { |
51
|
|
|
return 'by'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return string A translated string |
56
|
|
|
* @since 9.2.0 |
57
|
|
|
*/ |
58
|
|
|
public function getName() { |
59
|
|
|
return $this->l->t('By others'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return int |
64
|
|
|
* @since 9.2.0 |
65
|
|
|
*/ |
66
|
|
|
public function getPriority() { |
67
|
|
|
return 2; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string Full URL to an icon, empty string when none is given |
72
|
|
|
* @since 9.2.0 |
73
|
|
|
*/ |
74
|
|
|
public function getIcon() { |
75
|
|
|
return $this->url->getAbsoluteURL($this->url->imagePath('core', 'places/contacts.svg')); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param string[] $types |
80
|
|
|
* @return string[] An array of allowed apps from which activities should be displayed |
81
|
|
|
* @since 9.2.0 |
82
|
|
|
*/ |
83
|
|
|
public function filterTypes(array $types) { |
84
|
|
|
return $types; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string[] An array of allowed apps from which activities should be displayed |
89
|
|
|
* @since 9.2.0 |
90
|
|
|
*/ |
91
|
|
|
public function allowedApps() { |
92
|
|
|
return []; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.