Index: trunk/extensions/MoodBar/include/MoodBarUtil.php |
— | — | @@ -137,4 +137,14 @@ |
138 | 138 | |
139 | 139 | } |
140 | 140 | |
| 141 | + /** |
| 142 | + * Check if MarkAsHelpful extension is enabled |
| 143 | + * @return bool |
| 144 | + */ |
| 145 | + public static function isMarkAsHelpfulEnabled() { |
| 146 | + global $wgMarkAsHelpfulType; |
| 147 | + |
| 148 | + return is_array( $wgMarkAsHelpfulType ) && in_array( 'mbresponse', $wgMarkAsHelpfulType ); |
| 149 | + } |
| 150 | + |
141 | 151 | } |
\ No newline at end of file |
Index: trunk/extensions/MoodBar/SpecialFeedbackDashboard.php |
— | — | @@ -319,15 +319,25 @@ |
320 | 320 | $responder = User::newFromRow( $response_detail ); |
321 | 321 | |
322 | 322 | if ( $responder && !$responder->isAnon() ) { |
323 | | - $responsetime = MoodBarUtil::formatTimeSince( wfTimestamp( TS_UNIX, $response_detail->mbfr_timestamp ) ); |
| 323 | + $responsetime = MoodBarUtil::formatTimeSince( wfTimestamp( TS_UNIX, $response_detail->mbfr_timestamp ) ); |
| 324 | + $commenter = $feedbackItem->getProperty('user'); |
| 325 | + $permalinkTitle = $commenter->getTalkPage()->getFullText(); |
324 | 326 | |
325 | | - $permalinkTitle = $feedbackItem->getProperty('user')->getTalkPage()->getFullText(); |
326 | | - |
327 | | - $individual_response = wfMsgExt('moodbar-feedback-response-summary', array('parse'), |
328 | | - $responder->getUserPage()->getFullText(), |
329 | | - $responder->getName(), |
330 | | - $permalinkTitle . '#feedback-dashboard-response-' . $response_detail->mbfr_id, |
331 | | - $responsetime); |
| 327 | + if ( property_exists( $response_detail, 'mah_id' ) && intval($response_detail->mah_id ) > 0 ) { |
| 328 | + $individual_response = wfMsgExt('moodbar-feedback-response-helpful-summary', array('parse'), |
| 329 | + $responder->getUserPage()->getFullText(), |
| 330 | + $responder->getName(), |
| 331 | + $permalinkTitle . '#feedback-dashboard-response-' . $response_detail->mbfr_id, |
| 332 | + $responsetime, |
| 333 | + $commenter->getUserPage()->getFullText(), |
| 334 | + $commenter->getName()); |
| 335 | + } else { |
| 336 | + $individual_response = wfMsgExt('moodbar-feedback-response-summary', array('parse'), |
| 337 | + $responder->getUserPage()->getFullText(), |
| 338 | + $responder->getName(), |
| 339 | + $permalinkTitle . '#feedback-dashboard-response-' . $response_detail->mbfr_id, |
| 340 | + $responsetime); |
| 341 | + } |
332 | 342 | $showResponseBox = false; |
333 | 343 | |
334 | 344 | $responseElements = <<<HTML |
— | — | @@ -714,13 +724,13 @@ |
715 | 725 | } |
716 | 726 | |
717 | 727 | /** |
718 | | - * Get the latest response summary for a set of feedback, |
| 728 | + * Get the latest response summary for a set of feedback |
719 | 729 | * @param $res Iterator of Db row with index mbf_latest_response for feedback |
720 | 730 | * @return array |
721 | 731 | */ |
722 | 732 | public static function getResponseSummary( $res ) { |
723 | 733 | $dbr = wfGetDB( DB_SLAVE ); |
724 | | - |
| 734 | + |
725 | 735 | $mbfrIds = array(); |
726 | 736 | |
727 | 737 | foreach ( $res as $row ) { |
— | — | @@ -732,12 +742,24 @@ |
733 | 743 | $response = array(); |
734 | 744 | |
735 | 745 | if ( count( $mbfrIds ) > 0 ) { |
736 | | - $res = $dbr->select( array( 'moodbar_feedback_response', 'user' ), |
737 | | - array( 'mbfr_id', 'mbfr_mbf_id', 'mbfr_timestamp', 'user_id', 'user_name', 'user_real_name' ), |
738 | | - array( 'mbfr_id' => $mbfrIds, 'mbfr_user_id = user_id' ), |
739 | | - __METHOD__ |
740 | | - ); |
741 | 746 | |
| 747 | + $table = array( 'user', 'moodbar_feedback_response' ); |
| 748 | + $select = array( 'mbfr_id', 'mbfr_mbf_id', 'mbfr_timestamp', 'user_id', 'user_name', 'user_real_name' ); |
| 749 | + $conds = array( 'mbfr_id' => $mbfrIds, 'mbfr_user_id = user_id' ); |
| 750 | + $tableJoin = array(); |
| 751 | + |
| 752 | + // Adding markashelpful data if the extension is enabled |
| 753 | + if ( MoodBarUtil::isMarkAsHelpfulEnabled() ) { |
| 754 | + $table[] = 'moodbar_feedback'; |
| 755 | + $table[] = 'mark_as_helpful'; |
| 756 | + // Is there a workaround that does not specify INNER JOIN explicitly? |
| 757 | + $tableJoin['moodbar_feedback'] = array( 'INNER JOIN', 'mbfr_mbf_id = mbf_id' ); |
| 758 | + $tableJoin['mark_as_helpful'] = array( 'LEFT JOIN', "mah_type = 'mbresponse' AND mah_item = mbfr_id AND mah_user_id = mbf_user_id" ); |
| 759 | + $select[] = 'mah_id'; |
| 760 | + } |
| 761 | + |
| 762 | + $res = $dbr->select( $table, $select, $conds, __METHOD__, array(), $tableJoin ); |
| 763 | + |
742 | 764 | foreach ( $res as $row ) { |
743 | 765 | $response[$row->mbfr_mbf_id] = $row; |
744 | 766 | } |
— | — | @@ -745,5 +767,5 @@ |
746 | 768 | |
747 | 769 | return $response; |
748 | 770 | } |
749 | | - |
| 771 | + |
750 | 772 | } |
\ No newline at end of file |
Index: trunk/extensions/MoodBar/MoodBar.i18n.php |
— | — | @@ -140,6 +140,7 @@ |
141 | 141 | 'moodbar-invalid-item' => 'The system was unable to find the correct feedback item.', |
142 | 142 | 'moodbar-feedback-action-error' => 'An error occurred when trying to perform this action.', |
143 | 143 | 'moodbar-feedback-response-summary' => '[[$1|$2]] [[$3|responded]] $4 ago', |
| 144 | + 'moodbar-feedback-response-helpful-summary' => '[[$1|$2]] [[$3|responded]] $4 ago and [[$5|$6]] thinks it helpful', |
144 | 145 | 'moodbar-feedback-edit-summary' => 'Response to [[Special:FeedbackDashboard/$1|user feedback]]: $2', |
145 | 146 | 'moodbar-feedback-top-responders-title' => 'Top Responders', |
146 | 147 | // Mood types |
— | — | @@ -210,12 +211,10 @@ |
211 | 212 | This is a feature in development. See [[mw:MoodBar 0.1/Design]] for background information.', |
212 | 213 | 'moodbar-trigger-feedback' => 'Link text of the MoodBar overlay trigger. $1 is the SITENAME.', |
213 | 214 | '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.", |
214 | | - '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}}', |
215 | | - '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}}. |
216 | | -{{Identical|Month}}', |
217 | | - '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}}. |
218 | | -{{Identical|Year}}', |
219 | | - '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}}', |
| 215 | + '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}}', |
| 216 | + '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}}', |
| 217 | + '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}}', |
| 218 | + '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}}', |
220 | 219 | 'moodbar-close' => 'Link text of the close-button. Make sure to include parentheses. |
221 | 220 | |
222 | 221 | See also: |
— | — | @@ -315,7 +314,9 @@ |
316 | 315 | 'moodbar-hidden-footer-without-log' => '* $1 is a link to restore the item displaying {{msg-mw|moodbar-feedback-restore}}', |
317 | 316 | 'moodbar-action-reason' => 'Text for Admin action reason', |
318 | 317 | 'moodbar-action-reason-required' => 'Text explaining admin action reason is required', |
319 | | - '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', |
| 318 | + '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', |
| 319 | + '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, |
| 320 | +$3 is commenter user talk page, $4 is time, $5 is commenter user page, $6 is commenter user name', |
320 | 321 | 'moodbar-feedback-edit-summary' => 'Auto generated Edit summary for feedback response, $1 is the feedback id and $2 is the response text', |
321 | 322 | 'moodbar-feedback-top-responders-title' => 'The title for Top Responders, which is located below feedback dashboard filter', |
322 | 323 | 'moodbar-type-happy' => '$1 is the username that can be used for GENDER. Message is used on Special:FeedbackDashboard.', |