Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 38 additions & 29 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0"?>
<info>
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>activity</id>
<name>Activity</name>
<summary>This application enables users to view actions related to their files in Nextcloud.</summary>
<description>
This application enables users to view actions related to their files in Nextcloud.
Once enabled, users will see a new icon “Activity” in their apps menu.
Expand All @@ -12,34 +14,46 @@
More information is available in the Activity documentation.
</description>

<licence>AGPL</licence>
<author>Frank Karlitschek, Joas Schilling</author>
<shipped>true</shipped>
<version>2.7.0</version>
<licence>agpl</licence>
<author>Frank Karlitschek</author>
<author>Joas Schilling</author>

<default_enable/>
<types>
<filesystem/>
</types>

<website>https://github.com/nextcloud/activity/</website>
<bugs>https://github.com/nextcloud/activity/issues</bugs>
<repository type="git">https://github.com/nextcloud/activity.git</repository>

<documentation>
<admin>https://docs.nextcloud.org/server/14/admin_manual/configuration_server/activity_configuration.html</admin>
</documentation>

<category>monitoring</category>
<category>social</category>

<website>https://github.com/nextcloud/activity/</website>
<bugs>https://github.com/nextcloud/activity/issues</bugs>
<repository>https://github.com/nextcloud/activity.git</repository>

<dependencies>
<nextcloud min-version="14" max-version="14" />
</dependencies>

<navigations>
<navigation>
<name>Activity</name>
<route>activity.Activities.showList</route>
<order>1</order>
<icon>activity.svg</icon>
</navigation>
</navigations>
<background-jobs>
<job>OCA\Activity\BackgroundJob\EmailNotification</job>
<job>OCA\Activity\BackgroundJob\ExpireActivities</job>
</background-jobs>

<commands>
<command>OCA\Activity\Command\SendEmails</command>
</commands>

<settings>
<admin>OCA\Activity\Settings\Admin</admin>
<admin-section>OCA\Activity\Settings\AdminSection</admin-section>
<personal>OCA\Activity\Settings\Personal</personal>
<personal-section>OCA\Activity\Settings\PersonalSection</personal-section>
</settings>

<activity>
<filters>
Expand All @@ -49,17 +63,12 @@
</filters>
</activity>

<settings>
<admin>OCA\Activity\Settings\Admin</admin>
<admin-section>OCA\Activity\Settings\Section</admin-section>
</settings>

<background-jobs>
<job>OCA\Activity\BackgroundJob\EmailNotification</job>
<job>OCA\Activity\BackgroundJob\ExpireActivities</job>
</background-jobs>

<commands>
<command>OCA\Activity\Command\SendEmails</command>
</commands>
<navigations>
<navigation>
<name>Activity</name>
<route>activity.Activities.showList</route>
<icon>activity.svg</icon>
<order>1</order>
</navigation>
</navigations>
</info>
8 changes: 0 additions & 8 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public function __construct () {
public function register() {
$this->registerActivityConsumer();
$this->registerHooksAndEvents();
$this->registerPersonalPage();
}

/**
Expand Down Expand Up @@ -112,11 +111,4 @@ public function registerFilesActivity() {
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
$eventDispatcher->addListener('OCP\Share::preUnshare', [FilesHooksStatic::class, 'unShare']);
}

/**
* Register personal settings for notifications and emails
*/
public function registerPersonalPage() {
\OCP\App::registerPersonal($this->getContainer()->getAppName(), 'personal');
}
}
76 changes: 0 additions & 76 deletions lib/Controller/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,82 +217,6 @@ public function admin(
));
}

/**
* @NoAdminRequired
* @NoCSRFRequired
*
* @return TemplateResponse
*/
public function displayPanel() {
$settings = $this->manager->getSettings();
usort($settings, function(ISetting $a, ISetting $b) {
if ($a->getPriority() === $b->getPriority()) {
return $a->getIdentifier() > $b->getIdentifier();
}

return $a->getPriority() > $b->getPriority();
});

$activities = [];
foreach ($settings as $setting) {
if (!$setting->canChangeStream() && !$setting->canChangeMail()) {
// No setting can be changed => don't display
continue;
}

$methods = [];
if ($setting->canChangeStream()) {
$methods[] = IExtension::METHOD_STREAM;
}
if ($setting->canChangeMail()) {
$methods[] = IExtension::METHOD_MAIL;
}

$activities[$setting->getIdentifier()] = array(
'desc' => $setting->getName(),
IExtension::METHOD_MAIL => $this->userSettings->getUserSetting($this->user, 'email', $setting->getIdentifier()),
IExtension::METHOD_STREAM => $this->userSettings->getUserSetting($this->user, 'stream', $setting->getIdentifier()),
'methods' => $methods,
);
}

$settingBatchTime = UserSettings::EMAIL_SEND_HOURLY;
$currentSetting = (int) $this->userSettings->getUserSetting($this->user, 'setting', 'batchtime');
if ($currentSetting === 3600 * 24 * 7) {
$settingBatchTime = UserSettings::EMAIL_SEND_WEEKLY;
} else if ($currentSetting === 3600 * 24) {
$settingBatchTime = UserSettings::EMAIL_SEND_DAILY;
} else if ($currentSetting === 0) {
$settingBatchTime = UserSettings::EMAIL_SEND_ASAP;
}

$emailEnabled = $this->config->getAppValue('activity', 'enable_email', 'yes') === 'yes';
if ($emailEnabled) {
$methods = [
IExtension::METHOD_MAIL => $this->l10n->t('Mail'),
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
];
} else {
$methods = [
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
];
}

return new TemplateResponse('activity', 'settings/personal', [
'setting' => 'personal',
'activities' => $activities,
'is_email_set' => !empty($this->config->getUserValue($this->user, 'settings', 'email', '')),
'email_enabled' => $emailEnabled,

'setting_batchtime' => $settingBatchTime,

'notify_self' => $this->userSettings->getUserSetting($this->user, 'setting', 'self'),
'notify_selfemail' => $this->userSettings->getUserSetting($this->user, 'setting', 'selfemail'),

'methods' => $methods,
], '');
}

/**
* @NoAdminRequired
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Settings/Section.php → lib/Settings/AdminSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use OCP\IURLGenerator;
use OCP\Settings\IIconSection;

class Section implements IIconSection {
class AdminSection implements IIconSection {

/** @var IL10N */
private $l;
Expand Down
165 changes: 165 additions & 0 deletions lib/Settings/Personal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Activity\Settings;

use OCA\Activity\CurrentUser;
use OCA\Activity\UserSettings;
use OCP\Activity\IExtension;
use OCP\Activity\IManager;
use OCP\Activity\ISetting;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\ISettings;

class Personal implements ISettings {
/** @var \OCP\IConfig */
protected $config;

/** @var IManager */
protected $manager;

/** @var \OCA\Activity\UserSettings */
protected $userSettings;

/** @var \OCP\IL10N */
protected $l10n;

/** @var string */
protected $user;

/**
* constructor of the controller
*
* @param IConfig $config
* @param IManager $manager
* @param UserSettings $userSettings
* @param IL10N $l10n
* @param CurrentUser $currentUser
*/
public function __construct(IConfig $config,
IManager $manager,
UserSettings $userSettings,
IL10N $l10n,
CurrentUser $currentUser) {
$this->config = $config;
$this->manager = $manager;
$this->userSettings = $userSettings;
$this->l10n = $l10n;
$this->user = (string) $currentUser->getUID();
}

/**
* @return TemplateResponse
*/
public function getForm() {
$settings = $this->manager->getSettings();
usort($settings, function(ISetting $a, ISetting $b) {
if ($a->getPriority() === $b->getPriority()) {
return $a->getIdentifier() > $b->getIdentifier();
}

return $a->getPriority() > $b->getPriority();
});

$activities = [];
foreach ($settings as $setting) {
if (!$setting->canChangeStream() && !$setting->canChangeMail()) {
// No setting can be changed => don't display
continue;
}

$methods = [];
if ($setting->canChangeStream()) {
$methods[] = IExtension::METHOD_STREAM;
}
if ($setting->canChangeMail()) {
$methods[] = IExtension::METHOD_MAIL;
}

$identifier = $setting->getIdentifier();

$activities[$identifier] = array(
'desc' => $setting->getName(),
IExtension::METHOD_MAIL => $this->userSettings->getUserSetting($this->user, 'email', $identifier),
IExtension::METHOD_STREAM => $this->userSettings->getUserSetting($this->user, 'stream', $identifier),
'methods' => $methods,
);
}

$settingBatchTime = UserSettings::EMAIL_SEND_HOURLY;
$currentSetting = (int) $this->userSettings->getUserSetting($this->user, 'setting', 'batchtime');
if ($currentSetting === 3600 * 24 * 7) {
$settingBatchTime = UserSettings::EMAIL_SEND_WEEKLY;
} else if ($currentSetting === 3600 * 24) {
$settingBatchTime = UserSettings::EMAIL_SEND_DAILY;
} else if ($currentSetting === 0) {
$settingBatchTime = UserSettings::EMAIL_SEND_ASAP;
}

$emailEnabled = $this->config->getAppValue('activity', 'enable_email', 'yes') === 'yes';
if ($emailEnabled) {
$methods = [
IExtension::METHOD_MAIL => $this->l10n->t('Mail'),
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
];
} else {
$methods = [
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
];
}

return new TemplateResponse('activity', 'settings/personal', [
'setting' => 'personal',
'activities' => $activities,
'is_email_set' => !empty($this->config->getUserValue($this->user, 'settings', 'email', '')),
'email_enabled' => $emailEnabled,

'setting_batchtime' => $settingBatchTime,

'notify_self' => $this->userSettings->getUserSetting($this->user, 'setting', 'self'),
'notify_selfemail' => $this->userSettings->getUserSetting($this->user, 'setting', 'selfemail'),

'methods' => $methods,
], 'blank');
}

/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'activity';
}

/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 55;
}
}
Loading