Advertisement:

Author Topic: Bypass recycle bin when deleting several topics  (Read 320 times)

Offline Ataru Moroboshi

  • Semi-Newbie
  • *
  • Posts: 88
Bypass recycle bin when deleting several topics
« on: September 01, 2017, 06:28:32 AM »
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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,881
    • Arantor on GitHub
Re: Bypass recycle bin when deleting several topics
« Reply #1 on: September 01, 2017, 07:09:01 AM »
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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Ataru Moroboshi

  • Semi-Newbie
  • *
  • Posts: 88
Re: Bypass recycle bin when deleting several topics
« Reply #2 on: September 13, 2017, 04:41:32 AM »
ok, i just solved it using that script:

Code: [Select]
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);

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,881
    • Arantor on GitHub
Re: Bypass recycle bin when deleting several topics
« Reply #3 on: September 13, 2017, 07:26:06 AM »
And what happens if you run the find repair maintenance routines?
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Ataru Moroboshi

  • Semi-Newbie
  • *
  • Posts: 88
Re: Bypass recycle bin when deleting several topics
« Reply #4 on: September 13, 2017, 08:29:08 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.