/**
 * Delete comments in the moderation queue
 *
 * @param array $comments
 */
function deleteComments($comments)
{
    global $PIVOTX;
    // Abort immediately if no comments passed.
    if (empty($comments)) {
        return;
    }
    // execute a hook here before a comment is processed
    $PIVOTX['extensions']->executeHook('comment_approve', $comments);
    if ($PIVOTX['db']->db_type == "sql") {
        $commentstable = $PIVOTX['db']->db_lowlevel->commentstable;
        $comments = array_map('intval', $comments);
        $uids = implode(", ", $comments);
        $PIVOTX['db']->db_lowlevel->sql->query("DELETE FROM {$commentstable}\n            WHERE uid IN ({$uids});");
    } else {
        // process the queue for flat file model
        $modqueue = getModerationQueue();
        // Iterate through the queue, approving items as we go.
        foreach ($modqueue as $key => $comment) {
            if (in_array($comment['uid'], $comments)) {
                moderateProcessComment($comment, 2);
                unset($modqueue[$key]);
            }
        }
        // Save back what's left of the moderation queue..
        $modqueue_file = $PIVOTX['paths']['db_path'] . 'ser_modqueue.php';
        saveSerialize($modqueue_file, $modqueue);
    }
}
Beispiel #2
0
function pagem_comments()
{
    global $PIVOTX;
    $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
    // Get the 6 latest comments.. (non-moderated get priority)
    require_once dirname(__FILE__) . '/modules/module_comments.php';
    $modcomments = getModerationQueue();
    $comments = $PIVOTX['db']->read_latestcomments(array('amount' => 30, 'cats' => '', 'count' => 30, 'moderated' => 1));
    $comments = array_merge($modcomments, $comments);
    $comments = array_slice($comments, 0, 20);
    // Check for blocked IPs
    $blocklist = new IPBlock();
    foreach ($comments as $key => $comment) {
        $comments[$key]['blocked'] = $blocklist->isBlocked($comment["ip"]);
    }
    $PIVOTX['template']->assign('comments', $comments);
    $PIVOTX['template']->assign("title", __('Comments'));
    $PIVOTX['template']->assign("active", "comments");
    renderTemplate('mobile/comments.tpl');
}