Subject: | Detect Logged In Username On Edits |
When loading a page for edit, it is possible to load the current logged
in username (if there is one) by looking at the JavaScript generated by
MediaWiki, in the wgUserName variable. This is very useful to me, and
I've made a one-line patch that adds it as a page variable when a page
is loaded rw:
Index: page.pm
===================================================================
--- page.pm (revision 123)
+++ page.pm (working copy)
@@ -251,6 +251,7 @@
$obj->{content} = $a;
$obj->{exists} = 1;
+ ($obj->{loggedinuser}) = $t =~ m/var wgUserName = "(.*?)"/;
}
$obj->prepare_update_tokens($t);
return;
It may make sense to do something with this in MediaWiki.pm as well,
updating the object's internal state if it is determined that the user
is no longer logged in. I'm not sure if this is easy or not, though, so
it may be best left up to an application-level thing.
Thanks,
Tim