EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/111354
Change subject: Formatter for CheckUser rows
......................................................................
Formatter for CheckUser rows
Change-Id: I2037f3947b910186729f808a308a88602523b92c
---
M Flow.php
M Hooks.php
M container.php
A includes/CheckUser/Formatter.php
M includes/Data/RecentChanges.php
M includes/Formatter.php
6 files changed, 95 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/54/111354/1
diff --git a/Flow.php b/Flow.php
index 44fb6e8..6717141 100755
--- a/Flow.php
+++ b/Flow.php
@@ -134,6 +134,7 @@
$wgAutoloadClasses['Flow\Log\PostModerationLogger'] = $dir .
'includes/Log/PostModerationLogger.php';
$wgAutoloadClasses['Flow\Contributions\Query'] = $dir .
'includes/Contributions/Query.php';
$wgAutoloadClasses['Flow\Contributions\Formatter'] = $dir .
'includes/Contributions/Formatter.php';
+$wgAutoloadClasses['Flow\CheckUser\Formatter'] = $dir .
'includes/CheckUser/Formatter.php';
$wgAutoloadClasses['Flow\Data\UserNameListener'] = $dir .
'includes/Data/UserNameBatch.php';
$wgAutoloadClasses['Flow\Data\UserNameBatch'] = $dir .
'includes/Data/UserNameBatch.php';
$wgAutoloadClasses['Flow\Data\UserNameQuery'] = $dir .
'includes/Data/UserNameBatch.php';
@@ -179,6 +180,7 @@
$wgHooks['ContributionsLineEnding'][] = 'FlowHooks::onContributionsLineEnding';
$wgHooks['AbuseFilter-computeVariable'][] =
'FlowHooks::onAbuseFilterComputeVariable';
$wgHooks['AbortEmailNotification'][] = 'FlowHooks::onAbortEmailNotification';
+$wgHooks['SpecialCheckUserGetLinksFromRow'][] =
'FlowHooks::onSpecialCheckUserGetLinksFromRow';
// Extension initialization
$wgExtensionFunctions[] = 'FlowHooks::initFlowExtension';
diff --git a/Hooks.php b/Hooks.php
index b63f64f..43b3d26 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -109,6 +109,20 @@
return true;
}
+ public static function onSpecialCheckUserGetLinksFromRow( Language
$lang, $row, &$links ) {
+ if ( $row->cuc_type != RC_FLOW ) {
+ return true;
+ }
+
+ $line = Container::get( 'checkuser.formatter' )->format( $lang,
$row );
+ if ( $line === false ) {
+ return true;
+ }
+
+ $links = $line;
+ return false;
+ }
+
/**
* Add token type "flow", to generate edit tokens for Flow via
* api.php?action=tokens&type=flow
diff --git a/container.php b/container.php
index 11161ff..069caea 100644
--- a/container.php
+++ b/container.php
@@ -452,6 +452,14 @@
);
} );
+$c['checkuser.formatter'] = $c->share( function( $c ) {
+ return new Flow\CheckUser\Formatter(
+ $c['storage'],
+ $c['flow_actions'],
+ $c['templating']
+ );
+} );
+
$c['recentchanges.formatter'] = $c->share( function( $c ) {
return new Flow\RecentChanges\Formatter(
$c['storage'],
diff --git a/includes/CheckUser/Formatter.php b/includes/CheckUser/Formatter.php
new file mode 100644
index 0000000..7a2ce48
--- /dev/null
+++ b/includes/CheckUser/Formatter.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Flow\CheckUser;
+
+use Language;
+use Html;
+use Linker;
+use Title;
+use Flow\AbstractFormatter;
+use Flow\Model\UUID;
+
+class Formatter extends AbstractFormatter {
+
+ public function format( Language $lang, $row ) {
+ if ( $row->cuc_type != RC_FLOW || !$row->cuc_comment ) {
+ return false;
+ }
+
+ $title = Title::makeTitle( $row->cuc_namespace, $row->cuc_title
);
+ if ( !$title ) {
+ return false;
+ }
+
+ $data = explode( ',', $row->cuc_comment );
+ $post = null;
+ switch( count( $data ) ) {
+ case 3:
+ $post = UUID::create( $data[2] );
+ // fall-through to 2 parameter case
+ case 2:
+ $workflow = UUID::create( $data[1] );
+ $action = $data[0];
+ break;
+ default:
+ wfDebugLog( __CLASS__, __FUNCTION__ . ':
Invalid number of parameters received from cuc_comment. Expected 2 or 3 but
received ' . count( $data ) );
+ return false;
+ }
+
+ $links = $this->buildActionLinks( $title, $action, $workflow,
$post );
+ if ( $links === false ) {
+ return false;
+ }
+
+ $output = '';
+ foreach ( $links as $i => $link ) {
+ // @todo these $text strings are using $wgLang instead
of the provided lang
+ list( $url, $text ) = $link;
+ $output .= wfMessage( 'parentheses' )
+ ->inLanguage( $lang )
+ ->rawParams( Html::element(
+ 'a',
+ array(
+ 'href' => $url,
+ 'title' => $text,
+ ),
+ $text
+ ) ) . ' ';
+ }
+
+ return "$output . . " . Linker::link( $title );
+ }
+}
diff --git a/includes/Data/RecentChanges.php b/includes/Data/RecentChanges.php
index a9edc57..86c162f 100644
--- a/includes/Data/RecentChanges.php
+++ b/includes/Data/RecentChanges.php
@@ -59,6 +59,13 @@
}
$title = $workflow->getArticleTitle();
+ // Very hackish - allows CheckUser access to the basic
information without rc_params
+ // must stay below 255 chars.
+ $comment = $action . ',' . $workflow->getId()->getHex();
+ if ( isset( $changes['post'] ) ) {
+ $comment .= ',' . $changes['post'];
+ }
+
$attribs = array(
'rc_namespace' => $title->getNamespace(),
'rc_title' => $title->getDBkey(),
@@ -84,7 +91,7 @@
) + $changes,
) ),
'rc_cur_id' => 0, // TODO: wtf do we do with uuid's?
- 'rc_comment' => '',
+ 'rc_comment' => $comment,
'rc_timestamp' => $timestamp,
'rc_cur_time' => $timestamp,
'rc_deleted' => 0,
diff --git a/includes/Formatter.php b/includes/Formatter.php
index 5f85942..a566218 100644
--- a/includes/Formatter.php
+++ b/includes/Formatter.php
@@ -92,6 +92,7 @@
switch( $action ) {
case 'reply':
$links[] = $this->topicLink( $title,
$workflowId );
+ $links[] = $this->postLink( $title,
$workflowId, $postId );
break;
case 'new-post': // fall through
--
To view, visit https://gerrit.wikimedia.org/r/111354
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2037f3947b910186729f808a308a88602523b92c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits