* Improved the canedit hook interface, allowing a callback function to be
[ikiwiki.git] / IkiWiki / Plugin / signinedit.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::signinedit;
3
4 use warnings;
5 use strict;
6 use IkiWiki 2.00;
7
8 sub import { #{{{
9         hook(type => "canedit", id => "signinedit", call => \&canedit,
10              last => 1);
11 } # }}}
12
13 sub canedit ($$$) { #{{{
14         my $page=shift;
15         my $cgi=shift;
16         my $session=shift;
17
18         # Have the user sign in, if they are not already. This is why the
19         # hook runs last, so that any hooks that don't need the user to
20         # signin can override this.
21         if (! defined $session->param("name") ||
22             ! userinfo_get($session->param("name"), "regdate")) {
23                 return sub { IkiWiki::needsignin($cgi, $session) };
24         }
25         else {
26                 return "";
27         }
28 } #}}}
29
30 1