make checkcontent compatible with hooks that need the full content

Always pass the full (modified) content in `content` named parameter. When the
user edits an existing wiki page, also pass a `diff` named parameter, which
includes only the lines that they added to the page, or modified.

Signed-off-by: intrigeri <intrigeri@boum.org>
master
intrigeri 2009-01-19 19:44:39 +01:00
parent 14b49376dc
commit a3726968bc
3 changed files with 5 additions and 4 deletions

View File

@ -85,7 +85,7 @@ sub checkcontent (@) {
my $res = $client->send_request('testComment', { my $res = $client->send_request('testComment', {
ip => $ENV{REMOTE_ADDR}, ip => $ENV{REMOTE_ADDR},
comment => $params{content}, comment => defined $params{diff} ? $params{diff} : $params{content},
subject => defined $params{subject} ? $params{subject} : "", subject => defined $params{subject} ? $params{subject} : "",
name => defined $params{author} ? $params{author} : "", name => defined $params{author} ? $params{author} : "",
link => exists $params{url} ? $params{url} : "", link => exists $params{url} ? $params{url} : "",

View File

@ -93,7 +93,7 @@ sub check_content (@) {
foreach my $line (split("\n", $params{content})) { foreach my $line (split("\n", $params{content})) {
push @diff, $line if ! exists $old{$_}; push @diff, $line if ! exists $old{$_};
} }
$params{content}=join("\n", @diff); $params{diff}=join("\n", @diff);
} }
my $ok; my $ok;

View File

@ -368,8 +368,9 @@ the content the user has entered is a comment, it may also be passed some
additional parameters: `author`, `url`, and `subject`. The `subject` additional parameters: `author`, `url`, and `subject`. The `subject`
parameter may also be filled with the user's comment about the change. parameter may also be filled with the user's comment about the change.
Note: When the user edits an existing wiki page, the passed `content` will Note: When the user edits an existing wiki page, this hook is also
include only the lines that they added to the page, or modified. passed a `diff` named parameter, which will include only the lines
that they added to the page, or modified.
The hook should return `undef` on success. If the content is disallowed, it The hook should return `undef` on success. If the content is disallowed, it
should return a message stating what the problem is, or a function should return a message stating what the problem is, or a function