remove: implemented a new canremove hook; use it in the po plugin
Signed-off-by: intrigeri <intrigeri@boum.org>master
parent
5852f03efa
commit
741b26aa17
|
@ -39,6 +39,7 @@ sub import {
|
||||||
hook(type => "rename", id => "po", call => \&renamepages);
|
hook(type => "rename", id => "po", call => \&renamepages);
|
||||||
hook(type => "delete", id => "po", call => \&mydelete);
|
hook(type => "delete", id => "po", call => \&mydelete);
|
||||||
hook(type => "change", id => "po", call => \&change);
|
hook(type => "change", id => "po", call => \&change);
|
||||||
|
hook(type => "canremove", id => "po", call => \&canremove);
|
||||||
hook(type => "editcontent", id => "po", call => \&editcontent);
|
hook(type => "editcontent", id => "po", call => \&editcontent);
|
||||||
|
|
||||||
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
|
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
|
||||||
|
@ -406,6 +407,16 @@ sub change(@) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub canremove ($$$) {
|
||||||
|
my ($page, $cgi, $session) = (shift, shift, shift);
|
||||||
|
|
||||||
|
if (istranslation($page)) {
|
||||||
|
return gettext("Can not remove a translation. Removing the master page,".
|
||||||
|
"though, removes its translations as well.");
|
||||||
|
}
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
# As we're previewing or saving a page, the content may have
|
# As we're previewing or saving a page, the content may have
|
||||||
# changed, so tell the next filter() invocation it must not be lazy.
|
# changed, so tell the next filter() invocation it must not be lazy.
|
||||||
sub editcontent () {
|
sub editcontent () {
|
||||||
|
|
|
@ -54,6 +54,26 @@ sub check_canremove ($$$) {
|
||||||
error("renaming of attachments is not allowed");
|
error("renaming of attachments is not allowed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $canremove;
|
||||||
|
IkiWiki::run_hooks(canremove => sub {
|
||||||
|
return if defined $canremove;
|
||||||
|
my $ret=shift->($page, $q, $session);
|
||||||
|
if (defined $ret) {
|
||||||
|
if ($ret eq "") {
|
||||||
|
$canremove=1;
|
||||||
|
}
|
||||||
|
elsif (ref $ret eq 'CODE') {
|
||||||
|
$ret->();
|
||||||
|
$canremove=0;
|
||||||
|
}
|
||||||
|
elsif (defined $ret) {
|
||||||
|
error($ret);
|
||||||
|
$canremove=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return $canremove;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub formbuilder_setup (@) {
|
sub formbuilder_setup (@) {
|
||||||
|
|
|
@ -321,6 +321,14 @@ This hook should avoid directly redirecting the user to a signin page,
|
||||||
since it's sometimes used to test to see which pages in a set of pages a
|
since it's sometimes used to test to see which pages in a set of pages a
|
||||||
user can edit.
|
user can edit.
|
||||||
|
|
||||||
|
### canremove
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
### editcontent
|
### editcontent
|
||||||
|
|
||||||
hook(type => "editcontent", id => "foo", call => \&editcontent);
|
hook(type => "editcontent", id => "foo", call => \&editcontent);
|
||||||
|
|
Loading…
Reference in New Issue