po: use the new canrename hook to prevent translation renames in the CGI
Signed-off-by: intrigeri <intrigeri@boum.org>master
parent
3316f9cc73
commit
b24f236dfa
|
@ -40,6 +40,7 @@ sub import {
|
||||||
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 => "canremove", id => "po", call => \&canremove);
|
||||||
|
hook(type => "canrename", id => "po", call => \&canrename);
|
||||||
hook(type => "editcontent", id => "po", call => \&editcontent);
|
hook(type => "editcontent", id => "po", call => \&editcontent);
|
||||||
|
|
||||||
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
|
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
|
||||||
|
@ -417,6 +418,16 @@ sub canremove ($$$) {
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub canrename ($$$) {
|
||||||
|
my ($page, $cgi, $session) = (shift, shift, shift);
|
||||||
|
|
||||||
|
if (istranslation($page)) {
|
||||||
|
return gettext("Can not rename a translation. Renaming the master page,".
|
||||||
|
"though, renames 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 () {
|
||||||
|
|
|
@ -544,13 +544,6 @@ Creating new pages on the web
|
||||||
|
|
||||||
See [[contrib/po|contrib/po]].
|
See [[contrib/po|contrib/po]].
|
||||||
|
|
||||||
Renaming/deleting pages
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
Renaming or deleting a translation in the CGI should be forbidden.
|
|
||||||
Implementing this requires two new hooks: `canrename` and `canremove`,
|
|
||||||
that would be run respectively by the `rename` and the `remove` plugins.
|
|
||||||
|
|
||||||
Robustness tests
|
Robustness tests
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue