public static function moderate_these($comments, $status = null)
{
if (empty($status)) {
$status = Comment::status('unapproved');
}
// Ensure we have an id, not a string
$status = Comment::status($status);
$comments = Utils::single_array($comments);
if (count($comments) == 0) {
return false;
}
if ($comments[0] instanceof Comment) {
// We were passed an array of comment objects. Use them directly.
$result = true;
/** @var Comment $comment */
foreach ($comments as $comment) {
$comment->status = $status;
$result &= $comment->update();
EventLog::log(_t('Comment %1$s moderated from %2$s', array($comment->id, $comment->post->title)), 'info', 'comment', 'habari');
}
} else {
if (is_numeric($comments[0])) {
$result = true;
foreach ($comments as $commentid) {
$result &= DB::update(DB::table('comments'), array('status' => $status), array('id' => $commentid));
EventLog::log(_t('Comment %1$d moderated', array($commentid)), 'info', 'comment', 'habari');
}
} else {
// We were passed a type we could not understand.
return false;
}
}
return $result;
}