%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC %# %# %# (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 }}} <& /Elements/Header, Title => $title &> <& /AssetTracker/Elements/Tabs, current_tab => "AssetTracker/Search/Bulk.html", Title => $title, &> <& /Elements/ListActions, actions => \@results &>
% foreach my $var (qw(Query Format OrderBy Order Rows Page SavedChartSearchId)) { %} <& /Elements/CollectionList, Collection => $Assets, Query => $Query, DisplayFormat => $Format, Format => $ARGS{'Format'}, Verbatim => 1, AllowSorting => 1, OrderBy => $OrderBy, Order => $Order, Rows => $Rows, Page => $Page, BaseURL => RT->Config->Get('WebPath')."/AssetTracker/Search/Bulk.html?", Class => 'RTx::AssetTracker::Assets' &> % $m->callback(CallbackName => 'AfterAssetList', ARGSRef => \%ARGS);
<& /Elements/Submit, Label => loc('Update'), CheckboxNameRegex => '/^UpdateAsset\d+$/', CheckAll => 1, ClearAll => 1 &>
<& /Elements/TitleBoxStart, title => loc('Update selected assets') &>
% for my $role ( ActiveRoleArray() ) { % }
<&|/l&>Add <% $role %>:
<&|/l&>Remove <% $role %>:
(Username or Email separated by spaces)
<&|/l&>Make Description:
<&|/l&>Make Type: <& /AssetTracker/Elements/SelectType, Name => "Type" &>
<&|/l&>Make Status: <& /AssetTracker/Elements/SelectStatus, Name => "Status" &>
<& /Elements/TitleBoxEnd&> %#<& /Elements/TitleBoxStart, title => loc('Add comments or replies to selected assets') &> %# %# %# %# %#% while (my $CF = $TxnCFs->Next()) { %# %# %# %# %#% } # end if while %# %# %#
<&|/l&>Update Type: %#
<&|/l&>Subject:
<% $CF->Name %>:<& /Elements/EditCustomField, %# CustomField => $CF, %# NamePrefix => "Object-RT::Transaction--CustomField-" %# &><% $CF->FriendlyType %>
<&|/l&>Attach:
<&|/l&>Message: %# <& /Elements/MessageBox, Name=>"UpdateContent"&> %#
%# %#<& /Elements/TitleBoxEnd &> <&|/Widgets/TitleBox, title => loc('Edit Links'), color => "#336633"&> <& /AssetTracker/Asset/Elements/BulkLinks, Assets => $Assets &> <& /Elements/TitleBoxStart, title => loc('Edit Fields'), color => "#336633"&> % foreach (keys %allcfs) { % }
% my $cf = $allcfs{$_}; % my $pref; % if ($globalcfs{$cf->Id}) { % $pref = "[Global]"; % } else { % $pref = "[Type: " . join(',', sort keys %{$cfqnames{$_}}) . "]"; % } <%$pref%> <% $cf->Name %>
<% $cf->FriendlyType %> % if ($cf->Type =~ /(Select|Freeform|Text)/ and $cf->MaxValues == 1) {
<&|/l&>Don't update <% $cf->Name %> % }
% if ($cf->Type eq "Select" and $cf->MaxValues != 1) { Add Values <& /AssetTracker/Asset/Elements/EditCustomField, CustomField => $cf, NameSuffix => 'AddValues' &> Delete Values <& /AssetTracker/Asset/Elements/EditCustomField, CustomField => $cf, NameSuffix => 'DeleteValues' &> % } % elsif ($cf->Type =~ /(Select|Freeform)/ and $cf->MaxValues == 1) { <& /AssetTracker/Asset/Elements/EditCustomField, CustomField => $cf &> % } % elsif ($cf->Type eq 'Text') { % } else { Add Values
Delete Values
% }
<& /Elements/TitleBoxEnd &> <& /Elements/TitleBoxStart, title => 'Change Comment', color=> "#999900", width => "100%" &> <& /AssetTracker/Asset/Elements/ChangeComment, Name => "GlobalComment" &> <& /Elements/TitleBoxEnd &> <& /Elements/Submit, Label => loc('Update') &>
<%INIT> unless ($session{'CurrentUser'}->HasRight( Object => $RTx::AssetTracker::System, Right => 'BulkUpdate')) { Abort(loc("No permission to perform bulk updates of assets.")); } unless ( defined $Rows ) { $Rows = $RowsPerPage; $ARGS{Rows} = $RowsPerPage; } my $title = loc("Update multiple assets"); # Iterate through the ARGS hash and remove anything with a null value. map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS); my (@results); $Page ||= 1; $Format ||= RT->Config->Get('DefaultAssetSearchResultFormat'); # inject _CHECKBOX to the first field. $Format =~ s/'?([^']+)'?,/'___CHECKBOX__$1',/; my $Assets = RTx::AssetTracker::Assets->new($session{'CurrentUser'}); $Assets->FromSQL($Query); if ( $OrderBy =~ /\|/ ) { # Multiple Sorts my @OrderBy = split /\|/, $OrderBy; my @Order = split /\|/, $Order; $Assets->OrderByCols( map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } ( 0 .. $#OrderBy ) ); } else { $Assets->OrderBy( FIELD => $OrderBy, ORDER => $Order ); } $Assets->RowsPerPage($Rows) if ($Rows); $Assets->GotoPage( $Page - 1 ); # SB uses page 0 as the first page Abort(loc("No search to operate on.")) unless ($Assets); my %allcfs; my %cfqnames; my %cfqs; my $count = 0; while (my $Asset = $Assets->Next) { my $cfq = $Asset->TypeObj; my $cfqid = $cfq->Id; my $cfqn = $cfq->Name; unless ( exists $cfqs{$cfqid} ) { $cfqs{$cfqid} = 1; $count++; my $cfs = $cfq->AssetCustomFields; while (my $cf = $cfs->Next) { $allcfs{$cf->Id} = $cf; $cfqnames{$cf->Id}{$cfqn} = 1; } } } my %globalcfs; my $CFs = RT::CustomFields->new($RT::SystemUser); $CFs->LimitToGlobalAsset; while (my $cf = $CFs->Next) { $globalcfs{$cf->Id} = 1; } #my $do_comment_reply=0; ## Prepare for asset updates #$ARGS{'UpdateContent'} =~ s/\r\n/\n/g; #chomp ($ARGS{'UpdateContent'}) ; #if ($ARGS{'UpdateContent'} && #$ARGS{'UpdateContent'} ne '' && #$ARGS{'UpdateContent'} ne "-- \n" . #$session{'CurrentUser'}->UserObj->Signature) { #$do_comment_reply=1; #} #Iterate through each asset we've been handed my (@linkresults,@cfresults); my %queues; $Assets->RedoSearch(); while (my $Asset = $Assets->Next) { $queues{$Asset->TypeObj->Id}++; $RT::Logger->debug( "Checking Asset ".$Asset->Id ."\n"); next unless ($ARGS{"UpdateAsset".$Asset->Id}); $RT::Logger->debug ("Matched\n"); my @updateresults; #if ($do_comment_reply) { #ProcessUpdateMessage(AssetObj => $Asset, ARGSRef => \%ARGS, Actions => \@updateresults); #} #Update the basics. my @basicresults = ProcessAssetBasics(AssetObj => $Asset, ARGSRef => \%ARGS); my @cfresults = ProcessBulkCustomFieldUpdates(Object => $Asset, ARGSRef => \%ARGS); #my @dateresults = ProcessAssetDates(AssetObj => $Asset, ARGSRef => \%ARGS); #Update the watchers my @watchresults = ProcessAssetWatchers(AssetObj => $Asset, ARGSRef => \%ARGS); #Update the links $ARGS{'id'} = $Asset; foreach my $type ( keys %{ RTx::AssetTracker::Asset::LINKDIRMAP() } ) { $ARGS{ $Asset->id . "-" . $type } = $ARGS{"Asset-$type"}; $ARGS{ $type . "-" . $Asset->id } = $ARGS{"$type-Asset"}; } @linkresults = ProcessAssetLinks( AssetObj => $Asset, ARGSRef => \%ARGS ); foreach my $type ( keys %{ RTx::AssetTracker::Asset::LINKDIRMAP() } ) { delete $ARGS{ $type . "-" . $Asset->id }; delete $ARGS{ $Asset->id . "-" . $type }; } my @tempresults = ( @watchresults, @basicresults, @updateresults, @linkresults, @cfresults, ); @tempresults = map { loc("Asset #[_1] [_2]: [_3]",$Asset->Id,$Asset->Name,$_) } @tempresults; @results = (@results, @tempresults); } #my $TxnCFs = RT::CustomFields->new($session{CurrentUser}); #$TxnCFs->LimitToLookupType("RTx::AssetTracker::Type-RTx::AssetTracker::Asset-RT::Transaction"); #$TxnCFs->LimitToGlobalOrObjectId(sort keys %queues); <%args> $Format => undef $Page => 1 $Rows => undef $RowsPerPage => undef $Order => 'ASC' $OrderBy => 'id' $Query => undef $SavedSearchId => undef $SavedChartSearchId => undef