[Mediawiki-l] Keeping It Pretty when Disabling IP Edits

Emufarmers Sangly emufarmers at gmail.com
Wed Apr 18 09:03:26 UTC 2007


So I've decided to disable IP edits for my wiki.  Easy enough, but the
results are less than satisfactory aesthetically: The "edit" link remains at
the top of the screen for unregistered users, and they get a jarring error
message when they click on it. (I could probably tweak that to give them an
option to view the source, but the edit link would still be there.) That's
using the "typical" method of doing this.  I also found some code (
http://meta.wikimedia.org/wiki/Preventing_Access#Questions scroll down a
little bit) that does this by essentially making all pages protected with
regards to unregistered users:

function fnMyUserCan($title, $user, $action, $result)
{
  if (($action == 'edit') && $user->isAnon())
    $result = false;
}
$wgHooks['userCan'][] = 'fnMyUserCan';

The problem with this method is that it shows the same "view source" button
(and the same tooltip for it), and the same destination page for that, as
would be shown if the page really were protected!  This means that I would
have to change the "view source" page to say, "well, this page could be
protected, or it could be semi-protected, or it could just be that you need
to login; I really can't tell you which."  That might seem rather
complicated to a reader.

So, is there any way I can rewrite the second method to use a separate "view
source" button (which could have its own tooltip) and a separate "you need
to log in to edit, but here's the source" page for its destination?


More information about the MediaWiki-l mailing list