[Home]WikiPatches/RequireAUserName

UseModWiki | WikiPatches | RecentChanges | Preferences

See also: /NoAnonyms, LoginRework

Patch

Add this subroutine....

sub UserNamePresent {
  my ($userName);

  $userName = &GetParam("username","");
  if( $userName eq "" ) {
      return 0;
  }

  return 1;
}

..... And in the DoEdit subroutine, after all of the local variable decl ...

  if (!&UserNamePresent()) {
    print &GetHeader("", T('Editing Denied'), "");
    print Ts('Editing not allowed on %1 without a username. Please set your Preferences.', $SiteName);
    print &GetCommonFooter();
    return;
  }

See in action

You can try this out here: http://www.discursive.com/cgi-bin/wiki.pl; alternately [@archive.org].

[I know, I know, I know, the fact that I've created a separate UserNamePresent subroutine could be viewed as overengineering, but I wanted to leave room for expansion in case someone wants to add more features later...]


removed wiki words from the Perl Code (since question marks at the end of function calls are not incredibly useful) -ezterry (Feb 6, 2003)

Minor Tweak

A small but possibly useful extension to this is to add a global SandBox variable, and initialize that to the name of your sandbox page. Then change the check to

  if (!UserNamePresent() && ($id ne $SandBox)) {
     print &GetHeader("", T('Editing Denied'), "");
     print Tss('Editing %1 on %2 not allowed without a username. Please set your preferences.', $id, $SiteName);
     print &GetCommonFooter();
     return;
  }

so editting the sandbox is always allowed to guests, thus increasing the 'great, let's play' factor without sacrificing the purpose of this patch. -Jurriaan (Dec 6, 2003)


You would also need something on uploads as well. Even if it is a Sandbox you don't want anyone uploading anything. --MarkButler

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited January 27, 2008 9:57 am by JuanmaMP (diff)
Search: