Index: trunk/extensions/SimpleSecurity/SimpleSecurity_body.php |
— | — | @@ -20,10 +20,10 @@ |
21 | 21 | |
22 | 22 | # Add our hooks |
23 | 23 | $wgHooks['UserGetRights'][] = $this; |
| 24 | + $wgHooks['OutputPageBeforeHTML'][] = $this; |
24 | 25 | if ( $wgSecurityMagicIf ) $wgParser->setFunctionHook( $wgSecurityMagicIf, array( $this, 'ifUserCan' ) ); |
25 | 26 | if ( $wgSecurityMagicGroup ) $wgParser->setFunctionHook( $wgSecurityMagicGroup, array( $this, 'ifGroup' ) ); |
26 | 27 | if ( $wgSecurityAllowUnreadableLinks ) $wgHooks['BeforePageDisplay'][] = $this; |
27 | | - if ( $wgSecurityRenderInfo ) $wgHooks['OutputPageBeforeHTML'][] = $this; |
28 | 28 | |
29 | 29 | # Add a new log type |
30 | 30 | $wgLogTypes[] = 'security'; |
— | — | @@ -105,44 +105,51 @@ |
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Render security info if any restrictions on this title |
| 109 | + * Also make restricted pages not archive by robots |
109 | 110 | */ |
110 | 111 | public function onOutputPageBeforeHTML( &$out, &$text ) { |
111 | | - global $wgUser, $wgTitle; |
| 112 | + global $wgUser, $wgTitle, $wgSecurityRenderInfo; |
| 113 | + $title = $wgTitle; |
112 | 114 | |
113 | | - $title = $wgTitle; |
114 | | - # Render security info if any |
| 115 | + # Any restrictions? |
115 | 116 | if ( is_object( $title ) && $title->exists() && count( $this->info['LS'] ) + count( $this->info['PR'] ) ) { |
116 | 117 | |
117 | | - $rights = $wgUser->getRights(); |
118 | | - $title->getRestrictions( false ); |
119 | | - $reqgroups = $title->mRestrictions; |
120 | | - $sysop = in_array( 'sysop', $wgUser->getGroups() ); |
| 118 | + # Don't archive restricted pages |
| 119 | + $out->addMeta( "robots", "noarchive" ); |
121 | 120 | |
122 | | - # Build restrictions text |
123 | | - $itext = "<ul>\n"; |
124 | | - foreach ( $this->info as $source => $rules ) if ( !( $sysop && $source === 'CR' ) ) { |
125 | | - foreach ( $rules as $info ) { |
126 | | - list( $action, $groups, $comment ) = $info; |
127 | | - $gtext = $this->groupText( $groups ); |
128 | | - $itext .= "<li>" . wfMsg( 'security-inforestrict', "<b>$action</b>", $gtext ) . " $comment</li>\n"; |
| 121 | + # Render info if enabled |
| 122 | + if ( $wgSecurityRenderInfo ) { |
| 123 | + $rights = $wgUser->getRights(); |
| 124 | + $title->getRestrictions( false ); |
| 125 | + $reqgroups = $title->mRestrictions; |
| 126 | + $sysop = in_array( 'sysop', $wgUser->getGroups() ); |
| 127 | + |
| 128 | + # Build restrictions text |
| 129 | + $itext = "<ul>\n"; |
| 130 | + foreach ( $this->info as $source => $rules ) if ( !( $sysop && $source === 'CR' ) ) { |
| 131 | + foreach ( $rules as $info ) { |
| 132 | + list( $action, $groups, $comment ) = $info; |
| 133 | + $gtext = $this->groupText( $groups ); |
| 134 | + $itext .= "<li>" . wfMsg( 'security-inforestrict', "<b>$action</b>", $gtext ) . " $comment</li>\n"; |
| 135 | + } |
129 | 136 | } |
130 | | - } |
131 | | - if ( $sysop ) $itext .= "<li>" . wfMsg( 'security-infosysops' ) . "</li>\n"; |
132 | | - $itext .= "</ul>\n"; |
| 137 | + if ( $sysop ) $itext .= "<li>" . wfMsg( 'security-infosysops' ) . "</li>\n"; |
| 138 | + $itext .= "</ul>\n"; |
133 | 139 | |
134 | | - # Add some javascript to allow toggling the security-info |
135 | | - $out->addScript( "<script type='text/javascript'> |
136 | | - function toggleSecurityInfo() { |
137 | | - var info = document.getElementById('security-info'); |
138 | | - info.style.display = info.style.display ? '' : 'none'; |
139 | | - }</script>" |
140 | | - ); |
| 140 | + # Add some javascript to allow toggling the security-info |
| 141 | + $out->addScript( "<script type='text/javascript'> |
| 142 | + function toggleSecurityInfo() { |
| 143 | + var info = document.getElementById('security-info'); |
| 144 | + info.style.display = info.style.display ? '' : 'none'; |
| 145 | + }</script>" |
| 146 | + ); |
141 | 147 | |
142 | | - # Add info-toggle before title and hidden info after title |
143 | | - $link = "<a href='javascript:'>" . wfMsg( 'security-info-toggle' ) . "</a>"; |
144 | | - $link = "<span onClick='toggleSecurityInfo()'>$link</span>"; |
145 | | - $info = "<div id='security-info-toggle'>" . wfMsg( 'security-info', $link ) . "</div>\n"; |
146 | | - $text = "$info<div id='security-info' style='display:none'>$itext</div>\n$text"; |
| 148 | + # Add info-toggle before title and hidden info after title |
| 149 | + $link = "<a href='javascript:'>" . wfMsg( 'security-info-toggle' ) . "</a>"; |
| 150 | + $link = "<span onClick='toggleSecurityInfo()'>$link</span>"; |
| 151 | + $info = "<div id='security-info-toggle'>" . wfMsg( 'security-info', $link ) . "</div>\n"; |
| 152 | + $text = "$info<div id='security-info' style='display:none'>$itext</div>\n$text"; |
| 153 | + } |
147 | 154 | } |
148 | 155 | |
149 | 156 | return true; |
Index: trunk/extensions/SimpleSecurity/SimpleSecurity.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' ); |
24 | 24 | if ( version_compare( $wgVersion, '1.12.0' ) < 0 ) die( 'Sorry, this extension requires at least MediaWiki version 1.12.0' ); |
25 | 25 | |
26 | | -define( 'SIMPLESECURITY_VERSION', '4.3.4, 2009-07-29' ); |
| 26 | +define( 'SIMPLESECURITY_VERSION', '4.3.5, 2009-08-08' ); |
27 | 27 | |
28 | 28 | # Load the SimpleSecurity class and messages |
29 | 29 | $dir = dirname( __FILE__ ) . '/'; |