Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/89220
Change subject: Add topic participants' info
......................................................................
Add topic participants' info
* Added "Anonymous" as reserved username
* getCreatorName() now returns false (instead of message) if username is not
available
* Display "Anonymous" as username instead of IPs
* Added post method getParticipants()
* Added message to display topic participants' info
Change-Id: I3d1aedeebd595d24abbdb362e103860821d37a6f
---
M Flow.i18n.php
M Flow.php
M Hooks.php
M includes/Model/PostRevision.php
M templates/topic.html.php
5 files changed, 64 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/20/89220/1
diff --git a/Flow.i18n.php b/Flow.i18n.php
index ebdfc63..f454b8a 100644
--- a/Flow.i18n.php
+++ b/Flow.i18n.php
@@ -11,6 +11,8 @@
'flow-desc' => 'Workflow management system',
'flow-specialpage' => '$1 – Flow',
+ 'flow-user-anonymous' => 'Anonymous',
+
'flow-edit-header-link' => 'Edit header',
'flow-header-empty' => 'This talk page currently has no header.',
@@ -89,6 +91,7 @@
'flow-rev-message-censored-post' => 'Censored post',
'flow-topic-history' => 'Topic history',
+ 'flow-topic-participants' => '{{PLURAL:$1|$3 started this
topic|{{GENDER:$3|$3}} and {{GENDER:$4|$4}}|{{GENDER:$3|$3}}, {{GENDER:$4|$4}}
and $2 others}}',
'flow-comment-restored' => 'Restored comment',
'flow-comment-deleted' => 'Deleted comment',
@@ -144,6 +147,7 @@
*/
$messages['qqq'] = array(
'flow-desc' =>
'{{desc|name=Flow|url=http://www.mediawiki.org/wiki/Extension:Flow}}',
+ 'flow-user-anonymous' => 'Name to display for anonymous users',
'flow-specialpage' => 'Used as page title in [[Special:Flow]].
Parameters:
* $1 - page title',
'flow-post-moderated-toggle-show' => 'Text for link used to display a
moderated post.
@@ -295,6 +299,11 @@
'flow-rev-message-censored-post' => 'Used as revision comment when a
post has been censored(oversighted)',
'flow-topic-history' => 'Used as <code><nowiki><h2></nowiki></code>
heading in the "Topic history" page.
{{Identical|Topic history}}',
+ 'flow-topic-participants' => 'Message to display the amount of
participants in this discussion (and potentially a couple of names). Parameters:
+$1: The total amount of participants in the conversation, can be used for
PLURAL
+$2: The total amount of participants minus 2, can be used to generate a
message like (X, Y and $2 others)
+$3: Username of the topic starter, can be used for GENDER
+$4: Username of a second participant (if there is a second, otherwise not
available), can be used for GENDER',
'flow-comment-restored' => 'Used as revision comment when the post has
been restored.
See also:
diff --git a/Flow.php b/Flow.php
index 7c320a0..85311e5 100755
--- a/Flow.php
+++ b/Flow.php
@@ -148,6 +148,7 @@
$wgHooks['ApiTokensGetTokenTypes'][] = 'FlowHooks::onApiTokensGetTokenTypes';
$wgHooks['MediaWikiPerformAction'][] = 'FlowHooks::onPerformAction';
$wgHooks['OldChangesListRecentChangesLine'][] =
'FlowHooks::onOldChangesListRecentChangesLine';
+$wgHooks['UserGetReservedNames'][] = 'FlowHooks::onUserGetReservedNames';
// Extension initialization
$wgExtensionFunctions[] = 'FlowHooks::initFlowExtension';
diff --git a/Hooks.php b/Hooks.php
index affc1b6..e6f70c2 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -152,4 +152,13 @@
return true;
}
+
+ /**
+ * @param array $names
+ * @return bool
+ */
+ public function onUserGetReservedNames( &$names ) {
+ $names[] = 'msg:flow-user-anonymous';
+ return true;
+ }
}
diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php
index f5fabcc..a3c9d53 100644
--- a/includes/Model/PostRevision.php
+++ b/includes/Model/PostRevision.php
@@ -82,17 +82,25 @@
return $this->origUserId;
}
+ /**
+ * Returns the username or false if the current user has insufficient
+ * permissions to access this data for this post.
+ *
+ * @param null $user
+ * @return string|bool
+ */
public function getCreatorName( $user = null ) {
if ( $this->isAllowed( $user ) ) {
+ $user = User::newFromId( $this->getCreatorId() );
+
+ // @todo: not here
+ if ( $user->isAnon() ) {
+ return wfMessage( 'flow-user-anonymous'
)->plain();
+ }
+
return $this->getCreatorNameRaw();
} else {
- $moderatedAt = new MWTimestamp(
$this->moderationTimestamp );
-
- return wfMessage(
- self::$perms[$this->moderationState]['content'],
- $this->moderatedByUserText,
- $moderatedAt->getHumanTimestamp()
- );
+ return false;
}
}
@@ -119,6 +127,23 @@
return $this->children;
}
+ public function getParticipants() {
+ $children = $this->getChildren();
+ $creators = array();
+
+ foreach ( $children as $child ) {
+ $name = $this->getCreatorName();
+ if ( $name !== false ) {
+ // origUserText is unique to user, creatorname
may return multiple "Anonymous"
+ $creators[$this->origUserText] = $name;
+ }
+
+ $creators += $child->getParticipants();
+ }
+
+ return array_values( $creators );
+ }
+
public function findDescendant( $postId ) {
if ( ! $postId instanceof UUID ) {
$postId = UUID::create( $postId );
diff --git a/templates/topic.html.php b/templates/topic.html.php
index 0349b00..29a66e7 100644
--- a/templates/topic.html.php
+++ b/templates/topic.html.php
@@ -66,7 +66,19 @@
?>
<ul class="flow-topic-posts-meta">
- <li>@todo: participants</li>
+ <li>
+ <?php
+ $participants = $root->getParticipants();
+ $parameters = array(
+ count( $participants ), // total number
of participants
+ count( $participants ) - 2, // total
number minus 2
+ array_shift( $participants ), // first
participant
+ array_shift( $participants ), // second
participant
+ );
+
+ echo wfMessage( 'flow-topic-participants',
$parameters )->text();
+ ?>
+ </li>
<li>@todo: # comments</li>
</ul>
--
To view, visit https://gerrit.wikimedia.org/r/89220
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d1aedeebd595d24abbdb362e103860821d37a6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits