r107452 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107451‎ | r107452 | r107453 >
Date:23:55, 27 December 2011
Author:bsitu
Status:ok
Tags:
Comment:
Disallow anonymous user to mark an item as helpful
Modified paths:
  • /trunk/extensions/MoodBar/MoodBar.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/MoodBar.hooks.php
@@ -28,25 +28,23 @@
2929 */
3030 public static function onMarkItemAsHelpful( $mahaction, $type, $item, $User, &$isAbleToMark ) {
3131
 32+ if ( $User->isAnon() ) {
 33+ $isAbleToMark = false;
 34+ return true;
 35+ }
 36+
3237 if ( $type == 'mbresponse' ) {
3338
3439 switch ( $mahaction ) {
3540
3641 case 'mark':
3742 $dbr = wfGetDB( DB_SLAVE );
38 -
39 - $conds = array( 'mbf_id = mbfr_mbf_id', 'mbfr_id' => intval( $item ) );
40 -
41 - if ( !$User->isAnon() ) {
42 - $conds['mbf_user_id'] = $User->getId();
43 - }
44 - else {
45 - $conds['mbf_user_ip'] = $User->getName();
46 - }
47 -
 43+
4844 $res = $dbr->selectRow( array( 'moodbar_feedback', 'moodbar_feedback_response' ),
4945 array( 'mbf_id' ),
50 - $conds,
 46+ array( 'mbf_id = mbfr_mbf_id',
 47+ 'mbfr_id' => intval( $item ),
 48+ 'mbf_user_id' => $User->getId() ),
5149 __METHOD__ );
5250
5351 if ( $res === false ) {

Status & tagging log