[Rt-commit] r4116 - in rtir/branches/1.9-EXPERIMENTAL: . html/RTIR
html/RTIR/Elements html/RTIR/Incident
ruz at bestpractical.com
ruz at bestpractical.com
Fri Nov 18 04:00:19 EST 2005
Author: ruz
Date: Fri Nov 18 04:00:17 2005
New Revision: 4116
Modified:
rtir/branches/1.9-EXPERIMENTAL/ (props changed)
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Display.html
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/QueueTabs
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Display.html
Log:
r333 at cubic-pc: cubic | 2005-11-18 12:03:50 +0300
r329 at cubic-pc: cubic | 2005-11-18 07:23:24 +0300
* Quick argument in Diplay.html, redirect to search results after update
* allow user to update ticket when he has no right 'ShowTicket', may
be he has 'ModifyRight'
r330 at cubic-pc: cubic | 2005-11-18 10:07:00 +0300
* tidy
* get rid code duplication
* show warning about empty children only when deleting links
r331 at cubic-pc: cubic | 2005-11-18 10:09:12 +0300
* oops, forgot rename variable
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Display.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Display.html (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Display.html Fri Nov 18 04:00:17 2005
@@ -173,18 +173,17 @@
<%INIT>
my ($Type, $name);
-my $Ticket = new RT::Ticket($session{'CurrentUser'});
-my $QueueObj = new RT::Queue($session{'CurrentUser'});
+my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
+my $QueueObj = new RT::Queue( $session{'CurrentUser'} );
-if ( $id ne 'new' ) {
+unless ( $id eq 'new' ) {
$Ticket = LoadTicket( $id );
unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
Abort("No permission to view ticket");
}
$QueueObj->Load($Ticket->QueueObj->Name) || Abort(loc("Queue could not be loaded."));
-} elsif ( $Queue ) {
- $QueueObj->Load($Queue);
- Abort(loc("Queue could not be loaded.")) unless $QueueObj->id;
+} else {
+ $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
}
# Incidents have their own Create.html
@@ -202,31 +201,20 @@
);
delete $session{'Attachments'};
- unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
- Abort("No permission to view newly created ticket #".$Ticket->id.".");
- }
-
- $ARGS{'id'} = $id = $Ticket->Id;
} elsif( $id ) {
- unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
- Abort("No permission to view ticket");
- }
-
- $ARGS{UpdateAttachments} = delete $session{'Attachments'};
- push @results, ProcessUpdateMessage( ARGSRef=>\%ARGS, TicketObj=>$Ticket );
+ my $oldstate = $Ticket->FirstCustomFieldValue('_RTIR_State');
- if ($ARGS{'Action'} && $ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
+ if ( $ARGS{'Action'} && $ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/ ) {
my $action = $1;
my (undef, $msg) = $Ticket->$action();
- push(@results, $msg);
+ push @results, $msg;
}
- my $oldstate = $Ticket->FirstCustomFieldValue('_RTIR_State');
-
- #Process basics updates
- push @results, ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$Ticket);
- push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
- push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
+ $ARGS{UpdateAttachments} = delete $session{'Attachments'};
+ push @results, ProcessUpdateMessage( ARGSRef=>\%ARGS, TicketObj => $Ticket );
+ push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
+ push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS );
+ push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS );
my $newstate = $Ticket->FirstCustomFieldValue('_RTIR_State');
if ($newstate ne $oldstate) {
@@ -243,7 +231,25 @@
}
}
-($Type, undef) = $m->comp('Elements/Type', Ticket => $Ticket->Id);
+if( delete $ARGS{'Quick'} ) {
+ $m->comp( '/RTIR/Search/Results.html',
+ %ARGS,
+ Queue => $Queue->Name,
+ results => \@results
+ );
+ $m->abort;
+}
+
+unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
+ if( $id eq 'new' ) {
+ Abort("No permission to view newly created ticket #".$Ticket->id.".");
+ }
+ Abort("No permission to view ticket");
+}
+# update id argument in the case we took merged or created new
+$ARGS{'id'} = $id = $Ticket->Id;
+
+($Type) = $m->comp('Elements/Type', Ticket => $Ticket->Id);
if ($Type eq 'Report') {
$name = "Incident Report";
@@ -263,7 +269,7 @@
</%INIT>
<%ARGS>
-$id => ''
+$id => 0
$Queue => undef
@results => undef
</%ARGS>
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/QueueTabs
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/QueueTabs (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/QueueTabs Fri Nov 18 04:00:17 2005
@@ -138,16 +138,20 @@
if ( $Ticket->CurrentUserHasRight('ModifyTicket') ) {
if ( $Type eq 'Report' ) {
- if ( $Ticket->Status ne 'resolved' and $Ticket->Status ne 'rejected' ) {
+ if ( $Ticket->QueueObj->IsActiveStatus( $Ticket->Status ) ) {
my $state = $Ticket->FirstCustomFieldValue('_RTIR_State');
if ($state ne 'new') {
$actions->{'Ac'} = {
path => "RTIR/Update.html?Action=Comment&DefaultStatus=resolved&id=$id",
title => loc('Resolve'),
};
+ $actions->{'Acc'} = {
+ path => "RTIR/Display.html?Status=resolved&Quick=1&id=$id",
+ title => loc('Quick Resolve'),
+ };
}
$actions->{'B'} = {
- path => "RTIR/Display.html?Status=rejected&id=$id",
+ path => "RTIR/Display.html?Status=rejected&Quick=1&id=$id",
title => loc('Quick Reject'),
};
$actions->{'Bb'} = {
@@ -157,11 +161,15 @@
}
}
elsif ( $Type eq 'Incident' ) {
- if ( $Ticket->Status ne 'resolved' ) {
+ if ( $Ticket->QueueObj->IsActiveStatus( $Ticket->Status ) ) {
$actions->{'Ac'} = {
path => "RTIR/Incident/Reply.html?Action=Comment&DefaultStatus=resolved&id=$id&All=1",
title => loc('Resolve'),
};
+ $actions->{'Acc'} = {
+ path => "RTIR/Display.html?Status=resolved&Quick=1&id=$id",
+ title => loc('Quick Resolve'),
+ };
$actions->{'B'} = {
path => "RTIR/Incident/Reply.html?Action=Comment&DefaultStatus=rejected&id=$id&All=1",
title => loc('Abandon'),
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Display.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Display.html (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Display.html Fri Nov 18 04:00:17 2005
@@ -126,7 +126,7 @@
Ticket => $Ticket,
Queue => 'Incident Reports',
Rows => 8,
- FullList => $RT::WebPath."/RTIR/Incident/ShowChildren.html?Queue=Incident Reports&id=".$Ticket->id,
+ FullList => $RT::WebPath."/RTIR/Incident/ShowChildren.html?Queue=Incident%20Reports&id=".$Ticket->id,
&>
<& /Widgets/TitleBoxEnd &>
@@ -199,163 +199,135 @@
<%INIT>
-my ($Ticket, $ChildObj);
-$Ticket = new RT::Ticket($session{'CurrentUser'});
-if ($ARGS{'child'}) {
- $ChildObj = LoadTicket($ARGS{'child'});
+my ($Ticket, $ChildObj);
+$Ticket = new RT::Ticket( $session{'CurrentUser'} );
+if ( $ARGS{'child'} ) {
+ $ChildObj = LoadTicket( $ARGS{'child'} );
}
if ($SelectedTicket) {
- $id = $SelectedTicket;
- $ARGS{'Status'} = "open";
-}
-
-unless ($id) {
- Abort('No incident specified');
+ $id = $SelectedTicket;
+ $ARGS{'Status'} = "open";
}
+Abort('No incident specified') unless $id;
my $DoLinks = sub {
- my $Ticket = shift;
- my $Target = shift;
-
- my @linkresults;
- my ($Type) = $m->comp("/RTIR/Elements/Type", Ticket => $Ticket->Id);
- $ARGS{$Ticket->Id.'-MemberOf'} = $Target->Id;
-
- # Blocks can have multiple incidents
- my $unlinked;
- if ($Type ne 'Block') {
- my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id;
- my $incidents = new RT::Tickets($session{'CurrentUser'});
- $incidents->FromSQL($query);
- while (my $member = $incidents->Next) {
- $RT::Logger->debug ("Deleting: ".$member->Id."\n");
- $ARGS{'DeleteLink--MemberOf-'.$member->Id} = '';
- $unlinked->{$member->Id} = $member;
- }
- }
-
- # If we don't own the thing we're linking to, change the owner
- if ($Ticket->Owner != $session{'CurrentUser'}->id) {
- if ($Ticket->Owner == $RT::Nobody->id) {
- $ARGS{'Action'} = 'Take';
- } else {
- $ARGS{'Action'} = 'Steal';
- }
- my $action = $ARGS{'Action'};
- my ($res, $msg)=$Ticket->$action();
- push (@linkresults, $msg);
- }
+ my $Ticket = shift;
+ my $Target = shift;
- push @linkresults, ProcessTicketLinks(TicketObj => $Ticket, ARGSRef => \%ARGS);
+ my @results;
+ my ($Type) = $m->comp( "/RTIR/Elements/Type", TicketObj => $Ticket );
+ $ARGS{ $Ticket->Id .'-MemberOf' } = $Target->Id;
+
+ # Blocks can have multiple incidents
+ my $unlinked;
+ if ( $Type ne 'Block' ) {
+ my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id;
+ my $incidents = new RT::Tickets( $session{'CurrentUser'} );
+ $incidents->FromSQL( $query );
+ while ( my $member = $incidents->Next ) {
+ $RT::Logger->debug ("Deleting: ".$member->Id."\n");
+ # XXX: this code looks wrong absolutly.
+ $ARGS{'DeleteLink--MemberOf-'. $member->Id} = '';
+ $unlinked->{ $member->Id } = $member;
+ }
+ }
- @linkresults = map { loc("Ticket [_1]: [_2]",$Ticket->Id,$_) } @linkresults;
+ # If we don't own the thing we're linking to, change the owner
+ if ( $Ticket->Owner != $session{'CurrentUser'}->id ) {
+ my $action = 'Steal';
+ if ( $Ticket->Owner == $RT::Nobody->id ) {
+ $action = 'Take';
+ }
+ my ($res, $msg) = $Ticket->$action();
+ push @results, $msg;
+ }
- push (@results, @linkresults);
+ push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS );
+ return map { loc("Ticket [_1]: [_2]", $Ticket->Id, $_) } @results;
};
-if ($id eq 'new') {
- # {{{ Create a new ticket
-
- my $Queue = new RT::Queue($session{'CurrentUser'});
- unless ($Queue->Load($ARGS{'Queue'})) {
- Abort('Queue not found');
- }
-
- unless ($Queue->CurrentUserHasRight('CreateTicket')) {
- Abort('You have no permission to create tickets in that queue.');
- }
- ($Ticket, @results) =
- CreateTicket(Attachments => $session{'Attachments'}, %ARGS);
- delete $session{'Attachments'};
- unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
- Abort("No permission to view newly created ticket #".$Ticket->id.".");
- }
- $ARGS{'id'} = $Ticket->Id;
- # }}}
-
- if ($ChildObj) {
- $ARGS{'id'}=$Ticket->Id;
- &$DoLinks($ChildObj, $Ticket);
- }
+if ( $id eq 'new' ) {
+ my $Queue = new RT::Queue($session{'CurrentUser'});
+ $Queue->Load( $ARGS{'Queue'} ) || Abort(loc("Queue could not be loaded."));
+
+ unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
+ Abort('You have no permission to create tickets in that queue.');
+ }
+ ($Ticket, @results) =
+ CreateTicket( Attachments => $session{'Attachments'}, %ARGS );
+ delete $session{'Attachments'};
+
+ unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
+ Abort("No permission to view newly created ticket #".$Ticket->id.".");
+ }
+
+ $ARGS{'id'} = $id = $Ticket->Id;
+ push @results, $DoLinks->( $ChildObj, $Ticket ) if $ChildObj;
} else {
- $Ticket = LoadTicket($id);
- unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
+ $Ticket = LoadTicket( $id );
+ $ARGS{'id'} = $id = $Ticket->Id;
+
+ my $oldstate = $Ticket->FirstCustomFieldValue('_RTIR_State');
+
+ push @results, $DoLinks->( $ChildObj, $Ticket ) if $ChildObj;
+
+ if ( $ARGS{'Action'} && $ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/ ) {
+ my $action = $1;
+ my ($res, $msg) = $Ticket->$action();
+ push @results, $msg;
+ }
+
+ # XXX: check usage of this option
+ if ( $ARGS{'BulkLink'} ) {
+ #Iterate through each ticket we've been handed
+ while ( my $t = $session{'tickets'}->Next ) {
+ next unless $ARGS{ "UpdateTicket". $t->Id };
+ push @results, $DoLinks->( $t, $Ticket );
+ }
+ }
+
+ $ARGS{UpdateAttachments} = delete $session{'Attachments'};
+ push @results, ProcessUpdateMessage( ARGSRef => \%ARGS, TicketObj => $Ticket );
+ push @results, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj=>$Ticket );
+
+ my $newstate = $Ticket->FirstCustomFieldValue('_RTIR_State');
+ if ($newstate ne $oldstate) {
+ push @results, loc("State changed from [_1] to [_2]", $oldstate, $newstate);
+ }
+
+ # XXX: need the way to show @results when aborting
+ unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
Abort("No permission to view ticket");
}
+}
- if ($ChildObj) {
- $ARGS{'id'}=$Ticket->Id;
- &$DoLinks($ChildObj, $Ticket);
- }
-
- if (defined $ARGS{'Action'}) {
- if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
- my $action = $1;
- my ($res, $msg)=$Ticket->$action();
- push(@results, $msg);
- }
- } elsif ($ARGS{'BulkLink'}) {
- #Iterate through each ticket we've been handed
- my $IncidentObj = LoadTicket($id);
- while (my $t = $session{'tickets'}->Next) {
- next unless ($ARGS{"UpdateTicket".$t->Id});
- &$DoLinks($t, $IncidentObj);
- }
- }
-
- my ($oldstate, $newstate);
- $oldstate = $Ticket->FirstCustomFieldValue('_RTIR_State');
-
- $ARGS{UpdateAttachments} = delete $session{'Attachments'};
- push @results, ProcessUpdateMessage( ARGSRef => \%ARGS, TicketObj => $Ticket );
-
- #Process basics updates
- push @results, ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$Ticket);
-
- $newstate = $Ticket->FirstCustomFieldValue('_RTIR_State');
- if ($newstate ne $oldstate) {
- push (@results, loc("State changed from [_1] to [_2]", $oldstate, $newstate));
- }
-}
-
-my $TimeWorked;
-if (defined $Ticket) {
- $TimeWorked = $Ticket->TimeWorked;
- if ($Ticket->TimeLeft > 0 ) {
- $TimeWorked = $Ticket->TimeWorked."/".$Ticket->TimeLeft;
- }
+my $TimeWorked = $Ticket->TimeWorked;
+if ( $Ticket->TimeLeft > 0 ) {
+ $TimeWorked .= '/'. $Ticket->TimeLeft;
}
# If we deleted any links, check if what we deleted from still has children
-foreach my $arg (%ARGS) {
- if (substr($arg, 0, length('DeleteLink--MemberOf-')) eq
- 'DeleteLink--MemberOf-') {
- my $t = substr($arg, length('DeleteLink--MemberOf-'));
- my $children = new RT::Tickets ($session{'CurrentUser'});
- $children->LimitQueue(VALUE => 'Incident Reports');
- $children->LimitQueue(VALUE => 'Investigations');
- $children->LimitQueue(VALUE => 'Blocks');
- $children->LimitMemberOf($t);
+if ( grep $_ =~ /^DeleteLink-.*-MemberOf-.*$/, keys %ARGS ) {
+ my $children = new RT::Tickets( $session{'CurrentUser'} );
+ $children->LimitQueue( VALUE => 'Incident Reports' );
+ $children->LimitQueue( VALUE => 'Investigations' );
+ $children->LimitQueue( VALUE => 'Blocks' );
+ $children->LimitMemberOf( $id );
if ($children->Count == 0) {
- push (@results,
- loc("WARNING: Incident [_1] has no children.", $t));
+ push @results, loc("WARNING: Incident [_1] has no children.", $id);
}
- }
}
-# Check if the current incident still has children
-my $children;
-$children = new RT::Tickets ($session{'CurrentUser'});
-$children->LimitQueue(VALUE => 'Incident Reports');
-$children->LimitQueue(VALUE => 'Investigations');
-$children->LimitQueue(VALUE => 'Blocks');
-$children->LimitMemberOf($Ticket->Id);
-if ($children->Count == 0) {
- push (@results,
- loc("WARNING: Incident [_1] has no children.", $Ticket->Id));
+if( delete $ARGS{'Quick'} ) {
+ $m->comp( '/RTIR/Search/Results.html',
+ %ARGS,
+ Queue => $Ticket->QueueObj->Name,
+ results => \@results
+ );
+ $m->abort;
}
my $attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
More information about the Rt-commit
mailing list