<!DOCTYPE html >
<html lang="en">
<head>
  <title><%site_title%>: Settings: Display Settings: <%current.user_username%></title>
  <%include include_common_head.html%>
</head>
<body class="page-<%page_id%>">
  <div class="container-b">
    <%include include_header.html%>

    <div class="main">
      <%~set action = $in.action || 'email'%>
      <%~if $action eq 'email'%>
      <%~set content_header_title = 'Email Subscriptions'%>
      <%~elsif $action eq 'threads'%>
      <%~set content_header_title = 'Watched Threads'%>
      <%~endif%>

      <%~init array breadcrumbs%><%init hash breadcrumbs.0%><%init hash breadcrumbs.1%>
      <%~set breadcrumbs.0.name = 'User Profile'%>
      <%~set breadcrumbs.0.url  = GForum::SEO::url(params => "do=user_profile")%>
      <%~set breadcrumbs.1.name = $content_header_title%>

      <div class="contentwrapper clearfix">
        <div class="sidebar">
            <%include include_sidebar.html%>
        </div>

        <%include include_breadcrumb.html%>

        <div class="content"><%-- start content--%>
          <%include include_content_header.html%>

          <form action="<%GForum::SEO::url()%>" method="post">
            <input type="hidden" name="do" value="user_profile_<%action%>_change" />
            <input type="hidden" name="action" value="<%action%>" />
            <input type="hidden" name="next_do" value="user_profile" />
            <%hidden_form%>

            <%~if action eq 'email'%>
            <p>You can subscribe/unsubscribe to the following forums:</p>
            <div class="dtable">
              <div class="dhead">
                <div class="drow">
                  <div class="dcell icon">
                    <input type="checkbox" id="unsubscribe_checkall" class="checkbox" title="Check all" />
                  </div>
                  <div class="dcell">Forum Name</div>
                </div>
              </div>
              <div class="dbody">
                <%~loop all_forums%>
                <%~if forum_id%>
                <div class="drow">
                  <div class="dcell icon">
                    <%~if forum_permission >= 2 %><input type="checkbox" name="subscribe" value="<%forum_id%>"<%if forum_subscribed%> checked="checked"<%endif%> /><%endif%>
                  </div>
                  <div class="dcell"><%forum_name%></div>
                </div>
                <%~endif%>
                <%~endloop%>
              </div>
            </div>

            <div class="toolbar clearfix">
              <hr class="line" />
              <div class="btn-wrapper">
                <input type="submit" name="submit" value="Subscribe/Unsubscribe" class="btn default" />
              </div>
            </div>

            <%~elsif $action eq 'threads'%>

            <p>From this page you can unsubscribe from watched threads. To start watching
            a thread, click the "Watch Thread" button shown when viewing a thread. When
            a thread is watched, you will receive e-mail notifications when someone posts
            a reply to the thread.</p>
            <p>You are currently watching <b><%num_threads || 0%></b> threads:</p>

            <%~if threads.length%>
            <%GForum::Utils::new_alternation(threads)%>
            <div class="dtable">
              <div class="dhead">
                <div class="drow">
                  <div class="dcell icon">
                    <input type="checkbox" id="remove_checkall" class="checkbox" title="Check all" />
                  </div>
                  <div class="dcell subject">Subject</div>
                </div>
              </div><%-- end dhead --%>
              <div class="dbody">
                <%~loop threads%>
                <div class="drow">
                  <div class="dcell icon">
                    <input type="checkbox" name="stop_watching" value="<%post_id%>" />
                  </div>
                  <div class="dcell subject">
                    <a href="<%GForum::SEO::url(params => "forum=$forum_id")%>"><%forum_name%></a>:
                    <a href="<%GForum::SEO::url(params => "post=$post_id")%>" class="title"><%post_subject%></a>
                  </div>
                </div>
                <%~endloop%>
              </div>
            </div><%-- end dtable --%>
            <div class="toolbar clearfix">
              <hr class="line" />
              <div class="btn-wrapper">
                <input type="submit" name="submit" value="Stop Watching Selected Threads" class="btn default" />
              </div>
            </div>
            <%~endif%>

            <%~endif%>

          </form>

        </div>
      </div><%-- end content --%>
    </div>

  </div>
<%include include_footer.html%>
</body>
<%~include include_global_js.html%>
<script type="text/javascript">
    $(document).ready(function () {
      GForum.init_check_all('stop_watching', '#remove_checkall');
      GForum.init_check_all('subscribe', '#unsubscribe_checkall');
    });
</script>
</html>
