1 | <?php |
||
15 | class Activity implements IExtension { |
||
16 | |||
17 | const APP_NAME = 'files_antivirus'; |
||
18 | |||
19 | /** |
||
20 | * Filter with all app related activities |
||
21 | */ |
||
22 | const FILTER_AVIR = 'files_antivirus'; |
||
23 | |||
24 | /** |
||
25 | * Activity types known to this extension |
||
26 | */ |
||
27 | const TYPE_VIRUS_DETECTED = 'virus_detected'; |
||
28 | |||
29 | /** |
||
30 | * Subject keys for translation of the subjections |
||
31 | */ |
||
32 | const SUBJECT_VIRUS_DETECTED = 'virus_detected'; |
||
33 | |||
34 | /** |
||
35 | * Infected file deletion notice |
||
36 | */ |
||
37 | const MESSAGE_FILE_DELETED = 'file_deleted'; |
||
38 | |||
39 | |||
40 | /** @var Factory */ |
||
41 | protected $languageFactory; |
||
42 | |||
43 | /** @var IURLGenerator */ |
||
44 | protected $URLGenerator; |
||
45 | |||
46 | /** |
||
47 | * @param Factory $languageFactory |
||
48 | * @param IURLGenerator $URLGenerator |
||
49 | */ |
||
50 | 3 | public function __construct(Factory $languageFactory, IURLGenerator $URLGenerator) { |
|
54 | |||
55 | protected function getL10N($languageCode = null) { |
||
58 | |||
59 | /** |
||
60 | * The extension can return an array of additional notification types. |
||
61 | * If no additional types are to be added false is to be returned |
||
62 | * |
||
63 | * @param string $languageCode |
||
64 | * @return array|false |
||
65 | */ |
||
66 | public function getNotificationTypes($languageCode) { |
||
73 | |||
74 | /** |
||
75 | * For a given method additional types to be displayed in the settings can be returned. |
||
76 | * In case no additional types are to be added false is to be returned. |
||
77 | * |
||
78 | * @param string $method |
||
79 | * @return array|false |
||
80 | */ |
||
81 | public function getDefaultTypes($method) { |
||
86 | |||
87 | /** |
||
88 | * A string naming the css class for the icon to be used can be returned. |
||
89 | * If no icon is known for the given type false is to be returned. |
||
90 | * |
||
91 | * @param string $type |
||
92 | * @return string|false |
||
93 | */ |
||
94 | 1 | public function getTypeIcon($type) { |
|
95 | switch ($type) { |
||
96 | 1 | case self::TYPE_VIRUS_DETECTED: |
|
97 | 1 | return 'icon-info'; |
|
98 | } |
||
99 | 1 | return false; |
|
100 | } |
||
101 | |||
102 | /** |
||
103 | * The extension can translate a given message to the requested languages. |
||
104 | * If no translation is available false is to be returned. |
||
105 | * |
||
106 | * @param string $app |
||
107 | * @param string $text |
||
108 | * @param array $params |
||
109 | * @param boolean $stripPath |
||
110 | * @param boolean $highlightParams |
||
111 | * @param string $languageCode |
||
112 | * @return string|false |
||
113 | */ |
||
114 | public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) { |
||
115 | $l = $this->getL10N($languageCode); |
||
116 | |||
117 | if ($app === self::APP_NAME) { |
||
118 | switch ($text) { |
||
119 | case self::SUBJECT_VIRUS_DETECTED: |
||
120 | return $l->t('File %s is infected with %s', $params); |
||
121 | case self::MESSAGE_FILE_DELETED: |
||
122 | return $l->t('It is going to be deleted', $params); |
||
123 | } |
||
124 | } |
||
125 | |||
126 | return false; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * The extension can define the type of parameters for translation |
||
131 | * |
||
132 | * Currently known types are: |
||
133 | * * file => will strip away the path of the file and add a tooltip with it |
||
134 | * * username => will add the avatar of the user |
||
135 | * |
||
136 | * @param string $app |
||
137 | * @param string $text |
||
138 | * @return array|false |
||
139 | */ |
||
140 | 1 | public function getSpecialParameterList($app, $text) { |
|
141 | 1 | return false; |
|
142 | } |
||
143 | |||
144 | /** |
||
145 | * The extension can define the parameter grouping by returning the index as integer. |
||
146 | * In case no grouping is required false is to be returned. |
||
147 | * |
||
148 | * @param array $activity |
||
149 | * @return integer|false |
||
150 | */ |
||
151 | 1 | public function getGroupParameter($activity) { |
|
152 | 1 | return false; |
|
153 | } |
||
154 | |||
155 | /** |
||
156 | * The extension can define additional navigation entries. The array returned has to contain two keys 'top' |
||
157 | * and 'apps' which hold arrays with the relevant entries. |
||
158 | * If no further entries are to be added false is no be returned. |
||
159 | * |
||
160 | * @return array|false |
||
161 | */ |
||
162 | public function getNavigation() { |
||
175 | |||
176 | /** |
||
177 | * The extension can check if a customer filter (given by a query string like filter=abc) is valid or not. |
||
178 | * |
||
179 | * @param string $filterValue |
||
180 | * @return boolean |
||
181 | */ |
||
182 | public function isFilterValid($filterValue) { |
||
185 | |||
186 | /** |
||
187 | * The extension can filter the types based on the filter if required. |
||
188 | * In case no filter is to be applied false is to be returned unchanged. |
||
189 | * |
||
190 | * @param array $types |
||
191 | * @param string $filter |
||
192 | * @return array|false |
||
193 | */ |
||
194 | public function filterNotificationTypes($types, $filter) { |
||
197 | |||
198 | /** |
||
199 | * For a given filter the extension can specify the sql query conditions including parameters for that query. |
||
200 | * In case the extension does not know the filter false is to be returned. |
||
201 | * The query condition and the parameters are to be returned as array with two elements. |
||
202 | * E.g. return array('`app` = ? and `message` like ?', array('mail', 'ownCloud%')); |
||
203 | * |
||
204 | * @param string $filter |
||
205 | * @return array|false |
||
206 | */ |
||
207 | public function getQueryForFilter($filter) { |
||
216 | } |
||
217 |