Index: trunk/extensions/SimpleSecurity/SimpleSecurity.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | |
20 | 20 | if (!defined('MEDIAWIKI')) die('Not an entry point.'); |
21 | 21 | |
22 | | -define('SIMPLESECURITY_VERSION', '4.2.1, 2008-08-26'); |
| 22 | +define('SIMPLESECURITY_VERSION', '4.2.2, 2008-08-26'); |
23 | 23 | |
24 | 24 | # Global security settings |
25 | 25 | $wgSecurityMagicIf = "ifusercan"; # the name for doing a permission-based conditional |
— | — | @@ -142,9 +142,9 @@ |
143 | 143 | */ |
144 | 144 | public function onOutputPageBeforeHTML(&$out, &$text) { |
145 | 145 | global $wgTitle, $wgUser; |
146 | | - |
| 146 | + |
147 | 147 | # Render security info if any |
148 | | - if (count($this->info)) { |
| 148 | + if (is_object($wgTitle) && $wgTitle->exists() && count($this->info['LS'])+count($this->info['PR'])) { |
149 | 149 | |
150 | 150 | $rights = $wgUser->getRights(); |
151 | 151 | $wgTitle->getRestrictions(false); |
— | — | @@ -216,8 +216,15 @@ |
217 | 217 | elseif ($wgRequest->getVal('oldtitle')) $title = Title::newFromText($wgRequest->getVal('oldtitle')); |
218 | 218 | } else $title = $wgTitle; |
219 | 219 | if (!is_object($title)) return true; # If still no usable title bail |
220 | | - |
221 | | - # Process $wgPageRestrictions |
| 220 | + |
| 221 | + # Validate the title and then put anonymous read right back (see constructor above for details) |
| 222 | + $valid = $this->validateTitle($user, $title, $error); |
| 223 | + if ($this->default_read) { |
| 224 | + $wgGroupPermissions['*']['read'] = true; |
| 225 | + $rights[] = 'read'; |
| 226 | + } |
| 227 | + |
| 228 | + # Filter rights by processing $wgPageRestrictions |
222 | 229 | # - also adds LS (rules from local settings) items to info array |
223 | 230 | $this->pageRestrictions($rights, $groups, $title); |
224 | 231 | |
— | — | @@ -230,11 +237,9 @@ |
231 | 238 | } |
232 | 239 | |
233 | 240 | # If title is not readable by user, remove the read and move rights |
234 | | - if (!in_array('sysop', $groups)) { |
235 | | - if (!$this->validateTitle($user, $title, $error)) { |
236 | | - foreach ($rights as $i => $right) if ($right === 'read' || $right === 'move') unset($rights[$i]); |
237 | | - #$this->info['CR'] = array('read', '', ''); |
238 | | - } elseif ($this->default_read) $wgGroupPermissions['*']['read'] = $this->default_read; # see constructor |
| 241 | + if (!in_array('sysop', $groups) && !$valid) { |
| 242 | + foreach ($rights as $i => $right) if ($right === 'read' || $right === 'move') unset($rights[$i]); |
| 243 | + #$this->info['CR'] = array('read', '', ''); |
239 | 244 | } |
240 | 245 | |
241 | 246 | return true; |
— | — | @@ -405,7 +410,7 @@ |
406 | 411 | if ($wgSecurityUseDBHook) { |
407 | 412 | global $wgDBtype, $wgLoadBalancer; |
408 | 413 | |
409 | | - # Swicth DB type to new class |
| 414 | + # Switch DB type to new class |
410 | 415 | $wgDBtype = ucfirst($wgDBtype); |
411 | 416 | $oldType = $wgDBtype; |
412 | 417 | $wgDBtype = "Secure$wgDBtype"; |