function thread_top_change($tid, $top = 0)
{
    $thread = thread__read($tid);
    if (empty($thread)) {
        return FALSE;
    }
    if ($top != $thread['top']) {
        thread__update($tid, array('top' => $top));
        $fid = $thread['fid'];
        $tid = $thread['tid'];
        thread_top_cache_delete();
        thread_tids_cache_delete($fid);
        thread_new_cache_delete();
        return db_exec("REPLACE INTO `bbs_thread_top` SET fid='{$fid}', tid='{$tid}', top='{$top}'");
    }
    return FALSE;
}
Ejemplo n.º 2
0
function thread_delete($tid)
{
    global $conf;
    $thread = thread__read($tid);
    if (empty($thread)) {
        return TRUE;
    }
    $fid = $thread['fid'];
    $uid = $thread['uid'];
    $r = thread__delete($tid);
    if ($r === FALSE) {
        return FALSE;
    }
    // 删除所有回帖,同时更新 posts 统计数
    $n = post_delete_by_tid($tid);
    // 删除我的主题
    $uid and mythread_delete($uid, $tid);
    // 删除附件
    // 更新统计
    forum__update($fid, array('threads-' => 1));
    user__update($uid, array('threads-' => 1));
    // 删除 SEO URL
    thread_url_delete($tid);
    // 全站统计
    runtime_set('threads-', 1);
    // 清除相关缓存
    thread_tids_cache_delete($fid);
    forum_list_cache_delete();
    // 最新和置顶也清理
    thread_new_delete($tid);
    thread_top_delete($tid);
    thread_lastpid_delete($tid);
    thread_new_cache_delete();
    thread_top_cache_delete();
    thread_lastpid_cache_delete();
    return $r;
}