This commit was generated by cvs2svn to compensate for changes in r10640,
[freeside.git] / rt / share / html / Elements / SavedSearches
1 <& /Elements/ListActions, actions => \@results &>
2 <table width="100%"><tr>
3 % foreach my $type ('Ticket', 'Chart') {
4 <td width="50%">
5 <&|/Widgets/TitleBox, title => loc('Saved '.$titles{$type}) &>
6 %   foreach my $Object (@Objects) {
7 %     $SavedSearches = RT::SavedSearches->new($session{CurrentUser});
8 %     $SavedSearches->LimitToPrivacy(join('-',ref($Object),$Object->Id), $type);
9 %     my $title = $titles{$type};
10 %     if (ref $Object eq 'RT::User' && $Object->Id == $session{CurrentUser}->Id) {
11 %         $title = loc("My saved ".lc($title));
12 %     } else {
13 %         $title = loc("[_1]'s saved ".lc($title),$Object->Name);
14 %     }
15 %     $title = $m->interp->apply_escapes($title, 'h');
16 %
17 %     my $oid = join('-', ref($Object), $Object->Id, 'SavedSearch', '__id__');
18 %     my $resultpath = $paths{$type};
19 %     my @cols = (
20 %       qq{<a href="__WebPath__/$resultpath?__ResultsURL__">__Name__</a>/TITLE:$title},
21 %       '__Query__',
22 %       qq{<a href="__WebPath__/Search/Build.html?SavedSearchLoad=$oid">[Edit]</a>&nbsp;} . 
23 %       qq{<a href="$uri?Delete=$oid">[Delete]</a>/TITLE:},
24 %     );
25 %     my $format = join(',', map { "'$_'" } @cols);
26 <& /Elements/CollectionList,
27     %ARGS,
28     Class => 'RT::SavedSearch',
29     Format => $format,
30     Collection => $SavedSearches,
31     PassArguments => [qw(Format Name id)],
32 &>
33 %   } #foreach $Object
34 </&>
35 </td>
36 % } #foreach $type
37 </tr></table>
38 <%init>
39 my @Objects;
40 my $SavedSearches = RT::SavedSearches->new($session{'CurrentUser'});
41 push @Objects, $SavedSearches->_PrivacyObjects;
42 push @Objects, RT::System->new( $session{'CurrentUser'} )
43     if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
44                                           Right => 'SuperUser' );
45
46 my $uri = '__WebPath__'.$m->request_path;
47
48 my @results;
49 if ( $Delete =~ /(.*)-SavedSearch-(\d+)/) {
50   my ($privacy, $id) = ($1, $2);
51   my $record = RT::SavedSearch->new($session{'CurrentUser'});
52   $record->Load($privacy, $id);
53   if ( $record->Id ) {
54     my ($status, $msg) = $record->Delete;
55     push @results, $msg;
56   }
57   else {
58     push @results, "Saved search #$Delete not found";
59   }
60 }
61
62 my %titles = ( 'Ticket' => 'Searches', 'Chart' => 'Charts' );
63 my %paths = ( 'Ticket' => 'Search/Results.html',
64               'Chart' => 'Search/Chart.html',
65 );
66 </%init>
67 <%ARGS>
68 $user_attrs => undef
69 $Delete => undef
70 </%ARGS>