summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Interface/Web_Vendor.pm
diff options
context:
space:
mode:
authormark <mark>2011-05-31 23:30:13 +0000
committermark <mark>2011-05-31 23:30:13 +0000
commite02e5448d8fdad322dbe5562f92d9623e5d6f0dd (patch)
tree0b7385d69d9a8bac89f8d7387387faa8eb55ac2e /rt/lib/RT/Interface/Web_Vendor.pm
parentdd65ba99bb9281571f19744154a3b03bcd3f01ab (diff)
improve mandatory fields, #9260
Diffstat (limited to 'rt/lib/RT/Interface/Web_Vendor.pm')
-rw-r--r--rt/lib/RT/Interface/Web_Vendor.pm101
1 files changed, 101 insertions, 0 deletions
diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm
index 1999096a7..c79222be5 100644
--- a/rt/lib/RT/Interface/Web_Vendor.pm
+++ b/rt/lib/RT/Interface/Web_Vendor.pm
@@ -34,6 +34,7 @@ use_ok(RT::Interface::Web_Vendor);
package HTML::Mason::Commands;
use strict;
+no warnings qw(redefine);
=head2 ProcessTicketCustomers
@@ -197,5 +198,105 @@ sub ProcessObjectCustomers {
}
+=head2 ProcessTicketBasics ( TicketObj => $Ticket, ARGSRef => \%ARGS );
+
+Updates all core ticket fields except Status, and returns an array of results
+messages.
+
+=cut
+
+sub ProcessTicketBasics {
+
+ my %args = (
+ TicketObj => undef,
+ ARGSRef => undef,
+ @_
+ );
+
+ my $TicketObj = $args{'TicketObj'};
+ my $ARGSRef = $args{'ARGSRef'};
+
+ # {{{ Set basic fields
+ my @attribs = qw(
+ Subject
+ FinalPriority
+ Priority
+ TimeEstimated
+ TimeWorked
+ TimeLeft
+ Type
+ Queue
+ );
+
+ if ( $ARGSRef->{'Queue'} and ( $ARGSRef->{'Queue'} !~ /^(\d+)$/ ) ) {
+ my $tempqueue = RT::Queue->new($RT::SystemUser);
+ $tempqueue->Load( $ARGSRef->{'Queue'} );
+ if ( $tempqueue->id ) {
+ $ARGSRef->{'Queue'} = $tempqueue->id;
+ }
+ }
+
+ my @results = UpdateRecordObject(
+ AttributesRef => \@attribs,
+ Object => $TicketObj,
+ ARGSRef => $ARGSRef,
+ );
+
+ # We special case owner changing, so we can use ForceOwnerChange
+ if ( $ARGSRef->{'Owner'} && ( $TicketObj->Owner != $ARGSRef->{'Owner'} ) ) {
+ my ($ChownType);
+ if ( $ARGSRef->{'ForceOwnerChange'} ) {
+ $ChownType = "Force";
+ } else {
+ $ChownType = "Give";
+ }
+
+ my ( $val, $msg ) = $TicketObj->SetOwner( $ARGSRef->{'Owner'}, $ChownType );
+ push( @results, $msg );
+ }
+
+ # }}}
+
+ return (@results);
+}
+
+=head2 ProcessTicketStatus (TicketObj => RT::Ticket, ARGSRef => {})
+
+Process updates to the 'Status' field of the ticket. If the new value
+of Status is 'resolved', this will check required custom fields before
+allowing the update.
+
+=cut
+
+sub ProcessTicketStatus {
+ my %args = (
+ TicketObj => undef,
+ ARGSRef => undef,
+ @_
+ );
+
+ my $TicketObj = $args{'TicketObj'};
+ my $ARGSRef = $args{'ARGSRef'};
+ my @results;
+
+ return () if !$ARGSRef->{'Status'};
+
+ if ( lc( $ARGSRef->{'Status'} ) eq 'resolved' ) {
+ foreach my $field ( $TicketObj->MissingRequiredFields ) {
+ push @results, loc('Missing required field: [_1]', $field->Name);
+ }
+ }
+ if ( @results ) {
+ $m->notes('RedirectToBasics' => 1);
+ return @results;
+ }
+
+ return UpdateRecordObject(
+ AttributesRef => [ 'Status' ],
+ Object => $TicketObj,
+ ARGSRef => $ARGSRef,
+ );
+}
+
1;