X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FQueue.pm;h=f8c0791a62e954252f07e56f2b8de842b7d36890;hp=6e2bc8d1d3e8cd34e9c57176379447cac822f6ea;hb=7322f2afedcc2f427e997d1535a503613a83f088;hpb=ae14e320388fa5e7f400bff1c251ef885b7952e6 diff --git a/rt/lib/RT/Queue.pm b/rt/lib/RT/Queue.pm index 6e2bc8d1d..f8c0791a6 100755 --- a/rt/lib/RT/Queue.pm +++ b/rt/lib/RT/Queue.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -223,43 +223,6 @@ sub Delete { $self->loc('Deleting this object would break referential integrity') ); } - - -=head2 SetDisabled - -Takes a boolean. -1 will cause this queue to no longer be available for tickets. -0 will re-enable this queue. - -=cut - -sub SetDisabled { - my $self = shift; - my $val = shift; - - $RT::Handle->BeginTransaction(); - my ($ok, $msg) = $self->_Set( Field =>'Disabled', Value => $val); - unless ($ok) { - $RT::Handle->Rollback(); - $RT::Logger->warning("Couldn't ".(($val == 0) ? "enable" : "disable")." queue ".$self->Name.": $msg"); - return ($ok, $msg); - } - $self->_NewTransaction( Type => ($val == 0) ? "Enabled" : "Disabled" ); - - $RT::Handle->Commit(); - - RT->System->QueueCacheNeedsUpdate(1); - - if ( $val == 0 ) { - return (1, $self->loc("Queue enabled")); - } else { - return (1, $self->loc("Queue disabled")); - } - -} - - - =head2 Load Takes either a numerical id or a textual Name and loads the specified queue. @@ -354,8 +317,13 @@ sub SetSign { Content => $value, ); return ($status, $msg) unless $status; - return ($status, $self->loc('Signing enabled')) if $value; - return ($status, $self->loc('Signing disabled')); + + my ( undef, undef, $TransObj ) = $self->_NewTransaction( + Field => 'Signing', #loc + Type => $value ? "Enabled" : "Disabled" + ); + + return ($status, scalar $TransObj->BriefDescription); } sub SignAuto { @@ -380,8 +348,13 @@ sub SetSignAuto { Content => $value, ); return ($status, $msg) unless $status; - return ($status, $self->loc('Signing enabled')) if $value; - return ($status, $self->loc('Signing disabled')); + + my ( undef, undef, $TransObj ) = $self->_NewTransaction( + Field => 'AutoSigning', #loc + Type => $value ? "Enabled" : "Disabled" + ); + + return ($status, scalar $TransObj->BriefDescription); } sub Encrypt { @@ -406,8 +379,13 @@ sub SetEncrypt { Content => $value, ); return ($status, $msg) unless $status; - return ($status, $self->loc('Encrypting enabled')) if $value; - return ($status, $self->loc('Encrypting disabled')); + + my ( undef, undef, $TransObj ) = $self->_NewTransaction( + Field => 'Encrypting', #loc + Type => $value ? "Enabled" : "Disabled" + ); + + return ($status, scalar $TransObj->BriefDescription); } =head2 Templates @@ -793,11 +771,44 @@ sub IsAdminCc { sub _Set { my $self = shift; + my %args = ( + Field => undef, + Value => undef, + TransactionType => 'Set', + RecordTransaction => 1, + @_ + ); + unless ( $self->CurrentUserHasRight('AdminQueue') ) { return ( 0, $self->loc('Permission Denied') ); } + + my $Old = $self->SUPER::_Value("$args{'Field'}"); + + my ($ret, $msg) = $self->SUPER::_Set( + Field => $args{'Field'}, + Value => $args{'Value'}, + ); + + if ( $ret == 0 ) { return ( 0, $msg ); } + RT->System->QueueCacheNeedsUpdate(1); - return ( $self->SUPER::_Set(@_) ); + + if ( $args{'RecordTransaction'} == 1 ) { + if ($args{'Field'} eq 'Disabled') { + $args{'TransactionType'} = ($args{'Value'} == 1) ? "Disabled" : "Enabled"; + delete $args{'Field'}; + } + my ( undef, undef, $TransObj ) = $self->_NewTransaction( + Type => $args{'TransactionType'}, + Field => $args{'Field'}, + NewValue => $args{'Value'}, + OldValue => $Old, + TimeTaken => $args{'TimeTaken'}, + ); + } + + return ( $ret, $msg ); }