Index: trunk/extensions/MarkAsHelpful/api/ApiMarkAsHelpful.php |
— | — | @@ -8,25 +8,25 @@ |
9 | 9 | if ( $wgUser->isBlocked( false ) ) { |
10 | 10 | $this->dieUsageMsg( array( 'blockedtext' ) ); |
11 | 11 | } |
12 | | - |
| 12 | + |
13 | 13 | // Disallow anonymous user to unmark an 'Mark As Helpful' item |
14 | | - if ( $wgUser->isAnon() && $params['mahaction'] == 'unmark' ) { |
| 14 | + if ( $wgUser->isAnon() && $params['mahaction'] === 'unmark' ) { |
15 | 15 | $this->noPermissionError(); |
16 | 16 | } |
17 | | - |
| 17 | + |
18 | 18 | $params = $this->extractRequestParams(); |
19 | 19 | |
20 | 20 | $isAbleToMark = true; |
21 | | - |
| 21 | + |
22 | 22 | // 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 | + |
25 | 25 | if ( !$isAbleToMark ) { |
26 | 26 | $this->noPermissionError(); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $error = false; |
30 | | - |
| 30 | + |
31 | 31 | switch ( $params['mahaction'] ) { |
32 | 32 | case 'mark': |
33 | 33 | $item = new MarkAsHelpfulItem(); |
— | — | @@ -36,18 +36,17 @@ |
37 | 37 | |
38 | 38 | case 'unmark': |
39 | 39 | $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 | + |
46 | 46 | $status = $item->loadFromDatabase( $conds ); |
47 | | - |
| 47 | + |
48 | 48 | if ( $status ) { |
49 | 49 | $item->unmark( $wgUser ); |
50 | | - } |
51 | | - else { |
| 50 | + } else { |
52 | 51 | $error = wfMessage( 'mah-action-error' )->escaped(); |
53 | 52 | } |
54 | 53 | break; |
— | — | @@ -65,11 +64,11 @@ |
66 | 65 | } |
67 | 66 | $this->getResult()->addValue( null, $this->getModuleName(), $result ); |
68 | 67 | } |
69 | | - |
| 68 | + |
70 | 69 | 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' ); |
72 | 71 | } |
73 | | - |
| 72 | + |
74 | 73 | public function needsToken() { |
75 | 74 | return true; |
76 | 75 | } |
— | — | @@ -80,7 +79,7 @@ |
81 | 80 | |
82 | 81 | public function getAllowedParams() { |
83 | 82 | global $wgMarkAsHelpfulType; |
84 | | - |
| 83 | + |
85 | 84 | return array( |
86 | 85 | 'mahaction' => array( |
87 | 86 | ApiBase::PARAM_REQUIRED => true, |
— | — | @@ -135,4 +134,4 @@ |
136 | 135 | |
137 | 136 | } |
138 | 137 | |
139 | | -class MWApiMarkAsHelpfulInvalidActionException extends MWException {} |
\ No newline at end of file |
| 138 | +class MWApiMarkAsHelpfulInvalidActionException extends MWException {} |