Просмотр исходного кода

! Kill the 'email user' functionality (fixes #1403)

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 10 лет назад
Родитель
Сommit
b443bb82ae

+ 1 - 4
Sources/Display.php

@@ -378,9 +378,6 @@ function Display()
 	// Did we report a post to a moderator just now?
 	$context['report_sent'] = isset($_GET['reportsent']);
 
-	// Did we send this topic to a friend?
-	$context['topic_sent'] = isset($_GET['topicsent']);
-
 	// Let's get nosey, who is viewing this topic?
 	if (!empty($settings['display_who_viewing']))
 	{
@@ -1289,7 +1286,7 @@ function prepareDisplayContext($reset = false)
 		$memberContext[$message['id_member']]['group'] = $txt['guest_title'];
 		$memberContext[$message['id_member']]['link'] = $message['poster_name'];
 		$memberContext[$message['id_member']]['email'] = $message['poster_email'];
-		$memberContext[$message['id_member']]['show_email'] = showEmailAddress(true, 0);
+		$memberContext[$message['id_member']]['show_email'] = allowedTo('admin_forum');
 		$memberContext[$message['id_member']]['is_guest'] = true;
 	}
 	else

+ 1 - 1
Sources/Load.php

@@ -1142,7 +1142,7 @@ function loadMemberContext($user, $display_custom_fields = false)
 		'href' => $scripturl . '?action=profile;u=' . $profile['id_member'],
 		'link' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '">' . $profile['real_name'] . '</a>',
 		'email' => $profile['email_address'],
-		'show_email' => showEmailAddress(!empty($profile['hide_email']), $profile['id_member']),
+		'show_email' => !$user_info['is_guest'] && ($user_info['id'] == $profile['id_member'] || allowedTo('moderate_forum')),
 		'registered' => empty($profile['date_registered']) ? $txt['not_applicable'] : timeformat($profile['date_registered']),
 		'registered_timestamp' => empty($profile['date_registered']) ? 0 : forum_time(true, $profile['date_registered']),
 	);

+ 0 - 36
Sources/Security.php

@@ -1135,42 +1135,6 @@ function boardsAllowedTo($permissions, $check_access = true, $simple = true)
 	return $boards;
 }
 
-/**
- * Returns whether an email address should be shown and how.
- * Possible outcomes are
- *  'yes': show the full email address
- *  'yes_permission_override': show the full email address, either you
- *   are a moderator or it's your own email address.
- *  'no_through_forum': don't show the email address, but do allow
- *    things to be mailed using the built-in forum mailer.
- *  'no': keep the email address hidden.
- *
- * @param bool $userProfile_hideEmail
- * @param int $userProfile_id
- * @return string (yes, yes_permission_override, no_through_forum, no)
- */
-function showEmailAddress($userProfile_hideEmail, $userProfile_id)
-{
-	global $user_info;
-
-	// Should this user's email address be shown?
-	// If you're guest and the forum is set to hide email for guests: no.
-	// If the user is post-banned: no.
-	// If it's your own profile and you've set your address hidden: yes_permission_override.
-	// If you're a moderator with sufficient permissions: yes_permission_override.
-	// If the user has set their email address to be hidden: no.
-	// Otherwise: no_through_forum.
-
-	if ($user_info['is_guest'] || isset($_SESSION['ban']['cannot_post']))
-		return 'no';
-	elseif ((!$user_info['is_guest'] && $user_info['id'] == $userProfile_id && !$userProfile_hideEmail) || allowedTo('moderate_forum'))
-		return 'yes_permission_override';
-	elseif ($userProfile_hideEmail)
-		return 'no';
-	else
-		return 'no_through_forum';
-}
-
 /**
  * This function attempts to protect from spammed messages and the like.
  * The time taken depends on error_type - generally uses the modSetting.

+ 0 - 137
Sources/SendTopic.php

@@ -15,143 +15,6 @@
 if (!defined('SMF'))
 	die('No direct access...');
 
-/**
- * Allow a user to send an email.
- * Send an email to the user - allow the sender to write the message.
- * Can either be passed a user ID as uid or a message id as msg.
- * Does not check permissions for a message ID as there is no information disclosed.
- */
-function EmailUser()
-{
-	global $context, $user_info, $smcFunc, $txt, $scripturl, $sourcedir;
-
-	// Can the user even see this information?
-	if ($user_info['is_guest'])
-		fatal_lang_error('no_access', false);
-
-	isAllowedTo('send_email_to_members');
-
-	// Don't index anything here.
-	$context['robot_no_index'] = true;
-
-	// Load the template.
-	loadTemplate('SendTopic');
-
-	// Are we sending to a user?
-	$context['form_hidden_vars'] = array();
-	if (isset($_REQUEST['uid']))
-	{
-		$request = $smcFunc['db_query']('', '
-			SELECT email_address AS email, real_name AS name, id_member, hide_email
-			FROM {db_prefix}members
-			WHERE id_member = {int:id_member}',
-			array(
-				'id_member' => (int) $_REQUEST['uid'],
-			)
-		);
-
-		$context['form_hidden_vars']['uid'] = (int) $_REQUEST['uid'];
-	}
-	elseif (isset($_REQUEST['msg']))
-	{
-		$request = $smcFunc['db_query']('', '
-			SELECT IFNULL(mem.email_address, m.poster_email) AS email, IFNULL(mem.real_name, m.poster_name) AS name, IFNULL(mem.id_member, 0) AS id_member, hide_email
-			FROM {db_prefix}messages AS m
-				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
-			WHERE m.id_msg = {int:id_msg}',
-			array(
-				'id_msg' => (int) $_REQUEST['msg'],
-			)
-		);
-
-		$context['form_hidden_vars']['msg'] = (int) $_REQUEST['msg'];
-	}
-
-	if (empty($request) || $smcFunc['db_num_rows']($request) == 0)
-		fatal_lang_error('cant_find_user_email');
-
-	$row = $smcFunc['db_fetch_assoc']($request);
-	$smcFunc['db_free_result']($request);
-
-	// Are you sure you got the address?
-	if (empty($row['email']))
-		fatal_lang_error('cant_find_user_email');
-
-	// Can they actually do this?
-	$context['show_email_address'] = showEmailAddress(!empty($row['hide_email']), $row['id_member']);
-	if ($context['show_email_address'] === 'no')
-		fatal_lang_error('no_access', false);
-
-	// Setup the context!
-	$context['recipient'] = array(
-		'id' => $row['id_member'],
-		'name' => $row['name'],
-		'email' => $row['email'],
-		'email_link' => ($context['show_email_address'] == 'yes_permission_override' ? '<em>' : '') . '<a href="mailto:' . $row['email'] . '">' . $row['email'] . '</a>' . ($context['show_email_address'] == 'yes_permission_override' ? '</em>' : ''),
-		'link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['name'] . '</a>' : $row['name'],
-	);
-
-	// Can we see this person's email address?
-	$context['can_view_receipient_email'] = $context['show_email_address'] == 'yes' || $context['show_email_address'] == 'yes_permission_override';
-
-	// Are we actually sending it?
-	if (isset($_POST['send']) && isset($_POST['email_body']))
-	{
-		require_once($sourcedir . '/Subs-Post.php');
-
-		checkSession();
-
-		// If it's a guest sort out their names.
-		if ($user_info['is_guest'])
-		{
-			if (empty($_POST['y_name']) || $_POST['y_name'] == '_' || trim($_POST['y_name']) == '')
-				fatal_lang_error('no_name', false);
-			if (empty($_POST['y_email']))
-				fatal_lang_error('no_email', false);
-			if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['y_email']) == 0)
-				fatal_lang_error('email_invalid_character', false);
-
-			$from_name = trim($_POST['y_name']);
-			$from_email = trim($_POST['y_email']);
-		}
-		else
-		{
-			$from_name = $user_info['name'];
-			$from_email = $user_info['email'];
-		}
-
-		// Check we have a body (etc).
-		if (trim($_POST['email_body']) == '' || trim($_POST['email_subject']) == '')
-			fatal_lang_error('email_missing_data');
-
-		// We use a template in case they want to customise!
-		$replacements = array(
-			'EMAILSUBJECT' => $_POST['email_subject'],
-			'EMAILBODY' => $_POST['email_body'],
-			'SENDERNAME' => $from_name,
-			'RECPNAME' => $context['recipient']['name'],
-		);
-
-		// Don't let them send too many!
-		spamProtection('sendmail');
-
-		// Get the template and get out!
-		$emaildata = loadEmailTemplate('send_email', $replacements);
-		sendmail($context['recipient']['email'], $emaildata['subject'], $emaildata['body'], $from_email, 'custemail', false, 1, null, true);
-
-		// Now work out where to go!
-		if (isset($_REQUEST['uid']))
-			redirectexit('action=profile;u=' . (int) $_REQUEST['uid']);
-		elseif (isset($_REQUEST['msg']))
-			redirectexit('msg=' . (int) $_REQUEST['msg']);
-		else
-			redirectexit();
-	}
-
-	$context['sub_template'] = 'custom_email';
-	$context['page_title'] = $txt['send_email'];
-}
-
 /**
  * Report a post to the moderator... ask for a comment.
  * Gathers data from the user to report abuse to the moderator(s).

+ 2 - 11
Themes/default/Display.template.php

@@ -22,14 +22,6 @@ function template_main()
 				', $txt['report_sent'], '
 			</div>';
 	}
-	// Topic was sent successfully
-	elseif ($context['topic_sent'])
-	{
-		echo '
-			<div class="infobox">
-				', $txt['topic_sent'], '
-			</div>';
-	}
 
 	// Show the anchor for the top and for the first message. If the first message is new, say so.
 	echo '
@@ -656,11 +648,10 @@ function template_single_post($message, $force_alternate = null)
 		}
 
 	}
-
 	// Otherwise, show the guest's email.
-	elseif (!empty($message['member']['email']) && in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')) && $context['can_send_email'])
+	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
 		echo '
-								<li class="email"><a href="', $scripturl, '?action=emailuser;sa=email;msg=', $message['id'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
+								<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
 
 	// Show the IP to this user for this post - because you can moderate?
 	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))

+ 2 - 2
Themes/default/PersonalMessage.template.php

@@ -367,9 +367,9 @@ function template_folder()
 						<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
 
 					// Don't show the email address if they want it hidden.
-					if (in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')) && $context['can_send_email'])
+					if ($message['member']['show_email'])
 						echo '
-						<li><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $message['member']['id'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
+						<li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
 
 					// Since we know this person isn't a guest, you *can* message them.
 					if ($context['can_send_pm'])

+ 13 - 22
Themes/default/Profile.template.php

@@ -164,11 +164,10 @@ function template_summary()
 				</div>
 				', $context['member']['avatar']['image'], '
 				<ul class="reset">';
-	// @TODO fix the <ul> when no fields are visible
-	// What about if we allow email only via the forum??
-	if ($context['member']['show_email'] === 'yes' || $context['member']['show_email'] === 'no_through_forum' || $context['member']['show_email'] === 'yes_permission_override' && $context['can_send_email'])
+	// Email is only visible if it's your profile or you have the moderate_forum permission
+	if ($context['member']['show_email'])
 		echo '
-					<li><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $context['member']['id'], '" title="', $context['member']['show_email'] == 'yes' || $context['member']['show_email'] == 'yes_permission_override' ? $context['member']['email'] : '', '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
+					<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
 
 	// Don't show an icon if they haven't specified a website.
 	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
@@ -237,19 +236,11 @@ function template_summary()
 					<dt>', $txt['profile_posts'], ': </dt>
 					<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
 
-	if ($context['can_send_email'])
+	if ($context['member']['show_email'])
 	{
-		// Only show the email address fully if it's not hidden - and we reveal the email.
-		if ($context['member']['show_email'] == 'yes')
-			echo '
-						<dt>', $txt['email'], ': </dt>
-						<dd><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $context['member']['id'], '">', $context['member']['email'], '</a></dd>';
-
-		// ... Or if the one looking at the profile is an admin they can see it anyway.
-		elseif ($context['member']['show_email'] == 'yes_permission_override')
-			echo '
-						<dt>', $txt['email'], ': </dt>
-						<dd><em><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $context['member']['id'], '">', $context['member']['email'], '</a></em></dd>';
+		echo '
+					<dt>', $txt['email'], ': </dt>
+					<dd><a href="mailto:', $context['email']['member'], '">', $context['member']['email'], '</a></dd>';
 	}
 
 	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
@@ -626,7 +617,7 @@ function template_editBuddies()
 			<tr class="catbg">
 				<th class="first_th" scope="col" width="20%">', $txt['name'], '</th>
 				<th scope="col">', $txt['status'], '</th>';
-	if ($context['can_send_email'])
+	if (allowedTo('moderate_forum'))
 		echo '
 				<th scope="col">', $txt['email'], '</th>';
 
@@ -657,9 +648,9 @@ function template_editBuddies()
 			<tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
 				<td>', $buddy['link'], '</td>
 				<td align="center"><a href="', $buddy['online']['href'], '"><img src="', $buddy['online']['image_href'], '" alt="', $buddy['online']['text'], '" title="', $buddy['online']['text'], '"></a></td>';
-		if ($context['can_send_email'])
+		if ($buddy['show_email'])
 			echo '
-				<td align="center">', ($buddy['show_email'] == 'no' ? '' : '<a href="' . $scripturl . '?action=emailuser;sa=email;uid=' . $buddy['id'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>'), '</td>';
+				<td align="center"><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>';
 
 		// If these are off, don't show them
 		foreach ($buddy_fields as $key => $column)
@@ -745,7 +736,7 @@ function template_editIgnoreList()
 			<tr class="catbg">
 				<th class="first_th" scope="col" width="20%">', $txt['name'], '</th>
 				<th scope="col">', $txt['status'], '</th>';
-	if ($context['can_send_email'])
+	if (allowedTo('moderate_forum'))
 		echo '
 				<th scope="col">', $txt['email'], '</th>';
 	echo '
@@ -771,9 +762,9 @@ function template_editIgnoreList()
 			<tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
 				<td>', $member['link'], '</td>
 				<td align="center"><a href="', $member['online']['href'], '"><img src="', $member['online']['image_href'], '" alt="', $member['online']['text'], '" title="', $member['online']['text'], '"></a></td>';
-		if ($context['can_send_email'])
+		if ($member['show_email'])
 			echo '
-				<td align="center">', ($member['show_email'] == 'no' ? '' : '<a href="' . $scripturl . '?action=emailuser;sa=email;uid=' . $member['id'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>'), '</td>';
+				<td align="center"><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>';
 		echo '
 				<td align="center">', $member['icq']['link'], '</td>
 				<td align="center">', $member['aim']['link'], '</td>

+ 0 - 94
Themes/default/SendTopic.template.php

@@ -23,100 +23,6 @@
 		sc: the session id, or $context['session_id'].
 */
 
-// Send an email to a user!
-function template_custom_email()
-{
-	global $context, $txt, $scripturl;
-
-	echo '
-	<div id="send_topic">
-		<form action="', $scripturl, '?action=emailuser;sa=email" method="post" accept-charset="', $context['character_set'], '">
-			<div class="cat_bar">
-				<h3 class="catbg">
-					<span class="generic_icons mail icon"></span>', $context['page_title'], '
-				</h3>
-			</div>
-			<div class="windowbg">
-				<div class="content">
-					<dl class="settings send_mail">
-						<dt>
-							<strong>', $txt['sendtopic_receiver_name'], ':</strong>
-						</dt>
-						<dd>
-							', $context['recipient']['link'], '
-						</dd>';
-
-	// Can the user see the persons email?
-	if ($context['can_view_receipient_email'])
-		echo '
-						<dt>
-							<strong>', $txt['sendtopic_receiver_email'], ':</strong>
-						</dt>
-						<dd>
-							', $context['recipient']['email_link'], '
-						</dd>
-					</dl>
-					<hr>
-					<dl class="settings send_mail">';
-
-	// If it's a guest we need their details.
-	if ($context['user']['is_guest'])
-		echo '
-						<dt>
-							<label for="y_name"><strong>', $txt['sendtopic_sender_name'], ':</strong></label>
-						</dt>
-						<dd>
-							<input type="text" id="y_name" name="y_name" size="24" maxlength="40" value="', $context['user']['name'], '" class="input_text">
-						</dd>
-						<dt>
-							<label for="y_email"><strong>', $txt['sendtopic_sender_email'], ':</strong></label><br>
-							<span class="smalltext">', $txt['send_email_disclosed'], '</span>
-						</dt>
-						<dd>
-							<input type="email" id="y_mail" name="y_email" size="24" maxlength="50" value="', $context['user']['email'], '" class="input_text" required>
-						</dt>';
-	// Otherwise show the user that we know their email.
-	else
-		echo '
-						<dt>
-							<strong>', $txt['sendtopic_sender_email'], ':</strong><br>
-							<span class="smalltext">', $txt['send_email_disclosed'], '</span>
-						</dt>
-						<dd>
-							<em>', $context['user']['email'], '</em>
-						</dd>';
-
-	echo '
-						<dt>
-							<label for="email_subject"><strong>', $txt['send_email_subject'], ':</strong></label>
-						</dt>
-						<dd>
-							<input type="text" id="email_subject" name="email_subject" size="50" maxlength="100" class="input_text" required>
-						</dd>
-						<dt>
-							<label for="email_body"><strong>', $txt['message'], ':</strong></label>
-						</dt>
-						<dd>
-							<textarea id="email_body" name="email_body" rows="10" cols="20" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 90%; min-width: 90%' : 'width: 90%') . ';" required></textarea>
-						</dd>
-					</dl>
-					<hr class="hrcolor">
-					<div class="flow_auto">
-						<input type="submit" name="send" value="', $txt['sendtopic_send'], '" class="button_submit">
-					</div>
-				</div>
-			</div>';
-
-	foreach ($context['form_hidden_vars'] as $key => $value)
-		echo '
-			<input type="hidden" name="', $key, '" value="', $value, '">';
-
-	echo '
-			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
-		</form>
-	</div>';
-}
-
 function template_report()
 {
 	global $context, $txt, $scripturl;

+ 0 - 9
Themes/default/languages/index.english.php

@@ -277,7 +277,6 @@ $txt['redirect_board'] = 'Redirect Board';
 
 $txt['sendtopic_send'] = 'Send';
 $txt['report_sent'] = 'Your report has been sent successfully.';
-$txt['topic_sent'] = 'Your email has been sent successfully.';
 
 $txt['time_offset'] = 'Time Offset';
 $txt['or'] = 'or';
@@ -369,13 +368,6 @@ $txt['send_topic'] = 'Send this topic';
 $txt['watch'] = 'Watch';
 $txt['unwatch'] = 'Stop watching';
 
-$txt['sendtopic_sender_name'] = 'Your name';
-$txt['sendtopic_sender_email'] = 'Your email address';
-$txt['sendtopic_receiver_name'] = 'Recipient\'s name';
-$txt['sendtopic_receiver_email'] = 'Recipient\'s email address';
-
-$txt['allow_user_email'] = 'Allow users to email me';
-
 $txt['check_all'] = 'Check all';
 
 // Use numeric entities in the below string.
@@ -777,7 +769,6 @@ $txt['calendar_menu'] = 'View Calendar';
 // @todo Send email strings - should move?
 $txt['send_email'] = 'Send Email';
 $txt['send_email_disclosed'] = 'Note this will be visible to the recipient.';
-$txt['send_email_subject'] = 'Email Subject';
 
 $txt['ignoring_user'] = 'You are ignoring this user.';
 $txt['show_ignore_user_post'] = 'Show me the post.';

+ 0 - 1
index.php

@@ -290,7 +290,6 @@ function smf_main()
 		'dlattach' => array('Display.php', 'Download'),
 		'editpoll' => array('Poll.php', 'EditPoll'),
 		'editpoll2' => array('Poll.php', 'EditPoll2'),
-		'emailuser' => array('SendTopic.php', 'EmailUser'),
 		'findmember' => array('Subs-Auth.php', 'JSMembers'),
 		'groups' => array('Groups.php', 'Groups'),
 		'help' => array('Help.php', 'ShowHelp'),