Index: trunk/extensions/CodeReview/CodeReview.php |
— | — | @@ -239,6 +239,39 @@ |
240 | 240 | */ |
241 | 241 | $wgCodeReviewRepoStatsCacheTime = 6 * 60 * 60; // 6 Hours |
242 | 242 | |
| 243 | +/** |
| 244 | + * Possible states a revision can be in |
| 245 | + * |
| 246 | + * A system message will still needed to be added as code-status-<state> |
| 247 | + */ |
| 248 | +$wgCodeReviewStates = array( |
| 249 | + 'new', |
| 250 | + 'fixme', |
| 251 | + 'reverted', |
| 252 | + 'resolved', |
| 253 | + 'ok', |
| 254 | + 'deferred', |
| 255 | + 'old', |
| 256 | +); |
| 257 | + |
| 258 | +/** |
| 259 | + * Revisions states that a user cannot change to on their own revision |
| 260 | + */ |
| 261 | +$wgProtectedStates = array( |
| 262 | + 'ok', |
| 263 | + 'resolved', |
| 264 | +); |
| 265 | + |
| 266 | +/** |
| 267 | + * List of all flags a user can mark themself as having done to a revision |
| 268 | + * |
| 269 | + * A system message will still needed to be added as code-signoff-flag-<flag> |
| 270 | + */ |
| 271 | +$wgCodeReviewFlags = array( |
| 272 | + 'inspected', |
| 273 | + 'tested', |
| 274 | +); |
| 275 | + |
243 | 276 | # Schema changes |
244 | 277 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'efCodeReviewSchemaUpdates'; |
245 | 278 | |
Index: trunk/extensions/CodeReview/backend/CodeRevision.php |
— | — | @@ -244,10 +244,20 @@ |
245 | 245 | * @return Array |
246 | 246 | */ |
247 | 247 | public static function getPossibleStates() { |
248 | | - return array( 'new', 'fixme', 'reverted', 'resolved', 'ok', 'deferred', 'old' ); |
| 248 | + global $wgCodeReviewStates; |
| 249 | + return $wgCodeReviewStates; |
249 | 250 | } |
250 | 251 | |
251 | 252 | /** |
| 253 | + * List of all states that a user cannot set on their own revision |
| 254 | + * @return Array |
| 255 | + */ |
| 256 | + public static function getProtectedStates() { |
| 257 | + global $wgProtectedStates; |
| 258 | + return $wgProtectedStates; |
| 259 | + } |
| 260 | + |
| 261 | + /** |
252 | 262 | * @return array |
253 | 263 | */ |
254 | 264 | public static function getPossibleStateMessageKeys() { |
— | — | @@ -267,7 +277,8 @@ |
268 | 278 | * @return Array |
269 | 279 | */ |
270 | 280 | public static function getPossibleFlags() { |
271 | | - return array( 'inspected', 'tested' ); |
| 281 | + global $wgCodeReviewFlags; |
| 282 | + return $wgCodeReviewFlags; |
272 | 283 | } |
273 | 284 | |
274 | 285 | /** |
— | — | @@ -280,6 +291,15 @@ |
281 | 292 | } |
282 | 293 | |
283 | 294 | /** |
| 295 | + * Returns whether the provided status is protected |
| 296 | + * @param String $status |
| 297 | + * @return bool |
| 298 | + */ |
| 299 | + public static function isProtectedStatus( $status ) { |
| 300 | + return in_array( $status, self::getProtectedStates(), true ); |
| 301 | + } |
| 302 | + |
| 303 | + /** |
284 | 304 | * @throws MWException |
285 | 305 | * @param $status String, value in CodeRevision::getPossibleStates |
286 | 306 | * @param $user User |
— | — | @@ -293,7 +313,7 @@ |
294 | 314 | // Don't allow the user account tied to the committer account mark their own revisions as ok/resolved |
295 | 315 | // Obviously only works if user accounts are tied! |
296 | 316 | $wikiUser = $this->getWikiUser(); |
297 | | - if ( ( $status == 'ok' || $status == 'resolved' ) && $wikiUser && $user->getName() == $wikiUser->getName() ) { |
| 317 | + if ( self::isProtectedStatus( $status ) && $wikiUser && $user->getName() == $wikiUser->getName() ) { |
298 | 318 | // allow the user to review their own code if required |
299 | 319 | if ( !$wikiUser->isAllowed( 'codereview-review-own' ) ) { |
300 | 320 | return false; |