subscribe_user.naml

<macro name="subscribe_user" requires="servlet">
    <n.node_page.>
        <n.html>
            <head>
                <meta name="robots" content="noindex,nofollow"/>
                <n.title.><t>Subscribe via email</t></n.title.>
                <n.main_title_css/>
            </head>
            <body>
                <n.if.visitor.is_anonymous>
                    <then>
                        <n.edit_header first_text="[n.page_node.subject/]" second_text="[t]Email Subscription[/t]" />
                        <n.if.is_submitted_form>
                            <then>
                                <n.if.equal value1="send-anonymous" value2="[n.action_parameter/]">
                                    <then>
                                        <n.catch_exception. id="send-email-block">
                                            <n.handle_anonymous_subscription/>
                                        </n.catch_exception.>
                                    </then>
                                </n.if.equal>
                                <n.if.has_exception for="send-email-block">
                                    <then.show_subscription_error/>
                                    <else.show_success_message/>
                                </n.if.has_exception>
                            </then>
                        </n.if.is_submitted_form>
                        <n.anonymous_subscription_form/>
                    </then>
                    <else>
                        <n.set_local_user.get_user_from_id user_id="[n.get_parameter name='user'/]" />            
                        <n.local_user.profile_header/>
                        
                        <n.if.is_submitted_form>
                            <then.local_user.save_field_values_user/>
                            <else.local_user.load_field_values_user/>
                        </n.if.is_submitted_form>
                        
                        <n.local_user.subscription_form_user/>
                    </else>
                </n.if.visitor.is_anonymous>
            </body>
        </n.html>
    </n.node_page.>
</macro>

<macro name="subscription_form_user" requires="node_page,user">
    <div class="shaded-bg-color rounded second-font main-title">
        <t>Edit Subscription of This User inside <n.page_node.subject/></t>        
    </div>
    <n.form.>
        <input type="hidden" name="action" value="save-subscription"/>
        
        <n.if.page_node.is_app>
            <then.app_subscription_controls/>
            <else.post_subscription_controls/>
        </n.if.page_node.is_app>
        
        <n.show_mailing_list_alert/>
                
        <br/>
        <input type="submit" class="toolbar action-button" value="[t]Save Subscription to all Children[/t]"/>        
        
        <n.set_local_user.this_user/>
        <n.set_local_subscription.page_node.subscription_for email="[n.local_user.user_email/]" />
        
        <input type="button" class="toolbar action-button" value="[t]Save Digest top only[/t]" onclick="window.location='[n.page_node.subscribe_user_top_digestl_path/]'"/> 
        
        <input type="button" class="toolbar action-button" value="[t]Unsubscribe[/t]" onclick="window.location='[n.page_node.unsubscribe_user_path/]'"/>
        
        <input type="button" class="toolbar action-button" value="[t]Unsubscribe All Children[/t]" onclick="window.location='[n.page_node.unsubscribe_user_all_path/]'"/>
        <t>or</t> <a href="javascript:history.back()"><t>Cancel</t></a>
    </n.form.>
</macro>

<macro name="save_field_values_user" requires="user">
    <n.set_local_user.this_user/>
    <n.set_local_subscription.page_node.subscription_for email="[n.local_user.user_email/]" />
    <n.if.equal value1="save-subscription" value2="[n.action_parameter/]">
        <then>
            <n.local_subscription.save
            to="[n.subscription_to_field.value/]"
            type="[n.subscription_type_field.value/]"
            />
           <n.page_node.sub_descendants_user user="[n.local_user/]"/>
            
            <n.if.visitor.is_site_admin>
                <then>
                    <n.redirect_to.subscription_saved_user_url/>
                </then>
                <else>
                    <n.redirect_to.subscription_saved_url/>
                </else>
            </n.if.visitor.is_site_admin>
        </then>
    </n.if.equal>
</macro>


<macro name="load_field_values_user" requires="user">
    <n.set_local_user.this_user/>
    <n.set_local_subscription.page_node.subscription_for email="[n.local_user.user_email/]" />
    <n.subscription_to_field.set_value.>
        <n.if.local_subscription.is_subscribed>
            <then.local_subscription.to/>
            <else>DESCENDANTS</else>
        </n.if.local_subscription.is_subscribed>
    </n.subscription_to_field.set_value.>
    
    <n.subscription_type_field.set_value.>
        <n.if.local_subscription.is_subscribed>
            <then.local_subscription.type/>
            <else>INSTANT</else>
        </n.if.local_subscription.is_subscribed>
    </n.subscription_type_field.set_value.>
</macro>