pages.php: extract and display ban and warn messages

This commit is contained in:
Zankaria 2025-11-07 23:43:04 +01:00
parent 34ab8629ef
commit a7fef25e61

View file

@ -2210,6 +2210,8 @@ function mod_edit_post(Context $ctx, $board, $edit_raw_html, $postID) {
if ($edit_raw_html && !hasPermission($config['mod']['rawhtml'], $board))
error($config['error']['noaccess']);
$ban_msg_access = hasPermission($config['mod']['unban'], $board);
$security_token = make_secure_link_token($board . '/edit' . ($edit_raw_html ? '_raw' : '') . '/' . $postID);
$query = prepare(sprintf('SELECT * FROM ``posts_%s`` WHERE `id` = :id', $board));
@ -2257,6 +2259,20 @@ function mod_edit_post(Context $ctx, $board, $edit_raw_html, $postID) {
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . link_for($post) . '#' . $postID, true, $config['redirect_http']);
} else {
// Extract the ban/warn messages so that we can edit them.
if ($ban_msg_access) {
$post['modifiers'] = [];
$modifiers = extract_modifiers($post['body_nomarkup']);
if (isset($modifiers['ban message'])) {
$post['modifiers']['ban message'] = \strip_tags($modifiers['ban message']);
error_log($post['modifiers']['ban message']);
}
if (isset($modifiers['warning message'])) {
$post['modifiers']['warning message'] = \strip_tags($modifiers['warning message']);
error_log($post['modifiers']['warning message']);
}
}
// Remove modifiers
$post['body_nomarkup'] = remove_modifiers($post['body_nomarkup']);
@ -2269,9 +2285,9 @@ function mod_edit_post(Context $ctx, $board, $edit_raw_html, $postID) {
$post['body'] = str_replace("\r", '', $post['body']);
$post['body_nomarkup'] = str_replace("\t", '	', $post['body_nomarkup']);
$post['body'] = str_replace("\t", '	', $post['body']);
}
}
mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post));
mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post, 'ban_message_access' => $ban_msg_access));
}
}