experimental post editing (for mods)
This commit is contained in:
parent
e3f322e213
commit
3f1c279ce3
@ -712,6 +712,7 @@
|
||||
$config['mod']['link_unlock'] = '[-Lock]';
|
||||
$config['mod']['link_bumplock'] = '[Sage]';
|
||||
$config['mod']['link_bumpunlock'] = '[-Sage]';
|
||||
$config['mod']['link_editpost'] = '[Edit]';
|
||||
$config['mod']['link_move'] = '[Move]';
|
||||
|
||||
// Moderator capcodes
|
||||
@ -827,6 +828,8 @@
|
||||
$config['mod']['bumplock'] = MOD;
|
||||
// View whether a thread has been bumplocked ("-1" to allow non-mods to see too)
|
||||
$config['mod']['view_bumplock'] = MOD;
|
||||
// Edit posts (EXPERIMENTAL)
|
||||
$config['mod']['editpost'] = DISABLED;
|
||||
// "Move" a thread to another board (EXPERIMENTAL; has some known bugs)
|
||||
$config['mod']['move'] = DISABLED;
|
||||
// Post bypass unoriginal content check on robot-enabled boards
|
||||
|
@ -287,6 +287,10 @@
|
||||
if(!empty($this->file) && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="Remove file" href="?/' . $board['uri'] . '/deletefile/' . $this->id . '">' . $config['mod']['link_deletefile'] . '</a>';
|
||||
|
||||
// Edit post
|
||||
if(hasPermission($config['mod']['editpost'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="Edit post" href="?/' . $board['uri'] . '/edit/' . $this->id . '">' . $config['mod']['link_editpost'] . '</a>';
|
||||
|
||||
if(!empty($built))
|
||||
$built = '<span class="controls">' . $built . '</span>';
|
||||
}
|
||||
@ -399,6 +403,10 @@
|
||||
if(hasPermission($config['mod']['move'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="Move thread to another board" href="?/' . $board['uri'] . '/move/' . $this->id . '">' . $config['mod']['link_move'] . '</a>';
|
||||
|
||||
// Edit post
|
||||
if(hasPermission($config['mod']['editpost'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="Edit post" href="?/' . $board['uri'] . '/edit/' . $this->id . '">' . $config['mod']['link_editpost'] . '</a>';
|
||||
|
||||
if(!empty($built))
|
||||
$built = '<span class="controls op">' . $built . '</span>';
|
||||
}
|
||||
|
94
mod.php
94
mod.php
@ -2106,6 +2106,99 @@
|
||||
$page = buildThread($thread, true, $mod);
|
||||
|
||||
echo $page;
|
||||
} elseif(preg_match('/^\/' . $regex['board'] . 'edit\/(\d+)$/', $query, $matches)) {
|
||||
// Edit post body
|
||||
|
||||
$boardName = &$matches[1];
|
||||
|
||||
// Open board
|
||||
if(!openBoard($boardName))
|
||||
error($config['error']['noboard']);
|
||||
|
||||
if(!hasPermission($config['mod']['editpost'], $boardName)) error($config['error']['noaccess']);
|
||||
|
||||
$postID = &$matches[2];
|
||||
|
||||
$query = prepare(sprintf("SELECT `body_nomarkup`, `name`, `subject`, `thread` FROM `posts_%s` WHERE `id` = :id", $board['uri']));
|
||||
$query->bindValue(':id', $postID, PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
$post = $query->fetch() or error($config['error']['invalidpost']);
|
||||
|
||||
if(isset($_POST['submit']) && isset($_POST['body']) && isset($_POST['subject'])) {
|
||||
if(mb_strlen($_POST['subject']) > 100)
|
||||
error(sprintf($config['error']['toolong'], 'subject'));
|
||||
|
||||
$body = $_POST['body'];
|
||||
$body_nomarkup = $body;
|
||||
|
||||
wordfilters($body);
|
||||
$tracked_cites = markup($body, true);
|
||||
|
||||
$query = prepare("DELETE FROM `cites` WHERE `board` = :board AND `post` = :post");
|
||||
$query->bindValue(':board', $board['uri']);
|
||||
$query->bindValue(':post', $postID, PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
$query = prepare(sprintf("UPDATE `posts_%s` SET `body` = :body, `body_nomarkup` = :body_nomarkup, `subject` = :subject WHERE `id` = :id", $board['uri']));
|
||||
$query->bindValue(':id', $postID, PDO::PARAM_INT);
|
||||
$query->bindValue(':body', $body);
|
||||
$query->bindValue(':body_nomarkup', $body_nomarkup);
|
||||
$query->bindValue(':subject', utf8tohtml($_POST['subject']));
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
if(isset($tracked_cites)) {
|
||||
foreach($tracked_cites as $cite) {
|
||||
$query = prepare('INSERT INTO `cites` VALUES (:board, :post, :target_board, :target)');
|
||||
$query->bindValue(':board', $board['uri']);
|
||||
$query->bindValue(':post', $postID, PDO::PARAM_INT);
|
||||
$query->bindValue(':target_board',$cite[0]);
|
||||
$query->bindValue(':target', $cite[1], PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
}
|
||||
}
|
||||
|
||||
// Record the action
|
||||
modLog("Edited post #{$postID}");
|
||||
|
||||
buildThread($post['thread'] ? $post['thread'] : $postID);
|
||||
|
||||
// Rebuild board
|
||||
buildIndex();
|
||||
|
||||
// Redirect
|
||||
header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$body = '<form name="post" action="" method="post">' .
|
||||
'<table>' .
|
||||
'<tr>' .
|
||||
'<th>Name</th>' .
|
||||
'<td>' . utf8tohtml($post['name']) . '</td>' .
|
||||
'</tr>' .
|
||||
'<tr>' .
|
||||
'<th>Subject</th>' .
|
||||
'<td>' .
|
||||
'<input style="float:left;" type="text" name="subject" size="25" maxlength="50" value="' . str_replace('"', '"', $post['subject']) . '"/>' .
|
||||
'<input style="margin-left:2px;" type="submit" name="submit" value="Edit Post"/>' .
|
||||
'</td>' .
|
||||
'</tr>' .
|
||||
'<tr>' .
|
||||
'<th>Body</th>' .
|
||||
'<td>' .
|
||||
'<textarea name="body" rows="8" cols="38">' .
|
||||
utf8tohtml($post['body_nomarkup']) .
|
||||
'</textarea>' .
|
||||
'</td>' .
|
||||
'</tr>' .
|
||||
'</table>' .
|
||||
'</form>';
|
||||
|
||||
echo Element('page.html', Array(
|
||||
'config' => $config,
|
||||
'body' => $body,
|
||||
'title' => 'Edit Post #' . $postID
|
||||
));
|
||||
} elseif(preg_match('/^\/' . $regex['board'] . 'deletefile\/(\d+)$/', $query, $matches)) {
|
||||
// Delete file from post
|
||||
|
||||
@ -2128,7 +2221,6 @@
|
||||
// Rebuild board
|
||||
buildIndex();
|
||||
|
||||
|
||||
// Redirect
|
||||
header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']);
|
||||
} elseif(preg_match('/^\/' . $regex['board'] . 'delete\/(\d+)$/', $query, $matches)) {
|
||||
|
Loading…
Reference in New Issue
Block a user