* @todo fold these checks into userCan()
*/
public function userCanRead() {
- global $wgUser;
+ global $wgUser, $wgGroupPermissions;
$result = null;
wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) );
return $result;
}
+ # Shortcut for public wikis, allows skipping quite a bit of code
+ if ($wgGroupPermissions['*']['read'])
+ return true;
+
if( $wgUser->isAllowed( 'read' ) ) {
return true;
} else {
* @return boolean True: action is allowed, False: action should not be allowed
*/
function isAllowed($action='') {
- global $wgGroupPermissions;
- if( $action === '' ) {
+ if ( $action === '' )
// In the spirit of DWIM
return true;
- }
- if( !empty( $wgGroupPermissions['*'][$action] ) ) {
- # Permissions are additive, so there's no need to unstub the User
- # object in this case.
- return true;
- }
return in_array( $action, $this->getRights() );
}