function HTFV_Change($topic = 0, $hide_topic = false)
{
global $user_info, $smcFunc;
// Abort if we are not supposed to be here!
if (empty($user_info['id']) || empty($topic))
fatal_lang_error('no_topic_id', false);
// Get the board number that this topic resides in:
$request = $smcFunc['db_query']('', '
SELECT id_board
FROM {db_prefix}topics
WHERE id_topic IN ({int:id_topic})',
array(
'id_topic' => $topic = (int) $topic,
)
);
list($board) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// Remove any existing entries for this topic:
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}hide_topics
WHERE id_member = {int:id_member}
AND id_topic = {int:id_topic}',
array(
'id_member' => (int) $user_info['id'],
'id_topic' => (int) $topic,
)
);
// Are we being requested to hide the specified topic?
if ($hide_topic)
{
// Can't do anything if the board ID is empty, either....
$user = (int) $user_info['id'];
if (empty($board))
continue;
// Insert the row into the hide_topics table:
$smcFunc['db_insert']('insert',
'{db_prefix}hide_topics',
array('id_member' => 'int', 'id_topic' => 'int', 'id_board' => 'int'),
array($user, $topic, (int) $board),
array('id_member', 'id_topic', 'id_board')
);
}
// Force recache of the hidden topics for this user, then go to the board:
unset($_SESSION['hide_topics']);
return $board;
}