diff options
Diffstat (limited to 'rt/html/Search')
22 files changed, 701 insertions, 901 deletions
diff --git a/rt/html/Search/Build.html b/rt/html/Search/Build.html index cb6462651..bbf2a1de9 100644 --- a/rt/html/Search/Build.html +++ b/rt/html/Search/Build.html @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,27 +42,7 @@ %# 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). -%# +%# }}} END BPS TAGGED BLOCK <& /Elements/Header, Title => $title &> <& /Ticket/Elements/Tabs, current_tab => "Search/Build.html".$QueryString, @@ -78,28 +58,36 @@ <input type=hidden name=SearchId value="<%$SearchId%>"> <input type=hidden name=Query value="<%$Query%>"> <input type=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 &> +<table width=100%> +<tr> +<td valign=top class="boxcontainer"> +<& Elements/PickCriteria, query => $Query, cfqueues => \%queues &> <& /Elements/Submit, Caption => loc('Add additional criteria'), Label => loc('Add'), Name => 'AddClause'&> -</td> -<td> -<& Elements/EditQuery, - %ARGS, - actions => \@actions, - optionlist => $optionlist, - Description => $Description &> </td> -</tr> - -<tr valign="top"> -<td> +<td valign=top class="boxcontainer"> +<& /Elements/TitleBoxStart, title => loc("Query") . ": " .$Description &> +<& Elements/NewListActions, actions => \@actions &> +<select size="10" name="clauses" style="width: 100%"> +<%$optionlist|n%> +</select> +</td></tr><tr><td bgcolor="#dddddd" colspan="2"> +<center> +<input type=submit name="Up" value="^"> +<input type=submit name="Down" value="v"> +<input type=submit name="Left" value="<"> +<input type=submit name="Right" value=">"> +<input type=submit name="DeleteClause" value="Delete"> +<br /> +<input type=submit name="Clear" value="Clear"> +<input type=submit name="Toggle" value="And/Or"> +%#<input type=submit name="EditQuery" value="Advanced"> +</center> +<& /Elements/TitleBoxEnd &> +<br> <& Elements/EditSearches, CurrentSearch => $search_hash, Dirty => $dirty, SearchId => $SearchId &> </td> </tr> - <tr> <td colspan=2 class="boxcontainer"> @@ -107,35 +95,27 @@ AvailableColumns => $AvailableColumns, CurrentFormat => $CurrentFormat, RowsPerPage => $RowsPerPage, OrderBy => $OrderBy, Order => $Order &> </td> </tr> -<tr> -<td colspan=2 class="boxcontainer"> -<& /Elements/Submit, Caption => loc("Do the Search"), Label => loc('Search'), Name => 'DoSearch'&> -</td> -</tr> </table> </FORM> <%INIT> -use RT::Interface::Web::QueryBuilder; -use RT::Interface::Web::QueryBuilder::Tree; +use Tree::Simple; my $search_hash = {}; my $search; my $title = loc("Query Builder"); # {{{ Clear out unwanted data -if ( $NewQuery or $ARGS{'Delete'} ) { - +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 = ''; + $Query = ''; + $Format = ''; $Description = ''; - $SearchId = ''; - $Order = ''; - $OrderBy = ''; + $SearchId = ''; + $Order = ''; + $OrderBy = ''; $RowsPerPage = ''; - # ($search hasn't been set yet; no need to clear) # ..then wipe the session out.. @@ -144,7 +124,6 @@ if ( $NewQuery or $ARGS{'Delete'} ) { # ..and the search results. $session{'tickets'}->CleanSlate() if defined $session{'tickets'}; } - # }}} # {{{ Attempt to load what we can from the session, set defaults @@ -154,71 +133,61 @@ $search_hash = $session{'CurrentSearchHash'}; # These variables are what define a search_hash; this is also # where we give sane defaults. -$Query ||= $search_hash->{'Query'}; -$Format ||= $search_hash->{'Format'}; +$Query ||= $search_hash->{'Query'}; +$Format ||= $search_hash->{'Format'}; $Description ||= $search_hash->{'Description'}; -$SearchId ||= $search_hash->{'SearchId'} || 'new'; -$Order ||= $search_hash->{'Order'} || 'ASC'; -$OrderBy ||= $search_hash->{'OrderBy'} || 'id'; -$RowsPerPage = ( $search_hash->{'RowsPerPage'} || 50 ) - unless defined($RowsPerPage); +$SearchId ||= $search_hash->{'SearchId'} || 'new'; +$Order ||= $search_hash->{'Order'} || 'ASC'; +$OrderBy ||= $search_hash->{'OrderBy'} || 'id'; +$RowsPerPage = ($search_hash->{'RowsPerPage'} || 50) unless defined ($RowsPerPage); $search ||= $search_hash->{'Object'}; - # }}} my @actions = (); +my %queues; # Clean unwanted junk from the format -$Format = $m->comp( '/Elements/ScrubHTML', Content => $Format ) if ($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 if ( $ARGS{'SearchId'} =~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ ) { my $obj_type = $1; my $obj_id = $2; my $search_id = $3; - + my $container_object; - if ( $obj_type eq 'RT::User' && $obj_id == $session{'CurrentUser'}->Id ) - { - $container_object = $session{'CurrentUser'}->UserObj; + if ( $obj_type eq 'RT::User' && $obj_id == $session{'CurrentUser'}->Id) { + $container_object = $session{'CurrentUser'}->UserObj; } - elsif ( $obj_type eq 'RT::Group' ) { - $container_object = RT::Group->new( $session{'CurrentUser'} ); + elsif ($obj_type eq 'RT::Group') { + $container_object = RT::Group->new($session{'CurrentUser'}); $container_object->Load($obj_id); } - if ( $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 ($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 ); + $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. @@ -227,18 +196,15 @@ if ( $ARGS{'LoadSavedSearch'} =~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ ) { my $obj_type = $1; my $obj_id = $2; my $search_id = $3; - + # We explicitly list out the available types (user and group) and # don't trust user input here - if ( ( $obj_type eq 'RT::User' ) - && ( $obj_id == $session{'CurrentUser'}->id ) ) - { - $search = - $session{'CurrentUser'}->UserObj->Attributes->WithId($search_id); - + if ( ( $obj_type eq 'RT::User' ) && ( $obj_id == $session{'CurrentUser'}->id ) ) { + $search = $session{'CurrentUser'}->UserObj->Attributes->WithId($search_id); + } - elsif ( $obj_type eq 'RT::Group' ) { - my $group = RT::Group->new( $session{'CurrentUser'} ); + elsif ($obj_type eq 'RT::Group') { + my $group = RT::Group->new($session{'CurrentUser'}); $group->Load($obj_id); $search = $group->Attributes->WithId($search_id); } @@ -265,227 +231,260 @@ if ( $actions[0] ) { $m->abort(); } +my @options; +my $optionlist; $Query = ""; +%queues = (); -my @options = $tree->GetDisplayedNodes; +# Build the optionlist from the tree, so we can do additions and movements based on it +$optionlist = build_array( \$Query, $ARGS{clauses}, $tree, \@options, \%queues ); -my @current_values = grep { defined } @options[@clauses]; +my $currentkey; +$currentkey = $options[$ARGS{clauses}] if defined $ARGS{clauses}; # {{{ Try to find if we're adding a clause foreach my $arg ( keys %ARGS ) { - if ( - $arg =~ m/^ValueOf(.+)/ - && ( 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'"; + if ( $arg =~ m/ValueOf(.+)/ && $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; + } + + $value = $ARGS{'ValueOf' . $field}; + $op = $ARGS{ $field . 'Op' }; + if ( $value eq 'NULL' && $op =~ /=/) { + if ($op eq '=') { + $op = "IS"; + } elsif ($op eq '!=') { + $op = "IS NOT"; } - 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'} ); + # 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 = Tree::Simple->new($clause); + if ($currentkey) { + my $newindex = $currentkey->getIndex() + 1; + if (!$currentkey->getParent->getParent()->isRoot()) { + } + $currentkey->insertSibling($newindex, $newnode); + $currentkey = $newnode; + } + else { + $tree->getChild(0)->addChild($newnode); + $currentkey = $newnode; + } + $newnode->getParent()->setNodeValue($ARGS{'AndOr'}); } } - # }}} # {{{ 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 ] ); - } + if ($currentkey) { + my $index = $currentkey->getIndex(); + if ( $currentkey->getIndex() > 0 ) { + my $parent = $currentkey->getParent(); + $parent->removeChild($index); + $parent->insertChild($index - 1, $currentkey); + $currentkey = $parent->getChild($index - 1); + } + else { + push( @actions, [ "error: can't move up", -1 ] ); } } else { - push( @actions, [ loc("error: nothing to move"), -1 ] ); + push( @actions, [ "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 ] ); - } + if ($currentkey) { + my $index = $currentkey->getIndex(); + my $parent = $currentkey->getParent(); + if ( $currentkey->getIndex() < ($parent->getChildCount - 1) ) { + $parent->removeChild($index); + $parent->insertChild($index + 1, $currentkey); + $currentkey = $parent->getChild($index + 1); + } + else { + push( @actions, [ "error: can't move down", -1 ] ); } } else { - push( @actions, [ loc("error: nothing to move"), -1 ] ); + push( @actions, [ "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 ] ); - } + if ($currentkey) { + my $parent = $currentkey->getParent(); + my $grandparent = $parent->getParent(); + if (!$grandparent->isRoot) { + my $index = $parent->getIndex(); + $parent->removeChild($currentkey); + $grandparent->insertChild($index, $currentkey); + if ($parent->isLeaf()) { + $grandparent->removeChild($parent); + } + } + else { + push( @actions, [ "error: can't move left", -1 ] ); } } else { - push( @actions, [ loc("error: nothing to move"), -1 ] ); + push( @actions, [ "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 ] ); + if ($currentkey) { + my $parent = $currentkey->getParent(); + my $index = $currentkey->getIndex(); + my $newparent; + if ($index > 0 ) { + my $sibling = $parent->getChild($index - 1); + if (ref($sibling->getNodeValue)) { + $parent->removeChild($currentkey); + my $newtree = Tree::Simple->new('AND', $parent); + $newtree->addChild($currentkey); + } else { + $parent->removeChild($index); + $sibling->addChild($currentkey); + } + } + else { + $parent->removeChild($currentkey); + $newparent = Tree::Simple->new('AND', $parent); + $newparent->addChild($currentkey); + } + } else { + push( @actions, [ "error: nothing to move", -1 ] ); } } elsif ( $ARGS{"DeleteClause"} ) { - if (@current_values) { - $_->getParent()->removeChild($_) for @current_values; + if ($currentkey) { + $currentkey->getParent()->removeChild($currentkey); } else { - push( @actions, [ loc("error: nothing to delete"), -1 ] ); + push( @actions, [ "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'); - } - } + if ($currentkey) { + my $value = $currentkey->getNodeValue(); + my $parent = $currentkey->getParent(); + my $parentvalue = $parent->getNodeValue(); + + if ( $parentvalue eq 'AND') { + $parent->setNodeValue('OR'); + } + else { + $parent->setNodeValue('AND'); + } } else { - push( @actions, [ loc("error: nothing to toggle"), -1 ] ); + push( @actions, [ "error: nothing to toggle", -1 ] ); } } - -$tree->PruneChildlessAggregators; - +elsif ( $ARGS{"Clear"} ) { + $tree = Tree::Simple->new(Tree::Simple->ROOT); +} # }}} # {{{ 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; - +$Query = ""; +@options = (); +%queues = (); +$optionlist = build_array( \$Query, $currentkey, $tree, \@options, \%queues ); + +sub build_array { + my $Query = shift; + my $currentkey = shift; + my $tree = shift; + my ($keys, $queues) = @_; + my $i = 0; + my $optionlist; + my $depth = 0; + my %parens; + + $tree->traverse( sub { + my ($_tree) = @_; + + return if $_tree->getParent->isRoot(); + + push @$keys, $_tree; + my $clause = $_tree->getNodeValue(); + my $str; + my $ea = $_tree->getParent()->getNodeValue(); + if (ref($clause)) { + $str .= $ea . " " if $_tree->getIndex() > 0; + $str .= $clause->{Key} . " " . $clause->{Op} . " " . $clause->{Value}; + + if ( $clause->{Key} eq "Queue" ) { + $queues->{ $clause->{Value} } = 1; + } + } else { + $str = $ea if $_tree->getIndex() > 0; + } + + my $selected; + if ($_tree == $currentkey) { + $selected = "SELECTED"; + } + else { + $selected = ""; + } + + foreach my $p (keys %parens) { + if ($p > $_tree->getDepth) { + $$Query .= ')' x $parens{$p}; + $parens{$p}--; + } + } + + $optionlist .= "<option value=$i $selected>" . + (" " x 5 x ($_tree->getDepth() - 1)) . "$str</option>\n"; + my $parent = $_tree->getParent(); + if (!($parent->isRoot || $parent->getParent()->isRoot) && + !ref($parent->getNodeValue())) { + if ( $_tree->getIndex() == 0) { + $$Query .= '('; + $parens{$_tree->getDepth}++; + } + } + $$Query .= " " . $str . " "; + + if ($_tree->getDepth < $depth) { + $$Query .= ')'; + $parens{$depth}--; + } + + $i++; + }); + + foreach my $p (keys %parens) { + $$Query .= ") " x $parens{$p}; + } + return $optionlist; +} use Regexp::Common qw /delimited/; @@ -497,18 +496,18 @@ use constant PAREN => 8; use constant KEYWORD => 16; sub ParseQuery { - my $string = shift; - my $tree = shift; + my $string = shift; + my $tree = shift; my @actions = shift; - my $want = KEYWORD | PAREN; - my $last = undef; + 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 $lastnode = $root; + $$tree = Tree::Simple->new(Tree::Simple->ROOT); + my $root = Tree::Simple->new('AND', $$tree); + my $lastnode = $root; my $parentnode = $root; # get the FIELDS from Tickets_Overlay @@ -522,20 +521,17 @@ sub ParseQuery { 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_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 + # assume that $ea is AND if it's 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 =~ /( + while ( $string =~ /( $re_aggreg |$re_op |$re_keyword @@ -560,15 +556,7 @@ sub ParseQuery { # Error # FIXME: I will only print out the highest $want value my $token = $tokens[ ( ( log $want ) / ( log 2 ) ) ]; - push @actions, - [ - loc( -"current: $current, want $want, Error near ->$val<- expecting a " - . $token - . " in '$string'\n" - ), - -1 - ]; + push @actions, [ "current: $current, want $want, Error near ->$val<- expecting a " . $token . " in '$string'\n", -1 ]; } # State Machine: @@ -577,21 +565,20 @@ sub ParseQuery { # 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 ); + $depth++; + # make a new node that the clauses can be children of + $parentnode = Tree::Simple->new($ea, $parentnode); } else { - $depth--; - $parentnode = $parentnode->getParent(); - $lastnode = $parentnode; + $depth--; + $parentnode = $parentnode->getParent(); + $lastnode = $parentnode; } $want = KEYWORD | PAREN | AGGREG; } elsif ( $current & AGGREG ) { - $ea = $val; + $ea = $val; $want = KEYWORD | PAREN; } elsif ( $current & KEYWORD ) { @@ -629,27 +616,27 @@ sub ParseQuery { $val = "'$val'"; } - push @actions, [ loc("Unknown field: $key"), -1 ] unless $class; + push @actions, [ "Unknown field: $key", -1 ] unless $class; $want = PAREN | AGGREG; } else { - push @actions, [ loc("I'm lost"), -1 ]; + push @actions, [ "I'm lost", -1 ]; } if ( $current & VALUE ) { - if ( $key =~ /^CF./ ) { - $key = "'" . $key . "'"; - } + if ( $key =~ /^CF./ ) { + $key = "'" . $key . "'"; + } my $clause = { Key => $key, Op => $op, Value => $val }; - # explicity add a child to it - $lastnode = RT::Interface::Web::QueryBuilder::Tree->new( $clause, $parentnode ); - $lastnode->getParent()->setNodeValue($ea); + # explicity add a child to it + $lastnode = Tree::Simple->new($clause, $parentnode); + $lastnode->getParent()->setNodeValue($ea); ( $ea, $key, $op, $value ) = ( "", "", "", "" ); } @@ -657,14 +644,14 @@ sub ParseQuery { $last = $current; } # while - push @actions, [ loc("Incomplete query"), -1 ] + push @actions, [ "Incomplete query", -1 ] unless ( ( $want | PAREN ) || ( $want | KEYWORD ) ); - push @actions, [ loc("Incomplete Query"), -1 ] + push @actions, [ "Incomplete Query", -1 ] unless ( $last && ( $last | PAREN ) || ( $last || VALUE ) ); # This will never happen, because the parser will complain - push @actions, [ loc("Mismatched parentheses"), -1 ] + push @actions, [ "Mismatched parentheses", -1 ] unless $depth == 1; } @@ -680,32 +667,24 @@ sub _match { sub debug { my $message = shift; - $m->print( $message . "<br>" ); + $m->print($message . "<br>"); } # }}} # }}} -my $queues = $tree->GetReferencedQueues; - # {{{ Deal with format changes -my ( $AvailableColumns, $CurrentFormat ); -( $Format, $AvailableColumns, $CurrentFormat ) = $m->comp( - 'Elements/BuildFormatString', - cfqueues => $queues, - %ARGS, Format => $Format -); - +my ($AvailableColumns, $CurrentFormat); +($Format, $AvailableColumns, $CurrentFormat) = $m->comp('Elements/BuildFormatString', cfqueues => \%queues, %ARGS, Format => $Format); # }}} # {{{ if we're asked to save the current search, save it if ( $ARGS{'Save'} ) { - if ( $search && $search->id ) { - - # This search is based on a previously loaded search -- so - # just update the current search object with new values + if ($search && $search->id) { + # 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, @@ -713,102 +692,83 @@ if ( $ARGS{'Save'} ) { OrderBy => $OrderBy, RowsPerPage => $RowsPerPage, ); - $search->SetDescription($Description); + $search->SetDescription( $Description ); } elsif ( $SearchId eq 'new' && $ARGS{'Owner'} =~ /^(.*?)-(\d+)$/ ) { + # We're saving a new search + my $obj_type = $1; + my $obj_id = $2; + - # We're saving a new search - my $obj_type = $1; - my $obj_id = $2; - - # Find out if we're saving on the user, or a group + # Find out if we're saving on the user, or a group my $container_object; - if ( $obj_type eq 'RT::User' && $obj_id == $session{'CurrentUser'}->Id ) - { + if ( $obj_type eq 'RT::User' && $obj_id == $session{'CurrentUser'}->Id) { $container_object = $session{'CurrentUser'}->UserObj; } - elsif ( $obj_type eq 'RT::Group' ) { - $container_object = RT::Group->new( $session{'CurrentUser'} ); + elsif ($obj_type eq 'RT::Group') { + $container_object = RT::Group->new($session{'CurrentUser'}); $container_object->Load($obj_id); } - if ( $container_object->id ) { - - # If we got one or the other, add the saerch - my ( $search_id, $search_msg ) = $container_object->AddAttribute( - Name => 'SavedSearch', - Description => $Description, - Content => { - Format => $Format, - Query => $Query, - Order => $Order, - OrderBy => $OrderBy, - RowsPerPage => $RowsPerPage, - } - ); - $search = - $session{'CurrentUser'}->UserObj->Attributes->WithId($search_id); - - # Build new SearchId - $SearchId = - ref( $session{'CurrentUser'}->UserObj ) . '-' - . $session{'CurrentUser'}->UserObj->Id - . '-SavedSearch-' - . $search->Id; - } - unless ( $search->id ) { - push @actions, [ loc("Can't find a saved search to work with"), 0 ]; + if ($container_object->id ) { + # If we got one or the other, add the saerch + my ( $search_id, $search_msg ) = $container_object->AddAttribute( + Name => 'SavedSearch', + Description => $Description, + Content => { + Format => $Format, + Query => $Query, + Order => $Order, + OrderBy => $OrderBy, + RowsPerPage => $RowsPerPage, + } + ); + $search = $session{'CurrentUser'}->UserObj->Attributes->WithId($search_id); + # Build new SearchId + $SearchId = ref( $session{'CurrentUser'}->UserObj ) . '-' + . $session{'CurrentUser'}->UserObj->Id . '-SavedSearch-' . $search->Id; + } + unless ($search->id) { + push @actions, [loc("Can't find a saved search to work with"), 0]; } } else { - push @actions, [ loc("Can't save this search"), 0 ]; + push @actions, [loc("Can't save this search"), 0]; } } - # }}} # {{{ 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 ); - +$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->{'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->{'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("Results.html" , Query => $Query, Format => $Format, Order => $Order, OrderBy => $OrderBy, Rows => $RowsPerPage); $m->abort(); } - # }}} # {{{ Build a querystring for the tabs @@ -816,20 +776,14 @@ if ( $ARGS{"DoSearch"} ) { 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); } -else { - $QueryString = '?' - . $m->comp( - '/Elements/QueryString', - Query => $Query, - Format => $Format, - Order => $Order, - OrderBy => $OrderBy, - Rows => $RowsPerPage - ) - if ($Query); -} - # }}} </%INIT> @@ -844,6 +798,4 @@ $Order => undef $OrderBy => undef $RowsPerPage => undef $HideResults => 0 -@clauses => () </%ARGS> - diff --git a/rt/html/Search/Bulk.html b/rt/html/Search/Bulk.html index f9eef26b6..f75934bf3 100644 --- a/rt/html/Search/Bulk.html +++ b/rt/html/Search/Bulk.html @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,13 +42,13 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <& /Elements/Header, Title => loc("Bulk ticket update") &> <& /Elements/Tabs, Title => loc("Bulk ticket update") &> <& /Elements/ListActions, actions => \@results &> -<FORM METHOD="POST" ACTION="<%$RT::WebPath%>/Search/Bulk.html" > -<input type="hidden" name="Query" value="<%$ARGS{'Query'}%>"> + +<FORM METHOD=POST> <TABLE WIDTH=100% border=0 cellpadding=3 CELLSPACING=0> <TR> <TH><&|/l&>Update</&></TH> @@ -75,7 +75,8 @@ while (my $Ticket = $Tickets->Next) { } </%PERL> <TR bgcolor="<%$bgcolor%>"> -<TD><input type=checkbox name="UpdateTicket<%$Ticket->Id%>" value="1" CHECKED></TD> +<TD><input type=checkbox name="UpdateTicket<%$Ticket->Id%>" CHECKED></TD> +%# The ticket view is controlled by config.pm, WebOptions %foreach my $col (@cols) { <TD> % if ($col eq 'id') { @@ -152,26 +153,44 @@ while (my $Ticket = $Tickets->Next) { </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> -<& /Elements/TitleBoxEnd &> +<table> +% foreach (keys %allcfs) { +<tr><td class=label> +% my $cf = $allcfs{$_}; +% my $pref; +% if ($cf->Queue == 0) { +% $pref = "[Global]"; +% } else { +% $pref = "[Queue: " . $cfqnames{$_} . "]"; +% } +<%$pref%> <b><% $cf->Name %></b><br> +<% $cf->FriendlyType %> +</td> +<td> +% if ($cf->Type ne "FreeformMultiple") { +<& /Ticket/Elements/EditCustomField, CustomField => $cf &> +% } else { +Add Values<br> +<textarea cols=15 rows=3 name="<%$cf->Id%>-Values"></textarea> +</td><td> +Delete Values<br> +<textarea cols=15 rows=3 name="<%$cf->Id%>-DeleteValues"></textarea> +% } +</td> +</tr> +% } +</table> +<& /Elements/TitleBoxEnd &> <& /Elements/TitleBoxStart, title => loc('Edit Links'), color => "#336633"&> -<i><&|/l&>Enter tickets or URIs to link tickets to. Separate multiple entries with spaces.</&></i><br> +<i><&|/l&>Enter tickets or URIs to link tickets to. Seperate multiple entries with spaces.</&></i><br> <& /Ticket/Elements/BulkLinks &> <& /Elements/TitleBoxEnd &> @@ -204,7 +223,7 @@ while (my $Ticket = $Tickets->Next) { unless ( exists $cfqs{$cfqid} ) { $cfqs{$cfqid} = 1; $count++; - my $cfs = $cfq->TicketCustomFields; + my $cfs = $cfq->CustomFields; while (my $cf = $cfs->Next) { $allcfs{$cf->Id} = $cf; $cfqnames{$cf->Id} = $cfqn; @@ -226,11 +245,9 @@ if ($ARGS{'UpdateContent'} && #Iterate through each ticket we've been handed my @linkresults; -my %queues; $Tickets->RedoSearch(); while (my $Ticket = $Tickets->Next) { - $queues{$Ticket->QueueObj->Id}++; $RT::Logger->debug( "Checking Ticket ".$Ticket->Id ."\n"); next unless ($ARGS{"UpdateTicket".$Ticket->Id}); $RT::Logger->debug ("Matched\n"); @@ -245,6 +262,16 @@ while (my $Ticket = $Tickets->Next) { #Update the watchers my @watchresults = ProcessTicketWatchers(TicketObj => $Ticket, ARGSRef => \%ARGS); + #Update custom fields + my $pat = "^(\\d+)-(.*)\$"; + foreach (keys %ARGS) { + $ARGS{"Ticket-" . $Ticket->Id . "-CustomField-" . $1 . "-" . $2} = $ARGS{$_} if (/$pat/o); + } + my @cfresults = ProcessTicketCustomFieldUpdates(ARGSRef => \%ARGS); + foreach (keys %ARGS) { + delete $ARGS{"Ticket-" . $Ticket->Id . "-CustomField-" . $1 . "-" . $2} if (/$pat/o); + } + #Update the links $ARGS{'id'} = $Ticket; @@ -264,15 +291,11 @@ while (my $Ticket = $Tickets->Next) { delete $ARGS{'MemberOf-'.$Ticket->Id}; delete $ARGS{$Ticket->Id.'-RefersTo'}; delete $ARGS{'RefersTo-'.$Ticket->Id}; - my @tempresults = (@watchresults, @basicresults, @dateresults, - @updateresults, @linkresults); + + 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::Queue-RT::Ticket-RT::Transaction"); -$TxnCFs->LimitToGlobalOrObjectId(sort keys %queues); - </%INIT> diff --git a/rt/html/Search/Edit.html b/rt/html/Search/Edit.html index 16e8a0e71..769d38d9d 100755 --- a/rt/html/Search/Edit.html +++ b/rt/html/Search/Edit.html @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <& /Elements/Header, Title => $title&> <& /Ticket/Elements/Tabs, current_tab => "Search/Edit.html?".$QueryString, diff --git a/rt/html/Search/Elements/BuildFormatString b/rt/html/Search/Elements/BuildFormatString index 639e62c29..e5e131b6c 100644 --- a/rt/html/Search/Elements/BuildFormatString +++ b/rt/html/Search/Elements/BuildFormatString @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,76 +42,45 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} 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 @fields = ( + "QueueName", "OwnerName", + "id", "Status", + "Subject", "ExtendedStatus", + "Priority", "InitialPriority", + "FinalPriority", "EffectiveId", + "Type", "TimeWorked", + "TimeLeft", "TimeEstimated", + "Requestors", "Cc", + "AdminCc", "StartsRelative", + "StartedRelative", "CreatedRelative", + "LastUpdatedRelative", "ToldRelative", + "DueRelative", "ResolvedRelative", + "Starts", "Started", + "Created", "CreatedBy", + "LastUpdated", "LastUpdatedBy", + "Told", "Due", + "Resolved", "NEWLINE", + "RefersTo", "ReferredToBy", + "DependsOn", "DependedOnBy", + "MemberOf", "Members", + "Parents", "Children", + "-", ); my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'}); -foreach my $id (keys %cfqueues) { - # What does this _do_? What are the keys to cfqueues +foreach (keys %cfqueues) { + my $id = $_; $id =~ s/^.'*(.*).'*$/$1/; # Gotta load up the $queue object, since queues get stored by name now. my $queue = RT::Queue->new($session{'CurrentUser'}); @@ -148,8 +117,8 @@ foreach my $field (@format) { push @seen, \%column; } -if ( $RemoveCol ) { - my $index = $CurrentDisplayColumns; +if ( $ARGS{"RemoveCol"} ) { + my $index = $ARGS{'CurrentDisplayColumns'}; my $column = $seen[$index]; if ($index) { delete $seen[$index]; @@ -161,9 +130,9 @@ if ( $RemoveCol ) { } } } -elsif ( $AddCol ) { - if ( defined $SelectDisplayColumns ) { - my $selected = $SelectDisplayColumns; +elsif ( $ARGS{"AddCol"} ) { + if ( defined $ARGS{'SelectDisplayColumns'} ) { + my $selected = $ARGS{'SelectDisplayColumns'}; my @columns; if (ref($selected) eq 'ARRAY') { @columns = @$selected; @@ -172,71 +141,74 @@ elsif ( $AddCol ) { } 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' ); + $column{Column} = $fields[ $col ]; + + if ( $ARGS{Face} eq "Bold" ) { + $column{Prefix} .= "<B>"; + } + if ( $ARGS{Face} eq "Italic" ) { + $column{Prefix} .= "<I>"; + } + if ( $ARGS{Size} ) { + $column{Prefix} .= "<" . $ARGS{Size} . ">"; + } + if ( $ARGS{Link} eq "Display" ) { + $column{Prefix} .= "<A HREF=\"".$RT::WebPath."/Ticket/Display.html?id=__id__\">"; + } + elsif ( $ARGS{Link} eq "Take" ) { + $column{Prefix} .= + "<A HREF=\"".$RT::WebPath."/Ticket/Display.html?Action=Take&id=__id__\">"; + } + + my $suffix; + if ( $ARGS{'Link'} eq "Display" || $ARGS{'Link'} eq "Take" ) { + $column{Suffix} .= "</a>"; + } + if ( $ARGS{Size} ) { + $column{Suffix} .= "</" . $ARGS{Size} . ">"; + } + if ( $ARGS{Face} eq "Italic" ) { + $column{Suffix} .= "</I>"; + } + if ( $ARGS{Face} eq "Bold" ) { + $column{Suffix} .= "</B>"; + } + if ( $ARGS{Title} ) { + $column{Suffix} .= "/TITLE:" . $ARGS{Title}; + } + push @seen, \%column; + } } - push @seen, \%column; -} -} } -elsif ( $ColUp ) { - my $index = $CurrentDisplayColumns; +elsif ( $ARGS{"ColUp"} ) { + my $index = $ARGS{'CurrentDisplayColumns'}; if ( defined $index && ( $index - 1 ) >= 0 ) { my $column = $seen[$index]; $seen[$index] = $seen[ $index - 1 ]; $seen[ $index - 1 ] = $column; - $CurrentDisplayColumns = $index - 1; + $ARGS{CurrentDisplayColumns} = $index - 1; } } -elsif ( $ColDown ) { - my $index = $CurrentDisplayColumns; +elsif ( $ARGS{"ColDown"} ) { + my $index = $ARGS{'CurrentDisplayColumns'}; if ( defined $index && ( $index + 1 ) < scalar @seen ) { my $column = $seen[$index]; $seen[$index] = $seen[ $index + 1 ]; $seen[ $index + 1 ] = $column; - $CurrentDisplayColumns = $index + 1; + $ARGS{CurrentDisplayColumns} = $index + 1; } } - -my @format_string; +$Format = ""; foreach my $field (@seen) { next unless $field; - my $row = "'" . $field->{Prefix}; - $row .= "__" . $m->interp->apply_escapes( $field->{Column}, 'h' ) . "__" - unless ( $field->{Column} eq "<blank>" ); - $row .= $field->{Suffix} . "'"; - push( @format_string, $row ); + $Format .= ", \n" if $Format; + $Format .= "'"; + $Format .= $field->{Prefix}; + $Format .= "__" . $field->{Column} . "__" if ( $field->{Column} ne "<blank>" ) ; + $Format .= $field->{Suffix}; + $Format .= "'"; } - -$Format = join(",\n", @format_string); - - return($Format, \@fields, \@seen); </%init> diff --git a/rt/html/Search/Elements/DisplayOptions b/rt/html/Search/Elements/DisplayOptions index 43a9d9998..330948d32 100644 --- a/rt/html/Search/Elements/DisplayOptions +++ b/rt/html/Search/Elements/DisplayOptions @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <& /Elements/TitleBoxStart, title => loc("Display Columns") &> <table> <tr> @@ -54,15 +54,15 @@ <tr> <td class=label> <&|/l&>Order by</&>: -</td><td class=value> +</td><td class=label> <select name="OrderBy"> % foreach my $field (keys %fields) { % next unless $field; <option value=<%$field%> -% if ($field =~ /^$OrderBy$/i) { +% if ($field eq $OrderBy) { SELECTED % } -><&|/l&><%$field%></&></option> +><%$field%></option> % } </select> <select name="Order"> @@ -81,7 +81,7 @@ SELECTED </tr> <td class=label> <&|/l&>Rows per page</&>: -</td><td class="value"> +</td><td> <& /Elements/SelectResultsPerPage, Name => "RowsPerPage", Default => $RowsPerPage &> @@ -91,14 +91,13 @@ SELECTED </td> </tr> </table> +<& /Elements/Submit, Caption => "Do the Search", Label => loc('Search'), Name => 'DoSearch'&> <& /Elements/TitleBoxEnd &> <%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'}; - </%INIT> diff --git a/rt/html/Search/Elements/EditFormat b/rt/html/Search/Elements/EditFormat index dc8720f26..7d314aee6 100644 --- a/rt/html/Search/Elements/EditFormat +++ b/rt/html/Search/Elements/EditFormat @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,14 +42,14 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <table> <tr> <td> -<&|/l&>Add Columns</&>: +<&|/l&>Available Columns</&>: </td> <td> -<&|/l&>Format</&>: +Format: </td> <td></td> <td> @@ -58,42 +58,50 @@ <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') || +% my $i = 0; +% while ($i < scalar @$AvailableColumns) { +% my $field = $AvailableColumns->[$i]; +% if ($field) { +<option value=<%$i%> +><%$field%></option> +% } +% $i++; % } </select> </td> <td> -<&|/l&>Link</&>: -<select name="Link"> +Link: +<select name=Link> <option value="None">-</option> -<option value="Display"><&|/l&>Display</&></option> -<option value="Take"><&|/l&>Take</&></option> +<option value="Display">Display</option> +<option value="Take">Take</option> </select> -<br><&|/l&>Title</&>: <input name="Title" size=10> -<br><&|/l&>Size</&>: -<select name="Size"> +<br>Title: <input name="Title" size=10> +<br>Size: +<select name=Size> <option value="">-</option> -<option value="Small"><&|/l&>Small</&></option> -<option value="Large"><&|/l&>Large</&></option> +<option value="Small">Small</option> +<option value="Large">Large</option> </select> -<br><&|/l&>Style</&>: -<select name="Face"> +<br>Face: +<select name=Face> <option value="">-</option> -<option value="Bold"><&|/l&>Bold</&></option> -<option value="Italic"><&|/l&>Italic</&></option> +<option value="Bold">Bold</option> +<option value="Italic">Italic</option> </select> </td> <td> <input type=submit 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 size=4 name="CurrentDisplayColumns" style="width : 100%"> +% $i = 0; +% while ($i < scalar @$CurrentFormat) { +% my $field = $CurrentFormat->[$i]; +% if ($field) { +<option value=<%$i%>><%$field->{Column}%></option> +% } +% $i++; % } </select> <br> diff --git a/rt/html/Search/Elements/EditQuery b/rt/html/Search/Elements/EditQuery deleted file mode 100644 index 783541a64..000000000 --- a/rt/html/Search/Elements/EditQuery +++ /dev/null @@ -1,65 +0,0 @@ -%# BEGIN BPS TAGGED BLOCK {{{ -%# -%# COPYRIGHT: -%# -%# This software is Copyright (c) 1996-2005 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., 675 Mass Ave, Cambridge, MA 02139, USA. -%# -%# -%# 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 &> -<& /Elements/TitleBoxStart, title => join(': ', grep defined, loc("Query"), $Description) &> -<select size="10" name="clauses" style="width: 100%" multiple> -% $m->out($optionlist); -</select> -<p align="center"> -<input type=submit name="Up" value="^"> -<input type=submit name="Down" value="v"> -<input type=submit name="Left" value="<"> -<input type=submit name="Right" value=">"> -<input type=submit name="Toggle" value="<&|/l&>And/Or</&>"> -<input type=submit name="DeleteClause" value="<&|/l&>Delete</&>"> -%#<input type=submit name="EditQuery" value="Advanced"> -</p> -<& /Elements/TitleBoxEnd &> -<%ARGS> -$Description -$optionlist -$actions -</%ARGS> diff --git a/rt/html/Search/Elements/EditSearches b/rt/html/Search/Elements/EditSearches index bc6b80e6f..cd9f1ef3b 100644 --- a/rt/html/Search/Elements/EditSearches +++ b/rt/html/Search/Elements/EditSearches @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,11 +42,8 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <& /Elements/TitleBoxStart, title => loc('Saved searches') &> -%# 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> @@ -55,14 +52,13 @@ % } <&|/l&>Description</&>:<br> <font size="-1"><input size="25" name="Description" value="<%$CurrentSearch->{'Description'}%>"></font> -<nobr> +<br> % if ($SearchId ne 'new') { % if ($Dirty) { <input type="submit" name="Revert" value="<%loc('Revert')%>"> % } <input type="submit" name="Delete" value="<%loc('Delete')%>"> <input type="submit" name="CopySearch" value="<%loc('Copy')%>"> -</nobr> % } @@ -70,18 +66,12 @@ <input type="submit" name="Save" value="<%loc('Save')%>"> % } <hr> -% } <&|/l&>Load saved search:</&><br> <& SelectSearchesForObjects, Name => 'LoadSavedSearch', Objects => \@Objects&> <input value="<%loc('Load')%>" type="submit"> <& /Elements/TitleBoxEnd &> <%init> - -unless ($session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch', - Object=> $RT::System )) { - return; -} my @Objects; push @Objects, $session{CurrentUser}->UserObj; diff --git a/rt/html/Search/Elements/NewListActions b/rt/html/Search/Elements/NewListActions index eb82544f3..7b81d80b1 100644 --- a/rt/html/Search/Elements/NewListActions +++ b/rt/html/Search/Elements/NewListActions @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK % if ($actions[0] ) { <b><%loc('Results')%></b><br> % foreach my $action (@actions) { diff --git a/rt/html/Search/Elements/PickBasics b/rt/html/Search/Elements/PickBasics index 8a48f6b18..d7e19788f 100644 --- a/rt/html/Search/Elements/PickBasics +++ b/rt/html/Search/Elements/PickBasics @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,18 +42,11 @@ %# 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> - +%# }}} END BPS TAGGED BLOCK +<tr><td> +% foreach my $field (@fields) { <tr><td align=right> +% if ($field eq "Attachment") { <& /Elements/SelectAttachmentField, Name => 'AttachmentField' &> </td><td> <& /Elements/SelectBoolean, Name => "AttachmentOp", @@ -64,26 +57,44 @@ &> </td><td> <Input Name="ValueOfAttachment" Size=20> -</td> -</tr> -<tr> -<td class="label"> -<&|/l&>Queue</&> +% } elsif ($field eq "Dates") { +<& /Elements/SelectDateType, Name=>"DateField" &> </td><td> -<& /Elements/SelectBoolean, Name => "QueueOp" , - True => loc("is"), - False => loc("isn't"), - TrueVal=> '=', - FalseVal => '!=' &> +<& /Elements/SelectDateRelation, Name=>"DateOp" &> +</td><td> +<& /Elements/SelectDate, Name => "ValueOfDate", ShowTime => 0, Default => '' &> +% } elsif ($field eq "Links") { +<& 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> +%} elsif ($field eq "Priority") { +<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> +%} elsif ($field =~ m/Time.*/) { +<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/SelectQueue, - Name => "ValueOfQueue", - NamedValues => 1, - CheckQueueRight => 'ShowTicket' &> -</td> -</tr> -<tr> -<td class="label"> +<& /Elements/SelectEqualityOperator, Name => "TimeOp" &> +</td><td> +<INPUT Name="ValueOfTime" SIZE=5> +% } elsif ($field eq "Status") { <&|/l&>Status</&> </td><td> <& /Elements/SelectBoolean, Name => "StatusOp", @@ -94,9 +105,32 @@ &> </td><td> <& /Elements/SelectStatus, Name => "ValueOfStatus", SkipDeleted => 1 &> -</td> -</tr> +%} elsif ($field =~ m/.*Priority/ || $field =~ m/Time.*/) { +<&|/l&><%$field%></&> +</td><td> +<& /Elements/SelectEqualityOperator, Name => $field . "Op" &> +</td><td> +<INPUT Name="<%"ValueOf" . $field%>" SIZE=5> +% } elsif ($field eq "Queue") { +<&|/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 &> +% } elsif ($field eq "id") { +<&|/l&>Id</&> +</td><td> +<& /Elements/SelectEqualityOperator, Name => "idOp" &> +</td><td> +<INPUT Name="ValueOfid" SIZE=5> +% } elsif ($field eq "People") { +% foreach my $field (@people) { <tr><td class="label"> +% if ($field eq "Actor") { <SELECT NAME="ActorField"> <OPTION VALUE="Owner"><&|/l&>Owner</&></OPTION> <OPTION VALUE="Creator"><&|/l&>Creator</&></OPTION> @@ -108,80 +142,43 @@ FalseVal => '!=' &> </td><td> -<& /Elements/SelectOwner, Name => "ValueOfActor", ValueAttribute => 'Name' &> -</td> -</tr> -<tr> -<td class="label"> +<& /Elements/SelectOwner, Name => "ValueOfActor" &> +% } elsif ($field eq 'Watcher') { <& SelectPersonType, Name => 'WatcherField', Default => 'Requestor' &> </td><td> <& /Elements/SelectMatch, Name => "WatcherOp" &> </td><td> <Input Name="ValueOfWatcher" Size=20> -</tr> -<tr> -<td class="label"> -<& SelectPersonType, Name => 'WatcherGroupField', Default => 'RequestorGroup', Suffix => 'Group' &> -</td><td> -<& /Elements/SelectBoolean, Name => "WatcherGroupOp", - True=> loc('belongs to'), - False=> loc('does not belong to'), - TrueVal=> '=', - FalseVal => '!=' -&> -</td><td> -<& SelectGroup, Name => 'ValueOfWatcherGroup' &> -</td> -</tr> -<tr> -<td class="label"> -<& /Elements/SelectDateType, Name=>"DateField" &> -</td><td> -<& /Elements/SelectDateRelation, Name=>"DateOp" &> -</td><td> -<& /Elements/SelectDate, Name => "ValueOfDate", ShowTime => 0, Default => '' &> +% } else { +<&|/l&><%$field%></&> +<& /Elements/SelectMatch, Name => "$field" . "Op" &> +<INPUT Name="<%"ValueOf" . $field%>" value=""SIZE=20> +% } </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" &> +% } +% } else { +<&|/l&><%$field%></&> </td><td> -<INPUT Name="ValueOfTime" SIZE=5> -</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" &> +<& /Elements/SelectMatch, Name => "$field" . "Op" &> </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> +<INPUT Name="<%"ValueOf" . $field%>" value="" SIZE=20> +% } </td></tr> +% } +<& '/Elements/Callback', _CallbackName => 'EndOfList' &> <%INIT> +my @fields = ('Attachment', + 'Queue', + 'Status', + 'People', + 'Dates', + 'Time', + 'Priority', + 'Links', + 'id', + ); + my @people = ('Actor', 'Watcher', - 'WatcherGroup', ); </%INIT> diff --git a/rt/html/Search/Elements/PickCFs b/rt/html/Search/Elements/PickCFs index 435a07ad3..fb143ba57 100644 --- a/rt/html/Search/Elements/PickCFs +++ b/rt/html/Search/Elements/PickCFs @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,17 +42,24 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK % while ( my $CustomField = $CustomFields->Next ) { -% my $name = "'CF.{" . $CustomField->Name . "}'"; -<tr><td class="label"> +<tr><td class=label> + +% my $name; +% if ($CustomField->QueueObj->id) { +% $name = "'CF." . $CustomField->QueueObj->Name . +% ".{" . $CustomField->Name . "}'"; +% } else { +% $name = "'CF." . $CustomField->Name . "'"; +% } <% $CustomField->Name %> </td> <td> - <& /Elements/SelectCustomFieldOperator, Name => $name . "Op", - True => loc("is"), - False => loc("isn't"), - TrueVal=> '=', FalseVal => '!=' &> +<& /Elements/SelectCustomFieldOperator, Name => $name . "Op", + True => loc("is"), + False => loc("isn't"), + TrueVal=> '=', FalseVal => '!=' &> </td> <td> <& /Elements/SelectCustomFieldValue, Name => "ValueOf" . $name, @@ -60,11 +67,13 @@ &> </td></tr> % } + <%INIT> my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'}); -foreach my $id (keys %cfqueues) { +foreach (keys %cfqueues) { + my $id = $_; $id =~ s/^.'*(.*).'*$/$1/; - # Gotta load up the $queue object, since queues get stored by name now. my $id + # 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); diff --git a/rt/html/Search/Elements/PickCriteria b/rt/html/Search/Elements/PickCriteria index 129344443..344830e34 100644 --- a/rt/html/Search/Elements/PickCriteria +++ b/rt/html/Search/Elements/PickCriteria @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,32 +42,26 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <& /Elements/TitleBoxStart, 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</&>: + Aggregator: </td> <td><& SelectAndOr, Name => "AndOr" &> </td></tr> </table> </td></tr> <tr> - <td> + <td colspan=3> <hr> </td> </tr> - <tr> - <td valign=top> - <table cellspacing=0 border=0> - <& PickBasics &> - <& PickCFs, cfqueues => \%cfqueues &> - </table> - </td> - </tr> + <& PickBasics &> + <& PickCFs, cfqueues => \%cfqueues &> <tr><td> </td></tr> </table> diff --git a/rt/html/Search/Elements/SearchPrivacy b/rt/html/Search/Elements/SearchPrivacy index 270e1baa3..5f6f207fe 100644 --- a/rt/html/Search/Elements/SearchPrivacy +++ b/rt/html/Search/Elements/SearchPrivacy @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <%args> $Object => undef </%args> diff --git a/rt/html/Search/Elements/SelectAndOr b/rt/html/Search/Elements/SelectAndOr index 2f3c70477..11df03ff1 100644 --- a/rt/html/Search/Elements/SelectAndOr +++ b/rt/html/Search/Elements/SelectAndOr @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,10 +42,10 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} -<input type=radio NAME="<%$Name%>" CHECKED VALUE="AND"><&|/l&>AND</&></input> -<input type=radio NAME="<%$Name%>" VALUE="OR"><&|/l&>OR</&></input> +%# }}} END BPS TAGGED BLOCK +<input type=radio NAME="<%$Name%>" CHECKED VALUE="AND">AND</input> +<input type=radio NAME="<%$Name%>" VALUE="OR">OR</input> <%ARGS> $Name => "Operator" -</%ARGS> +</%ARGS>
\ No newline at end of file diff --git a/rt/html/Search/Elements/SelectGroup b/rt/html/Search/Elements/SelectGroup deleted file mode 100644 index edd53713f..000000000 --- a/rt/html/Search/Elements/SelectGroup +++ /dev/null @@ -1,65 +0,0 @@ -%# BEGIN BPS TAGGED BLOCK {{{ -%# -%# COPYRIGHT: -%# -%# This software is Copyright (c) 1996-2005 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., 675 Mass Ave, Cambridge, MA 02139, USA. -%# -%# -%# 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/SelectLinks b/rt/html/Search/Elements/SelectLinks index 00ec80bd3..b814e3088 100644 --- a/rt/html/Search/Elements/SelectLinks +++ b/rt/html/Search/Elements/SelectLinks @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <SELECT NAME="<%$Name%>"> % foreach (@fields) { <OPTION VALUE="<%$_%>"><&|/l&><%$_%></&></OPTION> @@ -56,7 +56,7 @@ $Name => 'LinksField' my @fields = ('HasMember', 'MemberOf', 'DependsOn', - 'DependedOnBy', + 'DependentOn', 'RefersTo', 'ReferredToBy', 'LinkedTo', diff --git a/rt/html/Search/Elements/SelectPersonType b/rt/html/Search/Elements/SelectPersonType index d4127c97b..01f389304 100644 --- a/rt/html/Search/Elements/SelectPersonType +++ b/rt/html/Search/Elements/SelectPersonType @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,20 +42,16 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} 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> -% } +%for my $option (@types) { +%foreach my $subtype (@subtypes) { +<OPTION VALUE="<%"$option.$subtype"%>" <%$option eq $Default && $subtype eq 'EmailAddress' && "SELECTED"%> ><%loc("[_1] [_2]",$option, $subtype)%></OPTION> % } +%} </SELECT> <%INIT> @@ -63,9 +59,6 @@ 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); } @@ -75,7 +68,6 @@ my @subtypes = qw(EmailAddress Name RealName Nickname Organization Address1 Addr </%INIT> <%ARGS> $AllowNull => 1 -$Suffix => '' $Default=>undef $Scope => 'ticket' $Name => 'WatcherType' diff --git a/rt/html/Search/Elements/SelectSearchObject b/rt/html/Search/Elements/SelectSearchObject index e9df5179f..6eaa680f8 100644 --- a/rt/html/Search/Elements/SelectSearchObject +++ b/rt/html/Search/Elements/SelectSearchObject @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <%args> @Objects => undef $Name => undef diff --git a/rt/html/Search/Elements/SelectSearchesForObjects b/rt/html/Search/Elements/SelectSearchesForObjects index e6be66a58..3f0c458cb 100644 --- a/rt/html/Search/Elements/SelectSearchesForObjects +++ b/rt/html/Search/Elements/SelectSearchesForObjects @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <%args> @Objects => undef $Name => undef @@ -57,9 +57,6 @@ $Name => undef % } % my @searches = $object->Attributes->Named('SavedSearch'); % foreach my $search (@searches) { -% # Skip it if it is not a ticket search. -% next if ($search->SubValue('SearchType') -% && $search->SubValue('SearchType') ne 'Ticket'); <option value="<%ref($object)%>-<%$object->id%>-SavedSearch-<%$search->Id%>"> -<%$search->Description||loc('Unnamed search')%></option> % } % } diff --git a/rt/html/Search/Results.html b/rt/html/Search/Results.html index 5849378a8..dfcc7885c 100755 --- a/rt/html/Search/Results.html +++ b/rt/html/Search/Results.html @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <& /Elements/Header, Title => $title, Refresh => $session{'tickets_refresh_interval'} &> <& /Ticket/Elements/Tabs, current_tab => "Search/Results.html".$QueryString, @@ -52,6 +52,7 @@ Rows => $Rows, OrderBy => $OrderBy, Order => $Order &> +<hr> <& /Elements/TicketList, Query => $Query, AllowSorting => 1, @@ -80,26 +81,24 @@ <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="<%$RT::WebPath%>/Search/Results.rdf<%$ShortQueryString%>"><&|/l&>RSS</&></a> | -<a href="<%$RT::WebPath%>/Tools/Offline.html<%$ShortQueryString%>"><&|/l&>Work offline</&></a><br> +<a href="<%$RT::WebPath%>/Search/Results.rdf<%$QueryString%>"><&|/l&>RSS</&></a> | +<a href="<%$RT::WebPath%>/Tools/Offline.html<%$QueryString%>"><&|/l&>Work offline</&></a><br> <& /Elements/Callback, _CallbackName => 'SearchActions', QueryString => $QueryString&> </div> <%INIT> my ($title, $ticketcount); $session{'i'}++; -$session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) ; +$session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) unless ($session{'tickets'}); $session{'tickets'}->FromSQL($Query) if ($Query); $session{'tickets'}->OrderBy(FIELD => $OrderBy, ORDER => $Order); - -$session{'CurrentSearchHash'} = { - Format => $Format, - Query => $Query, - Order => $Order, - OrderBy => $OrderBy, - RowsPerPage => $Rows - }; - +if ($OrderBy ne $session{'CurrentSearchHash'}->{'OrderBy'} + or $Order ne $session{'CurrentSearchHash'}->{'Order'}) { + $session{'CurrentSearchHash'}->{'OrderBy'} = $OrderBy; + $session{'CurrentSearchHash'}->{'Order'} = $Order; + # Invalidate the ordering cache + undef $session{'tickets'}->{'items_array'}; +} if ( $session{'tickets'}->Query()) { @@ -117,7 +116,6 @@ my $QueryString = "?".$m->comp('/Elements/QueryString', Order => $Order, Page => $Page); -my $ShortQueryString = "?".$m->comp('/Elements/QueryString', Query => $Query); if ($ARGS{'TicketsRefreshInterval'}) { $session{'tickets_refresh_interval'} = $ARGS{'TicketsRefreshInterval'}; diff --git a/rt/html/Search/Results.rdf b/rt/html/Search/Results.rdf index ee71fea94..8054c8616 100644 --- a/rt/html/Search/Results.rdf +++ b/rt/html/Search/Results.rdf @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <%INIT> my $Tickets = RT::Tickets->new($session{'CurrentUser'}); diff --git a/rt/html/Search/Results.tsv b/rt/html/Search/Results.tsv index 17aa88ae1..631e299f0 100644 --- a/rt/html/Search/Results.tsv +++ b/rt/html/Search/Results.tsv @@ -1,8 +1,8 @@ -%# BEGIN BPS TAGGED BLOCK {{{ +%# {{{ BEGIN BPS TAGGED BLOCK %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# END BPS TAGGED BLOCK }}} +%# }}} END BPS TAGGED BLOCK <%INIT> my $Tickets = RT::Tickets->new($session{'CurrentUser'}); @@ -84,8 +84,7 @@ my @attrs = qw( id QueueObj->Name Subject Status TimeEstimated TimeWorked TimeLe my @header; foreach my $attr (@attrs) { my $label = $attr; - $label =~ s'Obj-.(?:AsString|Name|ISO)''g; - $label =~ s'-\>MemberEmailAddressesAsString''g; + $label =~ s'Obj-.(AsString|Name|ISO)''g; push @header, $label; } foreach my $id (sort keys %known_cfs) { |