changeset 77:b31c38a09c41 website

Add justification text in registration
author Chris Cannam
date Sun, 07 Jul 2013 11:57:22 +0200
parents e3e11437ecea
children 96118bc49f04
files forum/Sources/Register.php forum/Sources/Subs-Members.php forum/Sources/Subs-Post.php forum/Themes/Vamp/Register.template.php forum/Themes/Vamp/languages/EmailTemplates.english.php
diffstat 5 files changed, 24 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/forum/Sources/Register.php	Sun Jul 07 11:25:48 2013 +0200
+++ b/forum/Sources/Register.php	Sun Jul 07 11:57:22 2013 +0200
@@ -247,6 +247,9 @@
 			fatal_lang_error('under_age_registration_prohibited', false, array($modSettings['coppaAge']));
 		}
 
+		if (!isset($_POST['justify']) || $_POST['justify'] == '')
+			fatal_error('You must give some description of your interest in Vamp plugins.  This helps us to weed out spam registrations, which are otherwise very numerous!', false);
+
 		// Check whether the visual verification code was entered correctly.
 		if (!empty($modSettings['reg_verification']))
 		{
@@ -358,6 +361,7 @@
 		'require' => !empty($modSettings['coppaAge']) && !$verifiedOpenID && empty($_SESSION['skip_coppa']) ? 'coppa' : (empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval')),
 		'extra_register_vars' => array(),
 		'theme_vars' => array(),
+		'justify' => 'default justification',
 	);
 
 	// Include the additional options that might have been filled in.
@@ -374,6 +378,10 @@
 		if (isset($_POST[$var]))
 			$regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;
 
+	// This doesn't go in db
+	if (isset($_POST['justify']))
+		$regOptions['justify'] = '\'' . htmlspecialchars__recursive($_POST['justify']) . '\'';
+
 	// Registration options are always default options...
 	if (isset($_POST['default_options']))
 		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
@@ -846,4 +854,4 @@
 	}
 }
 
-?>
\ No newline at end of file
+?>
--- a/forum/Sources/Subs-Members.php	Sun Jul 07 11:25:48 2013 +0200
+++ b/forum/Sources/Subs-Members.php	Sun Jul 07 11:57:22 2013 +0200
@@ -885,7 +885,7 @@
 		sendmail($regOptions['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
 
 		// Admin gets informed here...
-		adminNotify('approval', $memberID, $regOptions['username']);
+		adminNotify('approval', $memberID, $regOptions['username'], $regOptions['justify']);
 	}
 
 	// Okay, they're for sure registered... make sure the session is aware of this for security. (Just married :P!)
@@ -1389,4 +1389,4 @@
 	return substr(preg_replace('/\W/', '', sha1(microtime() . mt_rand() . $dbRand . $modSettings['rand_seed'])), 0, 10);
 }
 
-?>
\ No newline at end of file
+?>
--- a/forum/Sources/Subs-Post.php	Sun Jul 07 11:25:48 2013 +0200
+++ b/forum/Sources/Subs-Post.php	Sun Jul 07 11:57:22 2013 +0200
@@ -3077,7 +3077,7 @@
 }
 
 // This simple function gets a list of all administrators and sends them an email to let them know a new member has joined.
-function adminNotify($type, $memberID, $member_name = null)
+function adminNotify($type, $memberID, $member_name = null, $justify = null)
 {
 	global $txt, $modSettings, $language, $scripturl, $user_info, $context, $smcFunc;
 
@@ -3085,11 +3085,13 @@
 	if (empty($modSettings['notify_new_registration']))
 		return;
 
+	$member_email = null;
+
 	if ($member_name == null)
 	{
 		// Get the new user's name....
 		$request = $smcFunc['db_query']('', '
-			SELECT real_name
+			SELECT real_name, email_address
 			FROM {db_prefix}members
 			WHERE id_member = {int:id_member}
 			LIMIT 1',
@@ -3097,7 +3099,7 @@
 				'id_member' => $memberID,
 			)
 		);
-		list ($member_name) = $smcFunc['db_fetch_row']($request);
+		list ($member_name, $member_email) = $smcFunc['db_fetch_row']($request);
 		$smcFunc['db_free_result']($request);
 	}
 
@@ -3142,6 +3144,7 @@
 	{
 		$replacements = array(
 			'USERNAME' => $member_name,
+			'USEREMAIL' => $member_email,
 			'PROFILELINK' => $scripturl . '?action=profile;u=' . $memberID
 		);
 		$emailtype = 'admin_notify';
@@ -3156,7 +3159,7 @@
 		$emaildata = loadEmailTemplate($emailtype, $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
 
 		// And do the actual sending...
-		sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
+		sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'] . "\n\nJustification: $justify\n\n", null, null, false, 0);
 	}
 	$smcFunc['db_free_result']($request);
 
@@ -3235,4 +3238,4 @@
 	return $use_ref ? $ref : $matches[0];
 }
 
-?>
\ No newline at end of file
+?>
--- a/forum/Themes/Vamp/Register.template.php	Sun Jul 07 11:25:48 2013 +0200
+++ b/forum/Themes/Vamp/Register.template.php	Sun Jul 07 11:57:22 2013 +0200
@@ -330,6 +330,8 @@
 			</div>';
 	}
 
+	echo '<div class="title_bar"><h4 class="titlebg">Why are you interested in Vamp plugins?:</h4></div><div class="windowbg2"><span class="topslice"><span></span></span><fieldset class="content centertext"><input type="text" name="justify" size="60"/></fiedset></div>';
+
 	if ($context['visual_verification'])
 	{
 		echo '
@@ -712,4 +714,4 @@
 		<br class="clear" />';
 }
 
-?>
\ No newline at end of file
+?>
--- a/forum/Themes/Vamp/languages/EmailTemplates.english.php	Sun Jul 07 11:25:48 2013 +0200
+++ b/forum/Themes/Vamp/languages/EmailTemplates.english.php	Sun Jul 07 11:57:22 2013 +0200
@@ -886,7 +886,7 @@
 			@description:
 		*/
 		'subject' => 'A new member has joined',
-		'body' => '{USERNAME} has just signed up as a new member of your forum. Click the link below to view their profile.
+		'body' => '{USERNAME} <{USEREMAIL}> has just signed up as a new member of your forum. Click the link below to view their profile.
 {PROFILELINK}
 
 Before this member can begin posting they must first have their account approved. Click the link below to go to the approval screen.
@@ -1059,4 +1059,4 @@
 		'author' => '<a href="http://www.simplemachines.org/community/?action=profile;u=63186">karlbenson</a>',
 	),
 );
-?>
\ No newline at end of file
+?>