only pass named parameters to the canremove hook

Signed-off-by: intrigeri <intrigeri@boum.org>
master
intrigeri 2009-01-26 23:07:19 +01:00
parent f02672c113
commit 78a095aa42
4 changed files with 12 additions and 12 deletions

View File

@ -442,10 +442,10 @@ sub checkcontent (@) {
return undef; return undef;
} }
sub canremove ($$$) { sub canremove (@) {
my ($page, $cgi, $session) = (shift, shift, shift); my %params = @_;
if (istranslation($page)) { if (istranslation($params{page})) {
return gettext("Can not remove a translation. Removing the master page, ". return gettext("Can not remove a translation. Removing the master page, ".
"though, removes its translations as well."); "though, removes its translations as well.");
} }

View File

@ -58,7 +58,7 @@ sub check_canremove ($$$) {
my $canremove; my $canremove;
IkiWiki::run_hooks(canremove => sub { IkiWiki::run_hooks(canremove => sub {
return if defined $canremove; return if defined $canremove;
my $ret=shift->($page, $q, $session); my $ret=shift->(page => $page, cgi => $q, session => $session);
if (defined $ret) { if (defined $ret) {
if ($ret eq "") { if ($ret eq "") {
$canremove=1; $canremove=1;

View File

@ -183,10 +183,8 @@ sub canedit ($$$) {
debug("skeleton plugin running in canedit"); debug("skeleton plugin running in canedit");
} }
sub canremove ($$$) { sub canremove (@) {
my $page=shift; my %params=@_;
my $cgi=shift;
my $session=shift;
debug("skeleton plugin running in canremove"); debug("skeleton plugin running in canremove");
} }

View File

@ -325,9 +325,11 @@ user can edit.
hook(type => "canremove", id => "foo", call => \&canremove); hook(type => "canremove", id => "foo", call => \&canremove);
This hook can be used to implement arbitrary access methods to control when This hook can be used to implement arbitrary access methods to control
a page can be removed using the web interface (commits from revision control when a page can be removed using the web interface (commits from
bypass it). It works exactly like the `canedit` hook. 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 ### 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 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 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 but is passed the named parameters `cgi` (a CGI object), `session` (a
session object), `src`, `srcfile`, `dest` and `destfile`. session object), `src`, `srcfile`, `dest` and `destfile`.