mirror of
https://github.com/flarum/framework.git
synced 2025-01-21 16:41:02 +08:00
parent
6c878cfced
commit
e4a758dfdf
6
framework/core/js/admin/dist/app.js
vendored
6
framework/core/js/admin/dist/app.js
vendored
|
@ -19887,6 +19887,12 @@ System.register('flarum/components/PermissionGrid', ['flarum/Component', 'flarum
|
|||
value: function moderateItems() {
|
||||
var items = new ItemList();
|
||||
|
||||
items.add('viewPostIps', {
|
||||
icon: 'bullseye',
|
||||
label: app.translator.trans('core.admin.permissions.view_post_ips_label'),
|
||||
permission: 'discussion.viewPostIps'
|
||||
}, 110);
|
||||
|
||||
items.add('renameDiscussions', {
|
||||
icon: 'i-cursor',
|
||||
label: app.translator.trans('core.admin.permissions.rename_discussions_label'),
|
||||
|
|
|
@ -173,6 +173,12 @@ export default class PermissionGrid extends Component {
|
|||
moderateItems() {
|
||||
const items = new ItemList();
|
||||
|
||||
items.add('viewPostIps', {
|
||||
icon: 'bullseye',
|
||||
label: app.translator.trans('core.admin.permissions.view_post_ips_label'),
|
||||
permission: 'discussion.viewPostIps'
|
||||
}, 110);
|
||||
|
||||
items.add('renameDiscussions', {
|
||||
icon: 'i-cursor',
|
||||
label: app.translator.trans('core.admin.permissions.rename_discussions_label'),
|
||||
|
|
12
framework/core/js/forum/dist/app.js
vendored
12
framework/core/js/forum/dist/app.js
vendored
|
@ -24456,7 +24456,17 @@ System.register('flarum/components/PostMeta', ['flarum/Component', 'flarum/helpe
|
|||
app.translator.trans('core.forum.post.number_tooltip', { number: post.number() })
|
||||
),
|
||||
' ',
|
||||
fullTime(time),
|
||||
m(
|
||||
'span',
|
||||
{ className: 'PostMeta-time' },
|
||||
fullTime(time)
|
||||
),
|
||||
' ',
|
||||
m(
|
||||
'span',
|
||||
{ className: 'PostMeta-ip' },
|
||||
post.data.attributes.ipAddress
|
||||
),
|
||||
touch ? m(
|
||||
'a',
|
||||
{ className: 'Button PostMeta-permalink', href: permalink },
|
||||
|
|
|
@ -34,7 +34,8 @@ export default class PostMeta extends Component {
|
|||
|
||||
<div className="Dropdown-menu dropdown-menu">
|
||||
<span className="PostMeta-number">{app.translator.trans('core.forum.post.number_tooltip', {number: post.number()})}</span>{' '}
|
||||
{fullTime(time)}
|
||||
<span className="PostMeta-time">{fullTime(time)}</span>{' '}
|
||||
<span className="PostMeta-ip">{post.data.attributes.ipAddress}</span>
|
||||
{touch
|
||||
? <a className="Button PostMeta-permalink" href={permalink}>{permalink}</a>
|
||||
: <input className="FormControl PostMeta-permalink" value={permalink} onclick={e => e.stopPropagation()} />}
|
||||
|
|
|
@ -201,7 +201,7 @@
|
|||
display: inline;
|
||||
}
|
||||
.PostMeta .Dropdown-menu {
|
||||
width: 400px;
|
||||
width: 420px;
|
||||
padding: 10px;
|
||||
color: @muted-color;
|
||||
|
||||
|
@ -213,7 +213,7 @@
|
|||
color: @text-color;
|
||||
font-weight: bold;
|
||||
}
|
||||
.PostMeta-time {
|
||||
.PostMeta-time, .PostMeta-ip {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.PostMeta-permalink {
|
||||
|
|
|
@ -61,13 +61,14 @@ class CreateDiscussionController extends AbstractCreateController
|
|||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
$actor = $request->getAttribute('actor');
|
||||
$ipAddress = array_get($request->getServerParams(), 'REMOTE_ADDR', '127.0.0.1');
|
||||
|
||||
if (! $request->getAttribute('bypassFloodgate')) {
|
||||
$this->floodgate->assertNotFlooding($actor);
|
||||
}
|
||||
|
||||
$discussion = $this->bus->dispatch(
|
||||
new StartDiscussion($actor, array_get($request->getParsedBody(), 'data', []))
|
||||
new StartDiscussion($actor, array_get($request->getParsedBody(), 'data', []), $ipAddress)
|
||||
);
|
||||
|
||||
// After creating the discussion, we assume that the user has seen all
|
||||
|
|
|
@ -47,6 +47,9 @@ class PostSerializer extends PostBasicSerializer
|
|||
if ($canEdit) {
|
||||
$attributes['content'] = $post->content;
|
||||
}
|
||||
if ($gate->allows('viewPostIps', $post)) {
|
||||
$attributes['ipAddress'] = $post->ip_address;
|
||||
}
|
||||
} else {
|
||||
$attributes['content'] = $post->content;
|
||||
}
|
||||
|
|
|
@ -32,9 +32,10 @@ class StartDiscussion
|
|||
* @param User $actor The user authoring the discussion.
|
||||
* @param array $data The discussion attributes.
|
||||
*/
|
||||
public function __construct(User $actor, array $data)
|
||||
public function __construct(User $actor, array $data, $ipAddress)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->data = $data;
|
||||
$this->ipAddress = $ipAddress;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ class StartDiscussionHandler
|
|||
{
|
||||
$actor = $command->actor;
|
||||
$data = $command->data;
|
||||
$ipAddress = $command->ipAddress;
|
||||
|
||||
$this->assertCan($actor, 'startDiscussion');
|
||||
|
||||
|
@ -79,7 +80,7 @@ class StartDiscussionHandler
|
|||
// We will do this by running the PostReply command.
|
||||
try {
|
||||
$post = $this->bus->dispatch(
|
||||
new PostReply($discussion->id, $actor, $data)
|
||||
new PostReply($discussion->id, $actor, $data, $ipAddress)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$discussion->delete();
|
||||
|
|
Loading…
Reference in New Issue
Block a user