summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Action/StallDependent.pm
diff options
context:
space:
mode:
authorivan <ivan>2002-08-12 06:17:09 +0000
committerivan <ivan>2002-08-12 06:17:09 +0000
commit3ef62a0570055da710328937e7f65dbb2c027c62 (patch)
treed549158b172fd499b4f81a2981b62aabbde4f99b /rt/lib/RT/Action/StallDependent.pm
parent030438c9cb1c12ccb79130979ef0922097b4311a (diff)
import rt 2.0.14
Diffstat (limited to 'rt/lib/RT/Action/StallDependent.pm')
-rw-r--r--rt/lib/RT/Action/StallDependent.pm68
1 files changed, 68 insertions, 0 deletions
diff --git a/rt/lib/RT/Action/StallDependent.pm b/rt/lib/RT/Action/StallDependent.pm
new file mode 100644
index 0000000..09d3448
--- /dev/null
+++ b/rt/lib/RT/Action/StallDependent.pm
@@ -0,0 +1,68 @@
+# This Action will stall the BASE if a dependency or membership link
+# (according to argument) is created and if BASE is open.
+
+# TODO: Rename this .pm
+
+package RT::Action::StallDependent;
+require RT::Action::Generic;
+@ISA=qw|RT::Action::Generic|;
+
+# {{{ sub Describe
+sub Describe {
+ my $self = shift;
+ return (ref $self . " will stall a [local] BASE if it's dependent [or member] of a linked up request.");
+}
+# }}}
+
+
+# {{{ sub Prepare
+sub Prepare {
+ # nothing to prepare
+ return 1;
+}
+# }}}
+
+sub Commit {
+ my $self = shift;
+ # Find all Dependent
+ my $arg=$self->Argument || "DependsOn";
+ unless ($self->TransactionObj->Data =~ /^([^ ]+) $arg /) {
+ warn; return 0;
+ }
+ my $base_id=$1;
+ my $base;
+ if ($1 eq "THIS") {
+ $base=$self->TicketObj;
+ } else {
+ $base_id=&RT::Link::_IsLocal(undef, $base_id) || return 0;
+ $base=RT::Ticket->new($self->TicketObj->CurrentUser);
+ $base->Load($base_id);
+ }
+ $base->Stall if $base->Status eq 'open';
+ return 0;
+}
+
+
+# {{{ sub IsApplicable
+
+# Only applicable if:
+# 1. the link action is a dependency
+# 2. BASE is a local ticket
+
+sub IsApplicable {
+ my $self = shift;
+
+ my $arg=$self->Argument || "DependsOn";
+
+ # 1:
+ $self->TransactionObj->Data =~ /^([^ ]*) $arg / || return 0;
+
+ # 2:
+ # (dirty!)
+ &RT::Link::_IsLocal(undef,$1) || return 0;
+
+ return 1;
+}
+# }}}
+
+1;