-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickSavedSearch.diff
342 lines (338 loc) · 13.8 KB
/
QuickSavedSearch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
diff -rNu rt3.redhog.2009-07-22T12:10:56/etc/RT_Config.pm rt3.redhog.2009-07-24T12:34:14/etc/RT_Config.pm
--- rt3.redhog.2009-07-22T12:10:56/etc/RT_Config.pm 2009-03-25 14:24:58.000000000 +0000
+++ rt3.redhog.2009-07-24T12:34:14/etc/RT_Config.pm 2009-07-24 12:30:24.000000000 +0000
@@ -1085,7 +1085,7 @@
=cut
-Set($HomepageComponents, [qw(QuickCreate Quicksearch MyAdminQueues MySupportQueues MyReminders RefreshHomepage Dashboards)]);
+Set($HomepageComponents, [qw(QuickCreate Quicksearch QuickSavedSearch MyAdminQueues MySupportQueues MyReminders RefreshHomepage Dashboards)]);
=item C<@MasonParameters>
diff -rNu rt3.redhog.2009-07-22T12:10:56/share/html/Elements/QuickSavedSearch rt3.redhog.2009-07-24T12:34:14/share/html/Elements/QuickSavedSearch
--- rt3.redhog.2009-07-22T12:10:56/share/html/Elements/QuickSavedSearch 1970-01-01 00:00:00.000000000 +0000
+++ rt3.redhog.2009-07-24T12:34:14/share/html/Elements/QuickSavedSearch 2009-07-24 12:30:47.000000000 +0000
@@ -0,0 +1,67 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <[email protected]>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%# Modifications Copyright (c) 2009 FreeCode AS, Egil Möller <[email protected]>
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<div class="ticket-overview">
+<&|/Widgets/TitleBox, title => loc("Quick saved search"), bodyclass => "",
+ titleright => loc("Edit"), titleright_href => RT->Config->Get('WebPath').'/Prefs/QuickSavedSearch.html' &>
+<& /Elements/SearchSummary,
+ cache => 'quick_search_search',
+ search_filter => sub { !exists $unwanted->{$_->Description} },
+ conditions => \@conditions,
+&>
+</&>
+</div>
+<%INIT>
+my $unwanted = $session{'CurrentUser'}->UserObj->Preferences('QuickSavedSearch', {});
+
+my @conditions = ();
+foreach ( RT::Queue->ActiveStatusArray ) {
+ push @conditions, { cond => "Status = '$_'", name => loc($_) };
+}
+</%INIT>
diff -rNu rt3.redhog.2009-07-22T12:10:56/share/html/Elements/SearchSummary rt3.redhog.2009-07-24T12:34:14/share/html/Elements/SearchSummary
--- rt3.redhog.2009-07-22T12:10:56/share/html/Elements/SearchSummary 1970-01-01 00:00:00.000000000 +0000
+++ rt3.redhog.2009-07-24T12:34:14/share/html/Elements/SearchSummary 2009-07-24 12:30:56.000000000 +0000
@@ -0,0 +1,120 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <[email protected]>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%# Modifications Copyright (c) 2009 FreeCode AS, Egil Möller <[email protected]>
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+
+<table border="0" cellspacing="0" cellpadding="1" width="100%" class="queue-summary">
+<tr>
+ <th class="collection-as-table"><&|/l&>Search</&></th>
+% for my $condition (@$conditions) {
+ <th class="collection-as-table"><% $condition->{name} %></th>
+% }
+</tr>
+
+% my $i;
+% for my $search (@searches) {
+% $i++;
+
+% my $description = $search->Description;
+% my $query = $search->SubValue('Query');
+% my $format = $search->SubValue('Format');
+% my $order_by = $search->SubValue('OrderBy');
+% my $order = $search->SubValue('Order');
+% my $rows_per_page = $search->SubValue('RowsPerPage');
+
+% my $url = RT->Config->Get('WebPath') .
+% "/Search/Results.html?Format=" . uri_escape($format) .
+% "&OrderBy=" . uri_escape($order_by) .
+% "&Order=" . uri_escape($order) .
+% "&RowsPerPage=" . uri_escape($rows_per_page);
+
+<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
+<td><a href="<% $url %>&Query=<% uri_escape($query) %>" title="<% $description %>"><% $description %></a></td>
+
+% for my $condition (@$conditions) {
+% $Tickets->FromSQL($query . " AND ". $condition->{cond} );
+
+<td align="right"><a href="<% $url %>&Query=<% uri_escape($query . " AND " . $condition->{cond}) %>"><% $Tickets->Count() %></a></td>
+% }
+</tr>
+% }
+
+</table>
+
+<%INIT>
+use RT::SavedSearches;
+use URI::Escape;
+
+return unless $session{'CurrentUser'}->HasRight(
+ Right => 'LoadSavedSearch',
+ Object => $RT::System,
+);
+
+my @PrivacyObjects = RT::SavedSearches->new($session{CurrentUser})->_PrivacyObjects;
+push @PrivacyObjects, RT::System->new( $session{'CurrentUser'} )
+ if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
+ Right => 'SuperUser' );
+
+my @searches;
+foreach my $privacy_object (@PrivacyObjects) {
+ foreach my $search ($privacy_object->Attributes->Named('SavedSearch')) {
+ push @searches, $search;
+ }
+}
+
+@searches = grep(( $_->SubValue('SearchType')
+ && $_->SubValue('SearchType') == 'Ticket'), @searches);
+@searches = grep($search_filter->($_), @searches);
+
+my $Tickets = RT::Tickets->new($session{'CurrentUser'});
+</%INIT>
+<%ARGS>
+$cache => undef # Currently unused
+$search_filter => undef
+$conditions => []
+</%ARGS>
diff -rNu rt3.redhog.2009-07-22T12:10:56/share/html/Prefs/QuickSavedSearch.html rt3.redhog.2009-07-24T12:34:14/share/html/Prefs/QuickSavedSearch.html
--- rt3.redhog.2009-07-22T12:10:56/share/html/Prefs/QuickSavedSearch.html 1970-01-01 00:00:00.000000000 +0000
+++ rt3.redhog.2009-07-24T12:34:14/share/html/Prefs/QuickSavedSearch.html 2009-07-24 12:31:11.000000000 +0000
@@ -0,0 +1,131 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <[email protected]>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%# Modifications Copyright (c) 2009 FreeCode AS, Egil Möller <[email protected]>
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<& /Elements/Header, Title => $title &>
+<& /Prefs/Elements/Tabs,
+ current_tab => 'Prefs/MyRT.html',
+ current_subtab => 'Prefs/Quicksearch.html',
+ Title => $title
+&>
+<& /Elements/ListActions, actions => \@actions &>
+<h1><&|/l&>Select searches to be displayed on the "RT at a glance" page</&></h1>
+<form method="post" action="QuickSavedSearch.html" name="Preferences">
+<ul>
+% for my $search (@searches) {
+<li><input type="checkbox" class="checkbox" name="Want-<%$search->Id%>" value="1"
+% unless ($unwanted->{$search->Description}) {
+checked="checked"
+% }
+/>
+
+% my $description = $search->Description;
+% my $query = $search->SubValue('Query');
+% my $format = $search->SubValue('Format');
+% my $order_by = $search->SubValue('OrderBy');
+% my $order = $search->SubValue('Order');
+% my $rows_per_page = $search->SubValue('RowsPerPage');
+% my $url = RT->Config->Get('WebPath') .
+% "/Search/Build.html?Format=" . uri_escape($format) .
+% "&Query=" . uri_escape($query) .
+% "&OrderBy=" . uri_escape($order_by) .
+% "&Order=" . uri_escape($order) .
+% "&RowsPerPage=" . uri_escape($rows_per_page);
+%# This doesn't seem to work: Id is just the numeric id, while
+%# SavedSearchId should be something like RT::User-User-15-SavedSearch-45
+%# "&SavedSearchId=" . uri_escape($search->Id);
+<a href="<% $url %>"><%$search->Description%></a>
+</li>
+% }
+</ul>
+<& /Elements/Submit, Caption => loc("Save Changes"), Label => loc('Save'), Name => 'Save'&>
+
+</form>
+
+<%INIT>
+use RT::SavedSearches;
+use URI::Escape;
+
+my @actions;
+my $title = loc("Customize").' '.loc("Quick saved search");
+my $user = $session{'CurrentUser'}->UserObj;
+my $unwanted = $user->Preferences('QuickSavedSearch', {});
+
+my @PrivacyObjects = RT::SavedSearches->new($session{CurrentUser})->_PrivacyObjects;
+push @PrivacyObjects, RT::System->new( $session{'CurrentUser'} )
+ if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
+ Right => 'SuperUser' );
+
+my @searches;
+foreach my $privacy_object (@PrivacyObjects) {
+ foreach my $search ($privacy_object->Attributes->Named('SavedSearch')) {
+ push @searches, $search;
+ }
+}
+
+@searches = grep(( $_->SubValue('SearchType')
+ && $_->SubValue('SearchType') == 'Ticket'), @searches);
+
+if ($ARGS{'Save'}) {
+ for my $search (@searches) {
+ if ($ARGS{"Want-".$search->Id}) {
+ delete $unwanted->{$search->Description};
+ }
+ else {
+ ++$unwanted->{$search->Description};
+ }
+ }
+
+ my ($ok, $msg) = $user->SetPreferences('QuickSavedSearch', $unwanted);
+ push @actions, $ok ? loc('Preferences saved.') : $msg;
+
+ # Let SearchSummary rebuild the cache
+ delete $session{'quick_search_search'};
+}
+
+</%INIT>