MK wrote:
I need a way to get the user's name and password
to obtain an "edit"
token to use with api.php for a form that will be a special page in an
extension.* I'm doing this as a volunteer for the FSF, so any advice
would be much appreciated ;)
I'm not much with php, but I tried testing this based on what I could
glean from Manual:Special_pages and includes/User.php:
function execute($par) {
global $wgOut, $wgUser;
$tmp = $wgUser->mCacheVars['mName'];
$wgOut->addWikiText("$tmp");
}
However, this results in:
Undefined property: User::$mCacheVars
in /usr/share/mediawiki/extensions/TestExt/TestExt_body.php on line 12
Ie, I seem unable to access any of the variable or functions that are
part of User although the User object is recognized. What am I doing
wrong?
$mCacheVars isn't what you think it is. And even if it did, you
shouldn't be accesing it directly anyway, you would get fields not yet
loaded, etc.
To get the user name, do:
$tmp = $wgUser->getName();
You can't get the user password. It's not stored in plaintext anywhere.
Just this points that you are trying to solve the wrong half mof the
problem.
And still, getting the token inside mediawiki wouldn't need having the
user and password...
* further clarification: the extension needs to
include a special page
for adding new pages to the wiki (the pages have a fairly complex
format including Semantic mark-up that the user should not need to
understand) but these need to be 1) restricted to privileged users,
No problem. You can require a right in order to use that Special Page.
Take a look at how other restricted special pages do it.
2) be added via the special page/form->api.php
including the real,
specific user who added the page.
Who added this requisite? The special page runs inside mediawiki, it can
directly insert the article, why would it need to go via api.php? (look
at FauxRequest if you still want to go this rout, but it seems the wrong
one)