mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Merge branch 'master' into 322-notificate-user-when-suspended
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014-2017 Toby Zerner
|
Copyright (c) 2014-2018 Toby Zerner
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
"source": "https://github.com/flarum/flarum-ext-suspend"
|
"source": "https://github.com/flarum/flarum-ext-suspend"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"flarum/core": "^0.1.0-beta.6"
|
"flarum/core": "^0.1.0-beta.8"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@@ -71,7 +71,7 @@ System.register('flarum/suspend/components/SuspendUserModal', ['flarum/component
|
|||||||
m(
|
m(
|
||||||
'label',
|
'label',
|
||||||
{ className: 'checkbox' },
|
{ className: 'checkbox' },
|
||||||
m('input', { type: 'radio', name: 'status', checked: !this.status(), onclick: m.withAttr('value', this.status) }),
|
m('input', { type: 'radio', name: 'status', checked: !this.status(), value: '', onclick: m.withAttr('value', this.status) }),
|
||||||
app.translator.trans('flarum-suspend.forum.suspend_user.not_suspended_label')
|
app.translator.trans('flarum-suspend.forum.suspend_user.not_suspended_label')
|
||||||
),
|
),
|
||||||
m(
|
m(
|
||||||
|
@@ -35,7 +35,7 @@ export default class SuspendUserModal extends Modal {
|
|||||||
<label>{app.translator.trans('flarum-suspend.forum.suspend_user.status_heading')}</label>
|
<label>{app.translator.trans('flarum-suspend.forum.suspend_user.status_heading')}</label>
|
||||||
<div>
|
<div>
|
||||||
<label className="checkbox">
|
<label className="checkbox">
|
||||||
<input type="radio" name="status" checked={!this.status()} onclick={m.withAttr('value', this.status)}/>
|
<input type="radio" name="status" checked={!this.status()} value="" onclick={m.withAttr('value', this.status)}/>
|
||||||
{app.translator.trans('flarum-suspend.forum.suspend_user.not_suspended_label')}
|
{app.translator.trans('flarum-suspend.forum.suspend_user.not_suspended_label')}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Flarum\Database\Migration;
|
||||||
|
use Flarum\Group\Group;
|
||||||
|
|
||||||
|
return Migration::addPermissions([
|
||||||
|
'user.suspend' => Group::MODERATOR_ID
|
||||||
|
]);
|
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace Flarum\Suspend\Access;
|
namespace Flarum\Suspend\Access;
|
||||||
|
|
||||||
use Flarum\Core\Access\AbstractPolicy;
|
use Flarum\User\AbstractPolicy;
|
||||||
use Flarum\Core\User;
|
use Flarum\User\User;
|
||||||
|
|
||||||
class UserPolicy extends AbstractPolicy
|
class UserPolicy extends AbstractPolicy
|
||||||
{
|
{
|
||||||
|
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Suspend\Listener;
|
|
||||||
|
|
||||||
use Flarum\Event\ConfigureWebApp;
|
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
|
||||||
|
|
||||||
class AddClientAssets
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $events
|
|
||||||
*/
|
|
||||||
public function subscribe(Dispatcher $events)
|
|
||||||
{
|
|
||||||
$events->listen(ConfigureWebApp::class, [$this, 'addAssets']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ConfigureClientView $event
|
|
||||||
*/
|
|
||||||
public function addAssets(ConfigureWebApp $event)
|
|
||||||
{
|
|
||||||
if ($event->isForum()) {
|
|
||||||
$event->addAssets([
|
|
||||||
__DIR__.'/../../js/forum/dist/extension.js',
|
|
||||||
__DIR__.'/../../less/forum/extension.less'
|
|
||||||
]);
|
|
||||||
$event->addBootstrapper('flarum/suspend/main');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($event->isAdmin()) {
|
|
||||||
$event->addAssets([
|
|
||||||
__DIR__.'/../../js/admin/dist/extension.js',
|
|
||||||
__DIR__.'/../../less/admin/extension.less'
|
|
||||||
]);
|
|
||||||
$event->addBootstrapper('flarum/suspend/main');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
namespace Flarum\Suspend\Listener;
|
namespace Flarum\Suspend\Listener;
|
||||||
|
|
||||||
|
use Flarum\Api\Event\Serializing;
|
||||||
use Flarum\Api\Serializer\UserSerializer;
|
use Flarum\Api\Serializer\UserSerializer;
|
||||||
use Flarum\Core\User;
|
|
||||||
use Flarum\Event\ConfigureModelDates;
|
use Flarum\Event\ConfigureModelDates;
|
||||||
use Flarum\Event\PrepareApiAttributes;
|
use Flarum\User\User;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
|
||||||
class AddUserSuspendAttributes
|
class AddUserSuspendAttributes
|
||||||
@@ -25,7 +25,7 @@ class AddUserSuspendAttributes
|
|||||||
public function subscribe(Dispatcher $events)
|
public function subscribe(Dispatcher $events)
|
||||||
{
|
{
|
||||||
$events->listen(ConfigureModelDates::class, [$this, 'addDates']);
|
$events->listen(ConfigureModelDates::class, [$this, 'addDates']);
|
||||||
$events->listen(PrepareApiAttributes::class, [$this, 'addAttributes']);
|
$events->listen(Serializing::class, [$this, 'addAttributes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,9 +39,9 @@ class AddUserSuspendAttributes
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PrepareApiAttributes $event
|
* @param Serializing $event
|
||||||
*/
|
*/
|
||||||
public function addAttributes(PrepareApiAttributes $event)
|
public function addAttributes(Serializing $event)
|
||||||
{
|
{
|
||||||
if ($event->isSerializer(UserSerializer::class)) {
|
if ($event->isSerializer(UserSerializer::class)) {
|
||||||
$canSuspend = $event->actor->can('suspend', $event->model);
|
$canSuspend = $event->actor->can('suspend', $event->model);
|
||||||
|
@@ -12,8 +12,8 @@
|
|||||||
namespace Flarum\Suspend\Listener;
|
namespace Flarum\Suspend\Listener;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Flarum\Core\Group;
|
|
||||||
use Flarum\Event\PrepareUserGroups;
|
use Flarum\Event\PrepareUserGroups;
|
||||||
|
use Flarum\Group\Group;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
|
||||||
class RevokeAccessFromSuspendedUsers
|
class RevokeAccessFromSuspendedUsers
|
||||||
|
@@ -43,13 +43,13 @@ class SaveSuspensionToDatabase
|
|||||||
*/
|
*/
|
||||||
public function subscribe(Dispatcher $events)
|
public function subscribe(Dispatcher $events)
|
||||||
{
|
{
|
||||||
$events->listen(UserWillBeSaved::class, [$this, 'whenUserWillBeSaved']);
|
$events->listen(Saving::class, [$this, 'whenSavingUser']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserWillBeSaved $event
|
* @param Saving $event
|
||||||
*/
|
*/
|
||||||
public function whenUserWillBeSaved(UserWillBeSaved $event)
|
public function whenSavingUser(Saving $event)
|
||||||
{
|
{
|
||||||
$attributes = array_get($event->data, 'attributes', []);
|
$attributes = array_get($event->data, 'attributes', []);
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Flarum\Suspend;
|
namespace Flarum\Suspend;
|
||||||
|
|
||||||
use Flarum\Core\Validator\AbstractValidator;
|
use Flarum\Foundation\AbstractValidator;
|
||||||
|
|
||||||
class SuspendValidator extends AbstractValidator
|
class SuspendValidator extends AbstractValidator
|
||||||
{
|
{
|
||||||
@@ -19,6 +19,6 @@ class SuspendValidator extends AbstractValidator
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'suspendUntil' => ['date'],
|
'suspendUntil' => ['nullable', 'date'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user