delete_node.naml

<macro name="delete_post" requires="servlet">
	<n.node_page.>
		<n.if.not.visitor.can_delete.page_node>
			<then>
				<n.login.><t>Only authorized users can proceed in this area.</t></n.login.>
			</then>
		</n.if.not.visitor.can_delete.page_node>

		<n.page_node.delete_node_and_redirect/>
	</n.node_page.>
</macro>

<macro name="delete_node_and_redirect" requires="node">
	<n.set_var. name='next_url'>
		<n.parent_url_or_homepage/>
	</n.set_var.>
	<n.delete_message_or_node/>
	<n.redirect_to.var name='next_url'/>
</macro>

<macro name="delete_from_site" requires="servlet">
	<n.node_page.>
		<n.if.not.visitor.can_delete_recursively.page_node>
			<then>
				<n.login.><t>Only authorized users can proceed in this area.</t></n.login.>
			</then>
		</n.if.not.visitor.can_delete_recursively.page_node>

		<n.page_node.delete_node_recursively_and_redirect/>
	</n.node_page.>
</macro>

<macro name="delete_node_recursively_and_redirect" requires="node">
	<n.set_var. name='next_url'>
		<n.parent_url_or_homepage/>
	</n.set_var.>
	<n.send_deleted_nodes_email/>
	<n.delete_recursively/>
	<n.redirect_to.var name='next_url'/>
</macro>

<macro name="parent_url_or_homepage" requires="node">
	<n.if.has_parent>
		<then><n.parent_node.url/></then>
		<else><n.nabble_homepage/></else>
	</n.if.has_parent>
</macro>

<macro name="send_deleted_nodes_email" requires="node">
	<n.descendant_nodes_by_user.>
		<n.loop.>
			<n.if.current_user.is_registered>
				<then>
					<n.new_email.>
						<n.nodes_list.attach_nodes/>
						<n.send>
							<to.current_user.user_email/>
							<to_name.current_user.name/>
							<subject><t>Deleted posts</t></subject>
							<text_part.deleted_nodes_text/>
							<bounce_to.current_user.bounces_address/>
						</n.send>
					</n.new_email.>
				</then>
			</n.if.current_user.is_registered>
		</n.loop.>
	</n.descendant_nodes_by_user.>
</macro>

<macro name="deleted_nodes_text" unindent="true">
	<t>Dear user,</t>

	<t>Some of your posts have been deleted from <t.location.root_node.subject/>
	and we are sending you copies so that you have a chance to save them.</t>

	<t>Sincerely,</t>
	<t>The Nabble team</t>
	________________________________________
	<t>Free Embeddable <t.app.root_node.view_name/></t> powered by Nabble
	<n.nabble_homepage/>
</macro>

<macro name="attach_nodes" requires="node_list,email">
	<n.comment.>
		Attach valid nodes as ZIP files in the email
		(zip file contains message, images, files from the node)
	</n.comment.>
	<n.loop.>
		<n.if.not.current_node.message.is_deleted>
			<then.add_node_as_zip_attachment.current_node/>
		</n.if.not.current_node.message.is_deleted>
	</n.loop.>
</macro>