invite_subscribers.naml

<override_macro name="add_subscribers" requires="node">
	<n.if.is_submitted_form>
		<then.process_invited_emails/>
		<else.invite_subscribers_form/>
	</n.if.is_submitted_form>
</override_macro>

<macro name="invite_subscribers_form">
	<div class="weak-color" style="margin:.5em 0 .5em">
		<t>Enter one email address or user name per row:</t>
	</div>
	<n.form.>
		<input type="hidden" name="filter" value="invite"/>
		<textarea name="invited-emails" style="width:40em;height:12em"></textarea>

		<div class="weak-color" style="font-size:80%;margin:1em 0 .5em">
			<t>Examples:</t>
			<div style="margin-left:1em">
			john_smith<br/>
			john_smith@example.com<br/>
			John Smith &lt;john_smith@example.com&gt;
			</div>
		</div>

		<div class="weak-color" style="margin:1.5em 0 .5em">
			<t><b>IMPORTANT</b>: Nabble will send an invitation to each email in the list.
			Users will have to click on a link to confirm their subscription.</t>
		</div>

		<div style="margin-top:1.4em">
			<input type="submit" value="[t]Invite Subscribers[/t]" />
		</div>
	</n.form.>
</macro>

<macro name="invited_emails" requires="servlet">
	<n.get_parameter name="invited-emails"/>
</macro>

<macro name="process_invited_emails">
	<div class="second-font field-title">
		<t>Subscription Results</t>
	</div>
	<n.if.not.is_null.invited_emails>
		<then>
			<n.string_list. values="[n.invited_emails/]" separator="\n">
				<table>
					<n.loop.>
						<n.set_var. name='email'>
							<n.get_email_address_from.current_string/>
						</n.set_var.>

						<n.if.not.is_empty.var name='email'>
							<then>
								<n.set_local_subscription.page_node.subscription_for email="[n.var name='email'/]" />
								<n.if.not.local_subscription.is_subscribed>
									<then.if.local_subscription.user.can_view.local_subscription.node>
										<then>
											<n.local_subscription.send_subscription_invite/>
											<n.row_success.current_string/>
										</then>
										<else.row_failed text="[n.current_string/]" explaination="[t]This user doesn't have permission to view this application (add him/her to a group that allows this and try again)[/t]"/>
									</then.if.local_subscription.user.can_view.local_subscription.node>
									<else.row_success text="[n.current_string/]" explaination="[t]Already subscribed[/t]"/>
								</n.if.not.local_subscription.is_subscribed>
							</then>
							<else.row_failed.current_string/>
						</n.if.not.is_empty.var>
					</n.loop.>
				</table>
			</n.string_list.>
		</then>
	</n.if.not.is_null.invited_emails>
</macro>

<macro name="row_success" dot_parameter="text" parameters="explaination">
	<tr>
		<td style="padding:.3em"><n.text/></td>
		<td>
			<t>Success</t>
			<n.if.not.is_empty.explaination>
				<then> -- <n.explaination/></then>
			</n.if.not.is_empty.explaination>
		</td>
	</tr>
</macro>

<macro name="row_failed" dot_parameter="text" parameters="explaination">
	<tr>
		<td style="padding:.3em"><n.text/></td>
		<td class="important">
			<t>Failed</t>
			<n.if.not.is_empty.explaination>
				<then> -- <n.explaination/></then>
			</n.if.not.is_empty.explaination>
		</td>
	</tr>
</macro>

<macro name="send_subscription_invite" requires="subscription,node_page,servlet">
	<n.set_local_subscription.this_subscription />
	<n.new_email.>
		<n.send>
			<to><n.user.user_email/></to>
			<subject><t>Subscribe to <t.location.page_node.subject/></t></subject>
			<text_part>
				<t>Dear user,</t>

				<t><t.owner_name.page_node.owner.name/> is inviting you to subscribe to <t.location.page_node.subject/>:</t>
				<n.page_node.url/>

				<t>With your subscription, updates will be sent directly to your email address
				and you can reply to them to participate in the discussion. Your subscription works the same
				as a mailing list.</t>

				<t>To confirm your subscription, click on the link below:</t>
				<n.local_subscription.send_subscription_invite_subscribe_by_code_url/>

				<t>Sincerely,</t>
				<t>The Nabble team</t>
				________________________________________
				<t>Free Embeddable <t.app.page_node.view_name/></t> powered by Nabble
				<n.nabble_homepage/>
			</text_part>
			<html_part>
				<t>Dear user,</t><br/>
				<br/>
				<t><t.owner_name.page_node.owner.name/> is inviting you to subscribe to <t.location.bold.page_node.subject/>:</t><br/>
				<a href="[n.page_node.url/]"><n.page_node.url/></a><br/>
				<br/>
				<t>With your subscription, updates will be sent directly to your email address
				and you can reply to them to participate in the discussion. Your subscription works the same
				as a mailing list.</t><br/>
				<br/>
				<t>To confirm your subscription, click on the link below:</t>
				<div style="background-color:#FFFADB;border:#EDDD79 solid 1px;margin:1.2em 0;padding:.5em">
					<a href="[n.local_subscription.send_subscription_invite_subscribe_by_code_url/]">
						<n.local_subscription.send_subscription_invite_subscribe_by_code_url/>
					</a>
				</div>
				<t>Sincerely,</t><br/>
				<t>The Nabble team</t><br/>
				________________________________________<br/>
				<t>Free Embeddable <t.app.page_node.view_name/></t> powered by Nabble<br/>
				<n.nabble_homepage/><br/><br/>
			</html_part>
		</n.send>
	</n.new_email.>
</macro>

<macro name="send_subscription_invite_subscribe_by_code_url" requires="subscription">
	<n.subscribe_by_code_url subscription_to="DESCENDANTS"/>
</macro>