r103251 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103250‎ | r103251 | r103252 >
Date:22:45, 15 November 2011
Author:bsitu
Status:resolved (Comments)
Tags:
Comment:
Adding text to indicate which admin at what time hid a feedback along with reason
Modified paths:
  • /trunk/extensions/MoodBar/MoodBar.i18n.php (modified) (history)
  • /trunk/extensions/MoodBar/SpecialFeedbackDashboard.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/SpecialFeedbackDashboard.php
@@ -259,7 +259,11 @@
260260 ->link( $permalinkTitle, $linkText, array(), $query );
261261 $link = Xml::tags( 'span', array( 'class' => 'fbd-item-restore' ), "($link)" );
262262
263 - $footer = wfMessage('moodbar-hidden-footer')->rawParams($link)->escaped();
 263+ $feedback_hidden_detail = self::getFeedbackHiddenDetail($id);
 264+ $footer = wfMessage('moodbar-hidden-footer')->rawParams( array( htmlspecialchars( $feedback_hidden_detail->log_user_text ),
 265+ wfTimestamp( TS_DB, $feedback_hidden_detail->log_timestamp ),
 266+ htmlspecialchars( $feedback_hidden_detail->log_comment ),
 267+ $link ) )->escaped();
264268 return Xml::tags( 'div', array( 'class' => 'error' ), $footer );
265269 } elseif ( $mode === 'hidden' ) {
266270 $linkText = wfMessage('moodbar-feedback-show')->escaped();
@@ -489,4 +493,25 @@
490494 }
491495 return $query;
492496 }
 497+
 498+ /**
 499+ * Get admin's username/timestamp/reason for hiding a feedback
 500+ * @param $mbf_id primary key for moodbar_feedback
 501+ * @return stdObject
 502+ */
 503+ protected static function getFeedbackHiddenDetail( $mbf_id ) {
 504+ $dbr = wfGetDB( DB_SLAVE );
 505+
 506+ $res = $dbr->select( array( 'logging' ), array(
 507+ 'log_user_text', 'log_timestamp', 'log_comment' ),
 508+ array( "log_namespace = " . NS_SPECIAL . " AND log_title = 'FeedbackDashboard/" . intval( $mbf_id ) . "' AND log_action = 'hide' AND log_type = 'moodbar'" ),
 509+ __METHOD__,
 510+ array( 'LIMIT' => 1, 'ORDER BY' => "log_timestamp DESC" )
 511+ );
 512+
 513+ $rows = iterator_to_array( $res, /*$use_keys=*/false );
 514+
 515+ return current($rows);
 516+ }
 517+
493518 }
Index: trunk/extensions/MoodBar/MoodBar.i18n.php
@@ -94,7 +94,7 @@
9595 'moodbar-comment-hidden' => '(Feedback hidden by administrative action)',
9696 'moodbar-feedback-show' => 'show hidden feedback',
9797 'moodbar-feedback-hide' => 'hide feedback',
98 - 'moodbar-hidden-footer' => 'Hidden Feedback $1',
 98+ 'moodbar-hidden-footer' => 'Hidden Feedback by $1 on $2, reason: $3 $4',
9999 'moodbar-feedback-restore' => 'restore hidden feedback',
100100 'moodbar-action-item' => 'Feedback item:',
101101 'moodbar-action-reason' => 'Reason:',
@@ -273,7 +273,7 @@
274274 {{Identical|More}}',
275275 'moodbar-feedback-newer' => 'Text of the link that the user can click to go back to more recent results. Only visible if JavaScript is not enabled.',
276276 'moodbar-feedback-older' => 'Text of the link that the user can click to see less recent results. Only visible if JavaScript is not enabled.',
277 - 'moodbar-hidden-footer' => '* $1 is a link to restore the item displaying {{msg-mw|moodbar-feedback-restore}}',
 277+ 'moodbar-hidden-footer' => '* $1 is the username, $2 is the time stamp, $3 is the reason for hiding the feedback,$4 is a link to restore the item displaying {{msg-mw|moodbar-feedback-restore}}',
278278 'moodbar-type-happy' => '$1 is the username that can be used for GENDER',
279279 'moodbar-type-sad' => '$1 is the username that can be used for GENDER',
280280 'moodbar-type-confused' => '$1 is the username that can be used for GENDER',

Follow-up revisions

RevisionCommit summaryAuthorDate
r103272follow-up to r103251, separate date and time from the language filebsitu00:06, 16 November 2011
r103368follow up to r103251, remove array when calling Message::rawParams() and use ...bsitu19:58, 16 November 2011
r103495follow up to r103251, use date() and time() instead of userDate() and userTim...bsitu19:17, 17 November 2011

Comments

#Comment by Siebrand (talk | contribs)   23:00, 15 November 2011

You should probably split time and date here, instead of using a timestamp in a running sentence. Also see I18n#Separate_times_from_dates_in_sentences.

#Comment by Bsitu (talk | contribs)   00:14, 16 November 2011

fixed it in /trunk r103272

#Comment by Nikerabbit (talk | contribs)   07:42, 16 November 2011

rawParams takes varargs (as many arguments as you pass to it), no need for array(). You can also mix rawParams and params.

The query should use the array( foo => bar ) syntax for constructing query conditions.

Some of the lines are quite long.

#Comment by Bsitu (talk | contribs)   19:59, 16 November 2011

committed the fix in /trunk r103368

Status & tagging log