aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/CGI.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-07 16:34:13 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-07 16:34:13 -0500
commitc487b847e2053b13c4eea0ccfeecf5a41c396412 (patch)
treec58c8a1dcc3372907fdc2e2940dcc3cc5faf4adf /IkiWiki/CGI.pm
parent45de8dc710bf5844ed99514342bade439c396084 (diff)
downloadikiwiki-c487b847e2053b13c4eea0ccfeecf5a41c396412.tar
ikiwiki-c487b847e2053b13c4eea0ccfeecf5a41c396412.tar.gz
* Improved the canedit hook interface, allowing a callback function to be
returned (and not run in some cases) rather than the plugins directly forcing a user to log in. * opendiscussion: allow editing of the toplevel discussion page, and, indirectly, allow creating new discussion pages.
Diffstat (limited to 'IkiWiki/CGI.pm')
-rw-r--r--IkiWiki/CGI.pm21
1 files changed, 14 insertions, 7 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 197eabcf0..a6695b3a5 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -20,7 +20,7 @@ sub printheader ($) { #{{{
}
} #}}}
-
+
sub showform ($$$$) { #{{{
my $form=shift;
my $buttons=shift;
@@ -57,15 +57,22 @@ sub check_canedit ($$$;$) { #{{{
my $nonfatal=shift;
my $canedit;
+ my $callback;
run_hooks(canedit => sub {
return if defined $canedit;
my $ret=shift->($page, $q, $session);
- if (defined $ret && $ret eq "") {
- $canedit=1;
- }
- elsif (defined $ret) {
- $canedit=0;
- error($ret) unless $nonfatal;
+ if (defined $ret) {
+ if ($ret eq "") {
+ $canedit=1;
+ }
+ elsif (ref $ret eq 'CODE') {
+ $canedit=0;
+ $callback->() unless $nonfatal;
+ }
+ elsif (defined $ret) {
+ $canedit=0;
+ error($ret) unless $nonfatal;
+ }
}
});
return $canedit;