Reputation: 365
I'm trying to extend the user class of MediaWiki by adding some methods like $user->getNameOfPet()
. E.g. the extension Article_Class_Extended
extends the default article class using a hook:
$wgExtensionFunctions[] = "wfArticleExSetup";
function wfArticleExSetup()
{
global $wgHooks;
$wgHooks['ArticleFromTitle'][] = 'wfArticleExInit';
}
function wfArticleExInit( &$title, &$article )
{
// What really counts is what is returned in $article.
$GLOBALS['wgArticle'] = new ArticleExClass( $title, $article, true );
return true;
}
Is there a way for extending the user class in a similar way? I'm using MediaWiki 1.16.5.
Upvotes: 1
Views: 178
Reputation: 116140
I think from your settings file you could call
RequestContext::getMain()->setUser(new User());
I've used this to force an 'empty' (not logged in) user. If this call lets you set a user object, you should be able to feed it a User descendant as well. This line is similar to the line in Setup.php that sets the $wgUser global.
Upvotes: 1