Merge branch 'master' into 322-notificate-user-when-suspended

This commit is contained in:
David Sevilla Martín 2018-02-12 08:35:24 -05:00 committed by GitHub
commit 88ab68af10
11 changed files with 34 additions and 65 deletions

View File

@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal

View File

@ -15,7 +15,7 @@
"source": "https://github.com/flarum/flarum-ext-suspend"
},
"require": {
"flarum/core": "^0.1.0-beta.6"
"flarum/core": "^0.1.0-beta.8"
},
"autoload": {
"psr-4": {

View File

@ -71,7 +71,7 @@ System.register('flarum/suspend/components/SuspendUserModal', ['flarum/component
m(
'label',
{ 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')
),
m(

View File

@ -35,7 +35,7 @@ export default class SuspendUserModal extends Modal {
<label>{app.translator.trans('flarum-suspend.forum.suspend_user.status_heading')}</label>
<div>
<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')}
</label>

View File

@ -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
]);

View File

@ -11,8 +11,8 @@
namespace Flarum\Suspend\Access;
use Flarum\Core\Access\AbstractPolicy;
use Flarum\Core\User;
use Flarum\User\AbstractPolicy;
use Flarum\User\User;
class UserPolicy extends AbstractPolicy
{

View File

@ -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');
}
}
}

View File

@ -11,10 +11,10 @@
namespace Flarum\Suspend\Listener;
use Flarum\Api\Event\Serializing;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\Core\User;
use Flarum\Event\ConfigureModelDates;
use Flarum\Event\PrepareApiAttributes;
use Flarum\User\User;
use Illuminate\Contracts\Events\Dispatcher;
class AddUserSuspendAttributes
@ -25,7 +25,7 @@ class AddUserSuspendAttributes
public function subscribe(Dispatcher $events)
{
$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)) {
$canSuspend = $event->actor->can('suspend', $event->model);

View File

@ -12,8 +12,8 @@
namespace Flarum\Suspend\Listener;
use Carbon\Carbon;
use Flarum\Core\Group;
use Flarum\Event\PrepareUserGroups;
use Flarum\Group\Group;
use Illuminate\Contracts\Events\Dispatcher;
class RevokeAccessFromSuspendedUsers

View File

@ -43,13 +43,13 @@ class SaveSuspensionToDatabase
*/
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', []);

View File

@ -11,7 +11,7 @@
namespace Flarum\Suspend;
use Flarum\Core\Validator\AbstractValidator;
use Flarum\Foundation\AbstractValidator;
class SuspendValidator extends AbstractValidator
{
@ -19,6 +19,6 @@ class SuspendValidator extends AbstractValidator
* {@inheritdoc}
*/
protected $rules = [
'suspendUntil' => ['date'],
'suspendUntil' => ['nullable', 'date'],
];
}