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
7 changes: 0 additions & 7 deletions js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,4 @@ $(document).ready(function() {

saveSettings();
});

$('#activity_email_enabled').on('change', function() {
OCP.AppConfig.setValue(
'activity', 'enable_email',
$(this).attr('checked') === 'checked' ? 'yes' : 'no'
);
})
});
20 changes: 5 additions & 15 deletions lib/Controller/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,30 +260,20 @@ public function displayPanel() {
$settingBatchTime = UserSettings::EMAIL_SEND_DAILY;
}

$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,
'activity_email' => $this->config->getUserValue($this->user, 'settings', 'email', ''),

'setting_batchtime' => $settingBatchTime,

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

'methods' => $methods,
'methods' => [
IExtension::METHOD_MAIL => $this->l10n->t('Mail'),
IExtension::METHOD_STREAM => $this->l10n->t('Stream'),
],
], '');
}

Expand Down
3 changes: 1 addition & 2 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public function getForm() {
return new TemplateResponse('activity', 'settings/admin', [
'setting' => 'admin',
'activities' => $activities,
'is_email_set' => true,
'email_enabled' => $this->config->getAppValue('activity', 'enable_email', 'yes') === 'yes',
'activity_email' => '!empty',

'setting_batchtime' => $settingBatchTime,

Expand Down
10 changes: 1 addition & 9 deletions lib/UserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public function __construct(IManager $manager, IConfig $config) {
* @return bool|int
*/
public function getUserSetting($user, $method, $type) {
if ($method === 'email' && $this->config->getAppValue('activity', 'enable_email', 'yes') === 'no') {
return false;
}

$defaultSetting = $this->getDefaultFromSetting($method, $type);
if (is_bool($defaultSetting)) {
return (bool) $this->config->getUserValue(
Expand Down Expand Up @@ -171,11 +167,7 @@ public function getNotificationTypes($user, $method) {
*/
public function filterUsersBySetting($users, $method, $type) {
if (empty($users) || !is_array($users)) {
return [];
}

if ($method === 'email' && $this->config->getAppValue('activity', 'enable_email', 'yes') === 'no') {
return [];
return array();
}

$filteredUsers = array();
Expand Down
27 changes: 1 addition & 26 deletions templates/settings/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,4 @@
*/
script('activity', 'admin');
style('activity', 'settings');
/** @var array $_ */
/** @var \OCP\IL10N $l */
?>

<div class="section">

<h2><?php p($l->t('Activity')); ?></h2>

<input id="activity_email_enabled" name="activity_email_enabled" type="checkbox" class="checkbox"
value="1" <?php if ($_['email_enabled']) { print_unescaped('checked="checked"'); } ?> />
<label for="activity_email_enabled"><?php p($l->t('Send activity emails')); ?></label>

</div>

<form class="section" id="activity_notifications">

<h2><?php p($l->t('Default settings')); ?></h2>

<p class="settings-hint">
<?php p($l->t('Configure the default activity settings for new users.')); ?>
</p>

<?php print_unescaped($this->inc('settings/form')); ?>

</form>

print_unescaped($this->inc('settings/form'));
19 changes: 12 additions & 7 deletions templates/settings/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/** @var array $_ */
/** @var \OCP\IL10N $l */
?>

<form id="activity_notifications" class="section">
<h2 class="icon-activity" data-anchor-name="activity"><?php p($l->t('Activity')); ?></h2>
<p class="settings-hint">
<?php if ($_['setting'] === 'admin') {
p($l->t('Configure the default activity settings for new users.'));
} else {
p($l->t('Choose for which activities you want to get an email notification, and which should show up in the activity app stream.'));
} ?>
</p>

<table class="grid activitysettings">
<thead>
<tr>
Expand Down Expand Up @@ -64,14 +71,12 @@
value="1" <?php if ($_['notify_self']): ?> checked="checked"<?php endif; ?> />
<label for="notify_setting_self"><?php p($l->t('List your own actions in the stream')); ?></label>
<br />

<?php if ($_['email_enabled']) { ?>
<input id="notify_setting_selfemail" name="notify_setting_selfemail" type="checkbox" class="checkbox"
value="1" <?php if ($_['notify_selfemail']): ?> checked="checked"<?php endif; ?> />
<label for="notify_setting_selfemail"><?php p($l->t('Notify about your own actions via email')); ?></label>
<br />

<?php if (!$_['is_email_set']): ?>
<?php if (empty($_['activity_email'])): ?>
<br />
<strong><?php p($l->t('You need to set up your email address before you can receive notification emails.')); ?></strong>
<?php endif; ?>
Expand All @@ -83,4 +88,4 @@
<option value="1"<?php if ($_['setting_batchtime'] === \OCA\Activity\UserSettings::EMAIL_SEND_DAILY): ?> selected="selected"<?php endif; ?>><?php p($l->t('Daily')); ?></option>
<option value="2"<?php if ($_['setting_batchtime'] === \OCA\Activity\UserSettings::EMAIL_SEND_WEEKLY): ?> selected="selected"<?php endif; ?>><?php p($l->t('Weekly')); ?></option>
</select>
<?php }
</form>
19 changes: 1 addition & 18 deletions templates/settings/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,4 @@
*/
script('activity', 'settings');
style('activity', 'settings');
/** @var array $_ */
/** @var \OCP\IL10N $l */
?>

<form id="activity_notifications" class="section">

<h2><?php p($l->t('Activity')); ?></h2>
<p class="settings-hint">
<?php if ($_['email_enabled']) { ?>
<?php p($l->t('Choose for which activities you want to get an email notification, and which should show up in the activity app stream.')); ?>
<?php } else { ?>
<?php p($l->t('Choose which activities you want to see in the your stream.')); ?>
<?php } ?>
</p>

<?php print_unescaped($this->inc('settings/form')); ?>

</form>
print_unescaped($this->inc('settings/form'));