aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-07-16 21:43:17 -0400
committerNils Adermann <naderman@naderman.de>2011-07-16 21:43:17 -0400
commitb3cdd1d16981c5992d1bffb97786084f9f02cad1 (patch)
tree0803a2485de8e060325a3694597d70926d46fe0a
parentdcceeb8012cfe81dc8c481590495db1dc6a0535b (diff)
parentd60ffdd55c4066b8e69c0522c464ec1ada4b0913 (diff)
downloadforums-b3cdd1d16981c5992d1bffb97786084f9f02cad1.tar
forums-b3cdd1d16981c5992d1bffb97786084f9f02cad1.tar.gz
forums-b3cdd1d16981c5992d1bffb97786084f9f02cad1.tar.bz2
forums-b3cdd1d16981c5992d1bffb97786084f9f02cad1.tar.xz
forums-b3cdd1d16981c5992d1bffb97786084f9f02cad1.zip
Merge remote-tracking branch 'github-nickvergessen/ticket/10237' into develop-olympus
* github-nickvergessen/ticket/10237: [ticket/10237] Also display login-box on subscribing [ticket/10237] Handle watching and unwatching the same way. [ticket/10237] Use confirm-box to handle unwatching a forum/topic actions
-rw-r--r--phpBB/includes/functions_display.php80
-rw-r--r--phpBB/language/en/common.php8
-rw-r--r--phpBB/viewforum.php2
-rw-r--r--phpBB/viewtopic.php2
4 files changed, 67 insertions, 25 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index d7422aa2c9..7982b9908d 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -1058,7 +1058,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;
@@ -1091,28 +1091,43 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
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&amp;start=$start");
- $message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
- trigger_error($message);
- }
- if ($_GET['unwatch'] == $mode)
+ $token = request_var('hash', '');
+
+ if (($token && check_link_hash($token, "{$mode}_$match_id")) || confirm_box(true))
{
- $is_watching = 0;
+ if (($uid != $user_id) || ($_GET['unwatch'] != $mode))
+ {
+ $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&amp;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&amp;start=$start");
- meta_refresh(3, $redirect_url);
+ $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&amp;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
{
@@ -1132,26 +1147,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&amp;start=$start");
- if ($_GET['watch'] == $mode && check_link_hash($token, "{$mode}_$match_id"))
+ if (($token && check_link_hash($token, "{$mode}_$match_id")) || confirm_box(true))
{
+ if (($uid != $user_id) || ($_GET['watch'] != $mode))
+ {
+ $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&amp;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&amp;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
{
@@ -1161,7 +1195,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
}
else
{
- if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode)
+ if ((isset($_GET['unwatch']) && $_GET['unwatch'] == $mode) || (isset($_GET['watch']) && $_GET['watch'] == $mode))
{
login_box();
}
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index 078a280223..1c96818346 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -652,6 +652,10 @@ $lang = array_merge($lang, array(
'UNREAD_PMS' => '<strong>%d</strong> unread messages',
'UNREAD_POST' => 'Unread post',
'UNREAD_POSTS' => 'Unread posts',
+ 'UNWATCH_FORUM_CONFIRM' => 'Are you sure you wish to unsubscribe from this forum?',
+ 'UNWATCH_FORUM_DETAILED' => 'Are you sure you wish to unsubscribe from the forum “%s”?',
+ 'UNWATCH_TOPIC_CONFIRM' => 'Are you sure you wish to unsubscribe from this topic?',
+ 'UNWATCH_TOPIC_DETAILED' => 'Are you sure you wish to unsubscribe from the topic “%s”?',
'UNWATCHED_FORUMS' => 'You are no longer subscribed to the selected forums.',
'UNWATCHED_TOPICS' => 'You are no longer subscribed to the selected topics.',
'UNWATCHED_FORUMS_TOPICS' => 'You are no longer subscribed to the selected entries.',
@@ -700,6 +704,10 @@ $lang = array_merge($lang, array(
'WARNINGS' => 'Warnings',
'WARN_USER' => 'Warn user',
+ 'WATCH_FORUM_CONFIRM' => 'Are you sure you wish to subscribe to this forum?',
+ 'WATCH_FORUM_DETAILED' => 'Are you sure you wish to subscribe to the forum “%s”?',
+ 'WATCH_TOPIC_CONFIRM' => 'Are you sure you wish to subscribe to this topic?',
+ 'WATCH_TOPIC_DETAILED' => 'Are you sure you wish to subscribe to the topic “%s”?',
'WELCOME_SUBJECT' => 'Welcome to %s forums',
'WEBSITE' => 'Website',
'WHOIS' => 'Whois',
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 61ec27ed79..e0b51bf782 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -208,7 +208,7 @@ $s_watching_forum = array(
if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && $auth->acl_get('f_subscribe', $forum_id))
{
$notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL;
- watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status);
+ watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']);
}
$s_forum_rules = '';
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 08e82591de..8b081b4aec 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -488,7 +488,7 @@ $s_watching_topic = array(
if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] && $user->data['is_registered'])
{
- watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $topic_data['notify_status'], $start);
+ watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $topic_data['notify_status'], $start, $topic_data['topic_title']);
// Reset forum notification if forum notify is set
if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))