Login  Register

Re: Really need some more Admin capabilities

Posted by Pedro on Feb 11, 2014; 9:14pm
URL: https://support.nabble.com/Really-need-some-more-Admin-capabilities-tp7589349p7589385.html

In order to edit your users subscriptions, add this code to your code. Please, add them all in one file to make it easy to edit:
<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[/t]"/>        
        
        <n.set_local_user.this_user/>
        <n.set_local_subscription.page_node.subscription_for email="[n.local_user.user_email/]" />
        
        <n.if.local_subscription.is_subscribed>
            <then>
                <input type="button" class="toolbar action-button" value="[t]Unsubscribe[/t]" onclick="window.location='[n.page_node.unsubscribe_path/]'"/>
            </then>
        </n.if.local_subscription.is_subscribed>
        <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.redirect_to.subscription_saved_url/>
        </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>

For now, you can access this page with this address: http://forum.sudsol.org/template/NamlServlet.jtp?macro=subscribe_user&node=1&user=1

You have to set the parameters node and user. You can get these values clicking on the permalink of user profile and the related app.

Example: if you want to edit follal subscription at Business Talk:
1- go to follal profile page -> permalink:
http://forum.sudsol.org/template/NamlServlet.jtp?macro=user_nodes&user=13
her id is 13.
2- go to Business Talk subforum -> permalink:
http://forum.sudsol.org/Business-Talk-f3.html
the app id is the number near f, in this case 3

Finally, the address will be:
http://forum.sudsol.org/template/NamlServlet.jtp?macro=subscribe_user&node=3&user=13

I will make it more intuitive.
 
My test forum.