PukiWiki
Revisión | cc0bb66accdbd45240302587763ff4677e214364 (tree) |
---|---|
Tiempo | 2016-02-07 20:40:07 |
Autor | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack2/381 Handle failure to add comment - comment plugin
@@ -224,6 +224,8 @@ $_msg_comment = 'Comment: '; | ||
224 | 224 | $_title_comment_collided = 'On updating $1, a collision has occurred.'; |
225 | 225 | $_msg_comment_collided = 'It seems that someone has already updated the page you were editing.<br /> |
226 | 226 | The comment was added, alhough it may be inserted in the wrong position.<br />'; |
227 | +$_comment_plugin_fail_msg = 'It seems that someone has already updated the page you were editing.<br /> | |
228 | + Failed to add the comment.<br />'; | |
227 | 229 | |
228 | 230 | /////////////////////////////////////// |
229 | 231 | // deleted.inc.php |
@@ -226,6 +226,8 @@ $_msg_comment = 'コメント: '; | ||
226 | 226 | $_title_comment_collided = '$1 で【更新の衝突】が起きました'; |
227 | 227 | $_msg_comment_collided = 'あなたがこのページを編集している間に、他の人が同じページを更新してしまったようです。<br /> |
228 | 228 | コメントを追加しましたが、違う位置に挿入されているかもしれません。<br />'; |
229 | +$_comment_plugin_fail_msg = 'あなたがこのページを編集している間に、他の人が同じページを更新してしまったようです。<br /> | |
230 | +コメントの追加に失敗しました。<br />'; | |
229 | 231 | |
230 | 232 | /////////////////////////////////////// |
231 | 233 | // deleted.inc.php |
@@ -1,8 +1,8 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | -// $Id: comment.inc.php,v 1.41 2011/01/25 15:01:01 henoheno Exp $ | |
4 | -// Copyright (C) | |
5 | -// 2002-2005 PukiWiki Developers Team | |
3 | +// comment.inc.php | |
4 | +// Copyright | |
5 | +// 2002-2016 PukiWiki Development Team | |
6 | 6 | // 2001-2002 Originally written by yu-ji |
7 | 7 | // License: GPL v2 or (at your option) any later version |
8 | 8 | // |
@@ -22,6 +22,7 @@ function plugin_comment_action() | ||
22 | 22 | { |
23 | 23 | global $script, $vars, $now, $_title_updated, $_no_name; |
24 | 24 | global $_msg_comment_collided, $_title_comment_collided; |
25 | + global $_comment_plugin_fail_msg; | |
25 | 26 | |
26 | 27 | if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing'); |
27 | 28 |
@@ -51,9 +52,11 @@ function plugin_comment_action() | ||
51 | 52 | $postdata = ''; |
52 | 53 | $comment_no = 0; |
53 | 54 | $above = (isset($vars['above']) && $vars['above'] == '1'); |
55 | + $comment_added = FALSE; | |
54 | 56 | foreach (get_source($vars['refer']) as $line) { |
55 | 57 | if (! $above) $postdata .= $line; |
56 | 58 | if (preg_match('/^#comment/i', $line) && $comment_no++ == $vars['comment_no']) { |
59 | + $comment_added = TRUE; | |
57 | 60 | if ($above) { |
58 | 61 | $postdata = rtrim($postdata) . "\n" . |
59 | 62 | $comment . "\n" . |
@@ -65,21 +68,23 @@ function plugin_comment_action() | ||
65 | 68 | } |
66 | 69 | if ($above) $postdata .= $line; |
67 | 70 | } |
68 | - | |
69 | 71 | $title = $_title_updated; |
70 | 72 | $body = ''; |
71 | - if (md5(get_source($vars['refer'], TRUE, TRUE)) !== $vars['digest']) { | |
73 | + if ($comment_added) { | |
74 | + // new comment added | |
75 | + if (md5(get_source($vars['refer'], TRUE, TRUE)) !== $vars['digest']) { | |
76 | + $title = $_title_comment_collided; | |
77 | + $body = $_msg_comment_collided . make_pagelink($vars['refer']); | |
78 | + } | |
79 | + page_write($vars['refer'], $postdata); | |
80 | + } else { | |
81 | + // failed to add the comment | |
72 | 82 | $title = $_title_comment_collided; |
73 | - $body = $_msg_comment_collided . make_pagelink($vars['refer']); | |
83 | + $body = $_comment_plugin_fail_msg . make_pagelink($vars['refer']); | |
74 | 84 | } |
75 | - | |
76 | - page_write($vars['refer'], $postdata); | |
77 | - | |
78 | 85 | $retvars['msg'] = $title; |
79 | 86 | $retvars['body'] = $body; |
80 | - | |
81 | 87 | $vars['page'] = $vars['refer']; |
82 | - | |
83 | 88 | return $retvars; |
84 | 89 | } |
85 | 90 |
@@ -130,4 +135,3 @@ EOD; | ||
130 | 135 | |
131 | 136 | return $string; |
132 | 137 | } |
133 | -?> |