Index: trunk/phase3/includes/Article.php |
— | — | @@ -743,9 +743,7 @@ |
744 | 744 | if ( $this->mTitle->isProtected() ) { |
745 | 745 | $editrestr = $this->mTitle->getRestrictions('edit'); |
746 | 746 | $moverestr = $this->mTitle->getRestrictions('move'); |
747 | | - $wgOut->setSubtitle($wgOut->getSubtitle() . |
748 | | - wfMsg( 'protected-subtitle', |
749 | | - $editrestr[0], $moverestr[0] ) ); |
| 747 | + $this->addProtectionNotice( $editrestr, $moverestr ); |
750 | 748 | } |
751 | 749 | |
752 | 750 | $outputDone = false; |
— | — | @@ -894,6 +892,40 @@ |
895 | 893 | wfProfileOut( __METHOD__ ); |
896 | 894 | } |
897 | 895 | |
| 896 | + /* |
| 897 | + * Output a notice that a page is protected. Only give details for move/edit |
| 898 | + * restrictions. Cares only about the first permission in the arrays, which is |
| 899 | + * part of a larger shitty inconsistency about requiring several permissions... |
| 900 | + * @param Array $editrestr, edit restrictions |
| 901 | + * @param Array $moverestr, move restrictions |
| 902 | + */ |
| 903 | + function addProtectionNotice( $editrestr, $moverestr ) { |
| 904 | + global $wgOut; |
| 905 | + |
| 906 | + $editGroups = $moveGroups = ''; |
| 907 | + # Get groups that have each right |
| 908 | + if( !empty( $editrestr ) ) { |
| 909 | + $permission = ($editrestr[0]=='sysop') ? 'protect' : $editrestr[0]; |
| 910 | + $editGroups = $wgOut->getGroupsWithPermission( $permission ); |
| 911 | + $editGroups = implode( ', ', $editGroups ); |
| 912 | + } |
| 913 | + if( !empty( $moverestr ) ) { |
| 914 | + $permission = ($moverestr[0]=='sysop') ? 'protect' : $moverestr[0]; |
| 915 | + $moveGroups = $wgOut->getGroupsWithPermission( $permission ); |
| 916 | + $moveGroups = implode( ', ', $moveGroups ); |
| 917 | + } |
| 918 | + # Use general messages if no groups found for a type |
| 919 | + if( !$editGroups || !$moveGroups ) { |
| 920 | + $msg = wfMsg( 'protected-subtitle3' ); |
| 921 | + } else if( $editGroups == $moveGroups ) { |
| 922 | + $msg = wfMsg( 'protected-subtitle2', $editGroups, $moveGroups ); |
| 923 | + } else { |
| 924 | + $msg = wfMsg( 'protected-subtitle', $editGroups, $moveGroups ); |
| 925 | + } |
| 926 | + |
| 927 | + $wgOut->setSubtitle( $wgOut->getSubtitle() . $msg ); |
| 928 | + } |
| 929 | + |
898 | 930 | function addTrackbacks() { |
899 | 931 | global $wgOut, $wgUser; |
900 | 932 | |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -878,7 +878,7 @@ |
879 | 879 | * @param string $permission key required |
880 | 880 | */ |
881 | 881 | public function permissionRequired( $permission ) { |
882 | | - global $wgGroupPermissions, $wgUser; |
| 882 | + global $wgUser; |
883 | 883 | |
884 | 884 | $this->setPageTitle( wfMsg( 'badaccess' ) ); |
885 | 885 | $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) ); |
— | — | @@ -886,19 +886,7 @@ |
887 | 887 | $this->setArticleRelated( false ); |
888 | 888 | $this->mBodytext = ''; |
889 | 889 | |
890 | | - $groups = array(); |
891 | | - foreach( $wgGroupPermissions as $key => $value ) { |
892 | | - if( isset( $value[$permission] ) && $value[$permission] == true ) { |
893 | | - $groupName = User::getGroupName( $key ); |
894 | | - $groupPage = User::getGroupPage( $key ); |
895 | | - if( $groupPage ) { |
896 | | - $skin = $wgUser->getSkin(); |
897 | | - $groups[] = $skin->makeLinkObj( $groupPage, $groupName ); |
898 | | - } else { |
899 | | - $groups[] = $groupName; |
900 | | - } |
901 | | - } |
902 | | - } |
| 890 | + $groups = $this->getGroupsWithPermission( $permission ); |
903 | 891 | $n = count( $groups ); |
904 | 892 | $groups = implode( ', ', $groups ); |
905 | 893 | switch( $n ) { |
— | — | @@ -913,7 +901,31 @@ |
914 | 902 | $this->addHtml( $message ); |
915 | 903 | $this->returnToMain( false ); |
916 | 904 | } |
| 905 | + |
| 906 | + /** |
| 907 | + * Return an array of the groups in (UI name form) that have a permission |
| 908 | + * |
| 909 | + * @param string $permission key required |
| 910 | + */ |
| 911 | + public function getGroupsWithPermission( $permission ) { |
| 912 | + global $wgUser, $wgGroupPermissions; |
917 | 913 | |
| 914 | + $groups = array(); |
| 915 | + foreach( $wgGroupPermissions as $key => $value ) { |
| 916 | + if( isset( $value[$permission] ) && $value[$permission] == true ) { |
| 917 | + $groupName = User::getGroupName( $key ); |
| 918 | + $groupPage = User::getGroupPage( $key ); |
| 919 | + if( $groupPage ) { |
| 920 | + $skin = $wgUser->getSkin(); |
| 921 | + $groups[] = $skin->makeLinkObj( $groupPage, $groupName ); |
| 922 | + } else { |
| 923 | + $groups[] = $groupName; |
| 924 | + } |
| 925 | + } |
| 926 | + } |
| 927 | + return $groups; |
| 928 | + } |
| 929 | + |
918 | 930 | /** |
919 | 931 | * Use permissionRequired. |
920 | 932 | * @deprecated |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -797,7 +797,9 @@ |
798 | 798 | 'namespaceprotected' => "You do not have permission to edit pages in the '''$1''' namespace.", |
799 | 799 | 'customcssjsprotected' => "You do not have permission to edit this page, because it contains another user's personal settings.", |
800 | 800 | 'ns-specialprotected' => "Pages in the {{ns:special}} namespace cannot be edited.", |
801 | | -'protected-subtitle' => "<!-- This message will be displayed as the subtitle for pages that are protected. The argument $1 is the level of edit-protection (i.e., sysop or autoconfirmed), and $2 is the level of move-protection. --> (This page is protected.)", |
| 801 | +'protected-subtitle' => "(This page is protected. Only certain users ($1) can edit and others ($2) can move it.)", |
| 802 | +'protected-subtitle2' => "(This page is protected. Only certain users ($1) can edit and move it.)", |
| 803 | +'protected-subtitle3' => "(This page is protected)", |
802 | 804 | |
803 | 805 | # Login and logout pages |
804 | 806 | 'logouttitle' => 'User logout', |
— | — | @@ -1321,6 +1323,8 @@ |
1322 | 1324 | 'group-bureaucrat' => 'Bureaucrats', |
1323 | 1325 | 'group-all' => '(all)', |
1324 | 1326 | |
| 1327 | +'group-autoconfirmed' => 'autoconfirmed', |
| 1328 | + |
1325 | 1329 | 'group-bot-member' => 'Bot', |
1326 | 1330 | 'group-sysop-member' => 'Sysop', |
1327 | 1331 | 'group-bureaucrat-member' => 'Bureaucrat', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -190,6 +190,8 @@ |
191 | 191 | * Add accesskey 's' and tooltip to 'upload file' button at Special:Upload |
192 | 192 | * Introduced 'SkinAfterBottomScripts' hook; see docs/hooks.txt for |
193 | 193 | more information |
| 194 | +* (bug 10347) Give notice when a page is viewed that is protected. Does not |
| 195 | + show for cascade protection however. |
194 | 196 | |
195 | 197 | == Bugfixes since 1.10 == |
196 | 198 | |