Skip to content

Commit c2fce19

Browse files
authored
Merge pull request #250 from nextcloud/feature/noid/phpunit-update
Update calls for phpunit 6.5
2 parents 3d2ffe8 + 48386a4 commit c2fce19

11 files changed

Lines changed: 301 additions & 180 deletions

File tree

appinfo/info.xml

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0"?>
2-
<info>
2+
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
34
<id>activity</id>
45
<name>Activity</name>
6+
<summary>This application enables users to view actions related to their files in Nextcloud.</summary>
57
<description>
68
This application enables users to view actions related to their files in Nextcloud.
79
Once enabled, users will see a new icon “Activity” in their apps menu.
@@ -12,34 +14,46 @@
1214
More information is available in the Activity documentation.
1315
</description>
1416

15-
<licence>AGPL</licence>
16-
<author>Frank Karlitschek, Joas Schilling</author>
17-
<shipped>true</shipped>
1817
<version>2.7.0</version>
18+
<licence>agpl</licence>
19+
<author>Frank Karlitschek</author>
20+
<author>Joas Schilling</author>
21+
1922
<default_enable/>
2023
<types>
2124
<filesystem/>
2225
</types>
2326

24-
<website>https://github.com/nextcloud/activity/</website>
25-
<bugs>https://github.com/nextcloud/activity/issues</bugs>
26-
<repository type="git">https://github.com/nextcloud/activity.git</repository>
27-
2827
<documentation>
2928
<admin>https://docs.nextcloud.org/server/14/admin_manual/configuration_server/activity_configuration.html</admin>
3029
</documentation>
30+
31+
<category>monitoring</category>
32+
<category>social</category>
33+
34+
<website>https://github.com/nextcloud/activity/</website>
35+
<bugs>https://github.com/nextcloud/activity/issues</bugs>
36+
<repository>https://github.com/nextcloud/activity.git</repository>
37+
3138
<dependencies>
3239
<nextcloud min-version="14" max-version="14" />
3340
</dependencies>
3441

35-
<navigations>
36-
<navigation>
37-
<name>Activity</name>
38-
<route>activity.Activities.showList</route>
39-
<order>1</order>
40-
<icon>activity.svg</icon>
41-
</navigation>
42-
</navigations>
42+
<background-jobs>
43+
<job>OCA\Activity\BackgroundJob\EmailNotification</job>
44+
<job>OCA\Activity\BackgroundJob\ExpireActivities</job>
45+
</background-jobs>
46+
47+
<commands>
48+
<command>OCA\Activity\Command\SendEmails</command>
49+
</commands>
50+
51+
<settings>
52+
<admin>OCA\Activity\Settings\Admin</admin>
53+
<admin-section>OCA\Activity\Settings\AdminSection</admin-section>
54+
<personal>OCA\Activity\Settings\Personal</personal>
55+
<personal-section>OCA\Activity\Settings\PersonalSection</personal-section>
56+
</settings>
4357

4458
<activity>
4559
<filters>
@@ -49,17 +63,12 @@
4963
</filters>
5064
</activity>
5165

52-
<settings>
53-
<admin>OCA\Activity\Settings\Admin</admin>
54-
<admin-section>OCA\Activity\Settings\Section</admin-section>
55-
</settings>
56-
57-
<background-jobs>
58-
<job>OCA\Activity\BackgroundJob\EmailNotification</job>
59-
<job>OCA\Activity\BackgroundJob\ExpireActivities</job>
60-
</background-jobs>
61-
62-
<commands>
63-
<command>OCA\Activity\Command\SendEmails</command>
64-
</commands>
66+
<navigations>
67+
<navigation>
68+
<name>Activity</name>
69+
<route>activity.Activities.showList</route>
70+
<icon>activity.svg</icon>
71+
<order>1</order>
72+
</navigation>
73+
</navigations>
6574
</info>

lib/AppInfo/Application.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public function __construct () {
6767
public function register() {
6868
$this->registerActivityConsumer();
6969
$this->registerHooksAndEvents();
70-
$this->registerPersonalPage();
7170
}
7271

7372
/**
@@ -112,11 +111,4 @@ public function registerFilesActivity() {
112111
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
113112
$eventDispatcher->addListener('OCP\Share::preUnshare', [FilesHooksStatic::class, 'unShare']);
114113
}
115-
116-
/**
117-
* Register personal settings for notifications and emails
118-
*/
119-
public function registerPersonalPage() {
120-
\OCP\App::registerPersonal($this->getContainer()->getAppName(), 'personal');
121-
}
122114
}

lib/Controller/Settings.php

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -217,82 +217,6 @@ public function admin(
217217
));
218218
}
219219

220-
/**
221-
* @NoAdminRequired
222-
* @NoCSRFRequired
223-
*
224-
* @return TemplateResponse
225-
*/
226-
public function displayPanel() {
227-
$settings = $this->manager->getSettings();
228-
usort($settings, function(ISetting $a, ISetting $b) {
229-
if ($a->getPriority() === $b->getPriority()) {
230-
return $a->getIdentifier() > $b->getIdentifier();
231-
}
232-
233-
return $a->getPriority() > $b->getPriority();
234-
});
235-
236-
$activities = [];
237-
foreach ($settings as $setting) {
238-
if (!$setting->canChangeStream() && !$setting->canChangeMail()) {
239-
// No setting can be changed => don't display
240-
continue;
241-
}
242-
243-
$methods = [];
244-
if ($setting->canChangeStream()) {
245-
$methods[] = IExtension::METHOD_STREAM;
246-
}
247-
if ($setting->canChangeMail()) {
248-
$methods[] = IExtension::METHOD_MAIL;
249-
}
250-
251-
$activities[$setting->getIdentifier()] = array(
252-
'desc' => $setting->getName(),
253-
IExtension::METHOD_MAIL => $this->userSettings->getUserSetting($this->user, 'email', $setting->getIdentifier()),
254-
IExtension::METHOD_STREAM => $this->userSettings->getUserSetting($this->user, 'stream', $setting->getIdentifier()),
255-
'methods' => $methods,
256-
);
257-
}
258-
259-
$settingBatchTime = UserSettings::EMAIL_SEND_HOURLY;
260-
$currentSetting = (int) $this->userSettings->getUserSetting($this->user, 'setting', 'batchtime');
261-
if ($currentSetting === 3600 * 24 * 7) {
262-
$settingBatchTime = UserSettings::EMAIL_SEND_WEEKLY;
263-
} else if ($currentSetting === 3600 * 24) {
264-
$settingBatchTime = UserSettings::EMAIL_SEND_DAILY;
265-
} else if ($currentSetting === 0) {
266-
$settingBatchTime = UserSettings::EMAIL_SEND_ASAP;
267-
}
268-
269-
$emailEnabled = $this->config->getAppValue('activity', 'enable_email', 'yes') === 'yes';
270-
if ($emailEnabled) {
271-
$methods = [
272-
IExtension::METHOD_MAIL => $this->l10n->t('Mail'),
273-
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
274-
];
275-
} else {
276-
$methods = [
277-
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
278-
];
279-
}
280-
281-
return new TemplateResponse('activity', 'settings/personal', [
282-
'setting' => 'personal',
283-
'activities' => $activities,
284-
'is_email_set' => !empty($this->config->getUserValue($this->user, 'settings', 'email', '')),
285-
'email_enabled' => $emailEnabled,
286-
287-
'setting_batchtime' => $settingBatchTime,
288-
289-
'notify_self' => $this->userSettings->getUserSetting($this->user, 'setting', 'self'),
290-
'notify_selfemail' => $this->userSettings->getUserSetting($this->user, 'setting', 'selfemail'),
291-
292-
'methods' => $methods,
293-
], '');
294-
}
295-
296220
/**
297221
* @NoAdminRequired
298222
*
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use OCP\IURLGenerator;
2626
use OCP\Settings\IIconSection;
2727

28-
class Section implements IIconSection {
28+
class AdminSection implements IIconSection {
2929

3030
/** @var IL10N */
3131
private $l;

lib/Settings/Personal.php

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2016, ownCloud, Inc.
4+
*
5+
* @author Joas Schilling <coding@schilljs.com>
6+
* @author Lukas Reschke <lukas@statuscode.ch>
7+
*
8+
* @license AGPL-3.0
9+
*
10+
* This code is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Affero General Public License, version 3,
12+
* as published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License, version 3,
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>
21+
*
22+
*/
23+
24+
namespace OCA\Activity\Settings;
25+
26+
use OCA\Activity\CurrentUser;
27+
use OCA\Activity\UserSettings;
28+
use OCP\Activity\IExtension;
29+
use OCP\Activity\IManager;
30+
use OCP\Activity\ISetting;
31+
use OCP\AppFramework\Http\TemplateResponse;
32+
use OCP\IConfig;
33+
use OCP\IL10N;
34+
use OCP\Settings\ISettings;
35+
36+
class Personal implements ISettings {
37+
/** @var \OCP\IConfig */
38+
protected $config;
39+
40+
/** @var IManager */
41+
protected $manager;
42+
43+
/** @var \OCA\Activity\UserSettings */
44+
protected $userSettings;
45+
46+
/** @var \OCP\IL10N */
47+
protected $l10n;
48+
49+
/** @var string */
50+
protected $user;
51+
52+
/**
53+
* constructor of the controller
54+
*
55+
* @param IConfig $config
56+
* @param IManager $manager
57+
* @param UserSettings $userSettings
58+
* @param IL10N $l10n
59+
* @param CurrentUser $currentUser
60+
*/
61+
public function __construct(IConfig $config,
62+
IManager $manager,
63+
UserSettings $userSettings,
64+
IL10N $l10n,
65+
CurrentUser $currentUser) {
66+
$this->config = $config;
67+
$this->manager = $manager;
68+
$this->userSettings = $userSettings;
69+
$this->l10n = $l10n;
70+
$this->user = (string) $currentUser->getUID();
71+
}
72+
73+
/**
74+
* @return TemplateResponse
75+
*/
76+
public function getForm() {
77+
$settings = $this->manager->getSettings();
78+
usort($settings, function(ISetting $a, ISetting $b) {
79+
if ($a->getPriority() === $b->getPriority()) {
80+
return $a->getIdentifier() > $b->getIdentifier();
81+
}
82+
83+
return $a->getPriority() > $b->getPriority();
84+
});
85+
86+
$activities = [];
87+
foreach ($settings as $setting) {
88+
if (!$setting->canChangeStream() && !$setting->canChangeMail()) {
89+
// No setting can be changed => don't display
90+
continue;
91+
}
92+
93+
$methods = [];
94+
if ($setting->canChangeStream()) {
95+
$methods[] = IExtension::METHOD_STREAM;
96+
}
97+
if ($setting->canChangeMail()) {
98+
$methods[] = IExtension::METHOD_MAIL;
99+
}
100+
101+
$identifier = $setting->getIdentifier();
102+
103+
$activities[$identifier] = array(
104+
'desc' => $setting->getName(),
105+
IExtension::METHOD_MAIL => $this->userSettings->getUserSetting($this->user, 'email', $identifier),
106+
IExtension::METHOD_STREAM => $this->userSettings->getUserSetting($this->user, 'stream', $identifier),
107+
'methods' => $methods,
108+
);
109+
}
110+
111+
$settingBatchTime = UserSettings::EMAIL_SEND_HOURLY;
112+
$currentSetting = (int) $this->userSettings->getUserSetting($this->user, 'setting', 'batchtime');
113+
if ($currentSetting === 3600 * 24 * 7) {
114+
$settingBatchTime = UserSettings::EMAIL_SEND_WEEKLY;
115+
} else if ($currentSetting === 3600 * 24) {
116+
$settingBatchTime = UserSettings::EMAIL_SEND_DAILY;
117+
} else if ($currentSetting === 0) {
118+
$settingBatchTime = UserSettings::EMAIL_SEND_ASAP;
119+
}
120+
121+
$emailEnabled = $this->config->getAppValue('activity', 'enable_email', 'yes') === 'yes';
122+
if ($emailEnabled) {
123+
$methods = [
124+
IExtension::METHOD_MAIL => $this->l10n->t('Mail'),
125+
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
126+
];
127+
} else {
128+
$methods = [
129+
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
130+
];
131+
}
132+
133+
return new TemplateResponse('activity', 'settings/personal', [
134+
'setting' => 'personal',
135+
'activities' => $activities,
136+
'is_email_set' => !empty($this->config->getUserValue($this->user, 'settings', 'email', '')),
137+
'email_enabled' => $emailEnabled,
138+
139+
'setting_batchtime' => $settingBatchTime,
140+
141+
'notify_self' => $this->userSettings->getUserSetting($this->user, 'setting', 'self'),
142+
'notify_selfemail' => $this->userSettings->getUserSetting($this->user, 'setting', 'selfemail'),
143+
144+
'methods' => $methods,
145+
], 'blank');
146+
}
147+
148+
/**
149+
* @return string the section ID, e.g. 'sharing'
150+
*/
151+
public function getSection() {
152+
return 'activity';
153+
}
154+
155+
/**
156+
* @return int whether the form should be rather on the top or bottom of
157+
* the admin section. The forms are arranged in ascending order of the
158+
* priority values. It is required to return a value between 0 and 100.
159+
*
160+
* E.g.: 70
161+
*/
162+
public function getPriority() {
163+
return 55;
164+
}
165+
}

0 commit comments

Comments
 (0)