mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Notification user account settings + Notification Overview alignment + Small comment fix.
This commit is contained in:
parent
1ecf2a5a00
commit
472d4eb853
@ -69,16 +69,16 @@
|
||||
|
||||
// build new slider construct
|
||||
var _newHTML = '<label class="onoffswitch-label" for="' + $this.attr('id') + '">' +
|
||||
'<div class="onoffswitch-inner"></div>' +
|
||||
'<div class="onoffswitch-switch"></div>' +
|
||||
'</label>';
|
||||
'<div class="onoffswitch-inner"></div>' +
|
||||
'<div class="onoffswitch-switch"></div>' +
|
||||
'</label>';
|
||||
|
||||
// add new slider construckt
|
||||
$this.parent().append(_newHTML);
|
||||
|
||||
// build closing slider construct
|
||||
_newHTML = '<label class="onoffswitch-label" for="' + $this.attr('id') + '">' + _label + '</label>' +
|
||||
'<div class="onoffswitch-clear"></div>';
|
||||
'<div class="onoffswitch-clear"></div>';
|
||||
|
||||
// add closing slider contruct
|
||||
$this.parent().parent().after(_newHTML);
|
||||
@ -97,6 +97,7 @@
|
||||
// add new class
|
||||
$this.parent().parent().addClass('regular-checkbox-container');
|
||||
|
||||
|
||||
// add a new <div> at the end to clear floats
|
||||
$this.parent().parent().append('<div class="regular-checkbox-clear"></div>');
|
||||
}
|
||||
@ -111,7 +112,11 @@
|
||||
$this.parent().attr('for', $this.attr('id'));
|
||||
|
||||
var $checkbox = $('<div class="regular-checkbox-box"></div>').attr('style', $this.attr('style'));
|
||||
|
||||
|
||||
if ($this.is(':disabled')) {
|
||||
$checkbox.addClass('disabled');
|
||||
}
|
||||
|
||||
// add new checkbox element
|
||||
$this.parent().append($checkbox);
|
||||
}
|
||||
@ -140,9 +145,15 @@
|
||||
|
||||
// assign label to radio element
|
||||
$this.parent().attr('for', $this.attr('id'));
|
||||
|
||||
var $radio = $('<div class="regular-radio-button"></div>');
|
||||
|
||||
if ($this.is(':disabled')) {
|
||||
$radio.addClass('disabled');
|
||||
}
|
||||
|
||||
// add new radio element
|
||||
$this.parent().append('<div class="regular-radio-button"></div>');
|
||||
$this.parent().append($radio);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,11 @@ textarea.placeholder {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.help-block:not(.help-block-error):hover {
|
||||
color: @font2 !important;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.input-group-addon {
|
||||
border: none;
|
||||
}
|
||||
@ -169,31 +174,43 @@ a.label-warning:hover {
|
||||
|
||||
// Flatelements
|
||||
.onoffswitch-inner:before {
|
||||
background-color: @info;
|
||||
color: #fff;
|
||||
background-color: @info;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.onoffswitch-inner:after {
|
||||
background-color: @background3;
|
||||
color: #999;
|
||||
text-align: right;
|
||||
background-color: @background3;
|
||||
color: #999;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.regular-checkbox:checked + .regular-checkbox-box {
|
||||
border: 2px solid @info;
|
||||
background: @info;
|
||||
color: white;
|
||||
border: 2px solid @info;
|
||||
background: @info;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.regular-checkbox-box.disabled {
|
||||
background: @background3 !important;
|
||||
border: 2px solid @background3 !important;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.regular-radio:checked + .regular-radio-button:after {
|
||||
background: @info;
|
||||
background: @info;
|
||||
}
|
||||
|
||||
.regular-radio:checked + .regular-radio-button {
|
||||
background-color: none;
|
||||
color: #99a1a7;
|
||||
border: 2px solid @background3;
|
||||
margin-right: 5px;
|
||||
background-color: none;
|
||||
color: #99a1a7;
|
||||
border: 2px solid @background3;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.regular-radio.disabled {
|
||||
background: @background3 !important;
|
||||
border: 2px solid @background3 !important;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
//
|
||||
@ -255,4 +272,4 @@ a.label-warning:hover {
|
||||
border-color: @warning;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,25 @@
|
||||
display:block;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.notifications {
|
||||
position: inherit !important;
|
||||
float: left !important;
|
||||
}
|
||||
|
||||
.notifications .dropdown-menu {
|
||||
width: 300px !important;
|
||||
margin-left: 0 !important;
|
||||
.arrow {
|
||||
margin-left: -142px !important;
|
||||
#notification_overview_list {
|
||||
.img-space {
|
||||
position:absolute;
|
||||
top:25px;
|
||||
left:25px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.notifications {
|
||||
position: inherit !important;
|
||||
float: left !important;
|
||||
}
|
||||
|
||||
.notifications .dropdown-menu {
|
||||
width: 300px !important;
|
||||
margin-left: 0 !important;
|
||||
.arrow {
|
||||
margin-left: -142px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -149,7 +149,7 @@ class SettingController extends Controller
|
||||
public function actionNotification()
|
||||
{
|
||||
$form = new NotificationSettings();
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate() && $form->save()) {
|
||||
if ($form->load(Yii::$app->request->post()) && $form->save()) {
|
||||
$this->view->saved();
|
||||
}
|
||||
|
||||
|
@ -8,15 +8,16 @@ use yii\widgets\ActiveForm;
|
||||
<div class="help-block">
|
||||
<?= Yii::t('AdminModule.setting',
|
||||
'Here you can configure the default notification behaviour for your users.'); ?><br />
|
||||
<?= Yii::t('AdminModule.setting', 'You can enable outgoing notifications for a notification category by choosing the disired notification targets.'); ?>
|
||||
<?= Yii::t('AdminModule.setting', 'You can enable outgoing notifications for a category by choosing the disired notification targets.'); ?>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<?php $form = ActiveForm::begin() ?>
|
||||
<?= humhub\modules\notification\widgets\NotificationSettingsForm::widget([
|
||||
'model' => $model,
|
||||
'form' => $form
|
||||
]) ?>
|
||||
<?= humhub\modules\notification\widgets\NotificationSettingsForm::widget([
|
||||
'model' => $model,
|
||||
'form' => $form
|
||||
]) ?>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary" data-ui-loader><?= Yii::t('base', 'Save');?></button>
|
||||
<?php ActiveForm::end(); ?>
|
||||
</div>
|
||||
|
||||
|
@ -24,12 +24,13 @@ humhub.module('comment', function(module, require, $) {
|
||||
});
|
||||
};
|
||||
|
||||
Form.prototype.getRichtext = function(html) {
|
||||
Form.prototype.getRichtext = function() {
|
||||
return Widget.instance(this.$.find('div.humhub-ui-richtext'));
|
||||
};
|
||||
|
||||
Form.prototype.addComment = function(html) {
|
||||
var $html = $(html).hide();
|
||||
additions.applyTo($html);
|
||||
this.getCommentsContainer().append($html);
|
||||
$html.fadeIn();
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ class ContentContainerSettingsManager extends BaseSettingsManager
|
||||
*/
|
||||
public function getInherit($name, $default = null) {
|
||||
$result = $this->get($name);
|
||||
return ($result != null) ? $result
|
||||
return ($result !== null) ? $result
|
||||
: Yii::$app->getModule($this->moduleId)->settings->get($name, $default);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ abstract class NotificationCategory extends \yii\base\Object
|
||||
* @param type $target
|
||||
* @return type
|
||||
*/
|
||||
public function isFixedSettings(NotificationTarget $target)
|
||||
public function isFixedSetting(NotificationTarget $target)
|
||||
{
|
||||
return in_array($target->id, $this->getFixedSettings());
|
||||
}
|
||||
|
@ -215,6 +215,15 @@ abstract class NotificationTarget extends \yii\base\Object
|
||||
$category = $notification->getCategory();
|
||||
return ($category) ? $this->isCategoryEnabled($category, $user) : $this->defaultSetting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the settings for this target are editable.
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEditable(user $user = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enabled setting of this target for the given $category.
|
||||
@ -229,7 +238,7 @@ abstract class NotificationTarget extends \yii\base\Object
|
||||
return false;
|
||||
}
|
||||
|
||||
if($category->isFixedSettings($this)) {
|
||||
if($category->isFixedSetting($this)) {
|
||||
return $category->getDefaultSetting($this);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,14 @@ class WebNotificationTarget extends NotificationTarget
|
||||
throw new \yii\base\Exception('Notification record not found for BaseNotification "'.$notification->className().'"');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function isEditable(User $user = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ class ListController extends Controller
|
||||
$notifications = $query->all();
|
||||
$lastEntryId = 0;
|
||||
foreach ($notifications as $notification) {
|
||||
$output .= $notification->getClass()->render();
|
||||
$output .= $notification->getBaseModel()->render();
|
||||
$lastEntryId = $notification->id;
|
||||
}
|
||||
|
||||
|
@ -43,17 +43,13 @@ class OverviewController extends Controller
|
||||
$notifications = [];
|
||||
|
||||
$filterForm = new FilterForm();
|
||||
$filterForm->initFilter();
|
||||
$filterForm->load(Yii::$app->request->get());
|
||||
|
||||
$query = Notification::findGrouped();
|
||||
$query->andWhere(['user_id' => Yii::$app->user->id]);
|
||||
|
||||
|
||||
if ($filterForm->isExcludeFilter()) {
|
||||
if ($filterForm->hasFilter()) {
|
||||
$query->andFilterWhere(['not in', 'class', $filterForm->getExcludeClassFilter()]);
|
||||
} else if ($filterForm->isActive()) {
|
||||
$query->andFilterWhere(['in', 'class', $filterForm->getIncludeClassFilter()]);
|
||||
} else {
|
||||
return $this->render('index', [
|
||||
'notificationEntries' => [],
|
||||
|
@ -3,60 +3,60 @@
|
||||
namespace humhub\modules\notification\models\forms;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\notification\models\Notification;
|
||||
|
||||
/**
|
||||
* @package humhub.forms
|
||||
* @since 0.5
|
||||
*/
|
||||
class FilterForm extends \yii\base\Model
|
||||
{
|
||||
const FILTER_OTHER = 'other';
|
||||
|
||||
/**
|
||||
* Contains the current module filters
|
||||
* @var type array
|
||||
*/
|
||||
public $moduleFilter;
|
||||
|
||||
public $categoryFilter;
|
||||
|
||||
/**
|
||||
* Contains all available module filter
|
||||
* @var type array
|
||||
*/
|
||||
public $moduleFilterSelection;
|
||||
|
||||
public $categoryFilterSelection;
|
||||
|
||||
/**
|
||||
* Contains all notifications by modulenames
|
||||
* @var type
|
||||
*/
|
||||
public $moduleNotifications;
|
||||
|
||||
public function rules()
|
||||
public $notifications;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['moduleFilter'], 'safe'],
|
||||
[['categoryFilter'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'moduleFilter' => Yii::t('NotificationModule.views_overview_index', 'Module Filter'),
|
||||
'categoryFilter' => Yii::t('NotificationModule.views_overview_index', 'Module Filter'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Preselects all possible module filter
|
||||
*/
|
||||
public function initFilter()
|
||||
public function init()
|
||||
{
|
||||
$this->moduleFilter = [];
|
||||
|
||||
foreach($this->getModuleFilterSelection() as $moduleName => $title) {
|
||||
$this->moduleFilter[] = $moduleName;
|
||||
$this->categoryFilter = [];
|
||||
|
||||
foreach ($this->getCategoryFilterSelection() as $moduleName => $title) {
|
||||
$this->categoryFilter [] = $moduleName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all Notifications classes of modules not selected in the filter
|
||||
*
|
||||
@ -65,73 +65,54 @@ class FilterForm extends \yii\base\Model
|
||||
public function getExcludeClassFilter()
|
||||
{
|
||||
$result = [];
|
||||
$moduleNotifications = $this->getModuleNotifications();
|
||||
|
||||
foreach($this->moduleFilterSelection as $moduleName => $title) {
|
||||
if($moduleName != self::FILTER_OTHER && !in_array($moduleName, $this->moduleFilter)) {
|
||||
$result = array_merge($result, $moduleNotifications[$moduleName]);
|
||||
|
||||
foreach ($this->getNotifications() as $notification) {
|
||||
$categoryId = $notification->getCategory()->id;
|
||||
if (!in_array($categoryId, $this->categoryFilter)) {
|
||||
$result[] = $notification->className();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all Notifications classes of modules selected in the filter
|
||||
* Returns all available notification categories as checkbox list selection.
|
||||
* @return type
|
||||
*/
|
||||
public function getIncludeClassFilter()
|
||||
public function getCategoryFilterSelection()
|
||||
{
|
||||
$result = [];
|
||||
$moduleNotifications = $this->getModuleNotifications();
|
||||
|
||||
foreach($this->moduleFilter as $moduleName) {
|
||||
if($moduleName != self::FILTER_OTHER) {
|
||||
$result = array_merge($result, $moduleNotifications[$moduleName]);
|
||||
if ($this->categoryFilterSelection == null) {
|
||||
$this->categoryFilterSelection = [];
|
||||
|
||||
foreach (Yii::$app->notification->getNotificationCategories(Yii::$app->user->getIdentity()) as $category) {
|
||||
$this->categoryFilterSelection[$category->id] = $category->getTitle();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
return $this->categoryFilterSelection;
|
||||
}
|
||||
|
||||
public function getModuleFilterSelection()
|
||||
{
|
||||
if($this->moduleFilterSelection == null) {
|
||||
$this->moduleFilterSelection = [];
|
||||
|
||||
foreach(array_keys($this->getModuleNotifications()) as $moduleName) {
|
||||
$this->moduleFilterSelection[$moduleName] = $moduleName;
|
||||
}
|
||||
|
||||
$this->moduleFilterSelection[self::FILTER_OTHER] = Yii::t('NotificationModule.models_forms_FilterForm', 'Other');
|
||||
}
|
||||
return $this->moduleFilterSelection;
|
||||
}
|
||||
|
||||
public function getModuleNotifications()
|
||||
{
|
||||
if($this->moduleNotifications == null) {
|
||||
$this->moduleNotifications = Notification::getModuleNotifications();
|
||||
}
|
||||
|
||||
return $this->moduleNotifications;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines if this filter should exclude specific modules (if other filter is selected)
|
||||
* or rather include specific module filter.
|
||||
*
|
||||
* @return boolean true if other was selected, else false
|
||||
* Returns all available BaseNotification classes with a NotificationCategory.
|
||||
* @return type
|
||||
*/
|
||||
public function isExcludeFilter()
|
||||
public function getNotifications()
|
||||
{
|
||||
return $this->isActive() && in_array(self::FILTER_OTHER, $this->moduleFilter);
|
||||
if ($this->notifications == null) {
|
||||
$this->notifications = array_filter(Yii::$app->notification->getNotifications(), function($notification) {
|
||||
return $notification->getCategory() != null;
|
||||
});
|
||||
}
|
||||
|
||||
return $this->notifications;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if this filter is active (at least one filter selected)
|
||||
* @return type
|
||||
*/
|
||||
public function isActive()
|
||||
public function hasFilter()
|
||||
{
|
||||
return $this->moduleFilter != null;
|
||||
return $this->categoryFilter != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace humhub\modules\notification\models\forms;
|
||||
|
||||
use Yii;
|
||||
@ -12,7 +13,7 @@ class NotificationSettings extends \yii\base\Model
|
||||
{
|
||||
|
||||
public $settings = [];
|
||||
|
||||
public $user;
|
||||
protected $_targets;
|
||||
|
||||
public function rules()
|
||||
@ -22,32 +23,73 @@ class NotificationSettings extends \yii\base\Model
|
||||
];
|
||||
}
|
||||
|
||||
public function targets($user = null)
|
||||
public function targets()
|
||||
{
|
||||
if(!$this->_targets) {
|
||||
$this->_targets = Yii::$app->notification->getTargets($user);
|
||||
if (!$this->_targets) {
|
||||
$this->_targets = Yii::$app->notification->getTargets($this->user);
|
||||
}
|
||||
|
||||
|
||||
return $this->_targets;
|
||||
}
|
||||
|
||||
public function categories($user = null)
|
||||
public function categories()
|
||||
{
|
||||
return Yii::$app->notification->getNotificationCategories($user);
|
||||
}
|
||||
|
||||
public function getSettingFormname($category, $target)
|
||||
{
|
||||
return $this->formName()."[settings][".$target->getSettingKey($category)."]";
|
||||
return Yii::$app->notification->getNotificationCategories($this->user);
|
||||
}
|
||||
|
||||
public function save($user = null)
|
||||
public function getSettingFormname($category, $target)
|
||||
{
|
||||
return $this->formName() . "[settings][" . $target->getSettingKey($category) . "]";
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
if (!$this->checkPermission()) {
|
||||
throw new \yii\web\HttpException(403);
|
||||
}
|
||||
|
||||
if (!$this->validate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$module = Yii::$app->getModule('notification');
|
||||
$settingManager = ($user) ? $module->settings->user($user) : $module->settings;
|
||||
$settingManager = ($this->user) ? $module->settings->user($this->user) : $module->settings;
|
||||
|
||||
// Save all active settings
|
||||
foreach ($this->settings as $settingKey => $value) {
|
||||
$settingManager->set($settingKey, $value);
|
||||
}
|
||||
|
||||
// Save all inactive settings
|
||||
foreach ($this->targets() as $target) {
|
||||
if (!$target->isEditable($this->user)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($this->categories() as $category) {
|
||||
if ($category->isFixedSetting($target)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$settingKey = $target->getSettingKey($category);
|
||||
if (!array_key_exists($settingKey, $this->settings)) {
|
||||
$settingManager->set($settingKey, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkPermission()
|
||||
{
|
||||
if (Yii::$app->user->can(new \humhub\modules\admin\permissions\ManageSettings())) {
|
||||
return true;
|
||||
} else if (!$this->user) {
|
||||
return false; // Only ManageSettings user can set global notification settings
|
||||
} else {
|
||||
return Yii::$app->user->id == $this->user->id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ class NotificationCategoryTest extends HumHubDbTestCase
|
||||
|
||||
public function testGlobalCategorySetting()
|
||||
{
|
||||
$this->becomeUser('Admin');
|
||||
|
||||
$notification = new TestNotification();
|
||||
$category = $notification->getCategory();
|
||||
$mailTarget = Yii::$app->notification->getTarget(MailNotificationTarget::class);
|
||||
@ -41,6 +43,8 @@ class NotificationCategoryTest extends HumHubDbTestCase
|
||||
|
||||
public function testFixedCategorySetting()
|
||||
{
|
||||
$this->becomeUser('Admin');
|
||||
|
||||
$notification = new SpecialNotification();
|
||||
$category = $notification->getCategory();
|
||||
$mailTarget = Yii::$app->notification->getTarget(MailNotificationTarget::class);
|
||||
@ -65,10 +69,12 @@ class NotificationCategoryTest extends HumHubDbTestCase
|
||||
}
|
||||
|
||||
public function testInvisibleCategorySetting()
|
||||
{
|
||||
{
|
||||
// SpecialCategory is invisible for this user.
|
||||
$this->becomeUser('User1');
|
||||
$user = Yii::$app->user->getIdentity();
|
||||
|
||||
$this->becomeUser('Admin');
|
||||
$notification = new SpecialNotification();
|
||||
$category = $notification->getCategory();
|
||||
$mailTarget = Yii::$app->notification->getTarget(MailNotificationTarget::class);
|
||||
@ -110,6 +116,7 @@ class NotificationCategoryTest extends HumHubDbTestCase
|
||||
{
|
||||
$this->becomeUser('User2');
|
||||
$user = Yii::$app->user->getIdentity();
|
||||
|
||||
$notification = new TestNotification();
|
||||
$category = $notification->getCategory();
|
||||
$mailTarget = Yii::$app->notification->getTarget(MailNotificationTarget::class);
|
||||
@ -119,6 +126,8 @@ class NotificationCategoryTest extends HumHubDbTestCase
|
||||
$this->assertFalse($mailTarget->isEnabled($notification, $user));
|
||||
$this->assertTrue($webTarget->isEnabled($notification, $user));
|
||||
|
||||
$this->becomeUser('Admin');
|
||||
|
||||
// Change global default settings, deny both targets.
|
||||
$settingForm = new NotificationSettings([
|
||||
'settings' => [
|
||||
@ -133,15 +142,18 @@ class NotificationCategoryTest extends HumHubDbTestCase
|
||||
$this->assertFalse($mailTarget->isEnabled($notification, $user));
|
||||
$this->assertFalse($webTarget->isEnabled($notification, $user));
|
||||
|
||||
$this->becomeUser('User2');
|
||||
|
||||
// Change user settings.
|
||||
$userSettings = new NotificationSettings([
|
||||
'user' => $user,
|
||||
'settings' => [
|
||||
$mailTarget->getSettingKey($category) => true,
|
||||
$webTarget->getSettingKey($category) => true,
|
||||
]
|
||||
]);
|
||||
|
||||
$userSettings->save($user);
|
||||
$userSettings->save();
|
||||
|
||||
// Check that global settings are unaffected
|
||||
$this->assertFalse($mailTarget->isEnabled($notification));
|
||||
|
@ -31,13 +31,15 @@ use yii\widgets\ActiveForm;
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong><?= Yii::t('NotificationModule.views_overview_index', 'Filter'); ?></strong>
|
||||
<hr style="margin-bottom:0px"/>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<?php $form = ActiveForm::begin(['id' => 'notification_overview_filter', 'method' => 'GET']); ?>
|
||||
<div style="padding-left: 5px;">
|
||||
<?php echo $form->field($filterForm, 'moduleFilter')->checkboxList($filterForm->getModuleFilterSelection())->label(false); ?>
|
||||
<?= $form->field($filterForm, 'categoryFilter')->checkboxList($filterForm->getCategoryFilterSelection())->label(false); ?>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-xm" type="submit" data-ui-loader><?= Yii::t('NotificationModule.views_overview_index', 'Filter'); ?></button>
|
||||
<button class="btn btn-primary btn-xm" type="submit" data-ui-loader><?= Yii::t('NotificationModule.views_overview_index', 'Apply'); ?></button>
|
||||
<?php ActiveForm::end(); ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -53,7 +55,7 @@ use yii\widgets\ActiveForm;
|
||||
evt.preventDefault();
|
||||
$.ajax({
|
||||
'type': 'GET',
|
||||
'url': '<?php echo yii\helpers\Url::to(['/notification/list/mark-as-seen', 'ajax' => 1]); ?>',
|
||||
'url': '<?= yii\helpers\Url::to(['/notification/list/mark-as-seen', 'ajax' => 1]); ?>',
|
||||
'success': function () {
|
||||
location.reload();
|
||||
}
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
use yii\bootstrap\Html
|
||||
?>
|
||||
<div class="table-responsive">
|
||||
<div class="grid-view table-responsive">
|
||||
<table class="table table-middle table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= Yii::t('NotificationModule.widgets_views_notificationSettingsForm', 'Category') ?></th>
|
||||
<th><?= Yii::t('NotificationModule.widgets_views_notificationSettingsForm', 'Description') ?></th>
|
||||
<?php foreach ($model->targets($user) as $target): ?>
|
||||
<?php foreach ($model->targets() as $target): ?>
|
||||
<th class="text-center">
|
||||
<?= $target->getTitle(); ?>
|
||||
</th>
|
||||
@ -18,7 +18,7 @@ use yii\bootstrap\Html
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($model->categories($user) as $category): ?>
|
||||
<?php foreach ($model->categories() as $category): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?= $category->getTitle() ?></strong>
|
||||
@ -27,10 +27,11 @@ use yii\bootstrap\Html
|
||||
<?= $category->getDescription() ?>
|
||||
</td>
|
||||
|
||||
<?php foreach ($model->targets($user) as $target): ?>
|
||||
<?php foreach ($model->targets() as $target): ?>
|
||||
<td class="text-center">
|
||||
<label style="margin:0px;">
|
||||
<?= Html::checkbox($model->getSettingFormname($category, $target), $target->isCategoryEnabled($category), ['style' => 'margin:0px;']) ?>
|
||||
<?php $disabled = !$target->isEditable($model->user) || $category->isFixedSetting($target)?>
|
||||
<?= Html::checkbox($model->getSettingFormname($category, $target), $target->isCategoryEnabled($category, $model->user), ['style' => 'margin:0px;', 'disabled' => $disabled]) ?>
|
||||
</label>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
|
@ -238,8 +238,8 @@ humhub.module('stream', function(module, require, $) {
|
||||
// Sinc the response does not only include the node itself we have to search it.
|
||||
that.$ = $newEntry.find(DATA_STREAM_ENTRY_SELECTOR)
|
||||
.addBack(DATA_STREAM_ENTRY_SELECTOR);
|
||||
that.apply();
|
||||
$newEntry.fadeIn('fast', function() {
|
||||
that.apply();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
@ -582,8 +582,9 @@ humhub.module('stream', function(module, require, $) {
|
||||
var $html = $(html).hide();
|
||||
this.$content.prepend($html);
|
||||
var that = this;
|
||||
|
||||
additions.applyTo($html);
|
||||
$html.fadeIn('fast', function() {
|
||||
additions.applyTo($html);
|
||||
that.onChange();
|
||||
});
|
||||
};
|
||||
@ -592,8 +593,9 @@ humhub.module('stream', function(module, require, $) {
|
||||
var $html = $(html).hide();
|
||||
$entryNode.after($html);
|
||||
var that = this;
|
||||
|
||||
additions.applyTo($html);
|
||||
$html.fadeIn('fast', function() {
|
||||
additions.applyTo($html);
|
||||
that.onChange();
|
||||
});
|
||||
};
|
||||
@ -602,8 +604,9 @@ humhub.module('stream', function(module, require, $) {
|
||||
var $html = $(html).hide();
|
||||
this.$content.append($html);
|
||||
var that = this;
|
||||
|
||||
additions.applyTo($html);
|
||||
$html.fadeIn('fast', function() {
|
||||
additions.applyTo($html);
|
||||
that.onChange();
|
||||
});
|
||||
};
|
||||
|
@ -12,6 +12,7 @@ use Yii;
|
||||
use yii\web\HttpException;
|
||||
use humhub\modules\user\components\BaseAccountController;
|
||||
use humhub\modules\user\models\User;
|
||||
use humhub\modules\notification\models\forms\NotificationSettings;
|
||||
|
||||
/**
|
||||
* AccountController provides all standard actions for the current logged in
|
||||
@ -32,7 +33,7 @@ class AccountController extends BaseAccountController
|
||||
'connected-accounts' => Yii::t('UserModule.base', 'Connected accounts'),
|
||||
'edit-modules' => Yii::t('UserModule.base', 'Modules'),
|
||||
'delete' => Yii::t('UserModule.base', 'Delete'),
|
||||
'emailing' => Yii::t('UserModule.base', 'Notifications'),
|
||||
'notification' => Yii::t('UserModule.base', 'Notifications'),
|
||||
'change-email' => Yii::t('UserModule.base', 'Email'),
|
||||
'change-email-validate' => Yii::t('UserModule.base', 'Email'),
|
||||
'change-password' => Yii::t('UserModule.base', 'Password'),
|
||||
@ -110,7 +111,7 @@ class AccountController extends BaseAccountController
|
||||
$user->time_zone = $model->timeZone;
|
||||
$user->visibility = $model->visibility;
|
||||
$user->save();
|
||||
|
||||
|
||||
$this->view->saved();
|
||||
return $this->redirect(['edit-settings']);
|
||||
}
|
||||
@ -260,6 +261,20 @@ class AccountController extends BaseAccountController
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Mailing Settings
|
||||
*/
|
||||
public function actionNotification()
|
||||
{
|
||||
$form = new NotificationSettings(['user' => Yii::$app->user->getIdentity()]);
|
||||
|
||||
if ($form->load(Yii::$app->request->post()) && $form->save()) {
|
||||
$this->view->saved();
|
||||
}
|
||||
|
||||
return $this->render('notification', ['model' => $form]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change EMail Options
|
||||
*
|
||||
@ -268,15 +283,14 @@ class AccountController extends BaseAccountController
|
||||
public function actionEmailing()
|
||||
{
|
||||
$model = new \humhub\modules\user\models\forms\AccountEmailing();
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->save()) {
|
||||
$this->view->saved();
|
||||
}
|
||||
|
||||
|
||||
return $this->render('emailing', array('model' => $model));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change Current Password
|
||||
*
|
||||
|
23
protected/humhub/modules/user/views/account/notification.php
Normal file
23
protected/humhub/modules/user/views/account/notification.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
?>
|
||||
|
||||
<?php $this->beginContent('@user/views/account/_userSettingsLayout.php') ?>
|
||||
<div class="help-block">
|
||||
<?= Yii::t('UserModule.views_account_notification', 'This view allows you to configure your notification settings by selecting the desired targets for the given notification categories.'); ?>
|
||||
</div>
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= humhub\modules\notification\widgets\NotificationSettingsForm::widget([
|
||||
'model' => $model,
|
||||
'form' => $form
|
||||
]) ?>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary" data-ui-loader><?= Yii::t('base', 'Save');?></button>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
<?php $this->endContent() ?>
|
||||
|
||||
|
@ -37,9 +37,9 @@ class AccountSettingsMenu extends \humhub\widgets\BaseMenu
|
||||
|
||||
$this->addItem(array(
|
||||
'label' => Yii::t('UserModule.base', 'Notifications'),
|
||||
'url' => Url::toRoute(['/user/account/emailing']),
|
||||
'url' => Url::toRoute(['/user/account/notification']),
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'user' && Yii::$app->controller->id == 'account' && Yii::$app->controller->action->id == 'emailing'),
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'user' && Yii::$app->controller->id == 'account' && Yii::$app->controller->action->id == 'notification'),
|
||||
));
|
||||
|
||||
if (count($this->getSecondoaryAuthProviders()) != 0) {
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user