https://www.mediawiki.org/wiki/Special:Code/MediaWiki/109216

Revision: 109216
Author:   bsitu
Date:     2012-01-17 21:26:17 +0000 (Tue, 17 Jan 2012)
Log Message:
-----------
Surfacing MarkAsHelpful on FeedbackDashboard page

Modified Paths:
--------------
    trunk/extensions/MoodBar/MoodBar.i18n.php
    trunk/extensions/MoodBar/SpecialFeedbackDashboard.php
    trunk/extensions/MoodBar/include/MoodBarUtil.php

Modified: trunk/extensions/MoodBar/MoodBar.i18n.php
===================================================================
--- trunk/extensions/MoodBar/MoodBar.i18n.php   2012-01-17 21:21:50 UTC (rev 
109215)
+++ trunk/extensions/MoodBar/MoodBar.i18n.php   2012-01-17 21:26:17 UTC (rev 
109216)
@@ -140,6 +140,7 @@
        'moodbar-invalid-item' => 'The system was unable to find the correct 
feedback item.',
        'moodbar-feedback-action-error' => 'An error occurred when trying to 
perform this action.',
        'moodbar-feedback-response-summary' => '[[$1|$2]] [[$3|responded]] $4 
ago',
+       'moodbar-feedback-response-helpful-summary' => '[[$1|$2]] 
[[$3|responded]] $4 ago and [[$5|$6]] thinks it helpful',
        'moodbar-feedback-edit-summary' => 'Response to 
[[Special:FeedbackDashboard/$1|user feedback]]: $2',
        'moodbar-feedback-top-responders-title' => 'Top Responders',
        // Mood types
@@ -210,12 +211,10 @@
 This is a feature in development. See [[mw:MoodBar 0.1/Design]] for background 
information.',
        'moodbar-trigger-feedback' => 'Link text of the MoodBar overlay 
trigger. $1 is the SITENAME.',
        'moodbar-trigger-editing' => "Link text of the MoodBar overlay trigger. 
\$1 is the SITENAME. The implied sentence is ''\"Using [Sitename] made me 
happy/sad/...\"''. See [[mw:MoodBar 0.1/Design]] for background development 
information.",
-       'moodbar-weeks' => 'Full word for "weeks". $1 is the number of weeks. 
Part of variable $1 in {{msg-mw|Ago}} and variable $4 in 
{{msg-moodbar|moodbar-feedback-response-summary}}',
-       'moodbar-months' => 'Full word for "months". $1 is the number of 
months. Part of variable $1 in {{msg-mw|Ago}} and variable $4 in 
{{msg-moodbar|moodbar-feedback-response-summary}}.
-{{Identical|Month}}',
-       'moodbar-years' => 'Full word for "years". $1 is the number of years. 
Part of variable $1 in {{msg-mw|Ago}} and variable $4 in 
{{msg-moodbar|moodbar-feedback-response-summary}}.
-{{Identical|Year}}',
-       'moodbar-seconds' => 'The phrase "less than 1 minute", Part of variable 
$1 in {{msg-mw|Ago}} and variable $4 in 
{{msg-moodbar|moodbar-feedback-response-summary}}',
+       'moodbar-weeks' => 'Full word for "weeks". $1 is the number of weeks. 
Part of variable $1 in {{msg-mw|Ago}} and variable $4 in 
{{msg-moodbar|moodbar-feedback-response-summary}} and 
{{msg-moodbar|moodbar-feedback-response-helpful-summary}}',
+       'moodbar-months' => 'Full word for "months". $1 is the number of 
months. Part of variable $1 in {{msg-mw|Ago}} and variable $4 in 
{{msg-moodbar|moodbar-feedback-response-summary}} and 
{{msg-moodbar|moodbar-feedback-response-helpful-summary}}',
+       'moodbar-years' => 'Full word for "years". $1 is the number of years. 
Part of variable $1 in {{msg-mw|Ago}} and variable $4 in 
{{msg-moodbar|moodbar-feedback-response-summary}} and 
{{msg-moodbar|moodbar-feedback-response-helpful-summary}}',
+       'moodbar-seconds' => 'The phrase "less than 1 minute", Part of variable 
$1 in {{msg-mw|Ago}} and variable $4 in 
{{msg-moodbar|moodbar-feedback-response-summary}} and 
{{msg-moodbar|moodbar-feedback-response-helpful-summary}}',
        'moodbar-close' => 'Link text of the close-button. Make sure to include 
parentheses.
 
 See also:
@@ -315,7 +314,9 @@
        'moodbar-hidden-footer-without-log' => '* $1 is a link to restore the 
item displaying {{msg-mw|moodbar-feedback-restore}}',
        'moodbar-action-reason' => 'Text for Admin action reason',
        'moodbar-action-reason-required' => 'Text explaining admin action 
reason is required',
-       'moodbar-feedback-response-summary' => 'Text providing a summary of a 
user response, $1 is user page, $2 is user name, $3 is user talk page, $4 is 
time',
+       'moodbar-feedback-response-summary' => 'Text providing a summary of a 
user response, $1 is responder user page, $2 is responder user name, $3 is 
commenter talk page, $4 is time',
+       'moodbar-feedback-response-helpful-summary' => 'Text providing a 
summary of a user response and indicating that commenter has marked the 
response as helpful, $1 is responder user page, $2 is responder user name,
+$3 is commenter user talk page, $4 is time, $5 is commenter user page, $6 is 
commenter user name',
        'moodbar-feedback-edit-summary' => 'Auto generated Edit summary for 
feedback response, $1 is the feedback id and $2 is the response text',
        'moodbar-feedback-top-responders-title' => 'The title for Top 
Responders, which is located below feedback dashboard filter',
        'moodbar-type-happy' => '$1 is the username that can be used for 
GENDER. Message is used on Special:FeedbackDashboard.',

Modified: trunk/extensions/MoodBar/SpecialFeedbackDashboard.php
===================================================================
--- trunk/extensions/MoodBar/SpecialFeedbackDashboard.php       2012-01-17 
21:21:50 UTC (rev 109215)
+++ trunk/extensions/MoodBar/SpecialFeedbackDashboard.php       2012-01-17 
21:26:17 UTC (rev 109216)
@@ -319,15 +319,25 @@
                        $responder = User::newFromRow( $response_detail );
                        
                        if ( $responder && !$responder->isAnon() ) {
-                               $responsetime = MoodBarUtil::formatTimeSince( 
wfTimestamp( TS_UNIX, $response_detail->mbfr_timestamp ) );
+                               $responsetime   = MoodBarUtil::formatTimeSince( 
wfTimestamp( TS_UNIX, $response_detail->mbfr_timestamp ) );
+                               $commenter      = 
$feedbackItem->getProperty('user');
+                               $permalinkTitle = 
$commenter->getTalkPage()->getFullText();
                                
-                               $permalinkTitle = 
$feedbackItem->getProperty('user')->getTalkPage()->getFullText();
-                               
-                               $individual_response = 
wfMsgExt('moodbar-feedback-response-summary', array('parse'),
-                                                                               
                $responder->getUserPage()->getFullText(), 
-                                                                               
                $responder->getName(), 
-                                                                               
                $permalinkTitle . '#feedback-dashboard-response-' . 
$response_detail->mbfr_id,
-                                                                               
                $responsetime);
+                               if ( property_exists( $response_detail, 
'mah_id' ) && intval($response_detail->mah_id ) > 0 ) {
+                                       $individual_response = 
wfMsgExt('moodbar-feedback-response-helpful-summary', array('parse'),
+                                                                               
$responder->getUserPage()->getFullText(), 
+                                                                               
$responder->getName(), 
+                                                                               
$permalinkTitle . '#feedback-dashboard-response-' . $response_detail->mbfr_id,
+                                                                               
$responsetime,
+                                                                               
$commenter->getUserPage()->getFullText(), 
+                                                                               
$commenter->getName());
+                               } else {
+                                       $individual_response = 
wfMsgExt('moodbar-feedback-response-summary', array('parse'),
+                                                                               
$responder->getUserPage()->getFullText(), 
+                                                                               
$responder->getName(), 
+                                                                               
$permalinkTitle . '#feedback-dashboard-response-' . $response_detail->mbfr_id,
+                                                                               
$responsetime);
+                               }
                                $showResponseBox = false;
                                
                                $responseElements = <<<HTML
@@ -714,13 +724,13 @@
        }
        
        /**
-        * Get the latest response summary for a set of feedback, 
+        * Get the latest response summary for a set of feedback
         * @param $res Iterator of Db row with index mbf_latest_response for 
feedback
         * @return array
         */
        public static function getResponseSummary( $res ) {
                $dbr = wfGetDB( DB_SLAVE );
-               
+
                $mbfrIds = array();
 
                foreach ( $res as $row ) {
@@ -732,12 +742,24 @@
                $response = array();
 
                if ( count( $mbfrIds ) > 0 ) {
-                       $res = $dbr->select( array( 
'moodbar_feedback_response', 'user' ),
-                                               array( 'mbfr_id', 
'mbfr_mbf_id', 'mbfr_timestamp', 'user_id', 'user_name', 'user_real_name' ),
-                                               array( 'mbfr_id' => $mbfrIds, 
'mbfr_user_id = user_id' ),
-                                               __METHOD__
-                       );
 
+                       $table  = array( 'user', 'moodbar_feedback_response' );
+                       $select = array( 'mbfr_id', 'mbfr_mbf_id', 
'mbfr_timestamp', 'user_id', 'user_name', 'user_real_name' );
+                       $conds  = array( 'mbfr_id' => $mbfrIds, 'mbfr_user_id = 
user_id' );
+                       $tableJoin = array();
+
+                       // Adding markashelpful data if the extension is enabled
+                       if ( MoodBarUtil::isMarkAsHelpfulEnabled() ) {
+                               $table[] = 'moodbar_feedback';
+                               $table[] = 'mark_as_helpful';
+                               // Is there a workaround that does not specify 
INNER JOIN explicitly?
+                               $tableJoin['moodbar_feedback'] = array( 'INNER 
JOIN', 'mbfr_mbf_id = mbf_id' );
+                               $tableJoin['mark_as_helpful']  = array( 'LEFT 
JOIN', "mah_type = 'mbresponse' AND mah_item = mbfr_id AND mah_user_id = 
mbf_user_id" );
+                               $select[] = 'mah_id';
+                       }
+
+                       $res = $dbr->select( $table, $select, $conds, 
__METHOD__, array(), $tableJoin );
+
                        foreach ( $res as $row ) {
                                $response[$row->mbfr_mbf_id] = $row;
                        }
@@ -745,5 +767,5 @@
 
                return $response;
        }
-       
+
 }
\ No newline at end of file

Modified: trunk/extensions/MoodBar/include/MoodBarUtil.php
===================================================================
--- trunk/extensions/MoodBar/include/MoodBarUtil.php    2012-01-17 21:21:50 UTC 
(rev 109215)
+++ trunk/extensions/MoodBar/include/MoodBarUtil.php    2012-01-17 21:26:17 UTC 
(rev 109216)
@@ -137,4 +137,14 @@
 
        }
 
+       /**
+        * Check if MarkAsHelpful extension is enabled
+        * @return bool
+        */
+       public static function isMarkAsHelpfulEnabled() {
+               global $wgMarkAsHelpfulType;
+
+               return is_array( $wgMarkAsHelpfulType ) && in_array( 
'mbresponse', $wgMarkAsHelpfulType );
+       }
+
 }
\ No newline at end of file


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to