15 return 'Message cleaner';
29 private static function do()
32 $dbRes = Main\Application::getConnection()->query(<<<SQL
33SELECT ID, FORUM_ID, TOPIC_ID, MESSAGE_ID, NEW_TOPIC, APPROVED, PARAM1, PARAM2, AUTHOR_ID
34FROM b_forum_service_deleted_message
40 global $USER_FIELD_MANAGER;
42 while ($message = $dbRes->fetch())
44 if ($message[
"PARAM1"] ==
'VT')
46 $votes[] = $message[
"PARAM2"];
49 $selectSql =
"SELECT * FROM b_forum_file where MESSAGE_ID=" . intval($message[
'MESSAGE_ID']) .
" ORDER BY ID ASC";
51 $dbFileRes = Main\Application::getConnection()->query($selectSql);
53 if ($dbFileRes && ($file = $dbFileRes->fetch()))
57 \CFile::Delete($file[
"FILE_ID"]);
59 while ($file = $dbFileRes->fetch());
60 $deleteSql =
"DELETE FROM b_forum_file where MESSAGE_ID=" . intval($message[
'MESSAGE_ID']);
61 Main\Application::getConnection()->queryExecute($deleteSql);
64 $USER_FIELD_MANAGER->Delete(
"FORUM_MESSAGE", $message[
"MESSAGE_ID"]);
69 if (!empty($votes) && IsModuleInstalled(
"vote") && \CModule::IncludeModule(
"vote"))
71 array_map(
function($voteId) {
72 \CVote::Delete($voteId);
78 Main\Application::getConnection()->queryExecute(<<<SQL
79DELETE FROM b_forum_service_deleted_message WHERE ID <= {$last[
'ID']}
88 Main\Application::getConnection()->queryExecute(<<<SQL
89INSERT IGNORE INTO b_forum_service_deleted_message
90 (FORUM_ID, TOPIC_ID, MESSAGE_ID, NEW_TOPIC, APPROVED, PARAM1, PARAM2, AUTHOR_ID)
91SELECT FORUM_ID, TOPIC_ID, ID, NEW_TOPIC, APPROVED, PARAM1, PARAM2, AUTHOR_ID
93WHERE TOPIC_ID = {$topicId}