diff options
author | Igor Wiedler <igor@wiedler.ch> | 2011-08-18 22:31:25 +0200 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2011-08-18 22:31:25 +0200 |
commit | 38c65da553c83e787d8a8adc1d40d789713579c4 (patch) | |
tree | 3aff0778b74cfbf328991aa83af50e9d07aff4e6 /phpBB/includes/functions_display.php | |
parent | f84460c710f528724fac68278361af7fe18e458c (diff) | |
parent | 9589fbffe4cdad9fa35df2597c21fc0753ed1d52 (diff) | |
download | forums-38c65da553c83e787d8a8adc1d40d789713579c4.tar forums-38c65da553c83e787d8a8adc1d40d789713579c4.tar.gz forums-38c65da553c83e787d8a8adc1d40d789713579c4.tar.bz2 forums-38c65da553c83e787d8a8adc1d40d789713579c4.tar.xz forums-38c65da553c83e787d8a8adc1d40d789713579c4.zip |
Merge branch 'develop' into feature/request-class
* develop: (157 commits)
[ticket/10316] Resolve inconsistent move topic behavior
[ticket/9297] Add network to class name of unit tests.
[ticket/9297] Fix typo in localhost.
[ticket/9297] Rename test class to reflect its contents.
[ticket/9297] Adjust comment - IPv6 is needed for IPv6 connections to work.
[ticket/9297] Fix markTestSkipped call in setUpBeforeClass.
[ticket/9608] Remove use of references in topic_review
[ticket/9297] Skip FTP PASV/EPSV test if FTP connection fails.
[ticket/9297] Separate ipv4 and ipv6 tests into separate functions.
[ticket/9297] Update copyright year of unit test file.
[feature/template-engine] Delete _get_locator function.
[feature/template-engine] Clean up template locator usage in bbcode.
[ticket/9297] Make EPSV unit tests work without IPv6.
[ticket/9297] Unit tests for ftp_fsock PASV and EPSV.
[ticket/9297] Add support for Extended Passive Mode (EPSV) in ftp_fsock class.
[ticket/10312] Un-check the shadow option while moving.
[feature/template-engine] Need to call set_template on template.
[feature/template-engine] Update installer for template engine changes.
[feature/template-engine] Dependency inject locator into template.
[feature/template-engine] Delete useless code from set_template.
...
Conflicts:
phpBB/includes/functions.php
Diffstat (limited to 'phpBB/includes/functions_display.php')
-rw-r--r-- | phpBB/includes/functions_display.php | 82 |
1 files changed, 58 insertions, 24 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 407909a2f4..26a4e965a7 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1040,7 +1040,7 @@ function display_user_activity(&$userdata) /** * Topic and forum watching common code */ -function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0) +function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0, $item_title = '') { global $template, $db, $user, $phpEx, $start, $phpbb_root_path; global $request; @@ -1070,32 +1070,46 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, if (!is_null($notify_status) && $notify_status !== '') { - if (isset($_GET['unwatch'])) { $uid = request_var('uid', 0); - if ($uid != $user_id) - { - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); - trigger_error($message); - } - if ($request->variable('unwatch', '', false, phpbb_request_interface::GET) == $mode) + $token = request_var('hash', ''); + + if (($token && check_link_hash($token, "{$mode}_$match_id")) || confirm_box(true)) { - $is_watching = 0; + if (($uid != $user_id) || ($request->variable('unwatch', '', false, phpbb_request_interface::GET) != $mode)) + { + $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); + $message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); + trigger_error($message); + } $sql = 'DELETE FROM ' . $table_sql . " WHERE $where_sql = $match_id AND user_id = $user_id"; $db->sql_query($sql); - } - - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - meta_refresh(3, $redirect_url); + $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); + $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); + meta_refresh(3, $redirect_url); + trigger_error($message); + } + else + { + $s_hidden_fields = array( + 'uid' => $user->data['user_id'], + 'unwatch' => $mode, + 'start' => $start, + 'f' => $forum_id, + ); + if ($mode != 'forum') + { + $s_hidden_fields['t'] = $topic_id; + } - $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); - trigger_error($message); + $confirm_box_message = (($item_title == '') ? 'UNWATCH_' . strtoupper($mode) : $user->lang('UNWATCH_' . strtoupper($mode) . '_DETAILED', $item_title)); + confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); + } } else { @@ -1115,26 +1129,45 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, { if (isset($_GET['watch'])) { + $uid = request_var('uid', 0); $token = request_var('hash', ''); - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - if ($request->variable('watch', '', false, phpbb_request_interface::GET) == $mode && check_link_hash($token, "{$mode}_$match_id")) + if (($token && check_link_hash($token, "{$mode}_$match_id")) || confirm_box(true)) { + if (($uid != $user_id) || ($request->variable('watch', '', false, phpbb_request_interface::GET) != $mode)) + { + $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); + $message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); + trigger_error($message); + } + $is_watching = true; $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status) VALUES ($user_id, $match_id, " . NOTIFY_YES . ')'; $db->sql_query($sql); + + $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); + meta_refresh(3, $redirect_url); + trigger_error($message); } else { - $message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); - } - - meta_refresh(3, $redirect_url); + $s_hidden_fields = array( + 'uid' => $user->data['user_id'], + 'watch' => $mode, + 'start' => $start, + 'f' => $forum_id, + ); + if ($mode != 'forum') + { + $s_hidden_fields['t'] = $topic_id; + } - trigger_error($message); + $confirm_box_message = (($item_title == '') ? 'WATCH_' . strtoupper($mode) : $user->lang('WATCH_' . strtoupper($mode) . '_DETAILED', $item_title)); + confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); + } } else { @@ -1144,7 +1177,8 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, } else { - if ($request->variable('unwatch', '', false, phpbb_request_interface::GET) == $mode) + if ((isset($_GET['unwatch']) && $request->variable('unwatch', '', false, phpbb_request_interface::GET) == $mode) || + (isset($_GET['watch']) && $request->variable('watch', '', false, phpbb_request_interface::GET) == $mode)) { login_box(); } |