diff options
Diffstat (limited to 'rt/share/html/Elements/SavedSearches')
-rw-r--r-- | rt/share/html/Elements/SavedSearches | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/rt/share/html/Elements/SavedSearches b/rt/share/html/Elements/SavedSearches new file mode 100644 index 000000000..96d589fc1 --- /dev/null +++ b/rt/share/html/Elements/SavedSearches @@ -0,0 +1,70 @@ +<& /Elements/ListActions, actions => \@results &> +<table width="100%"><tr> +% foreach my $type ('Ticket', 'Chart') { +<td width="50%"> +<&|/Widgets/TitleBox, title => loc('Saved '.$titles{$type}) &> +% foreach my $Object (@Objects) { +% $SavedSearches = RT::SavedSearches->new($session{CurrentUser}); +% $SavedSearches->LimitToPrivacy(join('-',ref($Object),$Object->Id), $type); +% my $title = $titles{$type}; +% if (ref $Object eq 'RT::User' && $Object->Id == $session{CurrentUser}->Id) { +% $title = loc("My saved ".lc($title)); +% } else { +% $title = loc("[_1]'s saved ".lc($title),$Object->Name); +% } +% $title = $m->interp->apply_escapes($title, 'h'); +% +% my $oid = join('-', ref($Object), $Object->Id, 'SavedSearch', '__id__'); +% my $resultpath = $paths{$type}; +% my @cols = ( +% qq{<a href="__WebPath__/$resultpath?__ResultsURL__">__Name__</a>/TITLE:$title}, +% '__Query__', +% qq{<a href="__WebPath__/Search/Build.html?SavedSearchLoad=$oid">[Edit]</a> } . +% qq{<a href="$uri?Delete=$oid">[Delete]</a>/TITLE:}, +% ); +% my $format = join(',', map { "'$_'" } @cols); +<& /Elements/CollectionList, + %ARGS, + Class => 'RT::SavedSearch', + Format => $format, + Collection => $SavedSearches, + PassArguments => [qw(Format Name id)], +&> +% } #foreach $Object +</&> +</td> +% } #foreach $type +</tr></table> +<%init> +my @Objects; +my $SavedSearches = RT::SavedSearches->new($session{'CurrentUser'}); +push @Objects, $SavedSearches->_PrivacyObjects; +push @Objects, RT::System->new( $session{'CurrentUser'} ) + if $session{'CurrentUser'}->HasRight( Object=> $RT::System, + Right => 'SuperUser' ); + +my $uri = '__WebPath__'.$m->request_path; + +my @results; +if ( $Delete =~ /(.*)-SavedSearch-(\d+)/) { + my ($privacy, $id) = ($1, $2); + my $record = RT::SavedSearch->new($session{'CurrentUser'}); + $record->Load($privacy, $id); + if ( $record->Id ) { + my ($status, $msg) = $record->Delete; + push @results, $msg; + } + else { + push @results, "Saved search #$Delete not found"; + } +} + +my %titles = ( 'Ticket' => 'Searches', 'Chart' => 'Charts' ); +my %paths = ( 'Ticket' => 'Search/Results.html', + 'Chart' => 'Search/Chart.html', +); +</%init> +<%ARGS> +$user_attrs => undef +$Delete => undef +</%ARGS> |