2007-02-02 03:33:03 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
package IkiWiki::Plugin::signinedit;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2007-04-27 04:55:52 +02:00
|
|
|
use IkiWiki 2.00;
|
2007-02-02 03:33:03 +01:00
|
|
|
|
|
|
|
sub import { #{{{
|
2008-08-04 01:35:35 +02:00
|
|
|
hook(type => "getsetup", id => "signinedit", call => \&getsetup);
|
2007-02-02 03:33:03 +01:00
|
|
|
hook(type => "canedit", id => "signinedit", call => \&canedit,
|
|
|
|
last => 1);
|
|
|
|
} # }}}
|
|
|
|
|
2008-08-04 01:35:35 +02:00
|
|
|
sub getsetup () { #{{{
|
|
|
|
return
|
|
|
|
plugin => {
|
|
|
|
safe => 1,
|
|
|
|
rebuild => 0,
|
|
|
|
},
|
|
|
|
} #}}}
|
|
|
|
|
2007-02-02 03:33:03 +01:00
|
|
|
sub canedit ($$$) { #{{{
|
|
|
|
my $page=shift;
|
|
|
|
my $cgi=shift;
|
|
|
|
my $session=shift;
|
|
|
|
|
|
|
|
# Have the user sign in, if they are not already. This is why the
|
|
|
|
# hook runs last, so that any hooks that don't need the user to
|
|
|
|
# signin can override this.
|
2008-01-07 22:34:13 +01:00
|
|
|
if (! defined $session->param("name") ||
|
2008-01-07 22:37:19 +01:00
|
|
|
! IkiWiki::userinfo_get($session->param("name"), "regdate")) {
|
2008-01-07 22:34:13 +01:00
|
|
|
return sub { IkiWiki::needsignin($cgi, $session) };
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "";
|
|
|
|
}
|
2007-02-02 03:33:03 +01:00
|
|
|
} #}}}
|
|
|
|
|
|
|
|
1
|