Allow to re-moderate comments
This commit is contained in:
@ -78,6 +78,23 @@ if (isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminActio
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'pending' && serendipity_checkFormToken()) {
|
||||
$sql = "SELECT c.*, e.title, a.email as authoremail, a.mail_comments
|
||||
FROM {$serendipity['dbPrefix']}comments c
|
||||
LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)
|
||||
LEFT JOIN {$serendipity['dbPrefix']}authors a ON (e.authorid = a.authorid)
|
||||
WHERE c.id = " . (int)$serendipity['GET']['id'] ." AND status = 'approved'";
|
||||
$rs = serendipity_db_query($sql, true);
|
||||
|
||||
if ($rs === false) {
|
||||
echo ERROR .': '. sprintf(COMMENT_ALREADY_APPROVED, (int)$serendipity['GET']['id']);
|
||||
} else {
|
||||
|
||||
serendipity_approveComment($serendipity['GET']['id'], $rs['entry_id'], true, true);
|
||||
echo DONE . ': '. sprintf(COMMENT_MODERATED, (int)$serendipity['GET']['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/* We are asked to delete a comment */
|
||||
if (isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'delete' && serendipity_checkFormToken()) {
|
||||
serendipity_deleteComment($serendipity['GET']['id'], $serendipity['GET']['entry_id']);
|
||||
@ -470,6 +487,9 @@ foreach ($sql as $rs) {
|
||||
<?php if ($comment['status'] == 'pending') { ?>
|
||||
<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=approve&serendipity[id]=<?php echo $comment['id'] ?>&<?php echo serendipity_setFormToken('url'); ?>" class="serendipityIconLink" title="<?php echo APPROVE; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/accept.png'); ?>" alt="<?php echo APPROVE ?>" /><?php echo APPROVE ?></a>
|
||||
<?php } ?>
|
||||
<?php if ($comment['status'] == 'approved') { ?>
|
||||
<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=pending&serendipity[id]=<?php echo $comment['id'] ?>&<?php echo serendipity_setFormToken('url'); ?>" class="serendipityIconLink" title="<?php echo SET_TO_MODERATED; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png'); ?>" alt="<?php echo SET_TO_MODERATED ?>" /><?php echo SET_TO_MODERATED ?></a>
|
||||
<?php } ?>
|
||||
<?php if ($comment['excerpt']) { ?>
|
||||
<a href="#c<?php echo $comment['id'] ?>" onclick="FT_toggle(<?php echo $comment['id'] ?>); return false;" title="<?php echo VIEW; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo TOGGLE_ALL; ?>" /><span id="<?php echo $comment['id'] ?>_text"><?php echo TOGGLE_ALL ?></span></a>
|
||||
<?php } ?>
|
||||
|
@ -497,9 +497,10 @@ function serendipity_allowCommentsToggle($entry_id, $switch = 'disable') {
|
||||
* @param int The ID of the comment to approve
|
||||
* @param int The ID of the entry a comment belongs to
|
||||
* @param boolean Whether to force approving a comment despite of its current status
|
||||
* @param boolean If set to true, a comment will be moderated instead of approved.
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
function serendipity_approveComment($cid, $entry_id, $force = false) {
|
||||
function serendipity_approveComment($cid, $entry_id, $force = false, $moderate = false) {
|
||||
global $serendipity;
|
||||
|
||||
/* Get data about the comment, we need this query because this function can be called from anywhere */
|
||||
@ -518,7 +519,11 @@ function serendipity_approveComment($cid, $entry_id, $force = false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'approved' WHERE id = ". (int)$cid;
|
||||
if ($moderate) {
|
||||
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'pending' WHERE id = ". (int)$cid;
|
||||
} else {
|
||||
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'approved' WHERE id = ". (int)$cid;
|
||||
}
|
||||
serendipity_db_query($sql);
|
||||
|
||||
$field = ($rs['type'] == 'NORMAL' ? 'comments' : 'trackbacks');
|
||||
@ -531,14 +536,21 @@ function serendipity_approveComment($cid, $entry_id, $force = false) {
|
||||
$lm = (int)$rs['entry_last_modified'];
|
||||
}
|
||||
|
||||
$query = "UPDATE {$serendipity['dbPrefix']}entries SET $field=$field+1, last_modified=". $lm ." WHERE id='". (int)$entry_id ."'";
|
||||
if ($moderate) {
|
||||
$query = "UPDATE {$serendipity['dbPrefix']}entries SET $field=$field-1, last_modified=". $lm ." WHERE id='". (int)$entry_id ."'";
|
||||
} else {
|
||||
$query = "UPDATE {$serendipity['dbPrefix']}entries SET $field=$field+1, last_modified=". $lm ." WHERE id='". (int)$entry_id ."'";
|
||||
}
|
||||
serendipity_db_query($query);
|
||||
|
||||
if ($serendipity['allowSubscriptions']) {
|
||||
serendipity_mailSubscribers($entry_id, $rs['author'], $rs['email'], $rs['title'], $rs['authoremail'], $cid);
|
||||
if (!$moderate) {
|
||||
if ($serendipity['allowSubscriptions']) {
|
||||
serendipity_mailSubscribers($entry_id, $rs['author'], $rs['email'], $rs['title'], $rs['authoremail'], $cid);
|
||||
}
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_approvecomment', $rs);
|
||||
}
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_approvecomment', $rs);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user