Index: trunk/extensions/Reviews/includes/ReviewPager.php |
— | — | @@ -63,6 +63,18 @@ |
64 | 64 | public function getLang() { |
65 | 65 | return version_compare( $GLOBALS['wgVersion'], '1.18', '>' ) ? parent::getLang() : $GLOBALS['wgLang']; |
66 | 66 | } |
| 67 | + |
| 68 | + /** |
| 69 | + * Get the User being used for this instance. |
| 70 | + * IndexPager extends ContextSource as of 1.19. |
| 71 | + * |
| 72 | + * @since 0.1 |
| 73 | + * |
| 74 | + * @return User |
| 75 | + */ |
| 76 | + public function getUser() { |
| 77 | + return version_compare( $GLOBALS['wgUser'], '1.18', '>' ) ? parent::getLang() : $GLOBALS['wgUser']; |
| 78 | + } |
67 | 79 | |
68 | 80 | /** |
69 | 81 | * @return array |
— | — | @@ -110,6 +122,10 @@ |
111 | 123 | break; |
112 | 124 | case 'review_state': |
113 | 125 | $value = Review::getStateMessage( $value ); |
| 126 | + if ( $this->getUser()->isAllowed( 'reviewsadmin' ) ) { |
| 127 | + $action = $this->mCurrentRow->review_state == Review::STATUS_FLAGGED ? 'unflag' : 'flag'; |
| 128 | + $value .= ' (' . wfMsgHtml( 'reviews-pager-' . $action ) . ')'; |
| 129 | + } |
114 | 130 | break; |
115 | 131 | case 'review_page_id': |
116 | 132 | $title = Title::newFromID( $value ); |
Index: trunk/extensions/Reviews/Reviews.i18n.php |
— | — | @@ -26,9 +26,13 @@ |
27 | 27 | // Rights |
28 | 28 | 'right-reviewsadmin' => 'Manage reviews', |
29 | 29 | 'right-postreview' => 'Post reviews', |
| 30 | + 'right-flagreview' => 'Flag reviews', |
| 31 | + 'right-reviewreview' => 'Review reviews', |
30 | 32 | |
31 | 33 | 'action-reviewsadmin' => 'manage reviews', |
32 | 34 | 'action-postreview' => 'post reviews', |
| 35 | + 'action-flagreview' => 'flag reviews', |
| 36 | + 'action-reviewreview' => 'review reviews', |
33 | 37 | |
34 | 38 | // Groups |
35 | 39 | 'group-reviewsadmin' => 'Review admins', |
— | — | @@ -81,6 +85,8 @@ |
82 | 86 | 'reviews-pager-page' => 'For page', |
83 | 87 | 'reviews-pager-rating' => 'Rating', |
84 | 88 | 'reviews-pager-deleted' => 'The page was deleted', |
| 89 | + 'reviews-pager-flag' => 'Flag', |
| 90 | + 'reviews-pager-unflag' => 'Unflag', |
85 | 91 | ); |
86 | 92 | |
87 | 93 | /** Message documentation (Message documentation) |
— | — | @@ -89,8 +95,15 @@ |
90 | 96 | $messages['qqq'] = array( |
91 | 97 | 'reviews-toplink' => 'Text of top link linking to Special:MyReviews', |
92 | 98 | |
| 99 | + 'right-reviewsadmin' => '{{doc-right|reviewsadmin}}', |
| 100 | + 'right-postreview' => '{{doc-right|postreview}}', |
| 101 | + 'right-flagreview' => '{{doc-right|flagreview}}', |
| 102 | + 'right-reviewreview' => '{{doc-right|reviewreview}}', |
| 103 | + |
93 | 104 | 'action-postreview' => '{{doc-action|postreview}}', |
94 | 105 | 'action-reviewsadmin' => '{{doc-action|reviewsadmin}}', |
| 106 | + 'action-flagreview' => '{{doc-action|flagreview}}', |
| 107 | + 'action-reviewreview' => '{{doc-action|reviewreview}}', |
95 | 108 | |
96 | 109 | 'reviews-state-new' => 'A state a review can be in', |
97 | 110 | 'reviews-state-flagged' => 'A state a review can be in', |
— | — | @@ -126,5 +139,7 @@ |
127 | 140 | 'reviews-pager-user' => 'Tabele column header', |
128 | 141 | 'reviews-pager-page' => 'Tabele column header', |
129 | 142 | 'reviews-pager-rating' => 'Tabele column header', |
130 | | - 'reviews-pager-deleted' => 'Informs the user a page was deleted' |
| 143 | + 'reviews-pager-deleted' => 'Informs the user a page was deleted', |
| 144 | + 'reviews-pager-flag' => 'Link text to flag a review', |
| 145 | + 'reviews-pager-unflag' => 'Link text to unflag a review', |
131 | 146 | ); |
Index: trunk/extensions/Reviews/api/ApiFlagReview.php |
— | — | @@ -0,0 +1,93 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * API module to delete reviews. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file ApiDeleteReviews.php |
| 10 | + * @ingroup Reviews |
| 11 | + * @ingroup API |
| 12 | + * |
| 13 | + * @licence GNU GPL v3+ |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class ApiDeleteReviews extends ApiBase { |
| 17 | + |
| 18 | + public function execute() { |
| 19 | + |
| 20 | + if ( !$this->getUser()->isAllowed( 'reviewadmin' ) || $this->getUser()->isBlocked() ) { |
| 21 | + $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
| 22 | + } |
| 23 | + |
| 24 | + $params = $this->extractRequestParams(); |
| 25 | + |
| 26 | + $everythingOk = true; |
| 27 | + |
| 28 | + foreach ( $params['ids'] as $id ) { |
| 29 | + $review = new Review( array( 'id' => $id ) ); |
| 30 | + $everythingOk = $review->removeAllFromDB() && $everythingOk; |
| 31 | + } |
| 32 | + |
| 33 | + $this->getResult()->addValue( |
| 34 | + null, |
| 35 | + 'success', |
| 36 | + $everythingOk |
| 37 | + ); |
| 38 | + } |
| 39 | + |
| 40 | + public function needsToken() { |
| 41 | + return true; |
| 42 | + } |
| 43 | + |
| 44 | + public function mustBePosted() { |
| 45 | + return true; |
| 46 | + } |
| 47 | + |
| 48 | + public function getAllowedParams() { |
| 49 | + return array( |
| 50 | + 'ids' => array( |
| 51 | + ApiBase::PARAM_TYPE => 'integer', |
| 52 | + ApiBase::PARAM_REQUIRED => true, |
| 53 | + ApiBase::PARAM_ISMULTI => true, |
| 54 | + ), |
| 55 | + 'state' => array( |
| 56 | + ApiBase::PARAM_TYPE => array( 'flagged', 'reviewed', 'new' ), |
| 57 | + ApiBase::PARAM_DFLT => 'flagged', |
| 58 | + ), |
| 59 | + 'token' => null, |
| 60 | + ); |
| 61 | + } |
| 62 | + |
| 63 | + public function getParamDescription() { |
| 64 | + return array( |
| 65 | + 'ids' => 'The IDs of the reviews to flag', |
| 66 | + 'state' => 'The state to set for the review.', |
| 67 | + 'token' => 'Edit token. You can get one of these through prop=info.', |
| 68 | + ); |
| 69 | + } |
| 70 | + |
| 71 | + public function getDescription() { |
| 72 | + return array( |
| 73 | + 'API module for flagging reviews. By default their state will be changed to flagged, but using the state parameter, other states can also be set.' |
| 74 | + ); |
| 75 | + } |
| 76 | + |
| 77 | + public function getPossibleErrors() { |
| 78 | + return array_merge( parent::getPossibleErrors(), array( |
| 79 | + ) ); |
| 80 | + } |
| 81 | + |
| 82 | + protected function getExamples() { |
| 83 | + return array( |
| 84 | + 'api.php?action=flagreview&ids=42', |
| 85 | + 'api.php?action=flagreview&ids=4|2', |
| 86 | + 'api.php?action=flagreview&ids=42&state=reviewed', |
| 87 | + ); |
| 88 | + } |
| 89 | + |
| 90 | + public function getVersion() { |
| 91 | + return __CLASS__ . ': $Id$'; |
| 92 | + } |
| 93 | + |
| 94 | +} |
Property changes on: trunk/extensions/Reviews/api/ApiFlagReview.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 95 | + Id |
Index: trunk/extensions/Reviews/Reviews.php |
— | — | @@ -50,6 +50,7 @@ |
51 | 51 | $wgAutoloadClasses['ReviewsSettings'] = dirname( __FILE__ ) . '/Reviews.settings.php'; |
52 | 52 | |
53 | 53 | $wgAutoloadClasses['ApiDeleteReviews'] = dirname( __FILE__ ) . '/api/ApiDeleteReviews.php'; |
| 54 | +$wgAutoloadClasses['ApiFlagReviews'] = dirname( __FILE__ ) . '/api/ApiFlagReviews.php'; |
54 | 55 | $wgAutoloadClasses['ApiQueryReviews'] = dirname( __FILE__ ) . '/api/ApiQueryReviews.php'; |
55 | 56 | $wgAutoloadClasses['ApiReviewQuery'] = dirname( __FILE__ ) . '/api/ApiReviewQuery.php'; |
56 | 57 | $wgAutoloadClasses['ApiSubmitReview'] = dirname( __FILE__ ) . '/api/ApiSubmitReview.php'; |
— | — | @@ -73,6 +74,7 @@ |
74 | 75 | |
75 | 76 | // API |
76 | 77 | $wgAPIModules['deletereviews'] = 'ApiDeleteReviews'; |
| 78 | +$wgAPIModules['flagreviews'] = 'ApiFlagReviews'; |
77 | 79 | $wgAPIModules['submitreview'] = 'ApiSubmitReview'; |
78 | 80 | $wgAPIListModules['reviews'] = 'ApiQueryReviews'; |
79 | 81 | |
— | — | @@ -87,6 +89,8 @@ |
88 | 90 | // Rights |
89 | 91 | $wgAvailableRights[] = 'reviewsadmin'; |
90 | 92 | $wgAvailableRights[] = 'postreview'; |
| 93 | +$wgAvailableRights[] = 'flagreview'; |
| 94 | +$wgAvailableRights[] = 'reviewreview'; |
91 | 95 | |
92 | 96 | # Users that can manage the reviews. |
93 | 97 | $wgGroupPermissions['*' ]['reviewsadmin'] = false; |
— | — | @@ -103,8 +107,27 @@ |
104 | 108 | //$wgGroupPermissions['bot' ]['postreview'] = false; |
105 | 109 | $wgGroupPermissions['sysop' ]['postreview'] = true; |
106 | 110 | $wgGroupPermissions['reviewer']['postreview'] = true; |
| 111 | +$wgGroupPermissions['reviewsadmin' ]['postreview'] = true; |
107 | 112 | |
| 113 | +# Users that can flag reviews. |
| 114 | +$wgGroupPermissions['*' ]['flagreview'] = false; |
| 115 | +$wgGroupPermissions['user' ]['flagreview'] = true; |
| 116 | +//$wgGroupPermissions['autoconfirmed']['flagreview'] = true; |
| 117 | +//$wgGroupPermissions['bot' ]['flagreview'] = false; |
| 118 | +$wgGroupPermissions['sysop' ]['flagreview'] = true; |
| 119 | +$wgGroupPermissions['reviewer']['flagreview'] = true; |
| 120 | +$wgGroupPermissions['reviewsadmin' ]['flagreview'] = true; |
108 | 121 | |
| 122 | +# Users that can review reviews. |
| 123 | +$wgGroupPermissions['*' ]['reviewreview'] = false; |
| 124 | +$wgGroupPermissions['user' ]['reviewreview'] = true; |
| 125 | +//$wgGroupPermissions['autoconfirmed']['reviewreview'] = true; |
| 126 | +//$wgGroupPermissions['bot' ]['reviewreview'] = false; |
| 127 | +$wgGroupPermissions['sysop' ]['reviewreview'] = true; |
| 128 | +$wgGroupPermissions['reviewer']['reviewreview'] = false; |
| 129 | +$wgGroupPermissions['reviewsadmin' ]['reviewreview'] = true; |
| 130 | + |
| 131 | + |
109 | 132 | // Resource loader modules |
110 | 133 | $moduleTemplate = array( |
111 | 134 | 'localBasePath' => dirname( __FILE__ ) . '/resources', |