Bsitu has submitted this change and it was merged.
Change subject: Display post creator
..
Display post creator
Display the user who origionally created a post in the post title. On hover
of the username add links to their user page, talk page and contributions.
Change-Id: Id5af3e9b206fa81c22ebab51d36d7fa6c7ffa786
---
M includes/Model/AbstractRevision.php
M includes/Model/PostRevision.php
M includes/Model/UUID.php
M includes/Model/Workflow.php
M includes/ParsoidUtils.php
M includes/Templating.php
M modules/discussion/ui.js
M templates/post.html.php
M templates/topic.html.php
9 files changed, 70 insertions(+), 24 deletions(-)
Approvals:
Bsitu: Verified; Looks good to me, approved
diff --git a/includes/Model/AbstractRevision.php
b/includes/Model/AbstractRevision.php
index 92f1afa..7cfbd09 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -13,7 +13,7 @@
const MODERATED_CENSORED = 'censor';
- static private $perms = array(
+ static protected $perms = array(
self::MODERATED_NONE = array(
'perm' = null,
'usertext' = null,
diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php
index bd06b87..d450452 100644
--- a/includes/Model/PostRevision.php
+++ b/includes/Model/PostRevision.php
@@ -3,6 +3,7 @@
namespace Flow\Model;
use User;
+use MWTimestamp;
class PostRevision extends AbstractRevision {
protected $postId;
@@ -83,7 +84,21 @@
return $this-origUserId;
}
- public function getCreatorName() {
+ public function getCreatorName( $user = null ) {
+ if ( $this-isAllowed( $user ) ) {
+ return $this-getCreatorNameRaw();
+ } else {
+ $moderatedAt = new MWTimestamp(
$this-moderationTimestamp );
+
+ return wfMessage(
+ self::$perms[$this-moderationState]['content'],
+ $this-moderatedByUserText,
+ $moderatedAt-getHumanTimestamp()
+ );
+ }
+ }
+
+ public function getCreatorNameRaw() {
return $this-origUserText;
}
diff --git a/includes/Model/UUID.php b/includes/Model/UUID.php
index 8a2d5b0..04f7ffe 100644
--- a/includes/Model/UUID.php
+++ b/includes/Model/UUID.php
@@ -78,6 +78,14 @@
return $ts ? $ts-getTimestamp( TS_MW ) : false;
}
+ public function getHumanTimestamp( $relativeTo = null, User $user =
null, Language $lang = null ) {
+ if ( $relativeTo instanceof UUID ) {
+ $relativeTo = $relativeTo-getTimestampObj() ?: null;
+ }
+ $ts = $this-getTimestampObj();
+ return $ts ? $ts-getHumanTimestamp( $relativeTo, $user, $lang
) : false;
+ }
+
public static function convertUUIDs( $array ) {
foreach( ObjectManager::makeArray( $array ) as $key = $value )
{
if ( is_a( $value, 'Flow\Model\UUID' ) ) {
diff --git a/includes/Model/Workflow.php b/includes/Model/Workflow.php
index e6e9a9c..bc7194f 100644
--- a/includes/Model/Workflow.php
+++ b/includes/Model/Workflow.php
@@ -2,6 +2,7 @@
namespace Flow\Model;
+use MWTimestamp;
use SpecialPage;
use Title;
use User;
@@ -104,6 +105,7 @@
public function getUserId() { return $this-userId; }
public function getUserText() { return $this-userText; }
public function getLastModified() { return $this-lastModified; }
+ public function getLastModifiedObj() { return new MWTimestamp(
$this-lastModified ); }
public function updateLastModified() {
$this-lastModified = wfTimestampNow();
diff --git a/includes/ParsoidUtils.php b/includes/ParsoidUtils.php
index 2cca5fa..c507bb7 100644
--- a/includes/ParsoidUtils.php
+++ b/includes/ParsoidUtils.php
@@ -57,6 +57,7 @@
// 'basetimestamp' = ?,
// 'starttimestamp' = ?,
'paction' = $action,
+ 'oldid' = '',
$from = $content,
),
true // POST
diff --git a/includes/Templating.php b/includes/Templating.php
index 5fedb9e..87943f8 100644
--- a/includes/Templating.php
+++ b/includes/Templating.php
@@ -9,8 +9,13 @@
use Flow\Model\Workflow;
use OutputPage;
// These dont really belong here
-use RequestContext;
+use Html;
+use Linker;
use MWTimestamp;
+use RequestContext;
+use SpecialPage;
+use Title;
+use User;
class Templating {
protected $namespaces;
@@ -72,6 +77,11 @@
}
// Helper methods for the view
+ //
+ // Everything below here *DOES* *NOT* belong in this