Index: trunk/phase3/includes/ProtectionForm.php |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | var $mReason = ''; |
30 | 30 | var $mCascade = false; |
31 | 31 | var $mExpiry = null; |
| 32 | + var $mPermErrors = array(); |
32 | 33 | |
33 | 34 | function __construct( &$article ) { |
34 | 35 | global $wgRequest, $wgUser; |
— | — | @@ -56,7 +57,7 @@ |
57 | 58 | } |
58 | 59 | |
59 | 60 | // The form will be available in read-only to show levels. |
60 | | - $this->disabled = !$wgUser->isAllowed( 'protect' ) || wfReadOnly() || $wgUser->isBlocked(); |
| 61 | + $this->disabled = ($this->mPermErrors = $this->mTitle->getUserPermissionsErrors('protect',$wgUser)) != array(); |
61 | 62 | $this->disabledAttrib = $this->disabled |
62 | 63 | ? array( 'disabled' => 'disabled' ) |
63 | 64 | : array(); |
— | — | @@ -125,22 +126,11 @@ |
126 | 127 | # Show an appropriate message if the user isn't allowed or able to change |
127 | 128 | # the protection settings at this time |
128 | 129 | if( $this->disabled ) { |
129 | | - if( $wgUser->isAllowed( 'protect' ) ) { |
130 | | - if( $wgUser->isBlocked() ) { |
131 | | - # Blocked |
132 | | - $message = 'protect-locked-blocked'; |
133 | | - } else { |
134 | | - # Database lock |
135 | | - $message = 'protect-locked-dblock'; |
136 | | - } |
137 | | - } else { |
138 | | - # Permission error |
139 | | - $message = 'protect-locked-access'; |
140 | | - } |
| 130 | + $message = $wgOut->formatPermissionsErrorMessage( $this->mPermErrors ); |
141 | 131 | } else { |
142 | | - $message = 'protect-text'; |
| 132 | + $message = wfMsg( 'protect-text', wfEscapeWikiText( $this->mTitle->getPrefixedText() ) ); |
143 | 133 | } |
144 | | - $wgOut->addWikiText( wfMsg( $message, wfEscapeWikiText( $this->mTitle->getPrefixedText() ) ) ); |
| 134 | + $wgOut->addWikiText( $message ); |
145 | 135 | |
146 | 136 | $wgOut->addHTML( $this->buildForm() ); |
147 | 137 | |
— | — | @@ -394,4 +384,4 @@ |
395 | 385 | $logViewer->showList( $out ); |
396 | 386 | } |
397 | 387 | |
398 | | -} |
\ No newline at end of file |
| 388 | +} |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1709,7 +1709,7 @@ |
1710 | 1710 | global $wgUser, $wgRestrictionTypes, $wgContLang; |
1711 | 1711 | |
1712 | 1712 | $id = $this->mTitle->getArticleID(); |
1713 | | - if( !$wgUser->isAllowed( 'protect' ) || wfReadOnly() || $id == 0 ) { |
| 1713 | + if( array() != $this->mTitle->getUserPermissionsErrors( 'protect', $wgUser ) || wfReadOnly() || $id == 0 ) { |
1714 | 1714 | return false; |
1715 | 1715 | } |
1716 | 1716 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1188,6 +1188,13 @@ |
1189 | 1189 | } |
1190 | 1190 | } |
1191 | 1191 | |
| 1192 | + if ($action == 'protect') |
| 1193 | + { |
| 1194 | + if ($this->getUserPermissionsErrors('edit', $user) != array()) { |
| 1195 | + $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect. |
| 1196 | + } |
| 1197 | + } |
| 1198 | + |
1192 | 1199 | if( $action == 'create' ) { |
1193 | 1200 | if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) || |
1194 | 1201 | ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) ) { |
— | — | @@ -1195,9 +1202,9 @@ |
1196 | 1203 | } |
1197 | 1204 | } elseif( $action == 'move' && !( $this->isMovable() && $user->isAllowed( 'move' ) ) ) { |
1198 | 1205 | $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed'); |
1199 | | - } else if ( !$user->isAllowed( $action ) ) { |
| 1206 | + } else if ( !$user->isAllowed( $action ) ) { |
1200 | 1207 | $return = null; |
1201 | | - $groups = array(); |
| 1208 | + $groups = array(); |
1202 | 1209 | global $wgGroupPermissions; |
1203 | 1210 | foreach( $wgGroupPermissions as $key => $value ) { |
1204 | 1211 | if( isset( $value[$action] ) && $value[$action] == true ) { |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1941,6 +1941,7 @@ |
1942 | 1942 | 'protect-summary-cascade' => 'cascading', |
1943 | 1943 | 'protect-expiring' => 'expires $1 (UTC)', |
1944 | 1944 | 'protect-cascade' => 'Protect pages included in this page (cascading protection)', |
| 1945 | +'protect-cantedit' => 'You cannot change the protection levels of this page, because you do not have permission to edit it.', |
1945 | 1946 | 'restriction-type' => 'Permission:', |
1946 | 1947 | 'restriction-level' => 'Restriction level:', |
1947 | 1948 | 'minimum-size' => 'Min size', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -202,6 +202,7 @@ |
203 | 203 | * namespaceDupes.php no longer dies when coming across an illegal title |
204 | 204 | * (bug 12143) Do not show a link to patrol new pages for non existent pages |
205 | 205 | * (bug 12166) Fix XHTML validity for Special:Emailuser |
| 206 | +* (bug 11346) Users who cannot edit a page can now no longer unprotect it. |
206 | 207 | |
207 | 208 | == Parser changes in 1.12 == |
208 | 209 | |