[%# 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): Dave Miller <justdave@syndicomm.com>
  #                 Joel Peshkin <bugreport@peshkin.net>
  #                 Jacob Steenhagen <jake@bugzilla.org>
  #                 Vlad Dascalu <jocuri@softhome.net>
  #                 Max Kanat-Alexander <mkanat@bugzilla.org>
  #%]

[%# INTERFACE:
  # group: A Bugzilla::Group object representing the group that is
  #        about to be deleted.
  # shared_queries: int; The number of queries being shared with this
  #                 group.
  #%]


[% PROCESS global/header.html.tmpl
  title = "Delete group"
  doc_section = "groups.html"
%]

<table border="1">
  <tr>
    <th>Id</th>
    <th>Name</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>[% group.id FILTER html %]</td>
    <td>[% group.name FILTER html %]</td>
    <td>[% group.description FILTER html_light %]</td>
  </tr>
</table>

<form method="post" action="editgroups.cgi">
  [% IF group.members_non_inherited.size %]
    <p><b>[% group.members_non_inherited.size FILTER html %] users belong
      directly to this group. You cannot delete this group while there are
      users in it.</b>

    <br><a href="editusers.cgi?action=list&amp;groupid=
                 [%- group.id FILTER url_quote %]&amp;grouprestrict=1">Show
    me which users</a> - <label><input type="checkbox" name="removeusers">Remove
    all users from this group for me.</label></p>
  [% END %]

  [% IF group.granted_by_direct(constants.GROUP_MEMBERSHIP).size %]
    <p><b>Members of this group inherit membership in the following groups:</b></p>
    <ul>
      [% FOREACH grantor = group.granted_by_direct(constants.GROUP_MEMBERSHIP) %]
        <li>[% grantor.name FILTER html %]</li>
      [% END %]
    </ul>
  [% END %]

  [% IF group.bugs.size %]
    <p><b>[% group.bugs.size FILTER html %] [%+ terms.bug %] reports are
     visible only to this group. You cannot delete this group while any 
     [%+ terms.bugs %] are using it.</b>

    <br><a href="buglist.cgi?field0-0-0=bug_group&amp;type0-0-0=equals&amp;value0-0-0=
                 [%- group.name FILTER url_quote %]">Show me
    which [% terms.bugs %]</a> - 
    <label><input type="checkbox" name="removebugs">Remove
    all [% terms.bugs %] from this group restriction for me.</label></p>

    <p><b>NOTE:</b> It's quite possible to make confidential [% terms.bugs %]
    public by checking this box.  It is <B>strongly</B> suggested
    that you review the [% terms.bugs %] in this group before checking
    the box.</p>
  [% END %]

  [% IF group.products.size %]
    <p><b>This group is tied to the following products:</b></p>
    [% SET any_hidden = 0 %]
    <ul>
      [% FOREACH data = group.products %]

        [% SET active = [] %]
        [% FOREACH control = data.controls.keys.sort %]
          [% NEXT IF !data.controls.$control %]
          [% IF control == 'othercontrol' OR control == 'membercontrol' %]
            [% SWITCH data.controls.$control %]
              [% CASE constants.CONTROLMAPMANDATORY %]
                [% SET type = "Mandatory" %]
              [% CASE constants.CONTROLMAPSHOWN %]
                [% SET type = "Shown" %]
              [% CASE constants.CONTROLMAPDEFAULT %]
                [% SET type = "Default" %]
            [% END %]
            [% active.push("$control: $type") %]
          [% ELSE %]
            [% active.push(control) %]
          [% END %]
        [% END %]

        [% SET hidden = 0 %]
        [% IF data.controls.othercontrol == constants.CONTROLMAPMANDATORY
              AND data.controls.membercontrol == constants.CONTROLMAPMANDATORY
              AND data.controls.entry 
        %]
          [% SET hidden = 1 %]
        [% END %]

        <li><a href="editproducts.cgi?action=editgroupcontrols&amp;product=
                    [%- data.product.name FILTER url_quote %]">
          [%- data.product.name FILTER html %]</a>
          ([% active.join(', ') FILTER html %])
          [% IF hidden %]
            <strong>WARNING: This product is currently hidden.
            Deleting this group will make this product publicly visible.
            </strong>
          [% END %]</li>
      [% END %]
    </ul>

    <p><label><input type="checkbox" name="unbind">Delete this group anyway,
      and remove these controls.</label></p>
  [% END %]
  
  [% IF group.flag_types.size %]
    <p><b>This group restricts who can make changes to flags of certain types.
    You cannot delete this group while there are flag types using it.</b>

    <br><a href="editflagtypes.cgi?action=list&amp;group=
                 [%- group.id FILTER url_quote %]">Show
    me which types</a> - 
    <label><input type="checkbox" name="removeflags">Remove all
    flag types from this group for me.</label></p>
  [% END %]

  [% IF shared_queries %]
    <p>
      <b>There
      [% IF shared_queries > 1 %]
        are [% shared_queries %] saved searches
      [% ELSE %]
        is a saved search
      [% END %]
      being shared with this group.</b>
      If you delete this group,
      [% IF shared_queries > 1 %]
        these saved searches
      [% ELSE %]
        this saved search
      [% END %]
      will fall back to being private again.
    </p>
  [% END %]

  <h2>Confirmation</h2>

  <p>Do you really want to delete this group?</p>
  [% IF group.users.size || group.bugs.size || group.products.size 
        || group.flags.size
  %]
    <p><b>You must check all of the above boxes or correct the
          indicated problems first before you can proceed.</b></p>
  [% END %]

  <p>
    <input type="submit" id="delete" value="Yes, delete">
    <input type="hidden" name="action" value="delete">
    <input type="hidden" name="group" value="[% group.id FILTER html %]">
    <input type="hidden" name="token" value="[% token FILTER html %]">
  </p>
</form>

Go back to the <a href="editgroups.cgi">group list</a>.

[% PROCESS global/footer.html.tmpl %] 
