-%# BEGIN LICENSE BLOCK
+%# {{{ BEGIN BPS TAGGED BLOCK
%#
-%# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+%# <jesse@bestpractical.com>
%#
-%# (Except where explictly superceded by other copyright notices)
+%# (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
%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%# General Public License for more details.
%#
-%# Unless otherwise specified, all modifications, corrections or
-%# extensions to this work which alter its source code become the
-%# property of Best Practical Solutions, LLC when submitted for
-%# inclusion in the work.
+%# 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:
%#
-%# END LICENSE BLOCK
+%# (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 => loc("Bulk ticket update") &>
<& /Elements/Tabs, Title => loc("Bulk ticket update") &>
my $i;
-
-
-$session{'tickets'}->RedoSearch();
-while (my $Ticket = $session{'tickets'}->Next) {
+$Tickets->RedoSearch();
+while (my $Ticket = $Tickets->Next) {
$i++;
if ($i % 2) {
$bgcolor = "#dddddd";
<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&>Response 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>
<& /Elements/MessageBox, Name=>"UpdateContent"&>
</td></tr>
</table>
+
+<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 Relationships'), color => "#336633"&>
+<& /Elements/TitleBoxStart, title => loc('Edit Links'), color => "#336633"&>
<i><&|/l&>Enter tickets or URIs to link tickets to. Seperate multiple entries with spaces.</&></i><br>
<& /Ticket/Elements/BulkLinks &>
<& /Elements/TitleBoxEnd &>
-<& /Elements/Submit &>
+<& /Elements/Submit, Label => loc('Update All') &>
</FORM>
my ($bgcolor, @results);
my @cols = qw(id Status Priority Subject QueueObj->Name OwnerObj->Name RequestorAddresses DueAsString );
-Abort(loc("No search to operate on.")) unless ($session{'tickets'});
+my $Tickets = RT::Tickets->new($session{'CurrentUser'});
+$Tickets->FromSQL($ARGS{'Query'});
+
+Abort(loc("No search to operate on.")) unless ($Tickets);
+
+my %allcfs;
+my %cfqnames;
+my %cfqs;
+my $count = 0;
+while (my $Ticket = $Tickets->Next) {
+ my $cfq = $Ticket->QueueObj;
+ my $cfqid = $cfq->Id;
+ my $cfqn = $cfq->Name;
+ unless ( exists $cfqs{$cfqid} ) {
+ $cfqs{$cfqid} = 1;
+ $count++;
+ my $cfs = $cfq->CustomFields;
+ while (my $cf = $cfs->Next) {
+ $allcfs{$cf->Id} = $cf;
+ $cfqnames{$cf->Id} = $cfqn;
+ }
+ }
+}
my $do_comment_reply=0;
# Prepare for ticket updates
#Iterate through each ticket we've been handed
my @linkresults;
-$session{'tickets'}->RedoSearch();
-while (my $Ticket = $session{'tickets'}->Next) {
+$Tickets->RedoSearch();
+while (my $Ticket = $Tickets->Next) {
$RT::Logger->debug( "Checking Ticket ".$Ticket->Id ."\n");
next unless ($ARGS{"UpdateTicket".$Ticket->Id});
$RT::Logger->debug ("Matched\n");
+ 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);
+ #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;
$ARGS{$Ticket->Id.'-MergeInto'} = $ARGS{'Ticket-MergeInto'};
delete $ARGS{$Ticket->Id.'-RefersTo'};
delete $ARGS{'RefersTo-'.$Ticket->Id};
- my @updateresults;
- if ($do_comment_reply) {
- ProcessUpdateMessage(TicketObj => $Ticket, ARGSRef => \%ARGS, Actions => \@updateresults);
- }
- 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);