Esempio n. 1
0
function discuss_multi_edit()
{
    $parentid = safe_field("txp_discuss", "parentid", "parentid=" . doSlash(ps('discussid')));
    $deleted = event_multi_edit('txp_discuss', 'discussid');
    if (!empty($deleted)) {
        // might as well clean up all comment counts while we're here.
        clean_comment_counts();
        return discuss_list(messenger('comment', $deleted, 'deleted'));
    }
    return discuss_list();
}
Esempio n. 2
0
function discuss_multi_edit()
{
    //FIXME, this method needs some refactoring
    $selected = ps('selected');
    $method = ps('method');
    $done = array();
    if ($selected) {
        // Get all articles for which we have to update the count
        foreach ($selected as $id) {
            $ids[] = "'" . intval($id) . "'";
        }
        $parentids = safe_column("DISTINCT parentid", "txp_discuss", "discussid IN (" . implode(',', $ids) . ")");
        $rs = safe_rows_start('*', 'txp_discuss', "discussid IN (" . implode(',', $ids) . ")");
        while ($row = nextRow($rs)) {
            extract($row);
            $id = intval($discussid);
            $parentids[] = $parentid;
            if ($method == 'delete') {
                // Delete and if succesful update commnet count
                if (safe_delete('txp_discuss', "discussid='{$id}'")) {
                    $done[] = $id;
                }
            } elseif ($method == 'ban') {
                // Ban the IP and hide all messages by that IP
                if (!safe_field('ip', 'txp_discuss_ipban', "ip='" . doSlash($ip) . "'")) {
                    safe_insert("txp_discuss_ipban", "ip = '" . doSlash($ip) . "',\n\t\t\t\t\t\t\tname_used = '" . doSlash($name) . "',\n\t\t\t\t\t\t\tbanned_on_message = '" . doSlash($discussid) . "',\n\t\t\t\t\t\t\tdate_banned = now()\n\t\t\t\t\t\t");
                    safe_update('txp_discuss', "visible = " . SPAM, "ip='" . doSlash($ip) . "'");
                }
                $done[] = $id;
            } elseif ($method == 'spam') {
                if (safe_update('txp_discuss', "visible = " . SPAM, "discussid = {$id}")) {
                    $done[] = $id;
                }
            } elseif ($method == 'unmoderated') {
                if (safe_update('txp_discuss', "visible = " . MODERATE, "discussid = {$id}")) {
                    $done[] = $id;
                }
            } elseif ($method == 'visible') {
                if (safe_update('txp_discuss', "visible = " . VISIBLE, "discussid = {$id}")) {
                    $done[] = $id;
                }
            }
        }
        $done = join(', ', $done);
        if (!empty($done)) {
            // might as well clean up all comment counts while we're here.
            clean_comment_counts($parentids);
            $messages = array('delete' => messenger('comment', $done, 'deleted'), 'ban' => messenger('comment', $done, 'banned'), 'spam' => gTxt('comment') . ' ' . strong($done) . ' ' . gTxt('marked_as') . ' ' . gTxt('spam'), 'unmoderated' => gTxt('comment') . ' ' . strong($done) . ' ' . gTxt('marked_as') . ' ' . gTxt('unmoderated'), 'visible' => gTxt('comment') . ' ' . strong($done) . ' ' . gTxt('marked_as') . ' ' . gTxt('visible'));
            return discuss_list($messages[$method]);
        }
    }
    return discuss_list();
}
Esempio n. 3
0
function discuss_multi_edit()
{
    $selected = ps('selected');
    if ($selected) {
        // Get all articles for which we have to update the count
        foreach ($selected as $id) {
            $to_delete[] = intval($id);
        }
        $parentids = safe_rows("DISTINCT parentid", "txp_discuss", "discussid IN (" . implode(',', $to_delete) . ")");
        foreach ($parentids as $key => $value) {
            $parentids[$key] = $value['parentid'];
        }
        // Delete and if succesful update commnet count
        $deleted = event_multi_edit('txp_discuss', 'discussid');
        if (!empty($deleted)) {
            // might as well clean up all comment counts while we're here.
            clean_comment_counts($parentids);
            return discuss_list(messenger('comment', $deleted, 'deleted'));
        }
    }
    return discuss_list();
}
Esempio n. 4
0
function discuss_multi_edit()
{
    $method = ps('method');
    $things = ps('selected');
    if ($things) {
        if ($method == 'delete') {
            foreach ($things as $discussid) {
                if (safe_delete('txp_discuss', "discussid='{$discussid}'")) {
                    $ids[] = $id;
                }
            }
            discuss_list(messenger('comment', join(', ', $ids), 'deleted'));
        } else {
            discuss_list();
        }
    } else {
        discuss_list();
    }
}
Esempio n. 5
0
function discuss_multi_edit()
{
    // FIXME: this method needs some refactoring.
    $selected = ps('selected');
    $method = ps('edit_method');
    $done = array();
    if ($selected and is_array($selected)) {
        // Get all articles for which we have to update the count.
        foreach ($selected as $id) {
            $ids[] = assert_int($id);
        }
        $parentids = safe_column("DISTINCT parentid", "txp_discuss", "discussid IN (" . implode(',', $ids) . ")");
        $rs = safe_rows_start('*', 'txp_discuss', "discussid IN (" . implode(',', $ids) . ")");
        while ($row = nextRow($rs)) {
            extract($row);
            $id = assert_int($discussid);
            $parentids[] = $parentid;
            if ($method == 'delete') {
                // Delete and, if successful, update comment count.
                if (safe_delete('txp_discuss', "discussid = {$id}")) {
                    $done[] = $id;
                }
                callback_event('discuss_deleted', '', 0, $done);
            } elseif ($method == 'ban') {
                // Ban the IP and hide all messages by that IP.
                if (!safe_field('ip', 'txp_discuss_ipban', "ip='" . doSlash($ip) . "'")) {
                    safe_insert("txp_discuss_ipban", "ip = '" . doSlash($ip) . "',\n                        name_used = '" . doSlash($name) . "',\n                        banned_on_message = {$id},\n                        date_banned = now()\n                    ");
                    safe_update('txp_discuss', "visible = " . SPAM, "ip='" . doSlash($ip) . "'");
                }
                $done[] = $id;
            } elseif ($method == 'spam') {
                if (safe_update('txp_discuss', "visible = " . SPAM, "discussid = {$id}")) {
                    $done[] = $id;
                }
            } elseif ($method == 'unmoderated') {
                if (safe_update('txp_discuss', "visible = " . MODERATE, "discussid = {$id}")) {
                    $done[] = $id;
                }
            } elseif ($method == 'visible') {
                if (safe_update('txp_discuss', "visible = " . VISIBLE, "discussid = {$id}")) {
                    $done[] = $id;
                }
            }
        }
        $done = join(', ', $done);
        if ($done) {
            // Might as well clean up all comment counts while we're here.
            clean_comment_counts($parentids);
            $messages = array('delete' => gTxt('comments_deleted', array('{list}' => $done)), 'ban' => gTxt('ips_banned', array('{list}' => $done)), 'spam' => gTxt('comments_marked_spam', array('{list}' => $done)), 'unmoderated' => gTxt('comments_marked_unmoderated', array('{list}' => $done)), 'visible' => gTxt('comments_marked_visible', array('{list}' => $done)));
            update_lastmod();
            return discuss_list($messages[$method]);
        }
    }
    return discuss_list();
}