[%# 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):     Myk Melez <myk@mozilla.org>
  #                     Jeff Hedlund <jeff.hedlund@matrixsi.com>
  #                     Frédéric Buclin <LpSolit@gmail.com>
  #%]

[% BLOCK userlink %]<a href="[% Param('user_mailto') %][% u.email | html %]">[% (u.name || u.login) | html %]</a>[% END %]

[% bugidsummary = bug.bug_id _ ': ' _ bug.short_desc %]
[% attidsummary = attachment.id _ ': ' _ attachment.description %]
[% flagtype_name = flag ? flag.type.name : old_flag.type.name %]
[% statuses = { '+' => "granted" , '-' => 'denied' , 'X' => "canceled" ,
                '?' => "requested" } %]

[% to_identity = "" %]
[% on_behalf_of = 0 %]
[% action = flag.status || 'X' %]

[% IF flag && flag.status == '?' %]
  [% subject_status = "requested" %]
  [% IF flag.setter_id == user.id %]
    [% to_identity = flag.requestee.identity _ " for" %]
  [% ELSE %]
    [% on_behalf_of = 1 %]
    [% IF flag.requestee %][% to_identity = " to " _ flag.requestee.identity %][% END %]
  [% END %]
[% ELSE %]
  [% IF old_flag && old_flag.status == '?' %]
    [% to_identity = old_flag.setter.identity _ "'s request for" %]
  [% END %]
  [% subject_status = statuses.$action %]
[% END %]
From: [% Param('mailfrom') %]
To: [% to %]
Subject: [% flagtype_name %] [%+ subject_status %]: [[% terms.Bug %] [%+ bug.bug_id %]] [% bug.short_desc %]
[%- IF attachment %] :
  [Attachment [% attachment.id %]] [% attachment.description FILTER clean_text %][% END %]
X-Bugzilla-Type: request
[% IF Bugzilla.get_field('classification').enabled %]
X-Bugzilla-Classification: [% bug.classification %]
[% END %]
X-Bugzilla-Product: [% bug.product %]
X-Bugzilla-Component: [% bug.component %]
[% FOREACH keyword_item = bug.keywords_obj %]
X-Bugzilla-Keywords: [% keyword_item.name %]
[% END %]
[% IF bug.bug_severity %]
X-Bugzilla-Severity: [% bug.bug_severity_obj.name %]
[% END %]
X-Bugzilla-Who: [% user.email %]
X-Bugzilla-Status: [% bug.bug_status_obj.name %]
[% IF bug.priority %]
X-Bugzilla-Priority: [% bug.priority_obj.name %]
[% END %]
[% IF bug.assigned_to %]
X-Bugzilla-Assigned-To: [% bug.assigned_to.email %]
[% END %]
[% IF Bugzilla.get_field('qa_contact').enabled AND bug.qa_contact %]
X-Bugzilla-QA-Contact: [% bug.qa_contact.email %]
[% END %]
[% IF bug.target_milestone %]
X-Bugzilla-Target-Milestone: [% bug.target_milestone_obj.name %]
[% END %]
[%+ threadingmarker %]
[% USE date %]
[% SET boundary = "--" _ date.now %]
Content-Type: multipart/alternative; boundary=[% boundary %]
MIME-Version: 1.0

--[% boundary %]
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

[% FILTER quoted_printable %]
[%+ USE wrap -%]
[%- FILTER bullet = wrap(80) -%]
[% IF on_behalf_of %]
[% user.identity %] has reassigned [% flag.setter.identity %]'s request for [% flagtype_name %]
[% to_identity %]:
[% ELSE %]
[% user.identity %] has [% statuses.$action %] [%+ to_identity %] [%+ flagtype_name %]:
[% END %]

[% terms.Bug %] [%+ bugidsummary %]
[% END %]
[%+ urlbase %]show_bug.cgi?id=[% bug.bug_id %]
[% IF attachment %]

[% FILTER bullet = wrap(80) %]
Attachment [% attidsummary %]
[%- END %]
[%+ urlbase %]attachment.cgi?id=[% attachment.id %]&action=edit
[%- END %]
[%- FILTER bullet = wrap(80) %]

[%# FIXME Maybe the comment object should be used here, but it's hard to do without merging email/newchangedmail and request/email %]
[% IF comment != "" %]
------- Additional Comments from [% user.identity %]
[%+ comment %]
[% END %]

[%- END %]
[% END %]

--[% boundary %]
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

[% FILTER quoted_printable %]
<style>
<!--
body { font-family: Segoe UI, sans-serif; }
.bz_st_UNCONFIRMED { font-style: italic; }
.bz_st_RESOLVED { text-decoration: line-through; }
.bz_st_VERIFIED { text-decoration: line-through; border: 1px dashed #2f6fab; background-color: #f9f9f9; line-height: 1.1em; }
.bz_st_CLOSED { text-decoration: line-through; border: 1px solid #2f6fab; background-color: #f9f9f9; line-height: 1.1em; }
.bz_comment_text { font-size: 100%; white-space: normal; font-family: Consolas, monospace; }
.bz_comment_text .quote { color: #65379c; border-left: solid 3px #65379c; padding-left: .5em; margin-left: .5em; }
/*-->*/
</style>
<body>
<p>
[% IF on_behalf_of %]
 [% PROCESS userlink u=user %] has reassigned [% PROCESS userlink u=flag.setter %]'s request
 for <b>[% flag.type.name %]</b> [% IF flag.requestee %]to [% PROCESS userlink u=flag.requestee %][% END %]:
[% ELSE %]
 [% PROCESS userlink u=user %] has [% flag.status ? statuses.${flag.status} : statuses.X %]
 [% IF flag AND flag.status == '?' AND flag.setter.id == user.id %]
  [%+ PROCESS userlink u=flag.requestee %] for
 [% ELSIF old_flag AND old_flag.status == '?' AND old_flag.setter %]
  [%+ PROCESS userlink u=old_flag.setter %]'s request for
 [% END %]
 <b>[% flag ? flag.type.name : old_flag.type.name %]</b>:
[% END %]
</p>
<p><a style="font-size: 120%" href="[% urlbase %]show_bug.cgi?id=[% bug.bug_id %]#[% flag ? flag.creation_date : old_flag.creation_date | timestamp %]">[% terms.Bug %] [%+ bugidsummary %]</a>
<br /><span style="font-size: 90%">(prod:[% bug.product %].[% bug.component -%]
    [%- IF bug.priority %], pri:[% bug.priority_obj.name %][% END -%]
    [%- IF bug.bug_severity %], sev:[% bug.bug_severity_obj.name %][% END -%]
    [%- IF bug.target_milestone %], miles:[% bug.target_milestone_obj.name %][% END -%])</span>
[% IF attachment %]
<br /><a href="[%+ urlbase %]attachment.cgi?id=[% attachment.id %]&action=edit">Attachment [% attidsummary %]</a>
[% END %]
</p>
[%# FIXME Maybe the comment object should be used here, but it's hard to do without merging email/newchangedmail and request/email %]
[% IF comment != "" %]
<hr color="#A0A0A0" size="1" />
<p>
Additional Comments from [% PROCESS userlink u=user %]:
<div class="bz_comment_text">
[%- comment | quoteUrls(bug) | wrap_comment | absolute_uris -%]
</div>
</p>
[% END %]
</body>
[% END %]
--[% boundary %]--
