1[%# This Source Code Form is subject to the terms of the Mozilla Public
2  # License, v. 2.0. If a copy of the MPL was not distributed with this
3  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4  #
5  # This Source Code Form is "Incompatible With Secondary Licenses", as
6  # defined by the Mozilla Public License, v. 2.0.
7  #%]
8
9[%# INTERFACE:
10  # queryshare_groups: list of groups the user may share queries with
11  #                    (id, name).
12  # bless_group_ids: list of group ids the user may bless.
13  #%]
14
15[% IF user.can_bless %]
16  <script type="text/javascript"><!--
17    function update_checkbox(group) {
18      var bless_groups = [[% bless_group_ids.join(",") FILTER js %]];
19      var checkbox = document.getElementById(group.name.replace(/share_(\d+)/, "force_$1"));
20
21      if (bz_isValueInArray(bless_groups, group.value)) {
22        YAHOO.util.Dom.removeClass(checkbox.parentNode, "bz_default_hidden");
23      } else {
24        YAHOO.util.Dom.addClass(checkbox.parentNode, "bz_default_hidden");
25        checkbox.checked = false;
26      }
27    } //-->
28  </script>
29[% END %]
30
31<p>Your saved searches are as follows:</p>
32
33<blockquote>
34  <table border="1" cellpadding="3">
35    <tr>
36      <th>
37        Search
38      </th>
39      <th>
40        Run
41      </th>
42      <th>
43        Edit
44      </th>
45      <th>
46        Forget
47      </th>
48      <th>
49        Show in
50        Footer
51      </th>
52      [% may_share = user.in_group(Param('querysharegroup')) && queryshare_groups.size %]
53      [% IF may_share %]
54        <th>
55          Share With a Group
56        </th>
57      [% END %]
58    </tr>
59    <tr>
60      <td>My [% terms.Bugs %]</td>
61      <td>
62        [% filtered_username = user.login FILTER uri %]
63        <a href="[% Param('mybugstemplate').replace('%userid%', filtered_username) %]">Run</a>
64      </td>
65      <td>
66        &nbsp;
67      </td>
68      <td>
69        &nbsp;
70      </td>
71      <td align="center">
72        <input type="checkbox"
73               name="showmybugslink"
74               value="1"
75               [% " checked" IF user.showmybugslink %]>
76      </td>
77      [% IF may_share %]
78        <td>
79          &mdash;
80        </td>
81      [% END %]
82    </tr>
83    [% FOREACH q = user.queries %]
84      <tr>
85        <td>[% q.name FILTER html %]</td>
86        <td>
87          <a href="buglist.cgi?cmdtype=dorem&amp;remaction=run&amp;namedcmd=[% q.name FILTER uri %]
88                   [% IF q.shared_with_group.id %]&amp;sharer_id=[% user.id FILTER uri %][% END %]">Run</a>
89        </td>
90        <td>
91          <a href="query.cgi?[% q.edit_link FILTER html %]&amp;known_name=
92                   [% q.name FILTER uri %]">Edit</a>
93        </td>
94        <td>
95          [% IF q.used_in_whine %]
96            Remove from <a href="editwhines.cgi">whining</a> first
97          [% ELSE %]
98            <a href="buglist.cgi?cmdtype=dorem&amp;remaction=forget&amp;namedcmd=
99                     [% q.name FILTER uri %]&amp;token=
100                     [% issue_hash_token([q.id, q.name]) FILTER uri %]">Forget</a>
101          [% END %]
102        </td>
103        <td align="center">
104          <input type="checkbox"
105                 name="link_in_footer_[% q.id FILTER html %]"
106                 value="1"
107                 alt="[% q.name FILTER html %]"
108                 [% " checked" IF q.link_in_footer %]>
109        </td>
110        [% IF may_share %]
111          <td>
112            <select name="share_[% q.id FILTER html %]"
113              [% IF user.can_bless %] onchange="update_checkbox(this);"[% END %]>
114              <option value="">Don't share</option>
115              [% FOREACH group = queryshare_groups %]
116                <option value="[% group.id %]"
117                        [% ' selected="selected"'
118                           IF q.shared_with_group.id == group.id %]
119                >[% group.name FILTER html %]</option>
120              [% END %]
121            </select>
122            [% IF user.can_bless %]
123              <span [% IF !bless_group_ids.grep("^$q.shared_with_group.id\$").0
124                     %]class="bz_default_hidden"[% END %]>
125                <input type="checkbox" id="force_[% q.id FILTER html %]"
126                       name="force_[% q.id FILTER html %]" value="1">
127                <label for="force_[% q.id FILTER html %]">Add to footer</label>
128              </span>
129            [% END %]
130            [% IF q.shared_with_users %]
131              (shared with [% q.shared_with_users FILTER html %]
132              [%+ q.shared_with_users > 1 ? "users" : "user" %])
133            [% END %]
134          </td>
135        [% END %]
136      </tr>
137    [% END %]
138  </table>
139[% IF user.can_bless %]
140  <p>Note that for every search that has the "Add to footer" selected, a
141     link to the shared search is added to the footer of every user that is
142     a direct member of the group at the time you click Submit Changes.</p>
143[% END %]
144</blockquote>
145
146[% IF user.queries_available.size %]
147  <p>You may use these searches saved and shared by others:</p>
148
149  <table border="1" cellpadding="3">
150    <tr>
151      <th>
152        Search
153      </th>
154      <th>
155        Shared By
156      </th>
157      <th>
158        Shared To
159      </th>
160      <th>
161        Run
162      </th>
163      <th>
164        Edit
165      </th>
166      <th>
167        Show in
168        Footer
169      </th>
170    </tr>
171    [% FOREACH q = user.queries_available %]
172      <tr>
173        <td>[% q.name FILTER html %]</td>
174        <td>[% q.user.identity FILTER html %]</td>
175        <td>[% q.shared_with_group.name FILTER html %]</td>
176        <td>
177          <a href="buglist.cgi?cmdtype=dorem&amp;remaction=run&amp;namedcmd=
178                   [% q.name FILTER uri %]&amp;sharer_id=
179                   [% q.user.id FILTER uri %]">Run</a>
180        </td>
181        <td>
182          <a href="query.cgi?[% q.edit_link FILTER html %]&amp;known_name=
183                   [% q.name FILTER uri %]">Edit</a>
184        </td>
185        <td align="center">
186          <input type="checkbox"
187                 name="link_in_footer_[% q.id FILTER html %]"
188                 value="1"
189                 alt="[% q.name FILTER html %]"
190                 [% " checked" IF q.link_in_footer %]>
191        </td>
192      </tr>
193    [% END %]
194  </table>
195[% ELSE %]
196  <p>No searches are shared with you by other users.</p>
197[% END %]
198