|
From: FlorinCB <ory...@us...> - 2008-09-07 02:33:01
|
Update of /cvsroot/mxbb/core/modules/mx_phpbb3blocks/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4117 Modified Files: mx_functions_display.php Log Message: function upgraded for phpBB 3.0.2 ... Index: mx_functions_display.php =================================================================== RCS file: /cvsroot/mxbb/core/modules/mx_phpbb3blocks/includes/mx_functions_display.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mx_functions_display.php 1 Sep 2008 03:48:47 -0000 1.5 --- mx_functions_display.php 7 Sep 2008 02:32:55 -0000 1.6 *************** *** 995,999 **** * Topic and forum watching common code */ ! function mx_watch_topic_forum($mode, &$s_watching, &$s_watching_img, $mx_user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0) { global $template, $db, $mx_user, $phpEx, $start, $phpbb_root_path; --- 995,999 ---- * Topic and forum watching common code */ ! function mx_watch_topic_forum_old($mode, &$s_watching, &$s_watching_img, $mx_user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0) { global $template, $db, $mx_user, $phpEx, $start, $phpbb_root_path; *************** *** 1106,1109 **** --- 1106,1222 ---- /** + * Topic and forum watching common code + */ + function mx_watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0) + { + global $template, $db, $mx_user, $phpEx, $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) && $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); + } + + $redirect_url = mx3_append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); + + meta_refresh(3, $redirect_url); + + $message = $mx_user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($mx_user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</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); + } + + $redirect_url = mx3_append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); + meta_refresh(3, $redirect_url); + + $message = $mx_user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($mx_user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</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'] = mx3_append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start"); + $s_watching['title'] = $mx_user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)]; + $s_watching['is_watching'] = $is_watching; + } + + return; + } + + /** * Get user rank title and image * |