mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
- fixed dotted topics on some occassions being wrong
- fixed post author change - fixed moving topics (they should not count into read tracking now) - think about having only one column for shadow topics/similar to forum links - moved a function from functions.php to functions_display.php (this function is only used by viewtopic and viewforum which already include this file) - some rather tiny fixes for mssql git-svn-id: file:///svn/phpbb/trunk@5933 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -1075,4 +1075,113 @@ function display_user_activity(&$userdata)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Topic and forum watching common code
|
||||
*/
|
||||
function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0)
|
||||
{
|
||||
global $template, $db, $user, $phpEx, $SID, $start, $phpbb_root_path;
|
||||
|
||||
$table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
|
||||
$where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id';
|
||||
$match_id = ($mode == 'forum') ? $forum_id : $topic_id;
|
||||
|
||||
$u_url = ($mode == 'forum') ? 'f' : 'f=' . $forum_id . '&t';
|
||||
|
||||
// Is user watching this thread?
|
||||
if ($user_id != ANONYMOUS)
|
||||
{
|
||||
$can_watch = true;
|
||||
|
||||
if ($notify_status == 'unset')
|
||||
{
|
||||
$sql = "SELECT notify_status
|
||||
FROM $table_sql
|
||||
WHERE $where_sql = $match_id
|
||||
AND user_id = $user_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (!is_null($notify_status))
|
||||
{
|
||||
if (isset($_GET['unwatch']))
|
||||
{
|
||||
if ($_GET['unwatch'] == $mode)
|
||||
{
|
||||
$is_watching = 0;
|
||||
|
||||
$sql = 'DELETE FROM ' . $table_sql . "
|
||||
WHERE $where_sql = $match_id
|
||||
AND user_id = $user_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
meta_refresh(3, "view$mode.$phpEx$SID&$u_url=$match_id&start=$start");
|
||||
|
||||
$message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_watching = true;
|
||||
|
||||
if ($notify_status)
|
||||
{
|
||||
$sql = 'UPDATE ' . $table_sql . "
|
||||
SET notify_status = 0
|
||||
WHERE $where_sql = $match_id
|
||||
AND user_id = $user_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_GET['watch']))
|
||||
{
|
||||
if ($_GET['watch'] == $mode)
|
||||
{
|
||||
$is_watching = true;
|
||||
|
||||
$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
|
||||
VALUES ($user_id, $match_id, 0)";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
meta_refresh(3, "view$mode.$phpEx$SID&$u_url=$match_id&start=$start");
|
||||
|
||||
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_watching = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode)
|
||||
{
|
||||
login_box();
|
||||
}
|
||||
else
|
||||
{
|
||||
$can_watch = 0;
|
||||
$is_watching = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($can_watch)
|
||||
{
|
||||
$s_watching['link'] = "{$phpbb_root_path}view$mode.$phpEx$SID&$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start";
|
||||
$s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user