[%# 1.0@bugzilla.org %]
[%# The contents of this file are subject to the Mozilla Public
  # License Version 1.1 (the "License"); you may not use this file
  # except in compliance with the License. You may obtain a copy of
  # the License at http://www.mozilla.org/MPL/
  #
  # Software distributed under the License is distributed on an "AS
  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  # implied. See the License for the specific language governing
  # rights and limitations under the License.
  #
  # The Original Code is the Bugzilla Bug Tracking System.
  #
  # The Initial Developer of the Original Code is Netscape Communications
  # Corporation. Portions created by Netscape are
  # Copyright (C) 1998 Netscape Communications Corporation. All
  # Rights Reserved.
  #
  # Contributor(s): Gervase Markham <gerv@gerv.net>
  #                 Myk Melez <myk@mozilla.org>
  #%]

[%# INTERFACE:
  # watchedusers: string.
  #               Comma-separated list of email addresses this user watches.
  # excludeself:  boolean.
  #               True if user is not receiving self-generated mail.
  # <rolename>:   Multiple hashes, one for each rolename (e.g. owner; see
  #               below), keyed by reasonname (e.g. comments; again, see
  #               below). The value is a boolean - true if the user is
  #               receiving mail for that reason when in that role.
  # Also references the 'supportwatchers' Param.
  #%]

[% PROCESS global/variables.none.tmpl %]

[% useqacontact = Param('useqacontact') %]

<table>
  [% IF Param('supportwatchers') %]
    <tr>
      <td colspan="4">
        <hr>
      </td>
    </tr>

    <tr>
      <td colspan="4">
        If you want to help cover for someone when they're on vacation, or if
        you need to do the QA related to all of their [% terms.bugs %], you can tell
        [%+ terms.Bugzilla %] to send mail related to their [% terms.bugs %] to you also.  List the
        email addresses of any users you wish to watch here, separated by
        commas.
      </td>
    </tr>

    <tr>
      <th align="right">Users to watch:</th>
      <td>
        <input size="35" name="watchedusers" 
               value="[% watchedusers FILTER html %]">
      </td>
    </tr>
  [% END %]

  <tr>
    <td colspan="2">
      <p>
        If you don't like getting a notification for "trivial"
        changes to [% terms.bugs %], you can use the settings below to
        filter some (or even all) notifications.
      </p>
    </td>
  </tr>
</table>

<hr>

<table>
  <tr>
    <td colspan="2">
      <b>Global options:</b>
    </td>
  </tr>

  <tr>
    <td width="150"></td>
    <td>
      <input type="checkbox" name="ExcludeSelf" id="ExcludeSelf" value="on"
        [% " checked" IF excludeself %]>
      <label for="ExcludeSelf">Only email me reports of changes made by other people</label>
      <br>
    </td>
  </tr>
  <tr>
    <td width="150"></td>
    <td>
      <input type="checkbox" name="FlagRequestee" id="FlagRequestee" value="on"
        [% " checked" IF FlagRequestee %]>
      <label for="FlagRequestee">Email me when someone asks me to set a flag</label>
      <br>
    </td>
  </tr>
  <tr>
    <td width="150"></td>
    <td>
      <input type="checkbox" name="FlagRequester" id="FlagRequester" value="on"
        [% " checked" IF FlagRequester %]>
      <label for="FlagRequester">Email me when someone sets a flag I asked for</label>
      <br>
    </td>
  </tr>
</table>
<noscript>If you had Javascript active, you could toggle all of these with one click.<br></noscript>
<script type="text/javascript">
<!--
function SetCheckboxes(setting) {
  for (var count = 0; count < document.userprefsform.elements.length; count++) {
    var theinput = document.userprefsform.elements[count];
    if (theinput.type == "checkbox") {
      if (theinput.name == "ExcludeSelf") {
        theinput.checked = false;
      }
      else {
        theinput.checked = setting;
      }
    }
  }
}

document.write('<input type="button" value="Enable All Mail" onclick="SetCheckboxes(true); return false;">\n');
document.write('<input type="button" value="Disable All Mail" onclick="SetCheckboxes(false); return false;">\n');
// -->
</script>
<hr>
<b>Field/recipient specific options:</b>
<br>
<br>


<table width="100%" border="1">
  <tr>
    <td colspan="[% useqacontact ? '5' : '4' %]" align="center" width="50%">
      <b>When my relationship to this [% terms.bug %] is:</b>
    </td>
    <td rowspan="2" width="50%">
      <b>I want to receive mail when:</b>
    </td>
  </tr>

  <tr>
    <td align="center" width="10%">
      <b>Reporter</b>
    </td>
    <td align="center" width="10%">
      <b>Assignee</b>
    </td>
    [% IF useqacontact %]
      <td align="center" width="10%">
        <b>QA Contact</b>
      </td>
    [% END %]
    <td align="center" width="10%">
      <b>CC</b>
    </td>
    <td align="center" width="10%">
      <b>Voter</b>
    </td>
  </tr>

[% bugLabelLower = BLOCK %]
[% terms.bug %]
[% END %]

  [% FOREACH reason = [
      { name = 'Removeme',
        description = "I'm added to or removed from this capacity" },
      { name = 'Comments',
        description = "New Comments are added" },
      { name = 'Attachments',
        description = "New Attachments are added" },
      { name = 'Status',
        description = "Priority, status, severity, and/or milestone changes" },
      { name = 'Resolved',
        description = "The ${bugLabelLower} is resolved or verified" },
      { name = 'Keywords',
        description = "Keywords field changes" },
      { name = 'CC',
        description = "CC field changes" },
      { name = 'Other',
        description = "Any field not mentioned above changes" },
      { name = 'Unconfirmed',
        description = "The ${bugLabelLower} is in the unconfirmed state" },
  ] %]
    <tr>
      [% FOREACH role = [ "Reporter", "Owner", "QAcontact", "CClist", "Voter" ]
       %]
        [% NEXT IF role == "QAcontact" AND NOT useqacontact %]
        <td align="center">
          <input type="checkbox" name="email[% role %][% reason.name %]" value="on"
            [% " checked" IF $role.${reason.name} %]>
        </td>
      [% END %]
      <td>
        [% reason.description %]
      </td>
    </tr>
  [% END %]
</table>

<br>
