r67319 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67318‎ | r67319 | r67320 >
Date:01:41, 4 June 2010
Author:aaron
Status:deferred
Tags:
Comment:
Form permission check cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php
@@ -695,6 +695,15 @@
696696 $allowRereview = false; // re-review button
697697 }
698698
 699+ # Disable form for unprivileged users
 700+ $disabled = array();
 701+ if ( !$article->getTitle()->quickUserCan( 'review' ) ||
 702+ !$article->getTitle()->quickUserCan( 'edit' ) ||
 703+ !FlaggedRevs::userCanSetFlags( $flags ) )
 704+ {
 705+ $disabled = array( 'disabled' => 'disabled' );
 706+ }
 707+
699708 # Begin form...
700709 $reviewTitle = SpecialPage::getTitleFor( 'RevisionReview' );
701710 $action = $reviewTitle->getLocalUrl( 'action=submit' );
@@ -714,30 +723,25 @@
715724 $form .= wfMsgExt( 'revreview-text', array( 'parse' ) );
716725 }
717726
718 - # Disable form for unprivileged users
719 - $uneditable = !$article->getTitle()->quickUserCan( 'edit' );
720 - $disabled = !FlaggedRevs::userCanSetFlags( $flags ) || $uneditable;
721727 if ( $disabled ) {
722728 $form .= Xml::openElement( 'div', array( 'class' => 'fr-rating-controls-disabled',
723729 'id' => 'fr-rating-controls-disabled' ) );
724 - $toggle = array( 'disabled' => "disabled" );
725730 } else {
726731 $form .= Xml::openElement( 'div', array( 'class' => 'fr-rating-controls',
727732 'id' => 'fr-rating-controls' ) );
728 - $toggle = array();
729733 }
730734
731735 # Add main checkboxes/selects
732736 $form .= Xml::openElement( 'span', array( 'id' => 'mw-fr-ratingselects' ) );
733 - $form .= self::ratingInputs( $flags, $disabled, (bool)$frev );
 737+ $form .= self::ratingInputs( $flags, (bool)$disabled, (bool)$frev );
734738 $form .= Xml::closeElement( 'span' );
735739 # Add review notes input
736740 if ( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) {
737741 $form .= "<div id='mw-fr-notebox'>\n";
738742 $form .= "<p>" . wfMsgHtml( 'revreview-notes' ) . "</p>\n";
739 - $form .= Xml::openElement( 'textarea',
740 - array( 'name' => 'wpNotes', 'id' => 'wpNotes',
741 - 'class' => 'fr-notes-box', 'rows' => '2', 'cols' => '80' ) ) .
 743+ $params = array( 'name' => 'wpNotes', 'id' => 'wpNotes',
 744+ 'class' => 'fr-notes-box', 'rows' => '2', 'cols' => '80' ) + $disabled;
 745+ $form .= Xml::openElement( 'textarea', $params ) .
742746 htmlspecialchars( $reviewNotes ) .
743747 Xml::closeElement( 'textarea' ) . "\n";
744748 $form .= "</div>\n";
@@ -780,7 +784,7 @@
781785 array( 'class' => 'fr-comment-box' ) ) . "&#160;&#160;&#160;</span>";
782786 }
783787 # Add the submit buttons
784 - $form .= self::submitButtons( $frev, (bool)$toggle, $allowRereview );
 788+ $form .= self::submitButtons( $frev, (bool)$disabled, $allowRereview );
785789 # Show stability log if there is anything interesting...
786790 if ( $article->isPageLocked() ) {
787791 $form .= ' ' . FlaggedRevsXML::logToggle( 'revreview-log-toggle-show' );

Status & tagging log