r104205 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104204‎ | r104205 | r104206 >
Date:23:07, 24 November 2011
Author:jeroendedauw
Status:reverted
Tags:
Comment:
work on flagging/reviewing reviews
Modified paths:
  • /trunk/extensions/Reviews/Reviews.i18n.php (modified) (history)
  • /trunk/extensions/Reviews/Reviews.php (modified) (history)
  • /trunk/extensions/Reviews/api/ApiFlagReview.php (added) (history)
  • /trunk/extensions/Reviews/includes/ReviewPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Reviews/includes/ReviewPager.php
@@ -63,6 +63,18 @@
6464 public function getLang() {
6565 return version_compare( $GLOBALS['wgVersion'], '1.18', '>' ) ? parent::getLang() : $GLOBALS['wgLang'];
6666 }
 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+ }
6779
6880 /**
6981 * @return array
@@ -110,6 +122,10 @@
111123 break;
112124 case 'review_state':
113125 $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+ }
114130 break;
115131 case 'review_page_id':
116132 $title = Title::newFromID( $value );
Index: trunk/extensions/Reviews/Reviews.i18n.php
@@ -26,9 +26,13 @@
2727 // Rights
2828 'right-reviewsadmin' => 'Manage reviews',
2929 'right-postreview' => 'Post reviews',
 30+ 'right-flagreview' => 'Flag reviews',
 31+ 'right-reviewreview' => 'Review reviews',
3032
3133 'action-reviewsadmin' => 'manage reviews',
3234 'action-postreview' => 'post reviews',
 35+ 'action-flagreview' => 'flag reviews',
 36+ 'action-reviewreview' => 'review reviews',
3337
3438 // Groups
3539 'group-reviewsadmin' => 'Review admins',
@@ -81,6 +85,8 @@
8286 'reviews-pager-page' => 'For page',
8387 'reviews-pager-rating' => 'Rating',
8488 'reviews-pager-deleted' => 'The page was deleted',
 89+ 'reviews-pager-flag' => 'Flag',
 90+ 'reviews-pager-unflag' => 'Unflag',
8591 );
8692
8793 /** Message documentation (Message documentation)
@@ -89,8 +95,15 @@
9096 $messages['qqq'] = array(
9197 'reviews-toplink' => 'Text of top link linking to Special:MyReviews',
9298
 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+
93104 'action-postreview' => '{{doc-action|postreview}}',
94105 'action-reviewsadmin' => '{{doc-action|reviewsadmin}}',
 106+ 'action-flagreview' => '{{doc-action|flagreview}}',
 107+ 'action-reviewreview' => '{{doc-action|reviewreview}}',
95108
96109 'reviews-state-new' => 'A state a review can be in',
97110 'reviews-state-flagged' => 'A state a review can be in',
@@ -126,5 +139,7 @@
127140 'reviews-pager-user' => 'Tabele column header',
128141 'reviews-pager-page' => 'Tabele column header',
129142 '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',
131146 );
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
195 + Id
Index: trunk/extensions/Reviews/Reviews.php
@@ -50,6 +50,7 @@
5151 $wgAutoloadClasses['ReviewsSettings'] = dirname( __FILE__ ) . '/Reviews.settings.php';
5252
5353 $wgAutoloadClasses['ApiDeleteReviews'] = dirname( __FILE__ ) . '/api/ApiDeleteReviews.php';
 54+$wgAutoloadClasses['ApiFlagReviews'] = dirname( __FILE__ ) . '/api/ApiFlagReviews.php';
5455 $wgAutoloadClasses['ApiQueryReviews'] = dirname( __FILE__ ) . '/api/ApiQueryReviews.php';
5556 $wgAutoloadClasses['ApiReviewQuery'] = dirname( __FILE__ ) . '/api/ApiReviewQuery.php';
5657 $wgAutoloadClasses['ApiSubmitReview'] = dirname( __FILE__ ) . '/api/ApiSubmitReview.php';
@@ -73,6 +74,7 @@
7475
7576 // API
7677 $wgAPIModules['deletereviews'] = 'ApiDeleteReviews';
 78+$wgAPIModules['flagreviews'] = 'ApiFlagReviews';
7779 $wgAPIModules['submitreview'] = 'ApiSubmitReview';
7880 $wgAPIListModules['reviews'] = 'ApiQueryReviews';
7981
@@ -87,6 +89,8 @@
8890 // Rights
8991 $wgAvailableRights[] = 'reviewsadmin';
9092 $wgAvailableRights[] = 'postreview';
 93+$wgAvailableRights[] = 'flagreview';
 94+$wgAvailableRights[] = 'reviewreview';
9195
9296 # Users that can manage the reviews.
9397 $wgGroupPermissions['*' ]['reviewsadmin'] = false;
@@ -103,8 +107,27 @@
104108 //$wgGroupPermissions['bot' ]['postreview'] = false;
105109 $wgGroupPermissions['sysop' ]['postreview'] = true;
106110 $wgGroupPermissions['reviewer']['postreview'] = true;
 111+$wgGroupPermissions['reviewsadmin' ]['postreview'] = true;
107112
 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;
108121
 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+
109132 // Resource loader modules
110133 $moduleTemplate = array(
111134 'localBasePath' => dirname( __FILE__ ) . '/resources',

Status & tagging log