[Bps-public-commit] rt-extension-repeatticket branch, master, updated. 1.00-1-gdee3770
? sunnavy
sunnavy at bestpractical.com
Sun May 10 09:45:52 EDT 2015
The branch, master has been updated
via dee3770ab956bca50c79acc4d3022ac934efbd17 (commit)
from 201e9a8dee6cb075cbc8f1e478251fb9054cdbc6 (commit)
Summary of changes:
bin/rt-repeat-ticket.in | 3 +++
html/Callbacks/RepeatTicket/Elements/Tabs/Privileged | 3 +++
html/Callbacks/RepeatTicket/Ticket/Create.html/AfterBasics | 5 +++++
.../RepeatTicket/Ticket/Elements/ShowSummary/LeftColumn | 3 +++
html/Ticket/ModifyRecurrence.html | 12 +++++++++++-
5 files changed, 25 insertions(+), 1 deletion(-)
- Log -----------------------------------------------------------------
commit dee3770ab956bca50c79acc4d3022ac934efbd17
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun May 10 21:34:01 2015 +0800
allow to disable Repeat Ticket for some queues
if "Original Ticket" cf is disabled in some queues, the Recurrence links for
tickets in those queues will be hidden and the function will also be disabled.
diff --git a/bin/rt-repeat-ticket.in b/bin/rt-repeat-ticket.in
index 808d59f..87b132f 100755
--- a/bin/rt-repeat-ticket.in
+++ b/bin/rt-repeat-ticket.in
@@ -27,6 +27,8 @@ sub run{
my $attrs = RT::Attributes->new( RT->SystemUser );
$attrs->Limit( FIELD => 'Name', VALUE => 'RepeatTicketSettings' );
+ my $cf = RT::CustomField->new(RT->SystemUser);
+ $cf->Load('Original Ticket');
while ( my $attr = $attrs->Next ) {
my $date = $args{date}->clone;
@@ -34,6 +36,7 @@ sub run{
next if $args{ticket} && $args{ticket} != $attr->Object->id;
next
if $args{type} && $args{type} ne $attr->Content->{'repeat-type'};
+ next unless $cf->can('IsAdded') ? ( $cf->IsAdded(0) || $cf->IsAdded($attr->Object->Queue) ) : ( $cf->IsApplied(0) || $cf->IsApplied($attr->Object->Queue));
$RT::Logger->info( 'Repeating ticket ' . $attr->Object->id );
my @ids = RT::Extension::RepeatTicket::Run( $attr, $date );
diff --git a/html/Callbacks/RepeatTicket/Elements/Tabs/Privileged b/html/Callbacks/RepeatTicket/Elements/Tabs/Privileged
index 3a72672..d77ee2f 100644
--- a/html/Callbacks/RepeatTicket/Elements/Tabs/Privileged
+++ b/html/Callbacks/RepeatTicket/Elements/Tabs/Privileged
@@ -5,6 +5,9 @@ if ( $request_path =~ m{^/Ticket/} ) {
my $id = $1;
my $obj = RT::Ticket->new( $session{'CurrentUser'} );
$obj->Load($id);
+ my $cf = RT::CustomField->new($session{CurrentUser});
+ $cf->Load('Original Ticket');
+ return unless $cf->id && ( $cf->can('IsAdded') ? ( $cf->IsAdded(0) || $cf->IsAdded($obj->Queue) ) : ( $cf->IsApplied(0) || $cf->IsApplied($obj->Queue) ));
my $tabs = PageMenu();
diff --git a/html/Callbacks/RepeatTicket/Ticket/Create.html/AfterBasics b/html/Callbacks/RepeatTicket/Ticket/Create.html/AfterBasics
index f4346e1..73faca6 100644
--- a/html/Callbacks/RepeatTicket/Ticket/Create.html/AfterBasics
+++ b/html/Callbacks/RepeatTicket/Ticket/Create.html/AfterBasics
@@ -1,6 +1,11 @@
<&| /Widgets/TitleBox, title => loc("Recurrence"), class=>'ticket-info-repeat-recurrence', title_class => 'inverse' &>
<& /Ticket/Elements/EditRecurrence, ARGSRef => $ARGSRef, Initial => 1 &>
</&>
+<%init>
+my $cf = RT::CustomField->new($session{CurrentUser});
+$cf->Load('Original Ticket');
+return unless $cf->id && ( $cf->can('IsAdded') ? ( $cf->IsAdded(0) || $cf->IsAdded($ARGS{QueueObj}->id) ) : ( $cf->IsApplied(0) || $cf->IsApplied($ARGS{QueueObj}->id) ));
+</%init>
<%args>
$ARGSRef
</%args>
diff --git a/html/Callbacks/RepeatTicket/Ticket/Elements/ShowSummary/LeftColumn b/html/Callbacks/RepeatTicket/Ticket/Elements/ShowSummary/LeftColumn
index 5ed4ffc..06f2ee4 100644
--- a/html/Callbacks/RepeatTicket/Ticket/Elements/ShowSummary/LeftColumn
+++ b/html/Callbacks/RepeatTicket/Ticket/Elements/ShowSummary/LeftColumn
@@ -7,4 +7,7 @@ $Ticket
</%args>
<%init>
my $can_modify = $Ticket->CurrentUserHasRight('ModifyTicket');
+my $cf = RT::CustomField->new($session{CurrentUser});
+$cf->Load('Original Ticket');
+return unless $cf->id && ( $cf->can('IsAdded') ? ( $cf->IsAdded(0) || $cf->IsAdded($Ticket->Queue) ) : ( $cf->IsApplied(0) || $cf->IsApplied($Ticket->Queue)) );
</%init>
diff --git a/html/Ticket/ModifyRecurrence.html b/html/Ticket/ModifyRecurrence.html
index 081b69c..de8e100 100644
--- a/html/Ticket/ModifyRecurrence.html
+++ b/html/Ticket/ModifyRecurrence.html
@@ -3,6 +3,7 @@
<& /Elements/ListActions, actions => \@results &>
+% unless ( $skip ) {
<form method="post" name="ModifyRecurrence" action="ModifyRecurrence.html">
<input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" />
<&| /Widgets/TitleBox,title => loc('Modify recurrence for ticket # [_1]', $TicketObj->Id), class=> 'ticket-info-repeat' &>
@@ -10,12 +11,21 @@
</&>
<& /Elements/Submit, Name => 'SubmitTicket', Label => loc('Save Changes') &>
</form>
-
+% }
<%INIT>
my $TicketObj = LoadTicket($id);
my @results;
+
+my $skip;
+my $cf = RT::CustomField->new($session{CurrentUser});
+$cf->Load('Original Ticket');
+unless( $cf->id && ( $cf->can('IsAdded') ? ( $cf->IsAdded(0) || $cf->IsAdded($TicketObj->Queue) ) : ( $cf->IsApplied(0) || $cf->IsApplied($TicketObj->Queue)) ) ) {
+ push @results, loc('RepeatTicket is not enabled in this Queue');
+ $skip = 1;
+}
+
if ( $ARGS{SubmitTicket} ) {
my ( $ret, $message ) = RT::Extension::RepeatTicket::SetRepeatAttribute( $TicketObj, %ARGS );
$ARGSRef = \%ARGS if not $ret; # Save params on failure
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list