[Bps-public-commit] RT-Extension-MandatoryOnTransition branch, support-coreroles-and-customroles, repushed
Craig Kaiser
craig at bestpractical.com
Fri Jan 11 17:14:19 EST 2019
The branch support-coreroles-and-customroles was deleted and repushed:
was b06051524b7dca2ff8655f85baf6c9911147ee01
now eec1d04e1df6fe48d85be4c502704c926cbe4730
1: fa95e1a = 1: fa95e1a Support customroles for mandatoryontransition conditions
2: 78217cc ! 2: 6da4599 Support core roles for mandatoryontransation
@@ -10,7 +10,7 @@
grep { /^CF\./i } @$required;
my @roles = map { /^(:?[CustomRole\.]?.+)$/i; $1; }
- grep { /^CustomRole\./i } @$required;
-+ grep { /^CustomRole\.|^AdminCc|^Cc|^Requestor|^Owner/i } @$required;
++ grep { /^CustomRole\.|^AdminCc|^Cc|^Requestor/i } @$required;
# Pull out any must_be or must_not_be rules
my %cf_must_values = ();
@@ -49,7 +49,7 @@
- push @errors, $CurrentUser->loc("$msg") unless $ret;
- return \@errors unless $ret;
+ ($ret, $msg) = $role_values = $args{Ticket}->RoleGroup($role_object->GroupType);
-+ push @errors, $CurrentUser->loc("$msg") unless $ret;
++ push @errors, $CurrentUser->loc("Could not load current user") unless $ret;
+ return \@errors unless $ret;
+ } else {
+ $role_values = RT::Group->new($args{Ticket}->CurrentUser);
@@ -60,4 +60,14 @@
my @role_values;
my @row_input_id = grep $role_arg eq $ARGSRef->{$_}, keys %{$ARGSRef};
+@@
+ push @role_values, @temp_array if scalar @temp_array;
+
+ if ( not scalar @role_values ) {
+- push @errors, "Requires value for $role to perform action.";
++ push @errors, $CurrentUser->loc("[_1] is required when changing [_2] to [_3]",
++ $role, $CurrentUser->loc("$transition"), $CurrentUser->loc($args{To}));
+ return \@errors;
+ }
+ return \@errors if scalar @errors;
3: 0fdd060 ! 3: 3bb91be Allow group key to be set for roles
@@ -10,8 +10,8 @@
--- a/lib/RT/Extension/MandatoryOnTransition.pm
+++ b/lib/RT/Extension/MandatoryOnTransition.pm
@@
- if ( not scalar @role_values ) {
- push @errors, "Requires value for $role to perform action.";
+ push @errors, $CurrentUser->loc("[_1] is required when changing [_2] to [_3]",
+ $role, $CurrentUser->loc("$transition"), $CurrentUser->loc($args{To}));
return \@errors;
+ } elsif ( $role_group_values->{$role_full}->{group} ) {
+ my $group_name = $role_group_values->{$role_full}->{group};
4: 845bd08 ! 4: aef2cc5 Move Owner code into the roles code block
@@ -31,6 +31,15 @@
);
=head2 Methods
+@@
+ my @cfs = map { /^CF\.(.+)$/i; $1; }
+ grep { /^CF\./i } @$required;
+ my @roles = map { /^(:?[CustomRole\.]?.+)$/i; $1; }
+- grep { /^CustomRole\.|^AdminCc|^Cc|^Requestor/i } @$required;
++ grep { /^CustomRole\.|^AdminCc|^Cc|^Requestor|^Owner/i } @$required;
+
+ # Pull out any must_be or must_not_be rules
+ my %cf_must_values = ();
@@
: $CORE_FOR_CREATE{$field};
next unless $arg;
@@ -70,33 +79,38 @@
# Do we have a value currently?
@@
($ret, $msg) = $role_values = $args{Ticket}->RoleGroup($role_object->GroupType);
- push @errors, $CurrentUser->loc("$msg") unless $ret;
+ push @errors, $CurrentUser->loc("Could not load current user") unless $ret;
return \@errors unless $ret;
-+ } elsif ( $role =~ 'Owner' ) {
++ } elsif ( $role eq 'Owner' ) {
+ my $value;
-+ foreach my $owner (@{$ARGSRef->{$role}}) {
-+ if (defined($owner) && $owner =~ /\D/) {
-+ $value = $owner unless ($args{'Ticket'}->OwnerObj->Name eq $owner);
-+ }
-+ elsif (length $owner) {
-+ $value = $owner unless ($args{'Ticket'}->OwnerObj->id == $owner);
-+ }
++ # There are 2 Owner fields on Jumbo page, copied the same handling from it.
++ if (ref $ARGSRef->{$role}) {
++ foreach my $owner (@{$ARGSRef->{$role}}) {
++ if (defined($owner) && $owner =~ /\D/) {
++ $value = $owner unless ($args{'Ticket'}->OwnerObj->Name eq $owner);
++ } elsif (length $owner) {
++ $value = $owner unless ($args{'Ticket'}->OwnerObj->id == $owner);
++ }
++ }
++ } else {
++ $value = $ARGSRef->{$role};
+ }
+ if (($value || $args{'Ticket'}->$role()) == $RT::Nobody->id) {
+ push @errors,
+ $CurrentUser->loc(
+ "[_1] is required when changing [_2] to [_3]",
+ $role,
-+ $CurrentUser->loc($args{From}),
++ $CurrentUser->loc($transition),
+ $CurrentUser->loc($args{To})
+ );
++ } else {
++ my $user = RT::User->new($args{Ticket}->CurrentUser);
++ my ($ret, $msg) = $user->Load($value);
++ push @errors, $CurrentUser->loc("Could not load user: $value") unless $ret;
++ return \@errors unless $ret;
++
++ $role_values = $user->EmailAddress;
+ }
-+ my $user = RT::User->new($args{Ticket}->CurrentUser);
-+ my ($ret, $msg) = $user->Load($value);
-+ push @errors, $CurrentUser->loc("$msg") unless $ret;
-+ return \@errors unless $ret;
-+
-+ $role_values = $user->EmailAddress;
} else {
$role_values = RT::Group->new($args{Ticket}->CurrentUser);
my ($ret, $msg) = $role_values->LoadRoleGroup(Object => $args{Ticket}, Name => $role);
@@ -120,5 +134,5 @@
+ }
if ( not scalar @role_values ) {
- push @errors, "Requires value for $role to perform action.";
+ push @errors, $CurrentUser->loc("[_1] is required when changing [_2] to [_3]",
5: b060515 ! 5: 872c6d2 Update README
@@ -71,3 +71,4 @@
=head2 Restrictions on Queue Transitions
The default behavior for C<MandatoryOnTransition> operates on status transitions,
+
-: ------- > 6: eec1d04 Create test file for role mandatory fields
More information about the Bps-public-commit
mailing list