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