summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2009-01-26 23:07:19 +0100
committerintrigeri <intrigeri@boum.org>2009-01-26 23:07:19 +0100
commit78a095aa42acf19b5b28ca402d14e88e6dcf5c3b (patch)
tree5096ecb3986e9d3955cb55b7c91113c15411fe81
parentf02672c113813c37a659991ae984a2368e15b8db (diff)
only pass named parameters to the canremove hook
Signed-off-by: intrigeri <intrigeri@boum.org>
-rw-r--r--IkiWiki/Plugin/po.pm6
-rw-r--r--IkiWiki/Plugin/remove.pm2
-rw-r--r--IkiWiki/Plugin/skeleton.pm.example6
-rw-r--r--doc/plugins/write.mdwn10
4 files changed, 12 insertions, 12 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index b579d1f08..363720e1d 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -442,10 +442,10 @@ sub checkcontent (@) {
return undef;
}
-sub canremove ($$$) {
- my ($page, $cgi, $session) = (shift, shift, shift);
+sub canremove (@) {
+ my %params = @_;
- if (istranslation($page)) {
+ if (istranslation($params{page})) {
return gettext("Can not remove a translation. Removing the master page, ".
"though, removes its translations as well.");
}
diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm
index 3f1704846..cbc8a0f2c 100644
--- a/IkiWiki/Plugin/remove.pm
+++ b/IkiWiki/Plugin/remove.pm
@@ -58,7 +58,7 @@ sub check_canremove ($$$) {
my $canremove;
IkiWiki::run_hooks(canremove => sub {
return if defined $canremove;
- my $ret=shift->($page, $q, $session);
+ my $ret=shift->(page => $page, cgi => $q, session => $session);
if (defined $ret) {
if ($ret eq "") {
$canremove=1;
diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example
index ec5a0c725..6a97fb2f2 100644
--- a/IkiWiki/Plugin/skeleton.pm.example
+++ b/IkiWiki/Plugin/skeleton.pm.example
@@ -183,10 +183,8 @@ sub canedit ($$$) {
debug("skeleton plugin running in canedit");
}
-sub canremove ($$$) {
- my $page=shift;
- my $cgi=shift;
- my $session=shift;
+sub canremove (@) {
+ my %params=@_;
debug("skeleton plugin running in canremove");
}
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index b60dc66f2..dde0d431c 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -325,9 +325,11 @@ user can edit.
hook(type => "canremove", id => "foo", call => \&canremove);
-This hook can be used to implement arbitrary access methods to control when
-a page can be removed using the web interface (commits from revision control
-bypass it). It works exactly like the `canedit` hook.
+This hook can be used to implement arbitrary access methods to control
+when a page can be removed using the web interface (commits from
+revision control bypass it). It works exactly like the `canedit` hook,
+but is passed the named parameters `cgi` (a CGI object), `session`
+(a session object) and `page` (the page subject to deletion).
### canrename
@@ -335,7 +337,7 @@ bypass it). It works exactly like the `canedit` hook.
This hook can be used to implement arbitrary access methods to control when
a page can be renamed using the web interface (commits from revision control
-bypass it). It works exactly like the `canedit` and `canremove` hook,
+bypass it). It works exactly like the `canedit` hook,
but is passed the named parameters `cgi` (a CGI object), `session` (a
session object), `src`, `srcfile`, `dest` and `destfile`.