News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Bypass recycle bin when deleting several topics

Started by Ataru Moroboshi, September 01, 2017, 06:28:32 AM

Previous topic - Next topic

Ataru Moroboshi

Is there any way to delete topics without moving them in recycle bin?

I have a php script for press review in my forum that searches in a bunch of rss feeds for some kind of news, and then publishes all matches as topics (waiting for approval) in a News section.

so i've got hundreds topics a day waiting for approval, and i can check which to publish and which to delete.

deleted ones go to recycle bin, so I've got thousands topics in recycle bin, and i need every xxx days to prune them, but i need to  keep moderation related deleted topics and this takes forever to check which to definely delete and which i need to keep.

I need some way to delete all unapproved topics from News section without moving them in recycle bin (I noticed, also, that deleting an unapproved topic will approve it and then send to recycle bin).

Is there a way out to do it or i should build a script?

Arantor

Build a script, and even then that's going to be complicated because all the internal routines for deletion know to point them at the recycling if it's set up, and deleting them yourself will likely cause integrity issues unless you can get every single place where these things connect together.

Ataru Moroboshi

ok, i just solved it using that script:


global $smcFunc, $modSettings, $scripturl, $user_info, $txt, $color_profile, $context, $settings; // dont know which of these exactly i will use, so i put them all :D
include_once("Sources/RemoveTopic.php"); // dont know if those functions are called above.

$sql_qry='
SELECT
t.id_topic, m.subject, t.approved, m.poster_time
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
WHERE t.id_member_started = {int:newser_id}
AND t.id_board = {int:news_board}
AND m.poster_time < {int:time}
AND t.is_sticky = 0
AND t.locked = {int:locked}
ORDER BY m.poster_time DESC';

//echo $sql_qry;

$sql_params = array(
'newser_id' => 15,
'news_board' => 13,
'time' => time() - 3600 * 24 * 2,
'locked' => 1
);
$query = $smcFunc['db_query']('', $sql_qry, $sql_params);
while($result = $smcFunc['db_fetch_assoc']($query))
{
$topics[] = $result["id_topic"];
}

mysql_free_result($query);
if (count($topics) > 0) removeTopics($topics, true, true);

Arantor

And what happens if you run the find repair maintenance routines?

Ataru Moroboshi

Quote from: Arantor on September 13, 2017, 07:26:06 AM
And what happens if you run the find repair maintenance routines?

Elenco degli errori del forum
Congratulazioni, non è stato trovato alcun errore! Grazie per aver controllato.


in english:
Listing of forum errors
Congratulations, no errors found!  Thanks for checking.

Advertisement: