aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_display.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-05-19 21:08:48 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-05-19 21:08:48 +0000
commit8e800e333ceae99945cb818709a4aba4de3362b0 (patch)
tree48eb98a09be564dd57b2df95753a56a0f2d5319f /phpBB/includes/functions_display.php
parentc0e3a86ebb9297f15681de6107acaef58eb41ccb (diff)
downloadforums-8e800e333ceae99945cb818709a4aba4de3362b0.tar
forums-8e800e333ceae99945cb818709a4aba4de3362b0.tar.gz
forums-8e800e333ceae99945cb818709a4aba4de3362b0.tar.bz2
forums-8e800e333ceae99945cb818709a4aba4de3362b0.tar.xz
forums-8e800e333ceae99945cb818709a4aba4de3362b0.zip
- 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
Diffstat (limited to 'phpBB/includes/functions_display.php')
-rw-r--r--phpBB/includes/functions_display.php109
1 files changed, 109 insertions, 0 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 43b0caf794..e99e387b12 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -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 . '&amp;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&amp;$u_url=$match_id&amp;start=$start");
+
+ $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&amp;" . $u_url . "=$match_id&amp;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&amp;$u_url=$match_id&amp;start=$start");
+
+ $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&amp;" . $u_url . "=$match_id&amp;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&amp;$u_url=$match_id&amp;" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&amp;start=$start";
+ $s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
+ }
+
+ return;
+}
+
?> \ No newline at end of file