예제 #1
0
function deletearticle($aids, $istrash = true)
{
    global $_G;
    if (empty($aids)) {
        return false;
    }
    $trasharr = $article = $bids = $dels = $attachment = $attachaid = $catids = $pushs = array();
    $query = C::t('portal_article_title')->fetch_all($aids);
    foreach ($query as $value) {
        $catids[] = intval($value['catid']);
        $dels[$value['aid']] = $value['aid'];
        $article[] = $value;
        if (!empty($value['idtype'])) {
            $pushs[$value['idtype']][] = $value['id'];
        }
    }
    if ($dels) {
        foreach ($article as $key => $value) {
            if ($istrash) {
                $trasharr[] = array('aid' => $value['aid'], 'content' => serialize($value));
            } elseif ($value['pic']) {
                pic_delete($value['pic'], 'portal', $value['thumb'], $value['remote']);
                $attachaid[] = $value['aid'];
            }
        }
        if ($istrash && $trasharr) {
            C::t('portal_article_trash')->insert_batch($trasharr);
        } else {
            deletearticlepush($pushs);
            deletearticlerelated($dels);
        }
        C::t('portal_article_title')->delete($dels);
        C::t('common_moderate')->delete($dels, 'aid');
        $catids = array_unique($catids);
        if ($catids) {
            foreach ($catids as $catid) {
                $cnt = C::t('portal_article_title')->fetch_count_for_cat($catid);
                C::t('portal_category')->update($catid, array('articles' => dintval($cnt)));
            }
        }
    }
    return $article;
}
예제 #2
0
function deletearticle($aids, $istrash = true)
{
    global $_G;
    if (empty($aids)) {
        return false;
    }
    $trasharr = $article = $bids = $dels = $attachment = $attachaid = $catids = $pushs = array();
    $query = DB::query("SELECT * FROM " . DB::table('portal_article_title') . " WHERE aid IN (" . dimplode($aids) . ")");
    while ($value = DB::fetch($query)) {
        $catids[] = intval($value['catid']);
        $dels[$value['aid']] = $value['aid'];
        $article[] = $value;
        if (!empty($value['idtype'])) {
            $pushs[$value['idtype']][] = $value['id'];
        }
    }
    if ($dels) {
        foreach ($article as $key => $value) {
            if ($istrash) {
                $valstr = daddslashes(serialize($value));
                $trasharr[] = "('{$value['aid']}', '{$valstr}')";
            } elseif ($value['pic']) {
                pic_delete($value['pic'], 'portal', $value['thumb'], $value['remote']);
                $attachaid[] = $value['aid'];
            }
        }
        if ($istrash) {
            if ($trasharr) {
                DB::query("INSERT INTO " . DB::table('portal_article_trash') . " (`aid`, `content`) VALUES " . implode(',', $trasharr));
            }
        } else {
            deletearticlepush($pushs);
            deletearticlerelated($dels);
        }
        DB::delete('portal_article_title', "aid IN(" . dimplode($dels) . ")");
        DB::delete('common_moderate', "id IN (" . dimplode($dels) . ") AND idtype='aid'");
        $catids = array_unique($catids);
        if ($catids) {
            foreach ($catids as $catid) {
                $cnt = DB::result_first('SELECT COUNT(*) FROM ' . DB::table('portal_article_title') . " WHERE catid = '{$catid}'");
                DB::update('portal_category', array('articles' => $cnt), array('catid' => $catid));
            }
        }
    }
    return $article;
}