register.naml

<macro name="start_registration_page" requires="servlet">
	<n.if.is_submitted_form>
		<then.process_registration/>
	</n.if.is_submitted_form>

	<n.html>
		<head>
			<n.title.><t>Register to <t.app.root_node.subject/></t></n.title.>
			<n.registration_stylesheet/>
		</head>
		<body>
			<div class="center-content">
				<h1 class="weak-color"><t>Register</t></h1>
				<span class="second-font shaded-bg-color rounded big-title" style="padding:.2em .7em">
					<n.root_node.subject/>
				</span>

				<n.handle_registration_errors/>

				<n.form.>
					<n.nextUrl_field.hidden/>
					<div style="text-align:left;margin:0 auto">
						<n.registration_fields/>
						<div class="weak-color" style="margin-top:1em;text-align:center;">
							<input type="submit" class="toolbar action-button" value="[t]Register Now[/t]"/>
						</div>
					</div>
				</n.form.>
			</div>
		</body>
	</n.html>
</macro>

<macro name="registration_stylesheet">
	<style type="text/css">
		body { text-align:center; }
		div.center-content { margin:0px auto; margin-bottom: 3em; }
		table.field-table { margin:1em auto; border-collapse:collapse; }
		table.field-table td { vertical-align:middle; }
		td.column1 {
			text-align:right;
			width:7em;
			white-space:nowrap;
			padding-right:.3em;
		}
		input[type=text],input[type=password] { padding:.4em 0; }
		div.field-title { margin-top:.1em; white-space:nowrap; }
		div.field-title { margin-top:.1em; white-space:nowrap; }
		.important { font-weight:bold }
		#nabble-captcha { vertical-align:-.8em }
	</style>
</macro>

<macro name="process_registration">
	<n.catch_exception. id="save-block">
		<n.validate_registration_form/>
		<n.check_captcha/>

		<n.registration>
			<user_name><n.user_name_field.value/></user_name>
			<email><n.email_field.value/></email>
			<password><n.password_field.value/></password>
			<next_url><n.nextUrl_field.value/></next_url>
			<do>
				<n.send_registration_email
					email="[n.email_field.value/]"
					next_url="[n.nextUrl_field.value/]"
					key="[n.key/]"
				/>
				<n.redirect_to.registering_page_path/>
			</do>
		</n.registration>
	</n.catch_exception.>
</macro>

<macro name="handle_registration_errors">
	<n.if.is_submitted_form>
		<then>
			<n.if.has_exception for="save-block">
				<then>
					<n.handle_exception. for="save-block">
						<div class="error-message important" style="margin:1em;padding:.5em 0">
							<n.exception. name="user_already_registered">
								<t>You have already been registered.</t>
								<a href="[n.forgot_password_path/]"><t>Forgot your password?</t></a>
							</n.exception.>
							<n.exception. name="invalid_captcha_code">
								<t>The validation code did not match the picture.</t>
							</n.exception.>
							<n.exception. name="empty_registration_field">
								<t>You must fill in all fields below.</t>
							</n.exception.>
							<n.exception. name="must_accept_terms_of_use">
								<t>You must agree to the Terms of Use.</t>
							</n.exception.>
							<n.exception. name="invalid_email">
								<t>Enter a valid email address.</t>
							</n.exception.>
							<n.exception. name="passwords_dont_match">
								<t>The password fields don't match.</t>
							</n.exception.>
							<n.exception. name="user_name_already_in_use">
								<t>This user name is already in use.</t>
							</n.exception.>
						</div>
					</n.handle_exception.>
				</then>
			</n.if.has_exception>
		</then>
	</n.if.is_submitted_form>
</macro>

<macro name="registration_fields">
	<table class="field-table">
		<tr>
			<td class="column1"><div class="second-font field-title"><t>User Name</t></div></td>
			<td>
				<n.user_name_field.input type="text" size="35" maxlength="30"/>
				<n.user_name_field.highlight_if_empty/>
			</td>
		</tr>
		<tr>
			<td class="column1"><div class="second-font field-title"><t>Email</t></div></td>
			<td>
				<n.email_field.input type="text" size="35" maxlength="60"/>
				<n.email_field.highlight_if_empty/>
			</td>
		</tr>
		<tr>
			<td></td>
			<td class="weak-color" style="margin-top:1em;font-size:80%;padding-bottom:1em">
				<t>You will receive an email with a link to activate your account.</t>
			</td>
		</tr>
		<tr>
			<td class="column1"><div class="second-font field-title"><t>Password</t></div></td>
			<td>
				<n.password_field.input type="password" size="15" maxlength="15"/>
				<n.password_field.highlight_if_empty/>
			</td>
		</tr>
		<tr>
			<td class="column1"><div class="second-font field-title"><t>Confirm Password</t></div></td>
			<td>
				<n.password2_field.input type="password" size="15" maxlength="15"/>
				<n.password2_field.highlight_if_empty/>
			</td>
		</tr>
		<tr>
			<td class="column1" style="padding-top:.5em">
				<n.accept_terms_field.checkbox/>
			</td>
			<td class="nowrap" style="padding-top:.5em">
				<label for="accept_terms"><t>I have read and I agree to Nabble's <n.terms_link.>Terms of Use</n.terms_link.>.</t></label>
			</td>
		</tr>
		<tr>
			<td></td>
			<td style="padding-top:.5em">
				<n.captcha_control/>
			</td>
		</tr>
	</table>
</macro>

<macro name="validate_registration_form">
	<n.user_name_field.notify_if_empty/>
	<n.email_field.notify_if_empty/>
	<n.password_field.notify_if_empty/>
	<n.password2_field.notify_if_empty/>

	<n.if.not.equal value1="[n.password_field.value/]" value2="[n.password2_field.value/]">
		<then.throw_template_exception name="passwords_dont_match"/>
	</n.if.not.equal>

	<n.if.not.accept_terms_field.is_checked>
		<then.throw_template_exception name="must_accept_terms_of_use"/>
	</n.if.not.accept_terms_field.is_checked>
</macro>

<macro name="notify_if_empty" requires="field">
	<n.if.is_empty.value>
		<then.throw_template_exception name="empty_registration_field"/>
	</n.if.is_empty.value>
</macro>

<macro name="highlight_if_empty" requires="field">
	<n.if.both condition1="[n.is_submitted_form/]" condition2="[n.is_empty.value/]">
		<then><span class="important"><t>required</t></span></then>
	</n.if.both>
</macro>

<macro name="accept_terms_field" dot_parameter="do">
	<n.field. name="accept_terms"><n.do/></n.field.>
</macro>

<macro name="user_name_field" dot_parameter="do">
	<n.field. name="user_name"><n.do/></n.field.>
</macro>

<macro name="password2_field" dot_parameter="do">
	<n.field. name="password2"><n.do/></n.field.>
</macro>

<macro name="registering_page" requires="servlet">
	<n.html>
		<head>
			<n.title.><t>Registering...</t></n.title.>
			<style type="text/css">
				body { text-align:center; }
				div.center-content { margin:0px auto; margin-bottom: 3em; }
			</style>
		</head>
		<body>
			<div class="center-content">
				<h1 class="weak-color"><t>Registering...</t></h1>
				<p><t>An email has been sent to you.</t></p>
				<p><t>Please follow the instructions in the email to complete the registration process.</t></p>
				<n.show_email_warning/>
			</div>
		</body>
	</n.html>
</macro>

<macro name="registering_page_path" parameters="message,nextUrl">
	<n.encode_url.>
		/template/NamlServlet.jtp?macro=registering_page
	</n.encode_url.>
</macro>

<macro name="show_email_warning" requires="servlet">
	<div class="info-message" style="padding: .45em;margin: 1em 0">
		<t>If you are not receiving emails from Nabble, please check your <b>spam</b> folder.</t>
	</div>
</macro>


<macro name="finish_registration_page" requires="servlet">
	<n.html>
		<head>
			<n.title.><t>Registration Confirmed</t></n.title.>
		</head>
		<body>
			<n.set_local_user.get_user_from_email email="[n.email_field.value/]" />
			<n.if.both condition1="[n.not.is_null.local_user/]" condition2="[n.local_user.is_registered/]">
				<then>
					<h1><t>Registration Confirmed</t></h1>
					<p><t>You have already been registered.</t></p>
				</then>
				<else>
					<n.save_registration/>
				</else>
			</n.if.both>
		</body>
	</n.html>
</macro>

<macro name="save_registration">
	<n.catch_exception. id="save-block">
		<n.set_local_user.get_registration registration_key="[n.get_parameter name='key'/]" email="[n.email_field.value/]" />
		<n.if.is_null.local_user>
			<then>
				<h1><t>Registration Failed</t></h1>
				<p><t>Please make sure you are using the same browser that you used to fill in the registration request.</t></p>
				<p><t>You can try <n.register_link.>registering again</n.register_link.> or contact <n.support_link/>.</t></p>
			</then>
			<else>
				<n.local_user.register/>
				<n.set_var. name="next_url">
					<n.get_next_url_from_registration registration_key="[n.get_parameter name='key'/]" />
				</n.set_var.>

				<h1><t>Registration Confirmed</t></h1>
				<p><t>You have been registered to <t.subject.root_node.subject/>.</t></p>
				<p><a href="[n.var name='next_url'/]"><t>Continue</t></a></p>

				<n.local_user.after_registration/>
			</else>
		</n.if.is_null.local_user>
	</n.catch_exception.>
	<n.if.has_exception for="save-block">
		<then>
			<h1><t>Registration Failed</t></h1>
			<br />
			<n.handle_exception. for="save-block">
				<n.comment.>
					fill in as needed
				</n.comment.>
			</n.handle_exception.>
		</then>
	</n.if.has_exception>
</macro>

<macro name="after_registration" requires="user">
	<n.comment.>To be overridden</n.comment.>
</macro>

<macro name="send_registration_email" parameters="email, next_url, key" unindent="true">
	<n.set_var. name='confirm_url'>
		<n.remove_spaces.>
			<n.base_url/>
			<n.encode_url.>
				/template/NamlServlet.jtp?macro=finish_registration_page
				&email=<n.email/>
				&key=<n.key/>
				&date=<n.now.raw_time/>
			</n.encode_url.>
		</n.remove_spaces.>
	</n.set_var.>
	<n.new_email.>
		<n.send>
			<to><n.email/></to>
			<subject><t><t.app.root_node.subject/> Registration</t></subject>
			<text_part>
				<t>Dear user,</t>

				<t>Thank you for registering with <t.app.root_node.subject/>!</t>

				*<t>Email Confirmation</t>*
				<t>Please click on the confirmation link below to activate your account:</t>

				<n.var name='confirm_url'/>

				<t>If you didn't request this email or have no idea why you received it, please ignore it. It might have been a mistake from someone else.</t>

				<t>Sincerely,</t>
				<n.root_node.subject/>
				<n.base_url/>
			</text_part>
			<aol_part>
				<t>Dear user,</t>

				<t>Thank you for registering with <t.app.root_node.subject/>!</t>

				*<t>Email Confirmation</t>*
				<t>Please click on the confirmation link below to activate your account:</t>

				<n.var name='confirm_url'/>

				<t>If you didn't request this email or have no idea why you received it, please ignore it. It might have been a mistake from someone else.</t>

				<t>Sincerely,</t>
				<n.root_node.subject/>
				<n.base_url/>
			</aol_part>
			<html_part>
				<t>Dear user,</t><br/>
				<br/>
				<t>Thank you for registering with <t.app.root_node.subject/>!</t><br/>
				<br/>
				<div style="font-weight:bold;margin-bottom:.25em">
					<t>Email Confirmation</t>
				</div>
				<t>Please click on the confirmation link below to activate your account:</t>
				<div style="background-color:#FFFADB;border:#EDDD79 solid 1px;margin:1.2em 0;padding:.5em">
					<a href="[n.var name='confirm_url'/]"><n.var name='confirm_url'/></a>
				</div>
				<div style="margin:.3em 0 1.2em">
					<t>If you didn't request this email or have no idea why you received it, please ignore it.
						It might have been a mistake from someone else.</t>
				</div>
				<t>Sincerely,</t><br/>
				<n.root_node.subject/><br/>
				<a href="[n.base_url/]"><n.base_url/></a>
				<div style="margin:1.5em 0;color:#666666;font: 11px tahoma,geneva,helvetica,arial,sans-serif;">
					<n.macro_viewer_email_link macro="send_registration_email"/>
				</div>
			</html_part>
		</n.send>
	</n.new_email.>
</macro>