If the site options are set in such a way that only sysops (or only
authorArne Heizmann <timwi@users.mediawiki.org>
Tue, 10 Aug 2004 16:58:37 +0000 (16:58 +0000)
committerArne Heizmann <timwi@users.mediawiki.org>
Tue, 10 Aug 2004 16:58:37 +0000 (16:58 +0000)
developers) can create new accounts, currently the only way for them to
do that is to go to Special:Userlogin manually.  This patch adds a link
to that page on Special:Specialpages, but only if the options are set in
this way.

includes/SpecialPage.php

index 46b8aaa..dab7b7a 100644 (file)
@@ -1,7 +1,24 @@
 <?php
-global $wgSpecialPages;
+global $wgSpecialPages, $wgWhitelistAccount;
+
+# Special:Userlogin is a peculiar case: If the site options tell us to allow only sysops to
+# create new accounts, we want it displayed under "For sysop use only". If it's for developers
+# only, display it there. If anyone can create an account, we don't want it listed at all,
+# because there would already be a "create account or login" link in the top-right corner of
+# the page. If nobody can create an account, we don't want it listed either.
+
+$userlogin_listed = true;
+$userlogin_restr = '';
+if ( $wgWhitelistAccount && $wgWhitelistAccount['sysop'] && !$wgWhitelistAccount['user'] )
+       $userlogin_restr = 'sysop';
+else if ( $wgWhitelistAccount && $wgWhitelistAccount['developer'] &&
+          !$wgWhitelistAccount['sysop'] && !$wgWhitelistAccount['user'] )
+       $userlogin_restr = 'developer';
+else
+       $userlogin_listed = false;
+
 $wgSpecialPages = array(
-       "Userlogin"         => new UnlistedSpecialPage( "Userlogin" ),
+       "Userlogin"         => new SpecialPage( "Userlogin", $userlogin_restr, $userlogin_listed ),
        "Userlogout"        => new UnlistedSpecialPage( "Userlogout" ),
        "Preferences"       => new SpecialPage( "Preferences" ),
        "Watchlist"         => new SpecialPage( "Watchlist" ),