Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
best-practical
rt-extension-mandatoryontransition
Commits
04f33e13
Commit
04f33e13
authored
Nov 05, 2012
by
Jim Brandt
Browse files
Use CurrentUser->loc rather than calling back into Mason
parent
7f878e3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
lib/RT/Extension/MandatoryOnTransition.pm
lib/RT/Extension/MandatoryOnTransition.pm
+18
-8
No files found.
lib/RT/Extension/MandatoryOnTransition.pm
View file @
04f33e13
...
...
@@ -284,9 +284,23 @@ sub CheckMandatoryFields {
@
_
,
);
my
$ARGSRef
=
$args
{'
ARGSRef
'};
my
@errors
;
# Some convenience variables set depending on what gets passed
my
(
$CFs
,
$CurrentUser
);
if
(
$args
{'
Ticket
'}
){
$CFs
=
$args
{'
Ticket
'}
->
CustomFields
;
$CurrentUser
=
$args
{'
Ticket
'}
->
CurrentUser
();
}
elsif
(
$args
{'
Queue
'}
){
$CFs
=
$args
{'
Queue
'}
->
TicketCustomFields
;
$CurrentUser
=
$args
{'
Queue
'}
->
CurrentUser
();
}
else
{
$
RT::
Logger
->
error
("
CheckMandatoryFields requires a Ticket object or a Queue object
");
return
\
@errors
;
}
my
(
$core
,
$cfs
)
=
$self
->
RequiredFields
(
Ticket
=>
$args
{'
Ticket
'},
Queue
=>
$args
{'
Queue
'}
?
$args
{'
Queue
'}
->
Name
:
undef
,
...
...
@@ -312,14 +326,10 @@ sub CheckMandatoryFields {
(
my
$label
=
$field
)
=~
s/(?<=[a-z])(?=[A-Z])/ /g
;
# /
push
@errors
,
HTML::Mason::Commands::
loc
("
[_1] is required when changing Status to [_2]
",
$CurrentUser
->
loc
("
[_1] is required when changing Status to [_2]
",
$label
,
$ARGSRef
->
{
Status
});
}
# Find the CFs we want
my
$CFs
=
$args
{'
Ticket
'}
?
$args
{'
Ticket
'}
->
CustomFields
:
$args
{'
Queue
'}
->
TicketCustomFields
();
if
(
not
$CFs
){
$
RT::
Logger
->
error
("
Custom Fields object required to process mandatory custom fields
");
return
\
@errors
;
...
...
@@ -344,7 +354,7 @@ sub CheckMandatoryFields {
# Is there a validation error?
if
(
not
$ValidCFs
and
my
$msg
=
$
HTML::Mason::Commands::
m
->
notes
('
InvalidField-
'
.
$cf
->
Id
))
{
push
@errors
,
loc
(
$cf
->
Name
)
.
'
:
'
.
$msg
;
push
@errors
,
$CurrentUser
->
loc
(
$cf
->
Name
)
.
'
:
'
.
$msg
;
next
;
}
...
...
@@ -361,7 +371,7 @@ sub CheckMandatoryFields {
next
if
$args
{'
Ticket
'}
&&
$cf
->
ValuesForObject
(
$args
{'
Ticket
'})
->
Count
;
push
@errors
,
HTML::Mason::Commands::
loc
("
[_1] is required when changing Status to [_2]
",
$CurrentUser
->
loc
("
[_1] is required when changing Status to [_2]
",
$cf
->
Name
,
$ARGSRef
->
{
Status
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment