*Make a separate function in article for showing protection notice thingy on view. List out who can edit/move the page.
*Some messages added for above. Remove annoying html comment from one.
*Fix php array index errors with protection notice
* Add accesskey 's' and tooltip to 'upload file' button at Special:Upload
* Introduced 'SkinAfterBottomScripts' hook; see docs/hooks.txt for
more information
+* (bug 10347) Give notice when a page is viewed that is protected. Does not
+ show for cascade protection however.
== Bugfixes since 1.10 ==
if ( $this->mTitle->isProtected() ) {
$editrestr = $this->mTitle->getRestrictions('edit');
$moverestr = $this->mTitle->getRestrictions('move');
- $wgOut->setSubtitle($wgOut->getSubtitle() .
- wfMsg( 'protected-subtitle',
- $editrestr[0], $moverestr[0] ) );
+ $this->addProtectionNotice( $editrestr, $moverestr );
}
$outputDone = false;
wfProfileOut( __METHOD__ );
}
+ /*
+ * Output a notice that a page is protected. Only give details for move/edit
+ * restrictions. Cares only about the first permission in the arrays, which is
+ * part of a larger shitty inconsistency about requiring several permissions...
+ * @param Array $editrestr, edit restrictions
+ * @param Array $moverestr, move restrictions
+ */
+ function addProtectionNotice( $editrestr, $moverestr ) {
+ global $wgOut;
+
+ $editGroups = $moveGroups = '';
+ # Get groups that have each right
+ if( !empty( $editrestr ) ) {
+ $permission = ($editrestr[0]=='sysop') ? 'protect' : $editrestr[0];
+ $editGroups = $wgOut->getGroupsWithPermission( $permission );
+ $editGroups = implode( ', ', $editGroups );
+ }
+ if( !empty( $moverestr ) ) {
+ $permission = ($moverestr[0]=='sysop') ? 'protect' : $moverestr[0];
+ $moveGroups = $wgOut->getGroupsWithPermission( $permission );
+ $moveGroups = implode( ', ', $moveGroups );
+ }
+ # Use general messages if no groups found for a type
+ if( !$editGroups || !$moveGroups ) {
+ $msg = wfMsg( 'protected-subtitle3' );
+ } else if( $editGroups == $moveGroups ) {
+ $msg = wfMsg( 'protected-subtitle2', $editGroups, $moveGroups );
+ } else {
+ $msg = wfMsg( 'protected-subtitle', $editGroups, $moveGroups );
+ }
+
+ $wgOut->setSubtitle( $wgOut->getSubtitle() . $msg );
+ }
+
function addTrackbacks() {
global $wgOut, $wgUser;
* @param string $permission key required
*/
public function permissionRequired( $permission ) {
- global $wgGroupPermissions, $wgUser;
+ global $wgUser;
$this->setPageTitle( wfMsg( 'badaccess' ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
$this->setArticleRelated( false );
$this->mBodytext = '';
- $groups = array();
- foreach( $wgGroupPermissions as $key => $value ) {
- if( isset( $value[$permission] ) && $value[$permission] == true ) {
- $groupName = User::getGroupName( $key );
- $groupPage = User::getGroupPage( $key );
- if( $groupPage ) {
- $skin = $wgUser->getSkin();
- $groups[] = $skin->makeLinkObj( $groupPage, $groupName );
- } else {
- $groups[] = $groupName;
- }
- }
- }
+ $groups = $this->getGroupsWithPermission( $permission );
$n = count( $groups );
$groups = implode( ', ', $groups );
switch( $n ) {
$this->addHtml( $message );
$this->returnToMain( false );
}
+
+ /**
+ * Return an array of the groups in (UI name form) that have a permission
+ *
+ * @param string $permission key required
+ */
+ public function getGroupsWithPermission( $permission ) {
+ global $wgUser, $wgGroupPermissions;
+
+ $groups = array();
+ foreach( $wgGroupPermissions as $key => $value ) {
+ if( isset( $value[$permission] ) && $value[$permission] == true ) {
+ $groupName = User::getGroupName( $key );
+ $groupPage = User::getGroupPage( $key );
+ if( $groupPage ) {
+ $skin = $wgUser->getSkin();
+ $groups[] = $skin->makeLinkObj( $groupPage, $groupName );
+ } else {
+ $groups[] = $groupName;
+ }
+ }
+ }
+ return $groups;
+ }
/**
* Use permissionRequired.
'namespaceprotected' => "You do not have permission to edit pages in the '''$1''' namespace.",
'customcssjsprotected' => "You do not have permission to edit this page, because it contains another user's personal settings.",
'ns-specialprotected' => "Pages in the {{ns:special}} namespace cannot be edited.",
-'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.)",
+'protected-subtitle' => "(This page is protected. Only certain users ($1) can edit and others ($2) can move it.)",
+'protected-subtitle2' => "(This page is protected. Only certain users ($1) can edit and move it.)",
+'protected-subtitle3' => "(This page is protected)",
# Login and logout pages
'logouttitle' => 'User logout',
'group-bureaucrat' => 'Bureaucrats',
'group-all' => '(all)',
+'group-autoconfirmed' => 'autoconfirmed',
+
'group-bot-member' => 'Bot',
'group-sysop-member' => 'Sysop',
'group-bureaucrat-member' => 'Bureaucrat',