diff options
Diffstat (limited to 'rt/html/Search')
29 files changed, 3938 insertions, 0 deletions
diff --git a/rt/html/Search/Build.html b/rt/html/Search/Build.html new file mode 100644 index 000000000..263958775 --- /dev/null +++ b/rt/html/Search/Build.html @@ -0,0 +1,832 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +%# +%# Data flow here: +%# The page receives a Query from the previous page, and maybe arguments +%# corresponding to actions. (If it doesn't get a Query argument, it pulls +%# one out of the session hash. Also, it could be getting just a raw query from +%# Build/Edit.html (Advanced).) +%# +%# After doing some stuff with default arguments and saved searches, the ParseQuery +%# function (which is similar to, but not the same as, _parser in RT/Tickets_Overlay_SQL) +%# converts the Query into a RT::Interface::Web::QueryBuilder::Tree. This mason file +%# then adds stuff to or modifies the tree based on the actions that had been requested +%# by clicking buttons. It then calls GetQueryAndOptionList on the tree to generate +%# the SQL query (which is saved as a hidden input) and the option list for the Clauses +%# box in the top right corner. +%# +%# Worthwhile refactoring: the tree manipulation code for the actions could use some cleaning +%# up. The node-adding code is different in the "add" actions from in ParseQuery, which leads +%# to things like ParseQuery correctly not quoting numbers in numerical fields, while the "add" +%# action does quote it (this breaks SQLite). +%# +<& /Elements/Header, Title => $title &> +<& /Ticket/Elements/Tabs, + current_tab => "Search/Build.html".$QueryString, + Title => $title, + Format => $Format, + Query => $Query, + Order => $Order, + OrderBy => $OrderBy, + Rows => $RowsPerPage +&> + +<form method="post" action="Build.html" name="BuildQuery"> +<input type="hidden" class="hidden" name="SearchId" value="<%$SearchId%>" /> +<input type="hidden" class="hidden" name="Query" value="<%$Query%>" /> +<input type="hidden" class="hidden" name="Format" value="<%$Format%>" /> +<table width="100%" border="0" cellpadding="5"> +<tr valign="top"> +<td class="boxcontainer" rowspan="2" width="65%"> +<& Elements/PickCriteria, query => $Query, cfqueues => $queues &> +<& /Elements/Submit, Caption => loc('Add these terms to your search'), Label => loc('Add'), Name => 'AddClause'&> +</td> + +<td> +<& Elements/EditQuery, + %ARGS, + actions => \@actions, + optionlist => $optionlist, + Description => $Description &> +<& /Elements/Submit, Label => loc('Add and Search'), Name => 'DoSearch'&> +</td> +</tr> + +<tr valign="top"> +<td> +<& Elements/EditSearches, CurrentSearch => $search_hash, Dirty => $dirty, SearchId => $SearchId &> +</td> +</tr> + +<tr> +<td colspan="2" class="boxcontainer"> + +<& Elements/DisplayOptions, %ARGS, Format=> $Format, +AvailableColumns => $AvailableColumns, CurrentFormat => $CurrentFormat, RowsPerPage => $RowsPerPage, OrderBy => $OrderBy, Order => $Order &> +<& /Elements/Submit, Label => loc('Add and Search'), Name => 'DoSearch'&> +</td> +</tr> +</table> +</form> + +<%INIT> +use RT::Interface::Web::QueryBuilder; +use RT::Interface::Web::QueryBuilder::Tree; + +my $search_hash = {}; +my $search; +my $title = loc("Query Builder"); + +# {{{ Clear out unwanted data +if ( $NewQuery or $ARGS{'Delete'} ) { + + # Wipe all data-carrying variables clear if we want a new + # search, or we're deleting an old one.. + $Query = ''; + $Format = ''; + $Description = ''; + $SearchId = ''; + $Order = ''; + $OrderBy = ''; + $RowsPerPage = undef; + + # ($search hasn't been set yet; no need to clear) + + # ..then wipe the session out.. + undef $session{'CurrentSearchHash'}; + + # ..and the search results. + $session{'tickets'}->CleanSlate() if defined $session{'tickets'}; +} + +# }}} + +if (ref $OrderBy eq "ARRAY") { + $OrderBy = join("|", @$OrderBy); +} +if (ref $Order eq "ARRAY") { + $Order = join("|", @$Order); +} + +# {{{ Attempt to load what we can from the session, set defaults + +# We don't read or write to the session again until the end +$search_hash = $session{'CurrentSearchHash'}; + +# Read from user preferences +my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {}; + +# These variables are what define a search_hash; this is also +# where we give sane defaults. +$Query ||= $search_hash->{'Query'}; +$Format ||= $search_hash->{'Format'} || $prefs->{'Format'}; +$Description ||= $search_hash->{'Description'}; +$SearchId ||= $search_hash->{'SearchId'} || 'new'; +$Order ||= $search_hash->{'Order'} || $prefs->{'Order'} || 'ASC'; +$OrderBy ||= $search_hash->{'OrderBy'} || $prefs->{'OrderBy'} || 'id'; + +unless ( defined $RowsPerPage ) { + if ( defined $search_hash->{'RowsPerPage'} ) { + $RowsPerPage = $search_hash->{'RowsPerPage'}; + } + elsif ( defined $prefs->{'RowsPerPage'} ) { + $RowsPerPage = $prefs->{'RowsPerPage'}; + } + else { + $RowsPerPage = 50; + } +} + + $search ||= $search_hash->{'Object'}; + +# }}} + +my @actions = (); + +# Clean unwanted junk from the format +$Format = $m->comp( '/Elements/ScrubHTML', Content => $Format ) if ($Format); + +# {{{ If we're asked to delete the current search, make it go away and reset the search parameters +if ( $ARGS{'Delete'} ) { + + # We set $SearchId to 'new' above already, so peek into the %ARGS + my ($container_object, $search_id) = _parse_saved_search ($ARGS{'SearchId'}); + if ($container_object && $container_object->id) { + # We have the object the entry is an attribute on; delete the + # entry.. + $container_object->Attributes->DeleteEntry( + Name => 'SavedSearch', + id => $search_id + ); + } +} + +# }}} + +# {{{ If the user wants to copy a search, uncouple from the one that this was based on, but don't erase the $Query or $Format +if ( $ARGS{'CopySearch'} ) { + $SearchId = 'new'; + $search = undef; + $Description = loc( "[_1] copy", $Description ); +} + +# }}} + +# {{{ if we're asked to revert the current search, we just want to load it +if ( $ARGS{'Revert'} ) { + $ARGS{'LoadSavedSearch'} = $SearchId; +} + +# }}} + +# {{{ if we're asked to load a search, load it. + +if ( my ($container_object, $search_id ) = _parse_saved_search ($ARGS{'LoadSavedSearch'})) { + $search = $container_object->Attributes->WithId($search_id); + + # We have a $search and now; import the others + $SearchId = $ARGS{'LoadSavedSearch'}; + $Description = $search->Description; + $Format = $search->SubValue('Format'); + $Query = $search->SubValue('Query'); + $Order = $search->SubValue('Order'); + $OrderBy = $search->SubValue('OrderBy'); + $RowsPerPage = $search->SubValue('RowsPerPage'); +} + +# }}} + +# {{{ if we're asked to save the current search, save it +if ( $ARGS{'Save'} ) { + if ( $search && $search->id ) { + # permission check + if ($search->Object->isa('RT::System')) { + unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'SuperUser')) { + Abort("No permission to save system-wide searches"); + } + } + + # This search is based on a previously loaded search -- so + # just update the current search object with new values + $search->SetSubValues( + Format => $Format, + Query => $Query, + Order => $Order, + OrderBy => $OrderBy, + RowsPerPage => $RowsPerPage, + ); + $search->SetDescription($Description); + + } + elsif ( $SearchId eq 'new' ) { + my $saved_search = RT::SavedSearch->new( $session{'CurrentUser'} ); + my ( $ok, $search_msg ) = $saved_search->Save( + Privacy => $ARGS{'Owner'}, + Name => $Description, + SearchParams => { + Format => $Format, + Query => $Query, + Order => $Order, + OrderBy => $OrderBy, + RowsPerPage => $RowsPerPage } ); + + if ($ok) { + $search = $session{'CurrentUser'}->UserObj->Attributes->WithId($saved_search->Id); + # Build new SearchId + $SearchId = + ref( $session{'CurrentUser'}->UserObj ) . '-' + . $session{'CurrentUser'}->UserObj->Id + . '-SavedSearch-' + . $search->Id; + } + else { + push @actions, [ loc("Can't find a saved search to work with").': '.loc($search_msg), 0 ]; + } + } + else { + push @actions, [ loc("Can't save this search"), 0 ]; + } + +} + +# }}} + + +# {{{ Parse the query +use Regexp::Common qw /delimited/; + +# States +use constant VALUE => 1; +use constant AGGREG => 2; +use constant OP => 4; +use constant PAREN => 8; +use constant KEYWORD => 16; + +my $_match = sub { + + # Case insensitive equality + my ( $y, $x ) = @_; + return 1 if $x =~ /^$y$/i; + + # return 1 if ((lc $x) eq (lc $y)); # Why isnt this equiv? + return 0; +}; + +my $ParseQuery = sub { + my $string = shift; + my $tree = shift; + my $actions = shift; + my $want = KEYWORD | PAREN; + my $last = undef; + + my $depth = 1; + + # make a tree root + $$tree = RT::Interface::Web::QueryBuilder::Tree->new; + my $root = RT::Interface::Web::QueryBuilder::Tree->new( 'AND', $$tree ); + my $parentnode = $root; + + # on new searches, we're passed undef but still need to construct the + # RT::Interface::Web::QueryBuilder::Tree. Quiet warning + return unless defined $string; + + # get the FIELDS from Tickets_Overlay + my $tickets = new RT::Tickets( $session{'CurrentUser'} ); + my %FIELDS = %{ $tickets->FIELDS }; + + # Lower Case version of FIELDS, for case insensitivity + my %lcfields = map { ( lc($_) => $_ ) } ( keys %FIELDS ); + + my @tokens = qw[VALUE AGGREG OP PAREN KEYWORD]; + my $re_aggreg = qr[(?i:AND|OR)]; + my $re_value = qr[$RE{delimited}{-delim=>qq{\'\"}}|\d+]; + my $re_keyword = qr[$RE{delimited}{-delim=>qq{\'\"}}|(?:\{|\}|\w|\.)+]; + my $re_op = + qr[=|!=|>=|<=|>|<|(?i:IS NOT)|(?i:IS)|(?i:NOT LIKE)|(?i:LIKE)] + ; # long to short + my $re_paren = qr'\(|\)'; + + # assume that $ea is AND if it is not set + my ( $ea, $key, $op, $value ) = ( "AND", "", "", "" ); + + # order of matches in the RE is important.. op should come early, + # because it has spaces in it. otherwise "NOT LIKE" might be parsed + # as a keyword or value. + + while ( + $string =~ /( + $re_aggreg + |$re_op + |$re_keyword + |$re_value + |$re_paren + )/igx + ) + { + my $val = $1; + my $current = 0; + + # Highest priority is last + $current = OP if $_match->( $re_op, $val ); + $current = VALUE if $_match->( $re_value, $val ); + $current = KEYWORD + if $_match->( $re_keyword, $val ) && ( $want & KEYWORD ); + $current = AGGREG if $_match->( $re_aggreg, $val ); + $current = PAREN if $_match->( $re_paren, $val ); + + unless ( $current && $want & $current ) { + + # Error + # FIXME: I will only print out the highest $want value + my $token = $tokens[ ( ( log $want ) / ( log 2 ) ) ]; + push @$actions, + [ + loc("Error near ->[_1]<- expecting a [_2] in '[_3]'", + $val, $token, $string ), + -1 + ]; + } + + # State Machine: + my $parentdepth = $depth; + + # Parens are highest priority + if ( $current & PAREN ) { + if ( $val eq "(" ) { + $depth++; + + # make a new node that the clauses can be children of + $parentnode = RT::Interface::Web::QueryBuilder::Tree->new( $ea, $parentnode ); + } + else { + $depth--; + $parentnode = $parentnode->getParent(); + } + + $want = KEYWORD | PAREN | AGGREG; + } + elsif ( $current & AGGREG ) { + $ea = $val; + $parentnode->setNodeValue($ea); + $want = KEYWORD | PAREN; + } + elsif ( $current & KEYWORD ) { + $key = $val; + $want = OP; + } + elsif ( $current & OP ) { + $op = $val; + $want = VALUE; + } + elsif ( $current & VALUE ) { + $value = $val; + + # Remove surrounding quotes from $key, $val + # (in future, simplify as for($key,$val) { action on $_ }) + if ( $key =~ /$RE{delimited}{-delim=>qq{\'\"}}/ ) { + substr( $key, 0, 1 ) = ""; + substr( $key, -1, 1 ) = ""; + } + if ( $val =~ /$RE{delimited}{-delim=>qq{\'\"}}/ ) { + substr( $val, 0, 1 ) = ""; + substr( $val, -1, 1 ) = ""; + } + + # Unescape escaped characters + $key =~ s!\\(.)!$1!g; + $val =~ s!\\(.)!$1!g; + + my $class; + + my ($key_base, $subkey) = split(/\./,$key,2); + $key_base =~ s/\..*$//; # Strip off .EmailAddress, for example + + if ( exists $lcfields{lc $key_base } ) { + $key = $lcfields{lc $key_base } . (defined $subkey ? '.'.$subkey : ''); + $class = $FIELDS{$key_base}->[0]; + } + elsif ( $key =~ /^C(?:ustom)?F(?:ield)?\.{(.*)}$/i ) { + $class = $FIELDS{'CF'}->[0]; + } + + if ( $class ne 'INT' ) { + $val = "'$val'"; + } + + push @$actions, [ loc("Unknown field: [_1]", $key), -1 ] unless $class; + + $want = PAREN | AGGREG; + } + else { + push @$actions, [ loc("I'm lost"), -1 ]; + } + + if ( $current & VALUE ) { + if ( $key =~ /^CF./ ) { + $key = "'" . $key . "'"; + } + my $clause = { + Key => $key, + Op => $op, + Value => $val + }; + + # explicity add a child to it + RT::Interface::Web::QueryBuilder::Tree->new( $clause, $parentnode ); + + ( $ea, $key, $op, $value ) = ( "", "", "", "" ); + + } + + $last = $current; + } # while + + push @$actions, [ loc("Incomplete query"), -1 ] + unless ( ( $want | PAREN ) || ( $want | KEYWORD ) ); + + push @$actions, [ loc("Incomplete Query"), -1 ] + unless ( $last && ( $last | PAREN ) || ( $last || VALUE ) ); + + # This will never happen, because the parser will complain + push @$actions, [ loc("Mismatched parentheses"), -1 ] + unless $depth == 1; +}; + +my $tree; +{ + my @parsing_errors; + $ParseQuery->( $Query, \$tree, \@parsing_errors ); + + # if parsing went poorly, send them to the edit page + # to fix it + if ( @parsing_errors ) { + return $m->comp( + "Edit.html", + Query => $Query, + actions => \@parsing_errors + ); + } +} + +$Query = ""; + +my @options = $tree->GetDisplayedNodes; + +my @current_values = grep { defined } @options[@clauses]; + +# {{{ Move things around +if ( $ARGS{"Up"} ) { + if (@current_values) { + foreach my $value (@current_values) { + my $index = $value->getIndex(); + if ( $value->getIndex() > 0 ) { + my $parent = $value->getParent(); + $parent->removeChild($index); + $parent->insertChild( $index - 1, $value ); + $value = $parent->getChild( $index - 1 ); + } + else { + push( @actions, [ loc("error: can't move up"), -1 ] ); + } + } + } + else { + push( @actions, [ loc("error: nothing to move"), -1 ] ); + } +} +elsif ( $ARGS{"Down"} ) { + if (@current_values) { + foreach my $value (@current_values) { + my $index = $value->getIndex(); + my $parent = $value->getParent(); + if ( $value->getIndex() < ( $parent->getChildCount - 1 ) ) { + $parent->removeChild($index); + $parent->insertChild( $index + 1, $value ); + $value = $parent->getChild( $index + 1 ); + } + else { + push( @actions, [ loc("error: can't move down"), -1 ] ); + } + } + } + else { + push( @actions, [ loc("error: nothing to move"), -1 ] ); + } +} +elsif ( $ARGS{"Left"} ) { + if (@current_values) { + foreach my $value (@current_values) { + my $parent = $value->getParent(); + my $grandparent = $parent->getParent(); + if ( !$grandparent->isRoot ) { + my $index = $parent->getIndex(); + $parent->removeChild($value); + $grandparent->insertChild( $index, $value ); + if ( $parent->isLeaf() ) { + $grandparent->removeChild($parent); + } + } + else { + push( @actions, [ loc("error: can't move left"), -1 ] ); + } + } + } + else { + push( @actions, [ loc("error: nothing to move"), -1 ] ); + } +} +elsif ( $ARGS{"Right"} ) { + if (@current_values) { + foreach my $value (@current_values) { + my $parent = $value->getParent(); + my $index = $value->getIndex(); + my $newparent; + if ( $index > 0 ) { + my $sibling = $parent->getChild( $index - 1 ); + if ( ref( $sibling->getNodeValue ) ) { + $parent->removeChild($value); + my $newtree = RT::Interface::Web::QueryBuilder::Tree->new( 'AND', $parent ); + $newtree->addChild($value); + } + else { + $parent->removeChild($index); + $sibling->addChild($value); + } + } + else { + $parent->removeChild($value); + $newparent = RT::Interface::Web::QueryBuilder::Tree->new( 'AND', $parent ); + $newparent->addChild($value); + } + } + } + else { + push( @actions, [ loc("error: nothing to move"), -1 ] ); + } +} +elsif ( $ARGS{"DeleteClause"} ) { + if (@current_values) { + $_->getParent()->removeChild($_) for @current_values; + @current_values = (); + } + else { + push( @actions, [ loc("error: nothing to delete"), -1 ] ); + } +} +elsif ( $ARGS{"Toggle"} ) { + my $ea; + if (@current_values) { + foreach my $value (@current_values) { + my $parent = $value->getParent(); + + if ( $parent->getNodeValue eq 'AND' ) { + $parent->setNodeValue('OR'); + } + else { + $parent->setNodeValue('AND'); + } + } + } + else { + push( @actions, [ loc("error: nothing to toggle"), -1 ] ); + } +} + +# {{{ Try to find if we're adding a clause +foreach my $arg ( keys %ARGS ) { + if ( + $arg =~ m/^ValueOf(\w+|'CF.{.*?}')$/ + && ( ref $ARGS{$arg} eq "ARRAY" + ? grep { $_ ne "" } @{ $ARGS{$arg} } + : $ARGS{$arg} ne "" ) + ) + { + + # We're adding a $1 clause + my $field = $1; + my ( $keyword, $op, $value ); + + #figure out if it's a grouping + if ( $ARGS{ $field . "Field" } ) { + $keyword = $ARGS{ $field . "Field" }; + } + else { + $keyword = $field; + } + + my ( @ops, @values ); + if ( ref $ARGS{ 'ValueOf' . $field } eq "ARRAY" ) { + + # we have many keys/values to iterate over, because there is + # more than one CF with the same name. + @ops = @{ $ARGS{ $field . 'Op' } }; + @values = @{ $ARGS{ 'ValueOf' . $field } }; + } + else { + @ops = ( $ARGS{ $field . 'Op' } ); + @values = ( $ARGS{ 'ValueOf' . $field } ); + } + $RT::Logger->error("Bad Parameters passed into Query Builder") + unless @ops == @values; + + for my $i ( 0 .. @ops - 1 ) { + my ( $op, $value ) = ( $ops[$i], $values[$i] ); + next if $value eq ""; + + if ( $value eq 'NULL' && $op =~ /=/ ) { + if ( $op eq '=' ) { + $op = "IS"; + } + elsif ( $op eq '!=' ) { + $op = "IS NOT"; + } + + # This isn't "right", but... + # It has to be this way until #5182 is fixed + $value = "'NULL'"; + } + else { + $value = "'$value'"; + } + + my $clause = { + Key => $keyword, + Op => $op, + Value => $value + }; + + my $newnode = RT::Interface::Web::QueryBuilder::Tree->new($clause); + if (@current_values) { + foreach my $value (@current_values) { + my $newindex = $value->getIndex() + 1; + $value->insertSibling( $newindex, $newnode ); + $value = $newnode; + } + } + else { + $tree->getChild(0)->addChild($newnode); + @current_values = $newnode; + } + $newnode->getParent()->setNodeValue( $ARGS{'AndOr'} ); + } + } +} + +# }}} + +$tree->PruneChildlessAggregators; + +# }}} + +# {{{ Rebuild $Query based on the additions / movements +$Query = ""; +my $optionlist_arrayref; + +($Query, $optionlist_arrayref) = $tree->GetQueryAndOptionList(\@current_values); + +my $optionlist = join "\n", map { qq(<option value="$_->{INDEX}" $_->{SELECTED}>) + . (" " x (5 * $_->{DEPTH})) + . $m->interp->apply_escapes($_->{TEXT}, 'h') . qq(</option>) } @$optionlist_arrayref; + + + + +# }}} + +# }}} + +my $queues = $tree->GetReferencedQueues; + +# {{{ Deal with format changes +my ( $AvailableColumns, $CurrentFormat ); +( $Format, $AvailableColumns, $CurrentFormat ) = $m->comp( + 'Elements/BuildFormatString', + cfqueues => $queues, + %ARGS, Format => $Format +); + +# }}} + +# {{{ If we're modifying an old query, check if it has changed +my $dirty = 0; +$dirty = 1 + if defined $search + and ($search->SubValue('Format') ne $Format + or $search->SubValue('Query') ne $Query + or $search->SubValue('Order') ne $Order + or $search->SubValue('OrderBy') ne $OrderBy + or $search->SubValue('RowsPerPage') ne $RowsPerPage ); + +# }}} + +# {{{ Push the updates into the session so we don't loose 'em +$search_hash->{'SearchId'} = $SearchId; +$search_hash->{'Format'} = $Format; +$search_hash->{'Query'} = $Query; +$search_hash->{'Description'} = $Description; +$search_hash->{'Object'} = $search; +$search_hash->{'Order'} = $Order; +$search_hash->{'OrderBy'} = $OrderBy; +$search_hash->{'RowsPerPage'} = $RowsPerPage; + +$session{'CurrentSearchHash'} = $search_hash; + +# }}} + +# {{{ Show the results, if we were asked. +if ( $ARGS{"DoSearch"}) { + $m->comp( + "Results.html", + Query => $Query, + Format => $Format, + Order => $Order, + OrderBy => $OrderBy, + Rows => $RowsPerPage + ); + $m->comp('/Elements/Footer'); + $m->abort(); +} + +# }}} + +# {{{ Build a querystring for the tabs + +my $QueryString; +if ($NewQuery) { + $QueryString = '?NewQuery=1'; +} +else { + $QueryString = '?' + . $m->comp( + '/Elements/QueryString', + Query => $Query, + Format => $Format, + Order => $Order, + OrderBy => $OrderBy, + Rows => $RowsPerPage + ) + if ($Query); +} + +# }}} + +</%INIT> + +<%ARGS> +$NewQuery => 0 +$SearchId => undef +$Query => undef +$Format => undef +$Description => undef +$Order => undef +$OrderBy => undef +$RowsPerPage => undef +$HideResults => 0 +@clauses => () +</%ARGS> + diff --git a/rt/html/Search/Bulk.html b/rt/html/Search/Bulk.html new file mode 100644 index 000000000..9742df5ae --- /dev/null +++ b/rt/html/Search/Bulk.html @@ -0,0 +1,396 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 &> +<& /Ticket/Elements/Tabs, + current_tab => "Search/Bulk.html", + Title => $title, + Format => $ARGS{'Format'}, # we don't want the locally modified one + Query => $Query, + Rows => $Rows, + OrderBy => $OrderBy, + Order => $Order &> + +<& /Elements/ListActions, actions => \@results &> +<form method="post" action="<%$RT::WebPath%>/Search/Bulk.html" enctype="multipart/form-data"> +% foreach my $var qw(Query Format OrderBy Order Rows Page) { +<input type="hidden" class="hidden" name="<%$var%>" value="<%$ARGS{$var}%>" /> +%} +<& /Elements/TicketList, Query => $Query, + DisplayFormat => $Format, + Format => $ARGS{'Format'}, + Verbatim => 1, + AllowSorting => 1, + OrderBy => $OrderBy, + Order => $Order, + Rows => $Rows, + Page => $Page, + BaseURL => $RT::WebPath."/Search/Bulk.html?" + &> + +<hr> + +<& /Elements/Submit, Label => loc('Update'), CheckAll => 1, ClearAll => 1 &> +<br /> +<&|/Widgets/TitleBox, title => $title &> +<table> +<tr> +<td valign="top"> +<table> +<tr><td class="label"> <&|/l&>Make Owner</&>: </td> +<td class="value"> <& /Elements/SelectOwner, Name => "Owner" &> (<input type="checkbox" class="checkbox" name="ForceOwnerChange" /> <&|/l&>Force change</&>) </td></tr> +<tr><td class="label"> <&|/l&>Add Requestor</&>: </td> +<td class="value"> <input name="AddRequestor" size="20" /> </td></tr> +<tr><td class="label"> <&|/l&>Remove Requestor</&>: </td> +<td class="value"> <input name="DeleteRequestor" size="20" /> </td></tr> +<tr><td class="label"> <&|/l&>Add Cc</&>: </td> +<td class="value"> <input name="AddCc" size="20" /> </td></tr> +<tr><td class="label"> <&|/l&>Remove Cc</&>: </td> +<td class="value"> <input name="DeleteCc" size="20" /> </td></tr> +<tr><td class="label"> <&|/l&>Add AdminCc</&>: </td> +<td class="value"> <input name="AddAdminCc" size="20" /> </td></tr> +<tr><td class="label"> <&|/l&>Remove AdminCc</&>: </td> +<td class="value"> <input name="DeleteAdminCc" size="20" /> </td></tr> +</table> +</td> +<td valign="top"> +<table> +<tr><td class="label"> <&|/l&>Make subject</&>: </td> +<td class="value"> <input name="Subject" size="20" /> </td></tr> +<tr><td class="label"> <&|/l&>Make priority</&>: </td> +<td class="value"> <input name="Priority" size="4" /> </td></tr> +<tr><td class="label"> <&|/l&>Make queue</&>: </td> +<td class="value"> <& /Elements/SelectQueue, Name => "Queue" &> </td></tr> +<tr><td class="label"> <&|/l&>Make Status</&>: </td> +<td class="value"> <& /Elements/SelectStatus, Name => "Status" &> </td></tr> +<tr><td class="label"> <&|/l&>Make date Starts</&>: </td> +<td class="value"> <& /Elements/SelectDate, Name => "Starts_Date", ShowTime => 0, Default => '' &> </td></tr> +<tr><td class="label"> <&|/l&>Make date Started</&>: </td> +<td class="value"> <& /Elements/SelectDate, Name => "Started_Date", ShowTime => 0, Default => '' &> </td></tr> +<tr><td class="label"> <&|/l&>Make date Told</&>: </td> +<td class="value"> <& /Elements/SelectDate, Name => "Told_Date", ShowTime => 0, Default => '' &> </td></tr> +<tr><td class="label"> <&|/l&>Make date Due</&>: </td> +<td class="value"> <& /Elements/SelectDate, Name => "Due_Date", ShowTime => 0, Default => '' &> </td></tr> +<tr><td class="label"> <&|/l&>Make date Resolved</&>: </td> +<td class="value"> <& /Elements/SelectDate, Name => "Resolved_Date", ShowTime => 0, Default => '' &> </td></tr> +</table> + +</td> +</tr> +</table> +</&> +<&| /Widgets/TitleBox, title => loc('Add comments or replies to selected tickets') &> +<table> +<tr><td align="right"><&|/l&>Update Type</&>:</td> +<td><select name="UpdateType"> + <option value="private" ><&|/l&>Comments (not sent to requestors)</&></option> +<option value="response" ><&|/l&>Reply to requestors</&></option> +</select> +</td></tr> +<tr><td align="right"><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size="60" value="" /></td></tr> +% while (my $CF = $TxnCFs->Next()) { +<tr> +<td align="right"><% $CF->Name %>:</td> +<td><& /Elements/EditCustomField, + CustomField => $CF, + NamePrefix => "Object-RT::Transaction--CustomField-" + &><em><% $CF->FriendlyType %></em></td> +</td></tr> +% } # end if while + <tr><td align="right"><&|/l&>Attach</&>:</td><td><input name="UpdateAttachment" type="file" /></td></tr> + <tr><td class="labeltop"><&|/l&>Message</&>:</td><td> + <& /Elements/MessageBox, Name=>"UpdateContent"&> + </td></tr> + </table> + +</&> +<&|/Widgets/TitleBox, title => loc('Edit Custom Fields'), color => "#336633"&> +<%perl> +my $cfs = RT::CustomFields->new($session{'CurrentUser'}); +$cfs->LimitToGlobal(); +$cfs->LimitToQueue($_) for keys %$seen_queues; +</%perl> +<table> +<tr> +<th><&|/l&>Name</&></th> +<th><&|/l&>Add values</&></th> +<th><&|/l&>Delete values</&></th> +</tr> +% while (my $cf = $cfs->Next()) { +<tr> +<td class="label"><%$cf->Name%><br /> +<em>(<%$cf->FriendlyType%>)</em></td> +% my $rows = 5; +% my @add = (NamePrefix => 'Bulk-Add-CustomField-', CustomField => $cf, Rows => $rows, Multiple => ($cf->MaxValues ==1 ? 0 : 1) , Cols => 25); +% my @del = (NamePrefix => 'Bulk-Delete-CustomField-', CustomField => $cf, Rows => $rows, Multiple => 1, Cols => 25); +% if ($cf->Type eq 'Select') { +<td><& /Elements/EditCustomFieldSelect, @add &></td> +<td><& /Elements/EditCustomFieldSelect, @del &></td> +% } elsif ($cf->Type eq 'Combobox') { +<td><& /Elements/EditCustomFieldCombobox, @add &></td> +<td><& /Elements/EditCustomFieldCombobox, @del &></td> +% } elsif ($cf->Type eq 'Freeform') { +<td><& /Elements/EditCustomFieldFreeform, @add &></td> +<td><& /Elements/EditCustomFieldFreeform, @del &></td> +% } elsif ($cf->Type eq 'Text') { +<td><& /Elements/EditCustomFieldText, @add &></td> +<td> </td> +% } else { +% $RT::Logger->crit("Unknown CustomField type: " . $cf->Type); +% } +</tr> +% } +</table> +</&> + +<&|/Widgets/TitleBox, title => loc('Edit Links'), color => "#336633"&> +<em><&|/l&>Enter tickets or URIs to link tickets to. Separate multiple entries with spaces.</&></em><br /> +<& /Ticket/Elements/BulkLinks &> +</&> + +<& /Elements/Submit, Label => loc('Update') &> + + +</form> + + +<%INIT> +my $title = loc("Update multiple tickets"); + +# Iterate through the ARGS hash and remove anything with a null value. +map ( $ARGS{$_} =~ /^$/ && ( delete $ARGS{$_} ), keys %ARGS ); + +my (@results); + +$Page ||= 1; + +$Format ||= $RT::DefaultSearchResultFormat; + +# inject _CHECKBOX to the first field. +$Format =~ s/'?([^']+)'?,/'___CHECKBOX__$1',/; + +my $Tickets = RT::Tickets->new( $session{'CurrentUser'} ); +$Tickets->FromSQL($Query); +if ( $OrderBy =~ /\|/ ) { + + # Multiple Sorts + my @OrderBy = split /\|/, $OrderBy; + my @Order = split /\|/, $Order; + $Tickets->OrderByCols( + map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } + ( 0 .. $#OrderBy ) ); +} +else { + $Tickets->OrderBy( FIELD => $OrderBy, ORDER => $Order ); +} + +$Tickets->RowsPerPage($Rows) if ($Rows); +$Tickets->GotoPage( $Page - 1 ); # SB uses page 0 as the first page + +Abort( loc("No search to operate on.") ) unless ($Tickets); + +# build up a list of all custom fields for tickets that we're displaying, so +# we can display sane edit widgets. + +my $fields = {}; +my $seen_queues = {}; +while ( my $ticket = $Tickets->Next ) { + next if $seen_queues->{ $ticket->Queue }++; + + my $custom_fields = $ticket->QueueObj->TicketCustomFields; + while ( my $field = $custom_fields->Next ) { + $fields->{ $field->id } = $field; + } +} + +my $do_comment_reply = 0; + +# Prepare for ticket updates +if ($ARGS{'UpdateContent'}) { + $ARGS{'UpdateContent'} =~ s/\r\n/\n/g; + chomp( $ARGS{'UpdateContent'} ); + + if ($ARGS{'UpdateContent'} ne '' + && $ARGS{'UpdateContent'} ne "-- \n" + . $session{'CurrentUser'}->UserObj->Signature ) { + $do_comment_reply = 1; + } +} + +#Iterate through each ticket we've been handed +my @linkresults; +my %queues; + +$Tickets->RedoSearch(); + +# pull out the labels for any custom fields we want to update + +my $cf_del_keys; +@$cf_del_keys = grep { /^Bulk-Delete-CustomField/ } keys %ARGS; +my $cf_add_keys; +@$cf_add_keys = grep { /^Bulk-Add-CustomField/ } keys %ARGS; + + +while ( my $Ticket = $Tickets->Next ) { + next unless ( $ARGS{ "UpdateTicket" . $Ticket->Id } ); + + #Update the links + $ARGS{'id'} = $Ticket->id; + $queues{ $Ticket->QueueObj->Id }++; + + my @updateresults; + if ($do_comment_reply) { + ProcessUpdateMessage( + TicketObj => $Ticket, + ARGSRef => \%ARGS, + Actions => \@updateresults + ); + } + + #Update the basics. + my @basicresults = + ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS ); + my @dateresults = + ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS ); + + #Update the watchers + my @watchresults = + ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS ); + + foreach my $type qw(MergeInto DependsOn MemberOf RefersTo) { + $ARGS{ $Ticket->id . "-" . $type } = $ARGS{"Ticket-$type"}; + $ARGS{ $type . "-" . $Ticket->id } = $ARGS{"$type-Ticket"}; + } + @linkresults = + ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS ); + foreach my $type qw(MergeInto DependsOn MemberOf RefersTo) { + delete $ARGS{ $type . "-" . $Ticket->id }; + delete $ARGS{ $Ticket->id . "-" . $type }; + } + + my @cfresults; + + foreach my $list ( $cf_add_keys, $cf_del_keys ) { + next unless $list->[0]; + + + my $op; + if ( $list->[0] =~ /Add/ ) { + $op = 'add'; + + } + elsif ( $list->[0] =~ /Del/ ) { + $op = 'del'; + } + else { + $RT::Logger->crit( + "Got an op that was neither add nor delete. can never happen" + . $list->[0] ); + last; + } + + foreach my $key (@$list) { + my ( $cfid, $cf ); + if ( $key =~ /CustomField-(\d+)-/ ) { + $cfid = $1; + $cf = RT::CustomField->new( $session{'CurrentUser'} ); + $cf->Load($cfid); + } + else {next} + my @values = + ref( $ARGS{$key} ) eq 'ARRAY' + ? @{ $ARGS{$key} } + : ( $ARGS{$key} ); + map { s/(\r\n|\r)/\n/g; } @values; # fix the newlines + # now break the multiline values into multivalues + @values = map { split( /\n/, $_ ) } @values + unless ( $cf->SingleValue ); + + my $current_values = $Ticket->CustomFieldValues($cfid); + foreach my $value (@values) { + if ( $op eq 'del' && $current_values->HasEntry($value) ) { + my ( $id, $msg ) = $Ticket->DeleteCustomFieldValue( + Field => $cfid, + Value => $value + ); + push @cfresults, $msg; + } + + elsif ( $op eq 'add' && !$current_values->HasEntry($value) ) { + my ( $id, $msg ) = $Ticket->AddCustomFieldValue( + Field => $cfid, + Value => $value + ); + push @cfresults, $msg; + } + } + } + } + my @tempresults = ( + @watchresults, @basicresults, @dateresults, + @updateresults, @linkresults, @cfresults + ); + + @tempresults = + map { loc( "Ticket [_1]: [_2]", $Ticket->Id, $_ ) } @tempresults; + + @results = ( @results, @tempresults ); +} + +my $TxnCFs = RT::CustomFields->new( $session{CurrentUser} ); +$TxnCFs->LimitToLookupType( RT::Transaction->CustomFieldLookupType ); +$TxnCFs->LimitToGlobalOrObjectId( sort keys %queues ); + +</%INIT> +<%args> +$Format => undef +$Page => 1 +$Rows => undef +$Order => 'ASC' +$OrderBy => 'id' +$Query => undef +</%args> diff --git a/rt/html/Search/Chart b/rt/html/Search/Chart new file mode 100644 index 000000000..82704fdc7 --- /dev/null +++ b/rt/html/Search/Chart @@ -0,0 +1,188 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +$Query => "id > 0" +$PrimaryGroupBy => 'Queue' +$SecondaryGroupBy => undef +$ChartStyle => 'bars' +</%args> +<%init> +my @keys; +my @values; +my $chart_class; +use GD; +use GD::Text; + +if ($ChartStyle eq 'pie') { + require GD::Graph::pie; + $chart_class = "GD::Graph::pie"; +} else { + require GD::Graph::bars; + $chart_class = "GD::Graph::bars"; +} + +use RT::Report::Tickets; +my $tix = RT::Report::Tickets->new( $session{'CurrentUser'} ); +$tix->FromSQL( $Query ); +my $count_name = $tix->Column( FUNCTION => 'COUNT', FIELD => 'id' ); +$tix->GroupBy( FIELD => $PrimaryGroupBy ); +my $value_name = $tix->Column( FIELD => $PrimaryGroupBy ); + +my $chart = $chart_class->new( 600 => 400 ); + +my $font = $RT::ChartFont || ['verdana', 'arial', gdMediumBoldFont]; +$chart->set_title_font( $font, 12 ) if $chart->can('set_title_font'); +$chart->set_legend_font( $font, 12 ) if $chart->can('set_legend_font'); +$chart->set_x_label_font( $font, 10 ) if $chart->can('set_x_label_font'); +$chart->set_y_label_font( $font, 10 ) if $chart->can('set_y_label_font'); +$chart->set_label_font( $font, 10 ) if $chart->can('set_label_font'); +$chart->set_x_axis_font( $font, 9 ) if $chart->can('set_x_axis_font'); +$chart->set_y_axis_font( $font, 9 ) if $chart->can('set_y_axis_font'); +$chart->set_values_font( $font, 9 ) if $chart->can('set_values_font'); +$chart->set_value_font( $font, 9 ) if $chart->can('set_value_font'); + +# Pie charts don't like having no input, so we show a special image +# that indicates an error message. Because this is used in an <img> +# context, it can't be a simple error message. Without this check, +# the chart will just be a non-loading image. +if ($tix->Count == 0) { + my $plot = GD::Image->new(600 => 400); + $plot->colorAllocate(255, 255, 255); # background + my $black = $plot->colorAllocate(0, 0, 0); + + require GD::Text::Wrap; + my $error = GD::Text::Wrap->new($plot, + color => $black, + text => loc("No tickets found."), + ); + $error->set_font( $font, 12 ); + $error->draw(0, 0); + + $m->comp( 'SELF:Plot', plot => $plot, %ARGS ); +} + +if ($chart_class eq "GD::Graph::bars") { + $chart->set( + x_label => $tix->Label( $PrimaryGroupBy ), + x_labels_vertical => 1, + y_label => loc('Tickets'), + show_values => 1 + ); +} + +my %class = ( + Queue => 'RT::Queue', + Owner => 'RT::User', +); +my $class = $class{ $PrimaryGroupBy }; + +while ( my $entry = $tix->Next ) { + if ( $class ) { + my $q = $class->new( $session{'CurrentUser'} ); + $q->Load( $entry->__Value( $value_name ) ); + push @keys, $q->Name; + } + else { + push @keys, $entry->__Value($value_name); + } + + $keys[-1] ||= loc('(no value)'); + if ($chart_class eq 'GD::Graph::pie') { + $keys[-1] .= " - ". $entry->__Value( $count_name ); + } + push @values, $entry->__Value($count_name); +} + +# XXX: Convert 1970-01-01 date to the 'Not Set' +# this code should be generalized!!! +if ( $PrimaryGroupBy =~ /(Daily|Monthly|Annually)$/ ) { + my $re; + $re = qr{1970-01-01} if $PrimaryGroupBy =~ /Daily$/; + $re = qr{1970-01} if $PrimaryGroupBy =~ /Monthly$/; + $re = qr{1970} if $PrimaryGroupBy =~ /Annually$/; + foreach (@keys) { + s/^$re/loc('Not Set')/e; + } +} + +unless (@keys && @values) { + @keys = (''); + @values = (0); +} + +my %data; +foreach my $key (@keys) { $data{$key} = shift @values; } +my @sorted_keys = sort @keys; +my @sorted_values = map { $data{$_}} @sorted_keys; + + + +my $plot = $chart->plot( [ [@sorted_keys], [@sorted_values] ] ) or die $chart->error; +$m->comp( 'SELF:Plot', plot => $plot, %ARGS ); +</%init> + +<%METHOD Plot> +<%ARGS> +$plot => undef +</%ARGS> +<%INIT> +my @types = ('png', 'gif'); + +for my $type (@types) { + $plot->can($type) + or next; + + $r->content_type("image/$type"); + $m->out( $plot->$type ); + $m->abort(); +} + +die "Your GD library appears to support none of the following image types: " . join(', ', @types); +</%INIT> + +</%METHOD> diff --git a/rt/html/Search/Chart.html b/rt/html/Search/Chart.html new file mode 100644 index 000000000..a07d89502 --- /dev/null +++ b/rt/html/Search/Chart.html @@ -0,0 +1,73 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +$Query => "id > 0" +$PrimaryGroupBy => 'Queue' +$SecondaryGroupBy => '' +$ChartStyle => 'bars' +$Description => undef +</%args> +<%init> +$ARGS{SecondaryGroupBy} ||= ''; + +my $title = loc( "Search results grouped by [_1]", $PrimaryGroupBy ); + +my $saved_search = $m->comp( '/Widgets/SavedSearch:new', + SearchType => 'Chart', + SearchFields => [qw(Query PrimaryGroupBy SecondaryGroupBy ChartStyle)] ); + +my @actions = $m->comp( '/Widgets/SavedSearch:process', args => \%ARGS, self => $saved_search ); + +</%init> +<& /Elements/Header, Title => $title &> +<& /Ticket/Elements/Tabs, Title => $title &> +<& /Elements/ListActions, actions => \@actions &> +<& /Search/Elements/Chart, %ARGS &> + + +<& /Widgets/SavedSearch:show, %ARGS, Action => 'Chart.html', self => $saved_search, Title => 'Saved charts' &> diff --git a/rt/html/Search/Edit.html b/rt/html/Search/Edit.html new file mode 100755 index 000000000..21df0db97 --- /dev/null +++ b/rt/html/Search/Edit.html @@ -0,0 +1,88 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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&> +<& /Ticket/Elements/Tabs, + current_tab => "Search/Edit.html?".$QueryString, + Title => $title, + Format => $Format, + Query => $Query, + Rows => $ARGS{'Rows'}, + OrderBy => $ARGS{'OrderBy'}, + Order => $ARGS{'Order'} &> + +<& Elements/NewListActions, actions => \@actions &> + +<form method="post" action="Build.html"> +<input type="hidden" class="hidden" name="SearchId" value="<%$SearchId%>" /> +<textarea name="Query" rows="8" cols="72"><%$Query%></textarea> +<br /> +<textarea name="Format" rows="8" cols="72"><%$Format%></textarea> +<br /> +<& /Elements/Submit, Label => loc("Apply"), Reset => 1, Caption => loc("Apply your changes")&> +</form> + +<%INIT> +my $title = loc("Edit Query"); +$Format = $m->comp('/Elements/ScrubHTML', Content => $Format); +my $QueryString = $m->comp('/Elements/QueryString', + Query => $Query, + Format => $Format, + Rows => $ARGS{'Rows'}, + OrderBy => $ARGS{'OrderBy'}, + Order => $ARGS{'Order'}, + ); + +</%INIT> + + +<%ARGS> +$Query => undef +$Format => undef +$SearchId => 'new' +@actions => undef +</%ARGS> diff --git a/rt/html/Search/Elements/BuildFormatString b/rt/html/Search/Elements/BuildFormatString new file mode 100644 index 000000000..3bd39b5c2 --- /dev/null +++ b/rt/html/Search/Elements/BuildFormatString @@ -0,0 +1,244 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +$Format => undef +%cfqueues => undef +$Face => undef +$Size => undef +$Link => undef +$Title => undef +$AddCol => undef +$RemoveCol => undef +$ColUp => undef +$ColDown => undef +$SelectDisplayColumns => undef +$CurrentDisplayColumns => undef +</%args> +<%init> + +unless ($Format) { + $Format = $RT::DefaultSearchResultFormat; +} + + +# All the things we can display in the format string by default +my @fields = qw( + id + Status + ExtendedStatus + Subject + QueueName + OwnerName + Priority + InitialPriority + FinalPriority + Type + TimeWorked + TimeLeft + TimeEstimated + CreatedBy + LastUpdatedBy + Requestors + Cc + AdminCc + Starts + StartsRelative + Started + StartedRelative + Created + CreatedRelative + LastUpdated + LastUpdatedRelative + Told + ToldRelative + Due + DueRelative + Resolved + ResolvedRelative + RefersTo + ReferredToBy + DependsOn + DependedOnBy + MemberOf + Members + Parents + Children + NEWLINE +); + +my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'}); +foreach my $id (keys %cfqueues) { + # What does this _do_? What are the keys to cfqueues + $id =~ s/^.'*(.*).'*$/$1/; + # Gotta load up the $queue object, since queues get stored by name now. + my $queue = RT::Queue->new($session{'CurrentUser'}); + $queue->Load($id); + $CustomFields->LimitToQueue($queue->Id); +} +$CustomFields->LimitToGlobal; + +while ( my $CustomField = $CustomFields->Next ) { + push @fields, "CustomField.{" . $CustomField->Name . "}"; +} + +my ( @seen); + +my @format = split( /,\s*/, $Format ); +foreach my $field (@format) { + my %column = (); + $field =~ s/'(.*)'/$1/; + my ( $prefix, $suffix ); + if ( $field =~ m/(.*)__(.*)__(.*)/ ) { + $prefix = $1; + $suffix = $3; + $field = $2; + } + $field = "<blank>" if !$field; + $column{Prefix} = $prefix; + $column{Suffix} = $suffix; + $field =~ s/\s*(.*)\s*/$1/; + $column{Column} = $field; + push @seen, \%column; +} + +if ( $RemoveCol ) { + my $index = $CurrentDisplayColumns; + my $column = $seen[$index]; + if ($index) { + delete $seen[$index]; + my @temp = @seen; + @seen = (); + foreach my $element (@temp) { + next unless $element; + push @seen, $element; + } + } +} +elsif ( $AddCol ) { + if ( defined $SelectDisplayColumns ) { + my $selected = $SelectDisplayColumns; + my @columns; + if (ref($selected) eq 'ARRAY') { + @columns = @$selected; + } else { + push @columns, $selected; + } + foreach my $col (@columns) { + my %column = (); + $column{Column} = $col; + + if ( $Face eq "Bold" ) { + $column{Prefix} .= "<b>"; + $column{Suffix} .= "</b>"; + } + if ( $Face eq "Italic" ) { + $column{Prefix} .= "<i>"; + $column{Suffix} .= "</i>"; + } + if ($Size) { + $column{Prefix} .= "<" . $m->interp->apply_escapes( $Size, 'h' ) . ">"; + $column{Suffix} .= "</" . $m->interp->apply_escapes( $Size, 'h' ) . ">"; + } + if ( $Link eq "Display" ) { + $column{Prefix} .= + "<a HREF=\"" . $RT::WebPath . "/Ticket/Display.html?id=__id__\">"; + $column{Suffix} .= "</a>"; + } + elsif ( $Link eq "Take" ) { + $column{Prefix} .= "<a HREF=\"" . $RT::WebPath + . "/Ticket/Display.html?Action=Take&id=__id__\">"; + $column{Suffix} .= "</a>"; + } + + if ($Title) { + $column{Suffix} .= "/TITLE:" . $m->interp->apply_escapes( $Title, 'h' ); + } + push @seen, \%column; +} +} +} +elsif ( $ColUp ) { + my $index = $CurrentDisplayColumns; + if ( defined $index && ( $index - 1 ) >= 0 ) { + my $column = $seen[$index]; + $seen[$index] = $seen[ $index - 1 ]; + $seen[ $index - 1 ] = $column; + $CurrentDisplayColumns = $index - 1; + } +} +elsif ( $ColDown ) { + my $index = $CurrentDisplayColumns; + if ( defined $index && ( $index + 1 ) < scalar @seen ) { + my $column = $seen[$index]; + $seen[$index] = $seen[ $index + 1 ]; + $seen[ $index + 1 ] = $column; + $CurrentDisplayColumns = $index + 1; + } +} + + +my @format_string; +foreach my $field (@seen) { + next unless $field; + my $row = "'"; + $row .= $field->{Prefix} if $field->{Prefix}; + $row .= "__" . ($field->{Column} =~ m/\(/ ? $field->{Column} # func, don't escape + : $m->interp->apply_escapes( $field->{Column}, 'h' )) . "__" + unless ( $field->{Column} eq "<blank>" ); + $row .= $field->{Suffix} if $field->{Suffix}; + $row .= "'"; + push( @format_string, $row ); +} + +$Format = join(",\n", @format_string); + + +return($Format, \@fields, \@seen); + +</%init> + diff --git a/rt/html/Search/Elements/Chart b/rt/html/Search/Elements/Chart new file mode 100644 index 000000000..2eca6afda --- /dev/null +++ b/rt/html/Search/Elements/Chart @@ -0,0 +1,139 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +$Query => "id > 0" +$PrimaryGroupBy => 'Queue' +$SecondaryGroupBy => undef +$ChartStyle => 'bars' +</%args> +<%init> +use RT::Report::Tickets; +my $tix = RT::Report::Tickets->new( $session{'CurrentUser'} ); +$tix->FromSQL( $Query ); +my $count_name = $tix->Column( FUNCTION => 'COUNT', FIELD => 'id' ); +$tix->GroupBy( FIELD => $PrimaryGroupBy ); +my $value_name = $tix->Column( FIELD => $PrimaryGroupBy ); + +my %class = ( + Queue => 'RT::Queue', + Owner => 'RT::User', +); +my $class = $class{ $PrimaryGroupBy }; + +my (@keys, @values); +while ( my $entry = $tix->Next ) { + if ($class) { + my $q = $class->new( $session{'CurrentUser'} ); + $q->Load( $entry->__Value( $value_name ) ); + push @keys, $q->Name; + } + else { + push @keys, $entry->__Value( $value_name ); + } + $keys[-1] ||= loc('(no value)'); + push @values, $entry->__Value( $count_name ); +} + +# XXX: Convert 1970-01-01 date to the 'Not Set' +# this code should be generalized!!! +if ( $PrimaryGroupBy =~ /(Daily|Monthly|Annually)$/ ) { + my $re; + $re = qr{1970-01-01} if $PrimaryGroupBy =~ /Daily$/; + $re = qr{1970-01} if $PrimaryGroupBy =~ /Monthly$/; + $re = qr{1970} if $PrimaryGroupBy =~ /Annually$/; + foreach (@keys) { + s/^$re/loc('Not Set')/e; + } +} + +my %data; +foreach my $key (@keys) { $data{$key} = shift @values; } +my @sorted_keys = sort @keys; +my @sorted_values = map { $data{$_}} @sorted_keys; + + +my $query_string = $m->comp('/Elements/QueryString', %ARGS); +</%init> + +<% loc('Query:') %> <% $Query %><br /> + +<img src="<%$RT::WebPath%>/Search/Chart?<%$query_string|n%>" /><br /> + +<table class="collection-as-table"> +<tr> +<th class="collection-as-table"><% $tix->Label($PrimaryGroupBy) %> +</th> +<th class="collection-as-table"><&|/l&>Tickets</&> +</th> +</tr> +% my ($i,$total); +% while (my $key = shift @sorted_keys) { +% $i++; +% my $value = shift @sorted_values; +% $total += $value; +<tr class="<%$i%2 ? 'evenline' : 'oddline' %>"> +<td class="label collection-as-table"> +<%$key%> +</td> +<td class="value collection-as-table"> +<%$value%> +</td> +</tr> +% } + +%$i++; +<tr class="<%$i%2 ? 'evenline' : 'oddline' %>"> +<td class="label collection-as-table"> +<%loc('Total')%> +</td> +<td class="value collection-as-table"> +<%$total%> +</td> +</tr> + +</table> diff --git a/rt/html/Search/Elements/DisplayOptions b/rt/html/Search/Elements/DisplayOptions new file mode 100644 index 000000000..cc57f96dc --- /dev/null +++ b/rt/html/Search/Elements/DisplayOptions @@ -0,0 +1,143 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<&| /Widgets/TitleBox, title => loc("Display Columns") &> +<table width="100%"> +<tr> +<td> +<& EditFormat, %ARGS &> +</td> +<td valign="top"> +<table valign="top"> + +% for my $o (0..3) { +<tr> +<td class="label"> +% if ($o == 0) { +<&|/l&>Order by</&>: +% } +</td> +<td class="value"> +<select name="OrderBy"> +% if ($o > 0) { +<option value=""><&|/l&>~[none~]</&></option> +% } +% foreach my $field (sort keys %fields) { +% next unless $field; +<option value="<%$field%>" +% if (defined $OrderBy[$o] and $field eq $OrderBy[$o]) { +selected +% } +><&|/l&><%$field%></&></option> +% } +</select> +<select name="Order"> +<option value="ASC" +% unless ( ($Order[$o]||'') eq "DESC" ) { +selected +% } +><&|/l&>Asc</&></option> +<option value="DESC" +% if ( ($Order[$o]||'') eq "DESC" ) { +selected +% } +><&|/l&>Desc</&></option> +</select> +</td> +</tr> +% } +<tr> +<td class="label"> +<&|/l&>Rows per page</&>: +</td><td class="value"> +<& /Elements/SelectResultsPerPage, + Name => "RowsPerPage", + Default => $RowsPerPage &> +</td> +</tr> +</table> +</td> +</tr> +</table> +</&> + +<%INIT> +my $tickets = new RT::Tickets($session{'CurrentUser'}); +my %fields = %{$tickets->FIELDS}; +map { $fields{$_}->[0] =~ /^(?:ENUM|INT|DATE|STRING)$/ || delete $fields{$_} } keys %fields; +delete $fields{'EffectiveId'}; +$fields{ $_ . '.EmailAddress' } = 1 foreach( qw(Requestor Cc AdminCc) ); + +# Add all available CustomFields to the list of sortable columns. +my @cfs = grep /^CustomField/, @{$ARGS{AvailableColumns}}; +$fields{$_}=1 for @cfs; + +# Add PAW sort +$fields{'Custom.Ownership'} = 1; + +my @Order; +my @OrderBy; +if ($OrderBy =~ /\|/) { + @OrderBy = split /\|/, $OrderBy; +} else { + @OrderBy = ( $OrderBy ); +} +if ($Order =~ /\|/) { + @Order = split /\|/, $Order; +} else { + @Order = ( $Order ); +} + +</%INIT> + +<%ARGS> +$Order => undef +$OrderBy => undef +$RowsPerPage => undef +$Format => undef +$GroupBy => 'id' +</%ARGS> diff --git a/rt/html/Search/Elements/EditFormat b/rt/html/Search/Elements/EditFormat new file mode 100644 index 000000000..fa0ac96e0 --- /dev/null +++ b/rt/html/Search/Elements/EditFormat @@ -0,0 +1,116 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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> +<tr> +<td> +<&|/l&>Add Columns</&>: +</td> +<td> +<&|/l&>Format</&>: +</td> +<td></td> +<td> +<&|/l&>Show Columns</&>: +</td> +<tr> +<td valign="top"> +<select size="6" name="SelectDisplayColumns" multiple> +% foreach my $field ( @$AvailableColumns) { +<option value="<%$field%>"><% loc( $field) %></option> +%# $m->comp( '/Elements/RT__Ticket/ColumnMap', Name => $field, Attr => 'title') || +% } +</select> +</td> +<td> +<&|/l&>Link</&>: +<select name="Link"> +<option value="None">-</option> +<option value="Display"><&|/l&>Display</&></option> +<option value="Take"><&|/l&>Take</&></option> +</select> +<br /><&|/l&>Title</&>: <input name="Title" size="10" /> +<br /><&|/l&>Size</&>: +<select name="Size"> +<option value="">-</option> +<option value="Small"><&|/l&>Small</&></option> +<option value="Large"><&|/l&>Large</&></option> +</select> +<br /><&|/l&>Style</&>: +<select name="Face"> +<option value="">-</option> +<option value="Bold"><&|/l&>Bold</&></option> +<option value="Italic"><&|/l&>Italic</&></option> +</select> +</td> +<td> +<input type="submit" class="button" name="AddCol" value=" → " /> +</td> +<td valign="top"> +<select size="4" name="CurrentDisplayColumns"> +% my $i=0; +% foreach my $field (@$CurrentFormat) { +<option value="<%$i++%>><%$field->{Column}%>"> +<%loc( $field->{Column}) %></option> +% } +</select> +<br /> +<center> +<input type="submit" class="button" name="ColUp" value=" ↑ " /> +<input type="submit" class="button" name="ColDown" value=" ↓ " /> +<input type="submit" class="button" name="RemoveCol" value="<%loc('Delete')%>" /> +</center> +</td> +<td colspan="3" align="center"> +</td> +</tr> +</table> + +<%ARGS> +$CurrentFormat => undef +$AvailableColumns => undef +</%ARGS> diff --git a/rt/html/Search/Elements/EditQuery b/rt/html/Search/Elements/EditQuery new file mode 100644 index 000000000..5c40c2573 --- /dev/null +++ b/rt/html/Search/Elements/EditQuery @@ -0,0 +1,67 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<& NewListActions, actions => $actions &> +<&|/Widgets/TitleBox, title => join(': ', grep defined, loc("Current search"), $Description) &> +<select size="10" name="clauses" style="width: 100%" multiple> +% $m->out($optionlist); +</select> +<p align="center"> +<input type="submit" class="button" name="Up" value=" ↑ " /> +<input type="submit" class="button" name="Down" value=" ↓ " /> +<input type="submit" class="button" name="Left" value=" ← " /> +<input type="submit" class="button" name="Right" value=" → " /> +<input type="submit" class="button" name="Toggle" value="<&|/l&>And/Or</&>" /> +<input type="submit" class="button" name="DeleteClause" value="<&|/l&>Delete</&>" /> +%#<input type="submit" class="button" name="EditQuery" value="Advanced" /> +</p> +</&> +<%ARGS> +$Description +$optionlist +$actions +</%ARGS> diff --git a/rt/html/Search/Elements/EditSearches b/rt/html/Search/Elements/EditSearches new file mode 100644 index 000000000..3978ea320 --- /dev/null +++ b/rt/html/Search/Elements/EditSearches @@ -0,0 +1,103 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<&| /Widgets/TitleBox, title => loc($Title)&> +%# Hide all the save functionality if the user shouldn't see it. +% if ($session{'CurrentUser'}->HasRight( Right => 'CreateSavedSearch', +% Object=> $RT::System )) { +<&|/l&>Privacy:</&> +% if ($CurrentSearch->{'Object'} && $CurrentSearch->{'Object'}->id) { +<& SearchPrivacy, Object => $CurrentSearch->{'Object'}->Object &><br /> +% } else { +<& SelectSearchObject, Name => 'Owner', Objects => \@Objects &><br /> +% } +<&|/l&>Description</&>:<br> +<font size="-1"><input size="25" name="Description" value="<%$CurrentSearch->{'Description'} || ''%>" /></font> +% if ($SearchId ne 'new') { +<nobr> +% if ($Dirty) { +<input type="submit" class="button" name="Revert" value="<%loc('Revert')%>" /> +% } +<input type="submit" class="button" name="Delete" value="<%loc('Delete')%>" /> +% if ($AllowCopy) { +<input type="submit" class="button" name="CopySearch" value="<%loc('Copy')%>" /> +% } +</nobr> + +% } +<input type="submit" name="Save" value="<%loc('Save')%>" class="button" /> +<hr /> +% } +<&|/l&>Load saved search:</&><br /> +<& SelectSearchesForObjects, Name => 'LoadSavedSearch', Objects => \@Objects, SearchType => $SearchType &> +<input value="<%loc('Load')%>" type="submit" class="button" /> +</&> + +<%init> +unless ($session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch', + Object=> $RT::System )) { + return; +} + +use RT::SavedSearches; +my @Objects = RT::SavedSearches->new($session{CurrentUser})->_PrivacyObjects; +push @Objects, RT::System->new($session{'CurrentUser'}) + if $session{'CurrentUser'}->HasRight( Object=> $RT::System, + Right => 'SuperUser'); + +</%INIT> + +<%ARGS> +$SearchType => 'Ticket' +$SearchId => undef +$CurrentSearch => undef +$Description => undef +$HideResults => 0 +$Dirty => 0 +$AllowCopy => 1 +$Title => 'Saved searches' +</%ARGS> diff --git a/rt/html/Search/Elements/NewListActions b/rt/html/Search/Elements/NewListActions new file mode 100644 index 000000000..535ac8cb9 --- /dev/null +++ b/rt/html/Search/Elements/NewListActions @@ -0,0 +1,68 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +% if ($actions[0] ) { +<b><%loc('Results')%></b><br /> +% foreach my $action (@actions) { +% next unless ($action); +% my @item = @$action; +% if ($item[1] < 0) { +<font color="red"> +% } + <%$item[0]%><br /> +% if ($item[1] < 0) { +</font> +% } +% } +<br /> +% } +<%init> +@actions = grep (/./,@actions); +</%init> +<%ARGS> +@actions => undef +</%ARGS> diff --git a/rt/html/Search/Elements/PickBasics b/rt/html/Search/Elements/PickBasics new file mode 100644 index 000000000..44a378c14 --- /dev/null +++ b/rt/html/Search/Elements/PickBasics @@ -0,0 +1,176 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<tr> +<td class="label"> +<&|/l&>id</&> +</td><td> +<& /Elements/SelectEqualityOperator, Name => "idOp" &> +</td><td> +<input name="ValueOfid" size="5" /> +</td> +</tr> + +<tr><td> +<& /Elements/SelectAttachmentField, Name => 'AttachmentField' &> +</td><td> +<& /Elements/SelectBoolean, Name => "AttachmentOp", + True => loc("matches"), + False => loc("does not match"), + TrueVal => 'LIKE', + FalseVal => 'NOT LIKE' +&> +</td><td> +<input name="ValueOfAttachment" size="20" /> +</td> +</tr> +<tr> +<td class="label"> +<&|/l&>Queue</&> +</td><td> +<& /Elements/SelectBoolean, Name => "QueueOp" , + True => loc("is"), + False => loc("isn't"), + TrueVal=> '=', + FalseVal => '!=' &> +</td><td> +<& /Elements/SelectQueue, + Name => "ValueOfQueue", + NamedValues => 1, + CheckQueueRight => 'ShowTicket' &> +</td> +</tr> +<tr> +<td class="label"> +<&|/l&>Status</&> +</td><td> +<& /Elements/SelectBoolean, Name => "StatusOp", + True => loc("is"), + False => loc("isn't"), + TrueVal=> '=', + FalseVal => '!=' +&> +</td><td> +<& /Elements/SelectStatus, Name => "ValueOfStatus", SkipDeleted => 1 &> +</td> +</tr> +<tr><td class="label"> +<select name="ActorField"> +<option value="Owner"><&|/l&>Owner</&></option> +<option value="Creator"><&|/l&>Creator</&></option> +<option value="LastUpdatedBy"><&|/l&>LastUpdatedBy</&></option> +</select> +</td><td> +<& /Elements/SelectBoolean, Name => "ActorOp", + TrueVal=> '=', + FalseVal => '!=' +&> +</td><td> +<& /Elements/SelectOwner, Name => "ValueOfActor", ValueAttribute => 'Name' &> +</td> +</tr> +<tr> +<td class="label"> +<& SelectPersonType, Name => 'WatcherField', Default => 'Requestor' &> +</td><td> +<& /Elements/SelectMatch, Name => "WatcherOp" &> +</td><td> +<input name="ValueOfWatcher" size="20" /> +</tr> +<tr> +<td class="label"> +<& /Elements/SelectDateType, Name=>"DateField" &> +</td><td> +<& /Elements/SelectDateRelation, Name=>"DateOp" &> +</td><td> +<& /Elements/SelectDate, Name => "ValueOfDate", ShowTime => 0, Default => '' &> +</td></tr> +<tr> +<td class="label"> +<select name="TimeField"> +<option value="TimeWorked"><&|/l&>Time Worked</&></option> +<option value="TimeEstimated"><&|/l&>Time Estimated</&></option> +<option value="TimeLeft"><&|/l&>Time Left</&></option> +</select> +</td><td> +<& /Elements/SelectEqualityOperator, Name => "TimeOp" &> +</td><td> +<input name="ValueOfTime" size="5" /> +<& /Elements/SelectTimeUnits, Name =>'ValueOfTime' &> +</td> +</tr> +<tr> +<td class="label"> +<select name="PriorityField"> +<option value="Priority"><&|/l&>Priority</&></option> +<option value="InitialPriority"><&|/l&>Initial Priority</&></option> +<option value="FinalPriority"><&|/l&>Final Priority</&></option> +</select> +</td><td> +<& /Elements/SelectEqualityOperator, Name => "PriorityOp" &> +</td><td> +<input name="ValueOfPriority" size="5" /> +</td> +</tr> +<tr> +<td class="label"> +<& SelectLinks, Name=>"LinksField" &> +</td><td> +<& /Elements/SelectBoolean, Name => "LinksOp", + True => loc("is"), + False => loc("isn't"), + TrueVal=> '=', + FalseVal => '!=' &> +</td><td> +<input name="ValueOfLinks" value="" size="5" /> +</td></tr> +<%INIT> +my @people = ('Actor', + 'Watcher', + 'WatcherGroup', + ); +</%INIT> diff --git a/rt/html/Search/Elements/PickCFs b/rt/html/Search/Elements/PickCFs new file mode 100644 index 000000000..734f5f871 --- /dev/null +++ b/rt/html/Search/Elements/PickCFs @@ -0,0 +1,80 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +% while ( my $CustomField = $CustomFields->Next ) { +% my $name = "'CF.{" . $CustomField->Name . "}'"; +<tr><td class="label"> +<% $CustomField->Name %> +</td> +<td> + <& /Elements/SelectCustomFieldOperator, Name => $name . "Op", + True => loc("is"), + False => loc("isn't"), + TrueVal=> '=', FalseVal => '!=' &> +</td> +<td> +<& /Elements/SelectCustomFieldValue, Name => "ValueOf" . $name, + CustomField => $CustomField, + &> +</td></tr> +% } +<%INIT> +my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'}); +foreach my $id (keys %cfqueues) { + $id =~ s/^.'*(.*).'*$/$1/; + # Gotta load up the $queue object, since queues get stored by name now. my $id + my $queue = RT::Queue->new($session{'CurrentUser'}); + $queue->Load($id); + $CustomFields->LimitToQueue($queue->Id); +} +$CustomFields->LimitToGlobal(); + +</%INIT> + +<%ARGS> +%cfqueues => undef +</%ARGS> diff --git a/rt/html/Search/Elements/PickCriteria b/rt/html/Search/Elements/PickCriteria new file mode 100644 index 000000000..58b29fb57 --- /dev/null +++ b/rt/html/Search/Elements/PickCriteria @@ -0,0 +1,82 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<&| /Widgets/TitleBox, title => loc('Add Criteria')&> +<table width="100%" cellspacing="0" cellpadding="0" border="0"> + <tr> + <td> + <table cellspacing="0" border="0"> + <tr><td class="label"> + <&|/l&>Aggregator</&>: + </td> + <td><& SelectAndOr, Name => "AndOr" &> + </td></tr> + </table> + </td></tr> + <tr> + <td> + <hr> + </td> + </tr> + <tr> + <td valign="top"> + <table cellspacing="0" border="0"> + <& PickBasics &> + <& PickCFs, cfqueues => \%cfqueues &> + </table> + </td> + </tr> + <tr><td> </td></tr> +</table> + +</&> + +<%ARGS> +$addquery => 0 +$query => undef +%cfqueues => undef +</%ARGS> diff --git a/rt/html/Search/Elements/SearchPrivacy b/rt/html/Search/Elements/SearchPrivacy new file mode 100644 index 000000000..745ba62ac --- /dev/null +++ b/rt/html/Search/Elements/SearchPrivacy @@ -0,0 +1,55 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +$Object => undef +</%args> +% if (ref($Object) eq 'RT::User' && $Object->id == $session{'CurrentUser'}->Id) { +<&|/l&>My saved searches</&> +% } else { +<&|/l, $Object->Name&>[_1]'s saved searches</&> +% } diff --git a/rt/html/Search/Elements/SearchesForObject b/rt/html/Search/Elements/SearchesForObject new file mode 100644 index 000000000..45aa4535e --- /dev/null +++ b/rt/html/Search/Elements/SearchesForObject @@ -0,0 +1,65 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +$Object => undef +</%args> +<%init> +# Returns an array of search objects associated on $Object, +# in the form of [Description, searchObj] +my @result; +while (my $search = $Object->Attributes->Next) { + my $desc; + if ($search->Name eq 'SavedSearch') { + push @result, [$search->Description, $search]; + } + elsif ($search->Name =~ m/^Search - (.*)/) { + push @result, [$1, $search]; + } +} +return @result; +</%init> diff --git a/rt/html/Search/Elements/SelectAndOr b/rt/html/Search/Elements/SelectAndOr new file mode 100644 index 000000000..c8122660a --- /dev/null +++ b/rt/html/Search/Elements/SelectAndOr @@ -0,0 +1,53 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<input type="radio" class="radio" name="<%$Name%>" checked value="AND" /><&|/l&>AND</&></input> +<input type="radio" class="radio" name="<%$Name%>" value="OR" /><&|/l&>OR</&></input> + +<%ARGS> +$Name => "Operator" +</%ARGS> diff --git a/rt/html/Search/Elements/SelectChartType b/rt/html/Search/Elements/SelectChartType new file mode 100644 index 000000000..43a6182bf --- /dev/null +++ b/rt/html/Search/Elements/SelectChartType @@ -0,0 +1,56 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +$Name => 'ChartType' +$Default => 'bar' +</%args> +<select name="<%$Name%>"> +% foreach my $option qw(bar pie) { +<option value="<%$option%>" <% $option eq $Default ? 'SELECTED' : '' %>><%loc($option)%></option> +% } +</select> diff --git a/rt/html/Search/Elements/SelectGroup b/rt/html/Search/Elements/SelectGroup new file mode 100644 index 000000000..3f78d3964 --- /dev/null +++ b/rt/html/Search/Elements/SelectGroup @@ -0,0 +1,67 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<select name="<%$Name%>"> +% if ($AllowNull) { +<option value="">-</option> +% } +%while (my $group = $groups->Next) { +<option value="<%$group->id%>" <%$group->id eq $Default && "SELECTED"%>><%$group->Name%></option> +%} +</select> + +<%INIT> +my $groups = new RT::Groups($session{'CurrentUser'}); +$groups->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => $Domain); + +</%INIT> +<%ARGS> +$AllowNull => 1 +$Default=> '' +$Name => 'Group' +$Domain => 'UserDefined'; +</%ARGS> diff --git a/rt/html/Search/Elements/SelectGroupBy b/rt/html/Search/Elements/SelectGroupBy new file mode 100644 index 000000000..0ffb5e453 --- /dev/null +++ b/rt/html/Search/Elements/SelectGroupBy @@ -0,0 +1,63 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +$Name => 'GroupBy' +$Default => 'Status' +$Query => '' +</%args> +<select name="<% $Name %>"> +% while (@options) { +% my ($text, $value) = (shift @options, shift @options); +<option value="<% $value %>" <% $value eq $Default ? 'selected' : '' %>><% loc($text) %></option> +% } +</select> +<%init> +use RT::Report::Tickets; +my $report = RT::Report::Tickets->new( $session{'CurrentUser'} ); +my @options = $report->Groupings( Query => $Query ); +</%init> diff --git a/rt/html/Search/Elements/SelectLinks b/rt/html/Search/Elements/SelectLinks new file mode 100644 index 000000000..f3586528d --- /dev/null +++ b/rt/html/Search/Elements/SelectLinks @@ -0,0 +1,66 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<select name="<%$Name%>"> +% foreach (@fields) { +<option value="<%$_%>"><&|/l&><%$_%></&></option> +% } +</select> +<%ARGS> +$Name => 'LinksField' +</%ARGS> + +<%INIT> +my @fields = ('HasMember', + 'MemberOf', + 'DependsOn', + 'DependedOnBy', + 'RefersTo', + 'ReferredToBy', + 'LinkedTo', + ); +</%INIT> diff --git a/rt/html/Search/Elements/SelectPersonType b/rt/html/Search/Elements/SelectPersonType new file mode 100644 index 000000000..bc631dbb0 --- /dev/null +++ b/rt/html/Search/Elements/SelectPersonType @@ -0,0 +1,84 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<select NAME ="<%$Name%>"> +% if ($AllowNull) { +<option value="">-</option> +% } +% for my $option (@types) { +% if ($Suffix) { +<option value="<% $option %><% $Suffix %>" <%$option eq $Default && "SELECTED"%> ><%loc($option)%></option> +% next; +% } +% foreach my $subtype (@subtypes) { +<option value="<%"$option.$subtype"%>" <%$option eq $Default && $subtype eq 'EmailAddress' && "SELECTED"%> ><% loc($option) %> <% loc($subtype) %></option> +% } +% } +</select> + +<%INIT> +my @types; +if ($Scope =~ 'queue') { + @types = qw(Cc AdminCc); +} +elsif ($Suffix eq 'Group') { + @types = qw(Requestor Cc AdminCc Watcher); +} +else { + @types = qw(Requestor Cc AdminCc Watcher Owner); +} + +my @subtypes = qw(EmailAddress Name RealName Nickname Organization Address1 Address2 WorkPhone HomePhone MobilePhone PagerPhone); + +</%INIT> +<%ARGS> +$AllowNull => 1 +$Suffix => '' +$Default=>undef +$Scope => 'ticket' +$Name => 'WatcherType' +</%ARGS> diff --git a/rt/html/Search/Elements/SelectSearchObject b/rt/html/Search/Elements/SelectSearchObject new file mode 100644 index 000000000..f52a83372 --- /dev/null +++ b/rt/html/Search/Elements/SelectSearchObject @@ -0,0 +1,60 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +@Objects => undef +$Name => undef +</%args> +<select name="<%$Name%>"> +% foreach my $object (@Objects) { +% if (ref($object) eq 'RT::User' && $object->id == $session{'CurrentUser'}->Id) { +<option value="<%ref($object)%>-<%$object->id%>"><&|/l&>My saved searches</&></option> +% } else { +<option value="<%ref($object)%>-<%$object->id%>"><&|/l, $object->Name&>[_1]'s saved searches</&></option> +% } +% } +</select> diff --git a/rt/html/Search/Elements/SelectSearchesForObjects b/rt/html/Search/Elements/SelectSearchesForObjects new file mode 100644 index 000000000..dc8368577 --- /dev/null +++ b/rt/html/Search/Elements/SelectSearchesForObjects @@ -0,0 +1,69 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%args> +@Objects => undef +$Name => undef +$SearchType => 'Ticket', +</%args> +<select name="<%$Name%>"> +% foreach my $object (@Objects) { +% if (ref($object) eq 'RT::User' && $object->id == $session{'CurrentUser'}->Id) { +<option value=""><&|/l&>My saved searches</&></option> +% } else { +<option value=""></option> +<option value=""><&|/l, $object->Name&>[_1]'s saved searches</&></option> +% } +% my @searches = $object->Attributes->Named('SavedSearch'); +% foreach my $search (@searches) { +% # Skip it if it is not of search type we want. +% next if ($search->SubValue('SearchType') +% && $search->SubValue('SearchType') ne $SearchType); +<option value="<%ref($object)%>-<%$object->id%>-SavedSearch-<%$search->Id%>"> -<%$search->Description||loc('Unnamed search')%></option> +% } +% } +</select> diff --git a/rt/html/Search/Results.html b/rt/html/Search/Results.html new file mode 100755 index 000000000..01bdfffde --- /dev/null +++ b/rt/html/Search/Results.html @@ -0,0 +1,177 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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, Refresh => $session{'tickets_refresh_interval'}, + RSSAutoDiscovery => $RSSFeedURL &> +<& /Ticket/Elements/Tabs, + current_tab => "Search/Results.html".$QueryString, + Title => $title, + Format => $Format, + Query => $Query, + Rows => $Rows, + OrderBy => $OrderBy, + Order => $Order &> +<& /Elements/TicketList, + Query => $Query, + AllowSorting => 1, + OrderBy => $OrderBy, + Order => $Order, + Rows => $Rows, + Page => $Page, + Format => $Format, + BaseURL => $RT::WebPath."/Search/Results.html?" + + &> +% my %hiddens = (Query => $Query, Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order, HideResults => $HideResults, Page => $Page ); +<div align="right"> +<form method="get" action="<%$RT::WebPath%>/Search/Results.html"> +%foreach my $key (keys(%hiddens)) { +<input type="hidden" class="hidden" name="<%$key%>" value="<%defined($hiddens{$key})?$hiddens{$key}:''%>"/> +%} +<& /Elements/Refresh, Name => 'TicketsRefreshInterval', Default => $session {'tickets_refresh_interval'} &> +<input type="submit" class="button" value="<&|/l&>Go!</&>" /> +</form> +</div> +<div align="right"> +<a href="<%$RT::WebPath%>/Search/Bulk.html<%$QueryString%>"><&|/l&>Update multiple tickets</&></a><br /> +<a href="<%$RT::WebPath%>/Search/Results.html<%$QueryString%>"><&|/l&>Bookmarkable link</&></a><br /> +<a href="<%$RT::WebPath%>/Search/Results.tsv<%$QueryString%>"><&|/l&>spreadsheet</&></a> | +<a href="<%$RSSFeedURL%>"><&|/l&>RSS</&></a> | +<a href="<%$RT::WebPath%>/Tools/Offline.html<%$ShortQueryString%>"><&|/l&>Work offline</&></a><br /> +<form method="get" action="<%$RT::WebPath%>/Search/Chart.html"><&|/l&>chart</&> +% %hiddens = (Query => $Query, Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order); +%foreach my $key (keys(%hiddens)) { +<input type="hidden" class="hidden" name="<%$key%>" value="<%defined($hiddens{$key})?$hiddens{$key}:''%>"/> +%} +<&|/l, $m->scomp('Elements/SelectGroupBy', Name => 'PrimaryGroupBy', Query => $Query) &>grouped by [_1]</&> +<&|/l, $m->scomp('Elements/SelectChartType', Name => 'ChartStyle') &>style: [_1]</&> +<input type="submit" class="button" value="<%loc('Go!')%>" /> +</form> +<& /Elements/Callback, _CallbackName => 'SearchActions', QueryString => $QueryString&> +</div> +<%INIT> +# Read from user preferences +my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {}; + +# These variables are what define a search_hash; this is also +# where we give sane defaults. +$Format ||= $prefs->{'Format'}; +$Order ||= $prefs->{'Order'} || 'ASC'; +$OrderBy ||= $prefs->{'OrderBy'} || 'id'; + +# Some forms pass in "RowsPerPage" rather than "Rows" +# We call it RowsPerPage everywhere else. + +if ( !defined($Rows) ) { + if ( $ARGS{'RowsPerPage'} ) { + $Rows = $ARGS{'RowsPerPage'}; + } elsif ( defined $prefs->{'RowsPerPage'} ) { + $Rows = $prefs->{'RowsPerPage'}; + } else { + $Rows = 50; + } +} + +my ($title, $ticketcount); +$session{'i'}++; +$session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) ; +$session{'tickets'}->FromSQL($Query) if ($Query); + +if ($OrderBy =~ /\|/) { + # Multiple Sorts + my @OrderBy = split /\|/,$OrderBy; + my @Order = split /\|/,$Order; + $session{'tickets'}->OrderByCols( + map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } ( 0 + .. $#OrderBy ) );; +} else { + $session{'tickets'}->OrderBy(FIELD => $OrderBy, ORDER => $Order); +} + +$session{'CurrentSearchHash'} = { + Format => $Format, + Query => $Query, + Page => $Page, + Order => $Order, + OrderBy => $OrderBy, + RowsPerPage => $Rows + }; + + +if ( $session{'tickets'}->Query()) { + $ticketcount = $session{tickets}->CountAll(); + $title = loc('Found [quant,_1,ticket]', $ticketcount); +} else { + $title = loc("Find tickets"); +} + +my $QueryString = "?".$m->comp('/Elements/QueryString', + Query => $Query, + Format => $Format, + Rows => $Rows, + OrderBy => $OrderBy, + Order => $Order, + Page => $Page); +my $ShortQueryString = "?".$m->comp('/Elements/QueryString', Query => $Query); +my $RSSFeedURL = "$RT::WebPath/Search/Results.rdf$ShortQueryString"; + +if ($ARGS{'TicketsRefreshInterval'}) { + $session{'tickets_refresh_interval'} = $ARGS{'TicketsRefreshInterval'}; +} +</%INIT> +<%CLEANUP> +$session{'tickets'}->PrepForSerialization(); +</%CLEANUP> +<%ARGS> +$Query => undef +$Format => undef +$HideResults => 0 +$Rows => undef +$Page => 1 +$OrderBy => undef +$Order => undef +</%ARGS> diff --git a/rt/html/Search/Results.rdf b/rt/html/Search/Results.rdf new file mode 100644 index 000000000..fe97a314c --- /dev/null +++ b/rt/html/Search/Results.rdf @@ -0,0 +1,87 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%INIT> + +my $Tickets = RT::Tickets->new($session{'CurrentUser'}); +$Tickets->FromSQL($ARGS{'Query'}); +$r->content_type('application/rss+xml'); + + + + # create an RSS 1.0 file (http://purl.org/rss/1.0/) + use XML::RSS; + my $rss = new XML::RSS (version => '1.0'); + $rss->channel( + title => "$RT::rtname: Syndicated Search", + link => $RT::WebURL, + description => "", + dc => { + }, + syn => { + updatePeriod => "hourly", + updateFrequency => "1", + updateBase => "1901-01-01T00:00+00:00", + }, + ); + + + while ( my $Ticket = $Tickets->Next()) { + my $row; + $rss->add_item( + title => $Ticket->Subject, + link => $RT::WebURL."/Ticket/Display.html?id=".$Ticket->id, + description => $Ticket->Transactions->First->Content, + dc => { + subject => ($Ticket->Subject || loc('No subject')), + creator => $Ticket->CreatorObj->RealName . "<".$Ticket->CreatorObj->EmailAddress.">", + }, + ); + } +$m->out($rss->as_string); +$m->abort(); +</%INIT> diff --git a/rt/html/Search/Results.tsv b/rt/html/Search/Results.tsv new file mode 100644 index 000000000..bb1907317 --- /dev/null +++ b/rt/html/Search/Results.tsv @@ -0,0 +1,134 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 }}} +<%ARGS> +$OrderBy => 'id' +$Order => 'ASC' +</%ARGS> +<%INIT> + +my $Tickets = RT::Tickets->new( $session{'CurrentUser'} ); +$Tickets->FromSQL( $ARGS{'Query'} ); +if ( $OrderBy =~ /\|/ ) { + + # Multiple Sorts + my @OrderBy = split /\|/, $OrderBy; + my @Order = split /\|/, $Order; + $Tickets->OrderByCols( + map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } + ( 0 .. $#OrderBy ) ); +} +else { + $Tickets->OrderBy( FIELD => $OrderBy, ORDER => $Order ); +} + +my @rows; +my %known_cfs; + +my @attrs = qw( id QueueObj->Name Subject Status TimeEstimated TimeWorked TimeLeft Priority FinalPriority OwnerObj->Name + Requestors->MemberEmailAddressesAsString Cc->MemberEmailAddressesAsString AdminCc->MemberEmailAddressesAsString + DueObj->ISO ToldObj->ISO CreatedObj->ISO ResolvedObj->ISO LastUpdatedObj->ISO); + +$r->content_type('application/vnd.ms-excel'); +while ( my $Ticket = $Tickets->Next()) { + my $row; + foreach my $attr (@attrs) { + if ($attr =~ /(.*)->ISO$/ and $Ticket->$1->Unix <= 0) { + $row->{$attr} = ""; + } else { + my $method = '$Ticket->'.$attr.'()'; + $row->{$attr} = eval $method; + if ($@) {die "Failed to find $attr - ". $@}; + } + } + + my $cfs = $Ticket->QueueObj->TicketCustomFields(); + while (my $cf = $cfs->Next) { + my @content; + my $values = $Ticket->CustomFieldValues($cf->Id); + while (my $value = $values->Next) { + push @content, $value->Content; + } + $row->{'CustomField-'.$cf->Id} = join(', ',@content); + if ($row->{'CustomField-'.$cf->Id}) { + $known_cfs{$cf->Id} = $cf->Name; + } + } + push @rows, $row; +} + +{ + my @header; + foreach my $attr (@attrs) { + my $label = $attr; + $label =~ s'Obj-.(?:AsString|Name|ISO)''g; + $label =~ s'-\>MemberEmailAddressesAsString''g; + push @header, $label; + } + foreach my $id (sort keys %known_cfs) { + push @header, "CF-".$known_cfs{$id}; + } + $m->out(join("\t", @header)); + $m->out("\n"); +} + +foreach my $row (@rows) { + my @row; + foreach my $attr(@attrs) { + push @row, $row->{"$attr"}; + } + foreach my $id (sort keys %known_cfs) { + my $val = $row->{'CustomField-'.$id}; + $val =~ s/(\n|\r)//g; + push @row, $val; + } + $m->out(join("\t",@row)); + $m->out("\n"); +} + +$m->abort(); +</%INIT> diff --git a/rt/html/Search/Simple.html b/rt/html/Search/Simple.html new file mode 100644 index 000000000..01424a3b1 --- /dev/null +++ b/rt/html/Search/Simple.html @@ -0,0 +1,107 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# 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/copyleft/gpl.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 &> +<& /Elements/Tabs, + current_toptab => "Search/Simple.html", + Title => $title +&> + +<& /Elements/Callback, _CallbackName => 'PreForm', %ARGS &> + +<div id="SimpleSearchForm"> +<form action="Simple.html" method="get"> + +<p><&|/l&>Search for tickets. Enter <strong>id</strong> numbers, <strong>queues</strong> by name, Owners by <strong>username</strong> and Requestors by <strong>email address</strong>. RT will look for anything else you enter in ticket bodies and attachments.</&></p> + +<p><&|/l&>Searching the full text of every ticket can take a long time, but if you need to do it, you can search for any word in full ticket history for any word by typing <b>fulltext:<i>word</i></b>.</&></p> +<p><&|/l&>RT will look for anything else you enter in ticket subjects.</&></p> + +<br /> +<br /> +<div align="center"> +<input name="q" size="60" /><input type="submit" class="button" value="<&|/l&>Search</&>" /> +</div> + +</form> + +<& /Elements/Callback, _CallbackName => 'PostForm', %ARGS &> + +</div> + +<%INIT> +my $title = loc("Search for tickets"); +use RT::Search::Googleish; + +if ($q) { + my $tickets = new RT::Tickets( $session{'CurrentUser'} ); + + $m->comp('/Elements/Callback', %ARGS, _CallbackName => 'ModifyQuery', query => \$q); + + if ($q =~ /^(\d+)$/) { + RT::Interface::Web::Redirect($RT::WebURL."/Ticket/Display.html?id=".$q); + } + + my %args = ( + Argument => $q, + TicketsObj => $tickets, + ); + + $m->comp('/Elements/Callback', %ARGS, _CallbackName => 'SearchArgs', args => \%args); + + my $search = RT::Search::Googleish->new(%args); + + $m->comp( "Results.html", Query => $search->QueryToSQL() ); + $m->comp( "/Elements/Footer" ); + $m->abort(); +} +</%INIT> + +<%ARGS> +$q => undef +</%ARGS> + |