Topic Log
Time to see who viewed a topic. This modification enhances the topic log function of SMF and gives you the ability to view the log of the topic you want. Here are the features:
Display view count for each member
Display last view time
8 ways of sorting the list
Username asc/desc
Position asc/desc
Times Viewed asc/desc
Last View asc/desc
Pagination
20 logs per page
2 types of 'View Topic Log' permission
View own
View any
Show log topic name in who's online
File Edits
./Themes/default/languages/Modifications.english.phpFind (at the end of the file):
?>Add Before: // Topic Log Mod
$txt['lt_title'] = 'Topic Log';
$txt['lt_times'] = 'Times';
$txt['lt_lastView'] = 'Last View';
$txt['tl_no_topic_id'] = 'Topic ID is not set.';
$txt['tl_no_topic'] = 'Topic doesn\'t exist.';
$txt['who_log'] = 'Viewing the topic log of <a href="' . $scripturl . '?action=topiclog;id=%d">%s</a>.';
$txt['cannot_view_topic_log_own'] = 'You are not, on this board, allowed to view the topic log of your own posts.';
$txt['cannot_view_topic_log_any'] = 'Viewing just any topic log in this board is not allowed.';
$txt['permissionname_view_topic_log'] = 'View Topic Log';
$txt['permissionhelp_view_topic_log'] = 'This permission allows a user to view the topic view log.';
$txt['permissionname_view_topic_log_own'] = 'Own topic';
$txt['permissionname_view_topic_log_any'] = 'Any topic';
// Topic Log Mod ./Sources/Display.phpFind:
if (!empty($topicinfo['new_from']))
{
db_query("
UPDATE {$db_prefix}log_topics
SET ID_MSG = $modSettings[maxMsgID]
WHERE ID_MEMBER = $ID_MEMBER
AND ID_TOPIC = $topic
LIMIT 1", __FILE__, __LINE__);
$flag = db_affected_rows() !== 0;
}
if (empty($flag))
db_query("
REPLACE INTO {$db_prefix}log_topics
(ID_MSG, ID_MEMBER, ID_TOPIC)
VALUES ($modSettings[maxMsgID], $ID_MEMBER, $topic)", __FILE__, __LINE__);Replace With: if (!empty($topicinfo['new_from']))
{
db_query("
UPDATE {$db_prefix}log_topics
SET ID_MSG = $modSettings[maxMsgID], times = times + 1, lastView = " . time() . "
WHERE ID_MEMBER = $ID_MEMBER
AND ID_TOPIC = $topic
LIMIT 1", __FILE__, __LINE__);
$flag = db_affected_rows() !== 0;
}
if (empty($flag))
db_query("
REPLACE INTO {$db_prefix}log_topics
(ID_MSG, ID_MEMBER, ID_TOPIC, times, lastView)
VALUES ($modSettings[maxMsgID], $ID_MEMBER, $topic, 1, " . time(). ")", __FILE__, __LINE__);Find: $context['topic_starter_id'] = $topicinfo['ID_MEMBER_STARTED'];Replace With $context['topic_starter_id'] = $topicinfo['ID_MEMBER_STARTED'];
// Can he see the topic log.
$user_view = !allowedTo('view_topic_log_any');
if ($user_view && $context['topic_starter_id'] == $ID_MEMBER)
$context['can_view_topic_log'] = allowedTo('view_topic_log_own');
else
$context['can_view_topic_log'] = allowedTo('view_topic_log_any');./Sources/ManagePermissions.phpFind: 'announce_topic' => false,Replace With: 'announce_topic' => false,
'view_topic_log' => true,./Sources/Who.phpFind: $board_ids = array(); Replace With: $board_ids = array();
$log_ids = array(); Find: // Unlisted or unknown action. Replace With: // He must be viewing a topic log.
elseif (isset($actions['action']) && $actions['action'] == 'topiclog' && isset($actions['place']) && allowedTo('view_topic_log_any', $actions['place']))
{
// Assume they can't view it.
$data[$k] = $txt['who_hidden'];
$log_ids[(int) $actions['id']][$k] = $txt['who_log'];
}
// Unlisted or unknown action. Find: // Load member names for the profile. Replace With: // Load log names.
if (!empty($log_ids))
{
$result = db_query("
SELECT t.ID_TOPIC, m.subject
FROM ({$db_prefix}boards AS b, {$db_prefix}topics AS t, {$db_prefix}messages AS m)
WHERE $user_info[query_see_board]
AND t.ID_TOPIC IN (" . implode(', ', array_keys($log_ids)) . ")
AND t.ID_BOARD = b.ID_BOARD
AND m.ID_MSG = t.ID_FIRST_MSG
LIMIT " . count($log_ids), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
// Show the log topic's subject for each of the actions.
foreach ($log_ids[$row['ID_TOPIC']] as $k => $session_text)
$data[$k] = sprintf($session_text, $row['ID_TOPIC'], censorText($row['subject']));
}
mysql_free_result($result);
}
// Load member names for the profile../index.php
Find: 'trackip' => array('Profile.php', 'trackIP'), Replace With: 'trackip' => array('Profile.php', 'trackIP'),
'topiclog' => array('TopicLog.php', 'TopicLog'),./Themes/default/Display.template.phpFind: // Show the page index... "Pages: [1]".
Replace With: // Topic Log button.
if ($context['can_view_topic_log'])
$normal_buttons['view_topic_log'] = array('text' => 'lt_title', 'image' => 'topiclog.gif', 'lang' => true, 'url' => $scripturl . '?action=topiclog;id=' . $context['current_topic'] . ';place=' . $context['current_board']);
// Show the page index... "Pages: [1]".CodeThis file should not be able to execute standalone. You may have to run the following queries manually...
Query:
ALTER TABLE {$db_prefix}log_topics
ADD times SMALLINT( 8 ) DEFAULT 1 NOT NULL,
ADD lastView TEXT NOT NULLFile OperationsMove the included file "TopicLog.php" to "./Sources".
Move the included file "TopicLog.template.php" to "./Themes/default".
By [SiNaN]
Link to Mod