Example #1
0
/**
 * Moves comment from submission table to comments table
 * 
 * @copyright Jared Wenerd 2008
 * @author Jared Wenerd, wenerd87 AT gmail DOT com
 * @param  string $cid comment id
 * @return string of story id 
 */
function CMT_approveModeration($cid)
{
    global $_CONF, $_TABLES;
    $result = DB_query("SELECT type, sid, date, title, comment, uid, name, pid, ipaddress FROM {$_TABLES['commentsubmissions']} WHERE cid = '{$cid}'");
    $A = DB_fetchArray($result);
    if ($A['pid'] > 0) {
        // get indent+1 of parent
        $indent = DB_getItem($_TABLES['comments'], 'indent+1', "cid = '{$A['pid']}'");
    } else {
        $indent = 0;
    }
    $A['title'] = addslashes($A['title']);
    $A['comment'] = addslashes($A['comment']);
    if (isset($A['name'])) {
        // insert data
        $A['name'] = addslashes($A['name']);
        DB_save($_TABLES['comments'], 'type,sid,date,title,comment,uid,name,pid,ipaddress,indent', "'{$A['type']}','{$A['sid']}','{$A['date']}','{$A['title']}','{$A['comment']}','{$A['uid']}'," . "'{$A['name']}','{$A['pid']}','{$A['ipaddress']}',{$indent}");
    } else {
        // insert data, null automatically goes into name column
        DB_save($_TABLES['comments'], 'type,sid,date,title,comment,uid,pid,ipaddress,indent', "'{$A['type']}','{$A['sid']}','{$A['date']}','{$A['title']}','{$A['comment']}','{$A['uid']}'," . "'{$A['pid']}','{$A['ipaddress']}',{$indent}");
    }
    $newcid = DB_insertId();
    DB_delete($_TABLES['commentsubmissions'], 'cid', $cid);
    DB_change($_TABLES['commentnotifications'], 'cid', $newcid, 'mid', $cid);
    // notify of new published comment
    if ($_CONF['allow_reply_notifications'] == 1 && $A['pid'] > 0) {
        $result = DB_query("SELECT cid, uid, deletehash FROM {$_TABLES['commentnotifications']} WHERE cid = {$A['pid']}");
        $B = DB_fetchArray($result);
        if ($B !== false) {
            CMT_sendReplyNotification($B);
        }
    }
    return $A['sid'];
}
Example #2
0
/**
 * Moves comment from submission table to comments table
 *
 * @param   int   cid  comment id
 * @copyright Jared Wenerd 2008
 * @author Jared Wenerd, wenerd87 AT gmail DOT com
 * @param  string $cid comment id
 * @return string of story id
 */
function CMT_approveModeration($cid)
{
    global $_CONF, $_TABLES;
    $result = DB_query("SELECT type, sid, date, title, comment, uid, name, pid, ipaddress FROM {$_TABLES['commentsubmissions']} WHERE cid = '{$cid}'");
    $A = DB_fetchArray($result);
    if ($A['pid'] > 0) {
        // get indent+1 of parent
        $indent = DB_getItem($_TABLES['comments'], 'indent+1', "cid = '{$A['pid']}'");
        if (empty($indent)) {
            $indent = 0;
        }
    } else {
        $indent = 0;
    }
    $A['title'] = DB_escapeString($A['title']);
    $A['comment'] = DB_escapeString($A['comment']);
    if (isset($A['name'])) {
        // insert data
        $A['name'] = DB_escapeString($A['name']);
        DB_save($_TABLES['comments'], 'type,sid,date,title,comment,uid,name,pid,ipaddress,indent', "'{$A['type']}','{$A['sid']}','{$A['date']}','{$A['title']}','{$A['comment']}','{$A['uid']}'," . "'{$A['name']}','{$A['pid']}','{$A['ipaddress']}',{$indent}");
    } else {
        // insert data, null automatically goes into name column
        DB_save($_TABLES['comments'], 'type,sid,date,title,comment,uid,pid,ipaddress,indent', "'{$A['type']}','{$A['sid']}','{$A['date']}','{$A['title']}','{$A['comment']}','{$A['uid']}'," . "'{$A['pid']}','{$A['ipaddress']}',{$indent}");
    }
    $newcid = DB_insertId('', 'comments_cid_seq');
    DB_delete($_TABLES['commentsubmissions'], 'cid', $cid);
    DB_change($_TABLES['commentnotifications'], 'cid', $newcid, 'mid', $cid);
    // notify of new published comment
    if ($_CONF['allow_reply_notifications'] == 1 && $A['pid'] > 0) {
        // $sql = "SELECT cid, uid, deletehash FROM {$_TABLES['commentnotifications']} WHERE cid = $pid"; // Used in Geeklog 2.0.0 and before. Notification sent only if someone directly replies to the comment (not a reply of a reply)
        $sql = "SELECT cn.cid, cn.uid, cn.deletehash " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, " . "{$_TABLES['commentnotifications']} AS cn " . "WHERE c2.cid = cn.cid AND (c.lft >= c2.lft AND c.lft <= c2.rht) " . "AND c.cid = {$A['pid']} GROUP BY cn.uid";
        $result = DB_query($sql);
        $B = DB_fetchArray($result);
        if ($B !== false) {
            CMT_sendReplyNotification($B);
        }
    }
    // Update Comment Feeds
    COM_rdfUpToDateCheck('comment');
    // Delete What's New block cache so it can get updated again
    if ($_CONF['whatsnew_cache_time'] > 0 and !$_CONF['hidenewcomments']) {
        $cacheInstance = 'whatsnew__';
        // remove all whatsnew instances
        CACHE_remove_instance($cacheInstance);
    }
    return $A['sid'];
}