r107142 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107141‎ | r107142 | r107143 >
Date:09:08, 23 December 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Stylize, code conventions
Modified paths:
  • /trunk/extensions/MarkAsHelpful/api/ApiMarkAsHelpful.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MarkAsHelpful/api/ApiMarkAsHelpful.php
@@ -8,25 +8,25 @@
99 if ( $wgUser->isBlocked( false ) ) {
1010 $this->dieUsageMsg( array( 'blockedtext' ) );
1111 }
12 -
 12+
1313 // Disallow anonymous user to unmark an 'Mark As Helpful' item
14 - if ( $wgUser->isAnon() && $params['mahaction'] == 'unmark' ) {
 14+ if ( $wgUser->isAnon() && $params['mahaction'] === 'unmark' ) {
1515 $this->noPermissionError();
1616 }
17 -
 17+
1818 $params = $this->extractRequestParams();
1919
2020 $isAbleToMark = true;
21 -
 21+
2222 // Gives other extension the last chance to specify mark as helpful permission rules
23 - wfRunHooks( 'onMarkItemAsHelpful', array( $params['mahaction'], $params['type'], $params['item'], $wgUser, &$isAbleToMark ) );
24 -
 23+ wfRunHooks( 'onMarkItemAsHelpful', array( $params['mahaction'], $params['type'], $params['item'], $wgUser, &$isAbleToMark ) );
 24+
2525 if ( !$isAbleToMark ) {
2626 $this->noPermissionError();
2727 }
2828
2929 $error = false;
30 -
 30+
3131 switch ( $params['mahaction'] ) {
3232 case 'mark':
3333 $item = new MarkAsHelpfulItem();
@@ -36,18 +36,17 @@
3737
3838 case 'unmark':
3939 $item = new MarkAsHelpfulItem();
40 -
41 - $conds = array ( 'mah_type' => $params['type'],
42 - 'mah_item' => $params['item'],
43 - 'mah_user_id' => $wgUser->getId(),
44 - 'mah_user_ip' => NULL);
45 -
 40+
 41+ $conds = array( 'mah_type' => $params['type'],
 42+ 'mah_item' => $params['item'],
 43+ 'mah_user_id' => $wgUser->getId(),
 44+ 'mah_user_ip' => null );
 45+
4646 $status = $item->loadFromDatabase( $conds );
47 -
 47+
4848 if ( $status ) {
4949 $item->unmark( $wgUser );
50 - }
51 - else {
 50+ } else {
5251 $error = wfMessage( 'mah-action-error' )->escaped();
5352 }
5453 break;
@@ -65,11 +64,11 @@
6665 }
6766 $this->getResult()->addValue( null, $this->getModuleName(), $result );
6867 }
69 -
 68+
7069 private function noPermissionError() {
71 - $this->dieUsage( "You don't have permission to do that", 'permission-denied' );
 70+ $this->dieUsage( "You don't have permission to do that", 'permission-denied' );
7271 }
73 -
 72+
7473 public function needsToken() {
7574 return true;
7675 }
@@ -80,7 +79,7 @@
8180
8281 public function getAllowedParams() {
8382 global $wgMarkAsHelpfulType;
84 -
 83+
8584 return array(
8685 'mahaction' => array(
8786 ApiBase::PARAM_REQUIRED => true,
@@ -135,4 +134,4 @@
136135
137136 }
138137
139 -class MWApiMarkAsHelpfulInvalidActionException extends MWException {}
\ No newline at end of file
 138+class MWApiMarkAsHelpfulInvalidActionException extends MWException {}

Status & tagging log