[MediaWiki-commits] [Gerrit] Display post creator - change (mediawiki...Flow)

2013-09-19 Thread Bsitu (Code Review)
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 

[MediaWiki-commits] [Gerrit] Display post creator - change (mediawiki...Flow)

2013-09-05 Thread EBernhardson (WMF) (Code Review)
EBernhardson (WMF) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/83032


Change subject: Display post creator
..

Display post creator

Post template was incorrectly displaying the user that made the most recent
revision edit, as opposed to the original poster.  This is now fixed.

Change-Id: Id5af3e9b206fa81c22ebab51d36d7fa6c7ffa786
---
M includes/Model/AbstractRevision.php
M includes/Model/PostRevision.php
M templates/post.html.php
3 files changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/32/83032/1

diff --git a/includes/Model/AbstractRevision.php 
b/includes/Model/AbstractRevision.php
index e11b677..2b7a964 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -184,7 +184,7 @@
return wfMessage(
self::$perms[$this-moderationState]['content'],
$this-moderatedByUserText,
-   $moderatedAt-getHumanTimestamp( new 
MWTimestamp )
+   $moderatedAt-getHumanTimestamp()
);
}
}
diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php
index bd06b87..cbad898 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;
@@ -35,6 +36,20 @@
return $obj;
}
 
+   public function getOrigUserText( $user = null ) {
+   if ( $this-isAllowed( $user ) ) {
+   return $this-origUserText;
+   } else {
+   $moderatedAt = new MWTimestamp( 
$this-moderationTimestamp );
+
+   return wfMessage(
+   self::$perms[$this-moderationState]['content'],
+   $this-moderatedByUserText,
+   $moderatedAt-getHumanTimestamp()
+   );
+   }
+   }
+
static public function fromStorageRow( array $row, $obj = null ) {
if ( $row['rev_id'] !== $row['tree_rev_id'] ) {
throw new \MWException( 'tree revision doesn\'t match 
provided revision' );
diff --git a/templates/post.html.php b/templates/post.html.php
index 2178776..638715e 100644
--- a/templates/post.html.php
+++ b/templates/post.html.php
@@ -71,7 +71,7 @@
) ) .
Html::textarea( $block-getName() . '[content]', '', array(
'placeholder' = wfMessage( 'flow-reply-placeholder',
-   $post-getUserText() )-text(),
+   $post-getOrigUserText() )-text(),
'class' = 'flow-reply-content flow-input',
) ) .
Html::openElement( 'div', array( 'class' = 
'flow-post-form-extras' ) ) .

-- 
To view, visit https://gerrit.wikimedia.org/r/83032
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id5af3e9b206fa81c22ebab51d36d7fa6c7ffa786
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson (WMF) ebernhard...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits