denny/ShinyCMS

View on GitHub
root/newsletters/lists.tt

Summary

Maintainability
Test Coverage
[%-    meta.title = 'Mailing Lists' -%]

[%- IF c.user_exists OR token -%]

<div class="subscriptions">
<form id="list_subs" name="list_subs" action="[% c.uri_for( '/newsletters/lists/update' ) %]" method="post">
    [%- IF public_lists %]
    <h4>
        Public Lists
    </h4>
    [%- FOREACH list IN public_lists.all %]
    [%- list_id = list.id %]
    <label><input id="list_[% list.id %]" name="lists" value="[% list.id %]" type="checkbox"
    [%- IF user_is_subscribed_to_list.$list_id %] checked="checked"[% END %]> [% list.name | html %]</label>
    <br>
    [%- END  # FOREACH list    %]
    <br>
    [%- END  # IF public_lists %]

    [%- IF private_lists %]
    <h4>
        Private Lists
    </h4>
    [%- FOREACH list IN private_lists.all %]
    [%- list_id = list.id %]
    <label><input id="list_[% list.id %]" name="lists" value="[% list.id %]" type="checkbox"
    [%- IF user_is_subscribed_to_list.$list_id %] checked="checked"[% END %]> [% list.name | html %]</label>
    <br>
    [%- END  # FOREACH list     %]
    <br>
    [%- END  # IF private_lists %]

    [%- IF paid_lists %]
    <h4>
        Paid Lists
    </h4>
    [%- FOREACH list IN paid_lists.all %]
    [%- list_id = list.id %]
    <label><input id="list_[% list.id %]" name="lists" value="[% list.id %]" type="checkbox"
    [%- IF user_is_subscribed_to_list.$list_id %] checked="checked"[% END %]> [% list.name | html %]</label>
    <br>
    [%- END  # FOREACH list  %]
    <br>
    [%- END  # IF paid_lists %]

    [%- IF autoresponders %]
    <h4>
        Autoresponders
    </h4>
    [%- FOREACH ar IN autoresponders.all %]
    <input id="autoresponder_[% ar.id %]" name="autoresponder_[% ar.id %]" type="hidden" value="1">
    <label><input id="keep_autoresponder_[% ar.id %]" name="keep_autoresponder_[% ar.id %]" type="checkbox" checked="checked">
    &nbsp;[% ar.name | html %]</label><br>
    [%- END  # FOREACH ar        %]
    [%- END  # IF autoresponders %]

    [%- UNLESS c.user_exists %]
    [%- IF token %]
    <input name="token" value="[% token %]" type="hidden">
    [%- ELSE %]
    [%# TODO: this needs more thought - see notes in Newsletter.pm
    <br><label>Email address (required)
    <br><input id="email" name="email" type="text"></label>
    <br><label>Name (optional)
    <br><input id="name" name="name" type="text"></label>
    %]
    [%- END %]
    [%- END %]

    <p>
        [%- IF public_lists OR private_lists OR paid_lists OR autoresponders %]
        <input value="Update" type="submit">
        [%- ELSE %]
        There are currently no lists available for you to subscribe to.
        [%- END %]
    </p>
</form>
</div>

[%- IF public_lists OR private_lists OR paid_lists OR autoresponders %]
<div class="hintbox">
<p>
    To subscribe to a list, check the box next to it. If the box is already
    checked, you are already subscribed - to unsubscribe, uncheck the box.
    Once you have made your changes, please click 'Update' to save them.
</p>
[%- IF private_lists %]
<p>
    You can only see the private lists that you are currently subscribed
    to. If you unsubscribe they will disappear from this page, and you
    will not be able to resubscribe to them using this page.
</p>
[%- END %]
</div>
[%- END %]

<div class="clear"></div>

[%- ELSE -%]
<p>
    You need to <a href="[% c.uri_for( '/user/login' ) %]">log in</a>
    before you can edit your mailing list subscriptions. Alternatively,
    follow the link in the bottom of one of our emails to you.
</p>
[%- END %]