[%# UI for adding/removing users in a group
  # License: Dual-license GPL 3.0+ or MPL 1.1+
  # Author(s): Vitaliy Filippov <vitalif@mail.ru>, Stas Fomin <stas-fomin@yandex.ru> %]

[% PROCESS global/header.html.tmpl
  title = "Add/remove users in group: $group.name"
%]

<form method="POST" action="?">
  <input name="group" type="hidden" value="[% group.id | html %]" />
  <input name="token" type="hidden" value="[% token | html %]" />

  <table class="admin_table" cellpadding="4">
    <tr class="even_row">
      <th align="left">Group:</th>
      <td>[% group.name | html %]</td>
    </tr>
    <tr class="even_row">
      <th align="left">Description:</th>
      <td>[% group.description | html %]</td>
    </tr>
    [% IF group.regexp %]
    <tr class="even_row">
      <th align="left">Regexp:</th>
      <td>[% group.regexp | html %]</td>
    </tr>
    [% END %]
  </table>

  [% IF Bugzilla.user.in_group('creategroups') %]
  <p><a href="editgroups.cgi?action=changeform&group=[% group.id %]">Edit group parameters and inclusions</a></p>
  [% END %]

  <p>Add users to this group:</p>
  <p>
    [% INCLUDE global/userselect.html.tmpl
      id => "add_members"
      name => "add_members"
      value => ""
      size => 60
      multiple => 5
    %]
  </p>

  [% IF allow_bless %]
  <p>Allow these users to grant this group ("grant option"):</p>
  <p>
    [% INCLUDE global/userselect.html.tmpl
      id => "add_bless"
      name => "add_bless"
      value => ""
      size => 60
      multiple => 5
    %]
  </p>
  [% END %]

  <h4>Active users in group &laquo;[% group.name | html %]&raquo;</h4>

  <table class="admin_table" width="80%">
    <tr>
      <th>Login</th>
      <th>User Name</th>
      <th>Is member?</th>
      <th>Can grant?</th>
    </tr>
    [% row = 0 %]
    [% FOREACH u = user_members %]
    <tr class="[% loop.index % 2 ? 'odd_row' : 'even_row' %]">
      <td><a target="edituser" href="editusers.cgi?action=edit&userid=[% u.user.id %]">
        [% u.user.login | html %]</a>
      </td>
      <td>[% u.user.realname | html %]</td>
      <td align="center">
        [% IF u.member_direct %]
          explicit, <input type="checkbox" id="remove_[% u.user.id %]" name="remove"
            value="[% u.user.id %]" /><label title="remove [% u.user.login | html %] from [% group.name | html %]"
            for="remove_[% u.user.id %]">remove</label>
        [% ELSIF u.member_regexp %]
          matches regexp
        [% ELSIF u.member_indirect %]
          via [% u.member_indirect | html %]
        [% END %]
      </td>
      <td align="center">
        [% IF u.bless_direct %]
          explicit
          [%- IF allow_bless %], <input type="checkbox" id="unbless_[% u.user.id %]" name="unbless"
            value="[% u.user.id %]" /><label title="revoke [% group.name | html %] grant permission from [% u.user.login | html %]"
            for="unbless_[% u.user.id %]">revoke</label>
          [% END %]
        [% ELSIF u.bless_regexp %][%# (in fact impossible) %]
          matches regexp
        [% ELSIF u.bless_indirect %]
          via [% u.bless_indirect | html %]
        [% END %]
      </td>
    </tr>
    [% END %]
  </table>

  <p>
    <input value="Save changes" type="submit" />
  </p>
</form>

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