r85796 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85795‎ | r85796 | r85797 >
Date:16:32, 11 April 2011
Author:aaron
Status:ok
Tags:
Comment:
* Improved review forms to better handle view/submit differences (like master/slave)
* Made AJAX review error msgs a bit more uniform
* Use addWikiMsg() in some places
* Moved $permErrors checks up a bit in RevisionReview
* Added field doc comments to review form
Modified paths:
  • /trunk/extensions/FlaggedRevs/business/FRGenericSubmitForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/business/PageStabilityForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/RejectConfirmationFormGUI.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/specialpages/actions/RevisionReview_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/specialpages/actions/Stabilization_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/business/FRGenericSubmitForm.php
@@ -4,15 +4,20 @@
55 * Note: edit tokens are the responsibility of the caller
66 * Usage: (a) set ALL form params before doing anything else
77 * (b) call ready() when all params are set
8 - * (c) call submit() as needed
 8+ * (c) call preload() OR submit() as needed
99 */
1010 abstract class FRGenericSubmitForm {
11 - const ON_SUBMISSION = 1; # Notify functions when we are submitting
 11+ const FOR_SUBMISSION = 1; # Notify functions when we are submitting
 12+ /* Internal form state */
 13+ const FORM_UNREADY = 0; # Params not given yet
 14+ const FORM_READY = 1; # Params given and ready to submit
 15+ const FORM_PRELOADED = 2; # Params pre-loaded (likely from slave DB)
 16+ const FORM_SUBMITTED = 3; # Form submitted
 17+ private $state = self::FORM_UNREADY; # Form state (disallows bad operations)
1218
13 - protected $inputLock = 0; # Disallow bad submissions
14 - protected $user = null;
 19+ protected $user = null; # User performing the action
1520
16 - public function __construct( User $user ) {
 21+ final public function __construct( User $user ) {
1722 $this->user = $user;
1823 $this->initialize();
1924 }
@@ -27,39 +32,51 @@
2833 * Get the submitting user
2934 * @return User
3035 */
31 - public function getUser() {
 36+ final public function getUser() {
3237 return $this->user;
3338 }
3439
3540 /**
36 - * Signal that inputs will be given (via accessors)
37 - * @return void
 41+ * Get the internal form state
 42+ * @return int
3843 */
39 - public function start() {
40 - $this->inputLock = 0;
 44+ final protected function getState() {
 45+ return $this->state;
4146 }
4247
4348 /**
4449 * Signal that inputs are all given (via accessors)
4550 * @return mixed (true on success, error string on target failure)
4651 */
47 - public function ready() {
48 - $this->inputLock = 1;
49 - $status = $this->doCheckTarget();
 52+ final public function ready() {
 53+ if ( $this->state != self::FORM_UNREADY ) {
 54+ throw new MWException( __CLASS__ . " ready() already called.\n");
 55+ }
 56+ $this->state = self::FORM_READY;
 57+ $status = $this->doCheckTargetGiven();
5058 if ( $status !== true ) {
5159 return $status; // bad target
5260 }
53 - return $this->doLoadOnReady();
 61+ return $this->doBuildOnReady();
5462 }
5563
5664 /**
 65+ * Load any objects after ready() called
 66+ * NOTE: do not do any DB hits here, just build objects
 67+ * @return mixed (true on success, error string on failure)
 68+ */
 69+ protected function doBuildOnReady() {
 70+ return true;
 71+ }
 72+
 73+ /**
5774 * Set a member field to a value if the fields are unlocked
5875 * @param mixed &$field Field of this form
5976 * @param mixed $value Value to set the field to
6077 * @return void
6178 */
62 - protected function trySet( &$field, $value ) {
63 - if ( $this->inputLock ) {
 79+ final protected function trySet( &$field, $value ) {
 80+ if ( $this->state != self::FORM_UNREADY ) {
6481 throw new MWException( __CLASS__ . " fields cannot be set anymore.\n");
6582 } else {
6683 $field = $value; // still allowing input
@@ -67,51 +84,45 @@
6885 }
6986
7087 /*
71 - * Preload existing params from a DB (e.g. for GET request).
 88+ * Check that a target is given (e.g. from GET/POST request)
 89+ * NOTE: do not do any DB hits here, just check if there is a target
7290 * @return mixed (true on success, error string on failure)
7391 */
74 - public function preload() {
75 - if ( !$this->inputLock ) {
76 - throw new MWException( __CLASS__ . " input fields not set yet.\n");
77 - }
78 - $status = $this->doCheckTarget();
79 - if ( $status !== true ) {
80 - return $status; // bad target
81 - }
82 - return $this->doPreloadParameters();
83 - }
84 -
85 - /*
86 - * Preload existing params from a DB (e.g. for GET request).
87 - * @return mixed (true on success, error string on failure)
88 - */
89 - protected function doPreloadParameters() {
 92+ protected function doCheckTargetGiven() {
9093 return true;
9194 }
9295
9396 /*
9497 * Check that the target is valid (e.g. from GET/POST request)
95 - * @param int $flags ON_SUBMISSION (set on submit)
 98+ * @param int $flags FOR_SUBMISSION (set on submit)
9699 * @return mixed (true on success, error string on failure)
97100 */
98101 protected function doCheckTarget( $flags = 0 ) {
99102 return true;
100103 }
101104
102 - /**
103 - * Load any parameters after ready() called
 105+ /*
 106+ * Check that a target is and it is valid (e.g. from GET/POST request)
 107+ * NOTE: do not do any DB hits here, just check if there is a target
104108 * @return mixed (true on success, error string on failure)
105109 */
106 - protected function doLoadOnReady() {
107 - return true;
 110+ final public function checkTarget() {
 111+ if ( $this->state != self::FORM_READY ) {
 112+ throw new MWException( __CLASS__ . " input fields not set yet.\n");
 113+ }
 114+ $status = $this->doCheckTargetGiven();
 115+ if ( $status !== true ) {
 116+ return $status; // bad target
 117+ }
 118+ return $this->doCheckTarget();
108119 }
109120
110121 /*
111 - * Verify and clean up parameters (e.g. from POST request)
 122+ * Validate and clean up target/parameters (e.g. from POST request)
112123 * @return mixed (true on success, error string on failure)
113124 */
114 - protected function checkParameters() {
115 - $status = $this->doCheckTarget( self::ON_SUBMISSION );
 125+ final protected function checkParameters() {
 126+ $status = $this->checkTarget( self::FOR_SUBMISSION );
116127 if ( $status !== true ) {
117128 return $status; // bad target
118129 }
@@ -126,25 +137,57 @@
127138 return true;
128139 }
129140
130 - /**
131 - * Submit the form parameters for the page config to the DB.
132 - *
 141+ /*
 142+ * Preload existing params for the target from the DB (e.g. for GET request)
 143+ * NOTE: do not call this and then submit()
133144 * @return mixed (true on success, error string on failure)
134145 */
135 - public function submit() {
136 - if ( !$this->inputLock ) {
 146+ final public function preload() {
 147+ if ( $this->state != self::FORM_READY ) {
137148 throw new MWException( __CLASS__ . " input fields not set yet.\n");
138149 }
 150+ $status = $this->checkTarget();
 151+ if ( $status !== true ) {
 152+ return $status; // bad target
 153+ }
 154+ $status = $this->doPreloadParameters();
 155+ if ( $status !== true ) {
 156+ return $status; // bad target
 157+ }
 158+ $this->state = self::FORM_PRELOADED;
 159+ return true;
 160+ }
 161+
 162+ /*
 163+ * Preload existing params for the target from the DB (e.g. for GET request)
 164+ * @return mixed (true on success, error string on failure)
 165+ */
 166+ protected function doPreloadParameters() {
 167+ return true;
 168+ }
 169+
 170+ /**
 171+ * Submit the form parameters for the page config to the DB
 172+ * @return mixed (true on success, error string on failure)
 173+ */
 174+ final public function submit() {
 175+ if ( $this->state != self::FORM_READY ) {
 176+ throw new MWException( __CLASS__ . " input fields preloaded or not set yet.\n");
 177+ }
139178 $status = $this->checkParameters();
140179 if ( $status !== true ) {
141 - return $status; // cannot submit - broken params
 180+ return $status; // cannot submit - broken target or params
142181 }
143 - return $this->doSubmit();
 182+ $status = $this->doSubmit();
 183+ if ( $status !== true ) {
 184+ return $status; // cannot submit
 185+ }
 186+ $this->state = self::FORM_SUBMITTED;
 187+ return true;
144188 }
145189
146190 /**
147 - * Submit the form parameters for the page config to the DB.
148 - *
 191+ * Submit the form parameters for the page config to the DB
149192 * @return mixed (true on success, error string on failure)
150193 */
151194 protected function doSubmit() {
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -4,24 +4,24 @@
55 */
66 class RevisionReviewForm extends FRGenericSubmitForm {
77 /* Form parameters which can be user given */
8 - protected $page = null;
9 - protected $approve = false;
10 - protected $unapprove = false;
11 - protected $reject = false;
12 - protected $oldid = 0;
13 - protected $refid = 0;
14 - protected $templateParams = '';
15 - protected $imageParams = '';
16 - protected $fileVersion = '';
17 - protected $validatedParams = '';
18 - protected $comment = '';
19 - protected $dims = array();
20 - protected $lastChangeTime = null; # Conflict handling
21 - protected $newLastChangeTime = null; # Conflict handling
 8+ protected $page = null; # Target page obj
 9+ protected $approve = false; # Approval requested
 10+ protected $unapprove = false; # De-approval requested
 11+ protected $reject = false; # Rejection requested
 12+ protected $oldid = 0; # ID being reviewed (last "bad" ID for rejection)
 13+ protected $refid = 0; # Old, "last good", ID (used for rejection)
 14+ protected $templateParams = ''; # Included template versions (flat string)
 15+ protected $imageParams = ''; # Included file versions (flat string)
 16+ protected $fileVersion = ''; # File page file version (flat string)
 17+ protected $validatedParams = ''; # Parameter key
 18+ protected $comment = ''; # Review comments
 19+ protected $dims = array(); # Review flags (for approval)
 20+ protected $lastChangeTime = null; # Conflict handling
 21+ protected $newLastChangeTime = null; # Conflict handling
2222
23 - protected $oflags = array();
 23+ protected $oflags = array(); # Prior flags for Rev with ID $oldid
2424
25 - public function initialize() {
 25+ protected function initialize() {
2626 foreach ( FlaggedRevs::getTags() as $tag ) {
2727 $this->dims[$tag] = 0; // default to "inadequate"
2828 }
@@ -122,39 +122,45 @@
123123 $this->trySet( $this->dims[$tag], (int)$value );
124124 }
125125
 126+ /*
 127+ * Check that a target is given (e.g. from GET/POST request)
 128+ * @return mixed (true on success, error string on failure)
 129+ */
 130+ public function doCheckTargetGiven() {
 131+ if ( is_null( $this->page ) ) {
 132+ return 'review_page_invalid';
 133+ }
 134+ return true;
 135+ }
 136+
126137 /**
127 - * Load old config and last review status change time
128 - * @return mixed (true on success, error string on target failure)
 138+ * Load any objects after ready() called
 139+ * @return mixed (true on success, error string on failure)
129140 */
130 - public function doLoadOnReady() {
131 - # Get the revision's current flags, if any
132 - $this->oflags = FlaggedRevs::getRevisionTags( $this->page, $this->oldid, FR_MASTER );
133 - # Set initial value for newLastChangeTime (if unchanged on submit)
134 - $this->newLastChangeTime = $this->lastChangeTime;
 141+ protected function doBuildOnReady() {
 142+ $this->article = FlaggedArticle::getTitleInstance( $this->page );
135143 return true;
136144 }
137145
138146 /*
139147 * Check that the target is valid (e.g. from GET/POST request)
140 - * @param int $flags ON_SUBMISSION (set on submit)
 148+ * @param int $flags FOR_SUBMISSION (set on submit)
141149 * @return mixed (true on success, error string on failure)
142150 */
143151 protected function doCheckTarget( $flags = 0 ) {
144 - if ( is_null( $this->page ) ) {
145 - return 'review_page_invalid';
146 - } elseif ( !$this->page->exists() ) {
 152+ $flgs = ( $flags & self::FOR_SUBMISSION ) ? Title::GAID_FOR_UPDATE : 0;
 153+ if ( !$this->page->getArticleId( $flgs ) ) {
147154 return 'review_page_notexists';
148155 }
149 - $fa = FlaggedArticle::getTitleInstance( $this->page );
150 - $flags = ( $flags & self::ON_SUBMISSION ) ? FR_MASTER : 0;
151 - if ( !$fa->isReviewable( $flags ) ) {
 156+ $flgs = ( $flags & self::FOR_SUBMISSION ) ? FR_MASTER : 0;
 157+ if ( !$this->article->isReviewable( $flgs ) ) {
152158 return 'review_page_unreviewable';
153159 }
154160 return true;
155161 }
156162
157163 /*
158 - * Verify and clean up parameters (e.g. from POST request).
 164+ * Validate and clean up parameters (e.g. from POST request).
159165 * @return mixed (true on success, error string on failure)
160166 */
161167 protected function doCheckParameters() {
@@ -165,6 +171,10 @@
166172 if ( $this->getAction() === null ) {
167173 return 'review_param_missing'; // user didn't say
168174 }
 175+ # Get the revision's current flags, if any
 176+ $this->oflags = FlaggedRevs::getRevisionTags( $this->page, $this->oldid, FR_MASTER );
 177+ # Set initial value for newLastChangeTime (if unchanged on submit)
 178+ $this->newLastChangeTime = $this->lastChangeTime;
169179 # Fill in implicit tag data for binary flag case
170180 $iDims = $this->implicitDims();
171181 if ( $iDims ) {
Index: trunk/extensions/FlaggedRevs/business/PageStabilityForm.php
@@ -4,15 +4,15 @@
55 */
66 abstract class PageStabilityForm extends FRGenericSubmitForm {
77 /* Form parameters which can be user given */
8 - protected $page = false; # Target page obj
9 - protected $watchThis = null; # Watch checkbox
10 - protected $reviewThis = null; # Auto-review option...
11 - protected $reasonExtra = ''; # Custom/extra reason
12 - protected $reasonSelection = ''; # Reason dropdown key
13 - protected $expiryCustom = ''; # Custom expiry
14 - protected $expirySelection = ''; # Expiry dropdown key
15 - protected $override = -1; # Default version
16 - protected $autoreview = ''; # Autoreview restrictions...
 8+ protected $page = false; # Target page obj
 9+ protected $watchThis = null; # Watch checkbox
 10+ protected $reviewThis = null; # Auto-review option...
 11+ protected $reasonExtra = ''; # Custom/extra reason
 12+ protected $reasonSelection = ''; # Reason dropdown key
 13+ protected $expiryCustom = ''; # Custom expiry
 14+ protected $expirySelection = ''; # Expiry dropdown key
 15+ protected $override = -1; # Default version
 16+ protected $autoreview = ''; # Autoreview restrictions...
1717
1818 protected $oldConfig = array(); # Old page config
1919
@@ -78,8 +78,9 @@
7979 * @return 14-char timestamp or "infinity", or false if the input was invalid
8080 */
8181 public function getExpiry() {
 82+ $oldConfig = $this->getOldConfig();
8283 if ( $this->expirySelection == 'existing' ) {
83 - return $this->oldConfig['expiry'];
 84+ return $oldConfig['expiry'];
8485 } elseif ( $this->expirySelection == 'othertime' ) {
8586 $value = $this->expiryCustom;
8687 } else {
@@ -119,30 +120,38 @@
120121 }
121122
122123 /*
123 - * Preload existing page settings (e.g. from GET request).
 124+ * Check that a target is given (e.g. from GET/POST request)
124125 * @return mixed (true on success, error string on failure)
125126 */
126 - public function doPreloadParameters() {
127 - if ( $this->oldConfig['expiry'] == Block::infinity() ) {
128 - $this->expirySelection = 'infinite'; // no settings set OR indefinite
129 - } else {
130 - $this->expirySelection = 'existing'; // settings set and NOT indefinite
 127+ protected function doCheckTargetGiven() {
 128+ if ( is_null( $this->page ) ) {
 129+ return 'stabilize_page_invalid';
131130 }
132 - return $this->reallyDoPreloadParameters(); // load the params...
 131+ return true;
133132 }
134133
135134 /*
 135+ * Check that the target page is valid
 136+ * @param int $flags FOR_SUBMISSION (set on submit)
136137 * @return mixed (true on success, error string on failure)
137 - */
138 - protected function reallyDoPreloadParameters() {
 138+ */
 139+ protected function doCheckTarget( $flags = 0 ) {
 140+ $flgs = ( $flags & self::FOR_SUBMISSION ) ? Title::GAID_FOR_UPDATE : 0;
 141+ if ( !$this->page->getArticleId( $flgs ) ) {
 142+ return 'stabilize_page_notexists';
 143+ } elseif ( !FlaggedRevs::inReviewNamespace( $this->page ) ) {
 144+ return 'stabilize_page_unreviewable';
 145+ }
139146 return true;
140147 }
141148
142149 /*
143 - * Verify and clean up parameters (e.g. from POST request).
 150+ * Verify and clean up parameters (e.g. from POST request)
144151 * @return mixed (true on success, error string on failure)
145152 */
146153 protected function doCheckParameters() {
 154+ # Load old config settings from the master
 155+ $this->oldConfig = FlaggedPageConfig::getStabilitySettings( $this->page, FR_MASTER );
147156 if ( $this->expiryCustom != '' ) {
148157 // Custom expiry takes precedence
149158 $this->expirySelection = 'othertime';
@@ -159,28 +168,6 @@
160169 }
161170
162171 /*
163 - * Check that the target page is valid
164 - * @param int $flags ON_SUBMISSION (set on submit)
165 - * @return mixed (true on success, error string on failure)
166 - */
167 - protected function doCheckTarget( $flags = 0 ) {
168 - if ( is_null( $this->page ) ) {
169 - return 'stabilize_page_invalid';
170 - } elseif ( !$this->page->exists() ) {
171 - return 'stabilize_page_notexists';
172 - } elseif ( !FlaggedRevs::inReviewNamespace( $this->page ) ) {
173 - return 'stabilize_page_unreviewable';
174 - }
175 - return true;
176 - }
177 -
178 - protected function doLoadOnReady() {
179 - # Get the current page config
180 - $this->oldConfig = FlaggedPageConfig::getStabilitySettings( $this->page, FR_MASTER );
181 - return true;
182 - }
183 -
184 - /*
185172 * Can the user change the settings for this page?
186173 * Note: if the current autoreview restriction is too high for this user
187174 * then this will return false. Useful for form selectors.
@@ -195,6 +182,27 @@
196183 );
197184 }
198185
 186+ /*
 187+ * Preload existing page settings (e.g. from GET request).
 188+ * @return mixed (true on success, error string on failure)
 189+ */
 190+ public function doPreloadParameters() {
 191+ $oldConfig = $this->getOldConfig();
 192+ if ( $oldConfig['expiry'] == Block::infinity() ) {
 193+ $this->expirySelection = 'infinite'; // no settings set OR indefinite
 194+ } else {
 195+ $this->expirySelection = 'existing'; // settings set and NOT indefinite
 196+ }
 197+ return $this->reallyDoPreloadParameters(); // load the params...
 198+ }
 199+
 200+ /*
 201+ * @return mixed (true on success, error string on failure)
 202+ */
 203+ protected function reallyDoPreloadParameters() {
 204+ return true;
 205+ }
 206+
199207 /**
200208 * Submit the form parameters for the page config to the DB.
201209 *
@@ -309,9 +317,12 @@
310318 * @return Array
311319 */
312320 public function getOldConfig() {
313 - if ( !$this->inputLock ) {
 321+ if ( $this->getState() == self::FORM_UNREADY ) {
314322 throw new MWException( __CLASS__ . " input fields not set yet.\n");
315323 }
 324+ if ( $this->oldConfig === array() && $this->page ) {
 325+ $this->oldConfig = FlaggedPageConfig::getStabilitySettings( $this->page );
 326+ }
316327 return $this->oldConfig;
317328 }
318329
@@ -360,8 +371,9 @@
361372 }
362373
363374 protected function reallyDoPreloadParameters() {
364 - $this->override = $this->oldConfig['override'];
365 - $this->autoreview = $this->oldConfig['autoreview'];
 375+ $oldConfig = $this->getOldConfig();
 376+ $this->override = $oldConfig['override'];
 377+ $this->autoreview = $oldConfig['autoreview'];
366378 $this->watchThis = $this->page->userIsWatching();
367379 return true;
368380 }
@@ -384,7 +396,8 @@
385397 // Assumes $wgFlaggedRevsProtection is on
386398 class PageStabilityProtectForm extends PageStabilityForm {
387399 protected function reallyDoPreloadParameters() {
388 - $this->autoreview = $this->oldConfig['autoreview']; // protect level
 400+ $oldConfig = $this->getOldConfig();
 401+ $this->autoreview = $oldConfig['autoreview']; // protect level
389402 $this->watchThis = $this->page->userIsWatching();
390403 return true;
391404 }
@@ -392,9 +405,10 @@
393406 protected function reallyDoCheckParameters() {
394407 # WMF temp hack...protection limit quota
395408 global $wgFlaggedRevsProtectQuota;
 409+ $oldConfig = $this->getOldConfig();
396410 if ( isset( $wgFlaggedRevsProtectQuota ) // quota exists
397411 && $this->autoreview != '' // and we are protecting
398 - && FlaggedPageConfig::getProtectionLevel( $this->oldConfig ) == 'none' ) // unprotected
 412+ && FlaggedPageConfig::getProtectionLevel( $oldConfig ) == 'none' ) // unprotected
399413 {
400414 $dbw = wfGetDB( DB_MASTER );
401415 $count = $dbw->selectField( 'flaggedpage_config', 'COUNT(*)', '', __METHOD__ );
@@ -403,7 +417,7 @@
404418 }
405419 }
406420 # Autoreview only when protecting currently unprotected pages
407 - $this->reviewThis = ( FlaggedPageConfig::getProtectionLevel( $this->oldConfig ) == 'none' );
 421+ $this->reviewThis = ( FlaggedPageConfig::getProtectionLevel( $oldConfig ) == 'none' );
408422 # Autoreview restriction => use stable
409423 # No autoreview restriction => site default
410424 $this->override = ( $this->autoreview != '' )
Index: trunk/extensions/FlaggedRevs/presentation/specialpages/actions/Stabilization_body.php
@@ -32,15 +32,17 @@
3333 }
3434 # Set page title
3535 $this->setHeaders();
36 -
37 - $this->form = new PageStabilityGeneralForm( $wgUser );
38 - $form = $this->form; // convenience
 36+
3937 # Target page
4038 $title = Title::newFromURL( $wgRequest->getVal( 'page', $par ) );
4139 if ( !$title ) {
4240 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
4341 return;
4442 }
 43+
 44+ $this->form = new PageStabilityGeneralForm( $wgUser );
 45+ $form = $this->form; // convenience
 46+
4547 $form->setPage( $title );
4648 # Watch checkbox
4749 $form->setWatchThis( (bool)$wgRequest->getCheck( 'wpWatchthis' ) );
@@ -56,15 +58,14 @@
5759 $form->setOverride( (int)$wgRequest->getBool( 'wpStableconfig-override' ) );
5860 # Get autoreview restrictions...
5961 $form->setAutoreview( $wgRequest->getVal( 'mwProtect-level-autoreview' ) );
 62+ $form->ready(); // params all set
6063
61 - $status = $form->ready(); // params all set
 64+ $status = $form->checkTarget();
6265 if ( $status === 'stabilize_page_notexists' ) {
63 - $wgOut->addWikiText(
64 - wfMsg( 'stabilization-notexists', $title->getPrefixedText() ) );
 66+ $wgOut->addWikiMsg( 'stabilization-notexists', $title->getPrefixedText() );
6567 return;
6668 } elseif ( $status === 'stabilize_page_unreviewable' ) {
67 - $wgOut->addWikiText(
68 - wfMsg( 'stabilization-notcontent', $title->getPrefixedText() ) );
 69+ $wgOut->addWikiMsg( 'stabilization-notcontent', $title->getPrefixedText() );
6970 return;
7071 }
7172 # Form POST request...
Index: trunk/extensions/FlaggedRevs/presentation/specialpages/actions/RevisionReview_body.php
@@ -6,7 +6,9 @@
77 var $skin; // FIXME: with RevDel_RevisionList stuff
88
99 public function __construct() {
 10+ global $wgUser;
1011 parent::__construct( 'RevisionReview', 'review' );
 12+ $this->skin = $wgUser->getSkin();
1113 }
1214
1315 public function execute( $par ) {
@@ -27,16 +29,25 @@
2830 }
2931 $this->setHeaders();
3032
31 - $this->skin = $wgUser->getSkin();
32 - $this->form = new RevisionReviewForm( $wgUser );
3333 # Our target page
3434 $this->page = Title::newFromURL( $wgRequest->getVal( 'target' ) );
3535 if ( !$this->page ) {
3636 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
3737 return;
3838 }
 39+ # Basic page permission checks...
 40+ $permErrors = $this->page->getUserPermissionsErrors( 'review', $wgUser, false );
 41+ if ( !$permErrors ) {
 42+ $permErrors = $this->page->getUserPermissionsErrors( 'edit', $wgUser, false );
 43+ }
 44+ if ( $permErrors ) {
 45+ $wgOut->showPermissionsErrorPage( $permErrors, 'review' );
 46+ return;
 47+ }
3948
 49+ $this->form = new RevisionReviewForm( $wgUser );
4050 $form = $this->form; // convenience
 51+
4152 $form->setPage( $this->page );
4253 # Param for sites with binary flagging
4354 $form->setApprove( $wgRequest->getCheck( 'wpApprove' ) );
@@ -61,26 +72,8 @@
6273 }
6374 # Log comment
6475 $form->setComment( $wgRequest->getText( 'wpReason' ) );
 76+ $form->ready();
6577
66 - $status = $form->ready();
67 - # Page must exist and be in reviewable namespace
68 - if ( $status === 'review_page_unreviewable' ) {
69 - $wgOut->addWikiText( wfMsg( 'revreview-main' ) );
70 - return;
71 - } elseif ( $status === 'review_page_notexists' ) {
72 - $wgOut->showErrorPage( 'internalerror', 'nopagetext' );
73 - return;
74 - }
75 - # Basic page permission checks...
76 - $permErrors = $this->page->getUserPermissionsErrors( 'review', $wgUser, false );
77 - if ( !$permErrors ) {
78 - $permErrors = $this->page->getUserPermissionsErrors( 'edit', $wgUser, false );
79 - }
80 - if ( $permErrors ) {
81 - $wgOut->showPermissionsErrorPage( $permErrors, 'review' );
82 - return;
83 - }
84 -
8578 # Review the edit if requested (POST)...
8679 if ( $wgRequest->wasPosted() ) {
8780 // Check the edit token...
@@ -98,7 +91,13 @@
9992 $wgOut->addHtml( $html );
10093 // Failure...
10194 } else {
102 - if ( $status === 'review_bad_oldid' ) {
 95+ if ( $status === 'review_page_unreviewable' ) {
 96+ $wgOut->addWikiText( wfMsg( 'revreview-main' ) );
 97+ return;
 98+ } elseif ( $status === 'review_page_notexists' ) {
 99+ $wgOut->showErrorPage( 'internalerror', 'nopagetext' );
 100+ return;
 101+ } elseif ( $status === 'review_bad_oldid' ) {
103102 $wgOut->showErrorPage( 'internalerror', 'revreview-revnotfound' );
104103 } else {
105104 $wgOut->showErrorPage( 'internalerror', $status );
@@ -120,7 +119,13 @@
121120 }
122121 // Failure...
123122 } else {
124 - if ( $status === 'review_denied' ) {
 123+ if ( $status === 'review_page_unreviewable' ) {
 124+ $wgOut->addWikiText( wfMsg( 'revreview-main' ) );
 125+ return;
 126+ } elseif ( $status === 'review_page_notexists' ) {
 127+ $wgOut->showErrorPage( 'internalerror', 'nopagetext' );
 128+ return;
 129+ } elseif ( $status === 'review_denied' ) {
125130 $wgOut->permissionRequired( 'badaccess-group0' ); // protected?
126131 } elseif ( $status === 'review_bad_key' ) {
127132 $wgOut->permissionRequired( 'badaccess-group0' ); // fiddling
@@ -263,12 +268,6 @@
264269 $form->setPage( $title );
265270
266271 $status = $form->ready(); // all params loaded
267 - # Page must exist and be in reviewable namespace
268 - if ( $status === 'review_page_unreviewable' ) {
269 - return '<err#>' . wfMsgExt( 'revreview-main', 'parseinline' );
270 - } elseif ( $status === 'review_page_notexists' ) {
271 - return '<err#>' . wfMsgExt( 'nopagetext', 'parseinline' );
272 - }
273272 # Check session via user token
274273 if ( !$wgUser->matchEditToken( $editToken ) ) {
275274 return '<err#>' . wfMsgExt( 'sessionfailure', 'parseinline' );
Index: trunk/extensions/FlaggedRevs/presentation/RejectConfirmationFormGUI.php
@@ -17,6 +17,10 @@
1818 */
1919 public function getHtml() {
2020 global $wgLang, $wgContLang;
 21+ $status = $this->form->checkTarget();
 22+ if ( $status !== true ) {
 23+ return array( '', $status ); // not a reviewable existing page
 24+ }
2125 $oldRev = $this->oldRev; // convenience
2226 $newRev = $this->newRev; // convenience
2327 # Do not mess with archived/deleted revisions

Status & tagging log