". __('Items:') ."\n" . "
\n";
//delete the tags for these items
$sqlids = "select distinct i.id,i.cid " . $sql
. " order by i.cid, i.id desc";
$rs = rss_query($sqlids);
$ids = array();
$cids = array();
//echo "to be deleted\n";
while (list($id,$cid) = rss_fetch_row($rs)) {
$cids[$cid][]= $id;
//echo "cid=$cid, $id\n";
}
//echo "\n\n";
if (count($cids)) {
// Righto. Lets check which of these ids still is in cache:
$cacheIds = array();
// now, sort the ids to be deleted into two lists: in cache / to trash
$in_cache = array();
$to_trash = array();
foreach ($cids as $cid => $ids) {
$rsCache = rss_query("select itemsincache from " . getTable('channels') . " where id=$cid");
list($idString) = rss_fetch_row($rsCache);
if ($idString) {
$cacheIds = unserialize($idString);
} else {
$cacheIds = array();
}
foreach ($ids as $iid) {
//echo "examining: $iid (cid $cid) ->";
if (array_search($iid, $cacheIds) !== FALSE) {
$in_cache[] = $iid;
//echo " in cache!\n";
} else {
$to_trash[] = $iid;
//echo " not in cache!\n";
}
}
}
// cheers, we're set. Now delete the metatag links for *all*
// items to be deleted
if (count($ids)) {
$sqldel = "delete from " .getTable('metatag') . " where fid in ("
. implode(",",array_merge($in_cache,$to_trash)) .")";
rss_query($sqldel);
}
// finally, delete the actual items
if (count($to_trash)) {
rss_query( "delete from " . getTable('item') ." where id in ("
. implode(", ", $to_trash)
.")"
);
}
if (count($in_cache)) {
rss_query( "update " . getTable('item')
." set unread = unread | " . RSS_MODE_DELETED_STATE
.", description='' "
." where id in ("
. implode(", ", $in_cache)
.")"
);
}
rss_invalidate_cache();
}
$ret__ = CST_ADMIN_DOMAIN_ITEM;
} else {
list($cnt_d) = rss_fetch_row(rss_query("select count(distinct(i.id)) as cnt " . $sql
. " and (i.unread & " . RSS_MODE_DELETED_STATE.")=0 "
));
rss_error(sprintf(__('Warning: you are about to delete %s items (of %s)'),$cnt_d,$cnt), RSS_ERROR_ERROR,true);
echo "\n";
}
} else {
rss_error(__('oops, no period specified'), RSS_ERROR_ERROR,true);
$ret__ = CST_ADMIN_DOMAIN_ITEM;
}
break;
default:
$ret__ = CST_ADMIN_DOMAIN_ITEM;
break;
}
return $ret__;
}
?>