From 3767ee4bf60d44f6478ce194e7527184fdf53d6c Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 2 Jan 2016 15:25:48 +1030 Subject: [PATCH] Allow admins to set a time when creating a post via the API Again, the use-case for this is to allow the API to be used to import data from an old forum. --- src/Core/Command/PostReplyHandler.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Core/Command/PostReplyHandler.php b/src/Core/Command/PostReplyHandler.php index 937568a9a..ca62b2859 100644 --- a/src/Core/Command/PostReplyHandler.php +++ b/src/Core/Command/PostReplyHandler.php @@ -10,6 +10,7 @@ namespace Flarum\Core\Command; +use DateTime; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Validator\PostValidator; use Flarum\Event\PostWillBeSaved; @@ -85,6 +86,10 @@ class PostReplyHandler $command->ipAddress ); + if ($actor->isAdmin() && ($time = array_get($command->data, 'attributes.time'))) { + $post->time = new DateTime($time); + } + $this->events->fire( new PostWillBeSaved($post, $actor, $command->data) );