Skip to content

Commit 04e6df0

Browse files
committed
fix(targetticket,targetchange): fix misuse of constants
Signed-off-by: Thierry Bugier <[email protected]>
1 parent b9ad9a3 commit 04e6df0

File tree

2 files changed

+48
-39
lines changed

2 files changed

+48
-39
lines changed

inc/targetbase.class.php

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -819,14 +819,15 @@ protected function showCategorySettings(PluginFormcreatorForm $form, $rand) {
819819
echo '<td width="15%">' . __('Ticket category', 'formcreator') . '</td>';
820820
echo '<td width="25%">';
821821
Dropdown::showFromArray(
822-
'category_rule',
823-
static::getEnumCategoryRule(),
824-
[
825-
'value' => $this->fields['category_rule'],
826-
'on_change' => 'change_category()',
827-
'rand' => $rand,
828-
]);
829-
$script = <<<EOS
822+
'category_rule',
823+
static::getEnumCategoryRule(),
824+
[
825+
'value' => $this->fields['category_rule'],
826+
'on_change' => 'change_category()',
827+
'rand' => $rand,
828+
]
829+
);
830+
$script = <<<SCRIPT
830831
function change_category() {
831832
$('#category_specific_title').hide();
832833
$('#category_specific_value').hide();
@@ -845,7 +846,7 @@ function change_category() {
845846
}
846847
}
847848
change_category();
848-
EOS;
849+
SCRIPT;
849850
echo Html::scriptBlock($script);
850851
echo '</td>';
851852
echo '<td width="15%">';
@@ -953,24 +954,28 @@ protected function showPluginTagsSettings(PluginFormcreatorForm $form, $rand) {
953954
]
954955
);
955956

956-
$script = <<<EOS
957+
$tagTypeQuestions = self::TAG_TYPE_QUESTIONS;
958+
$tagTypeSpecifics = self::TAG_TYPE_SPECIFICS;
959+
$tagTypeQuestionAndSpecific = self::TAG_TYPE_QUESTIONS_AND_SPECIFIC;
960+
$tagTypeQuestinOrSpecific = self::TAG_TYPE_QUESTIONS_OR_SPECIFIC;
961+
$script = <<<SCRIPT
957962
function change_tag_type() {
958963
$('#tag_question_title').hide();
959964
$('#tag_specific_title').hide();
960965
$('#tag_question_value').hide();
961966
$('#tag_specific_value').hide();
962967
963968
switch($('#dropdown_tag_type$rand').val()) {
964-
case 'questions' :
969+
case $tagTypeQuestions :
965970
$('#tag_question_title').show();
966971
$('#tag_question_value').show();
967972
break;
968-
case 'specifics' :
973+
case $tagTypeSpecifics :
969974
$('#tag_specific_title').show();
970975
$('#tag_specific_value').show();
971976
break;
972-
case 'questions_and_specific' :
973-
case 'questions_or_specific' :
977+
case $tagTypeQuestionAndSpecific :
978+
case $tagTypeQuestinOrSpecific :
974979
$('#tag_question_title').show();
975980
$('#tag_specific_title').show();
976981
$('#tag_question_value').show();
@@ -979,7 +984,7 @@ function change_tag_type() {
979984
}
980985
}
981986
change_tag_type();
982-
EOS;
987+
SCRIPT;
983988

984989
echo Html::scriptBlock($script);
985990
echo '</td>';
@@ -1285,35 +1290,35 @@ protected function showActorsSettings() {
12851290
foreach ($actors['requester'] as $id => $values) {
12861291
echo '<div>';
12871292
switch ($values['actor_type']) {
1288-
case 'creator' :
1293+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_CREATOR :
12891294
echo $img_user . ' <b>' . __('Form requester', 'formcreator') . '</b>';
12901295
break;
1291-
case 'validator' :
1296+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_VALIDATOR :
12921297
echo $img_user . ' <b>' . __('Form validator', 'formcreator') . '</b>';
12931298
break;
1294-
case 'person' :
1299+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON :
12951300
$user = new User();
12961301
$user->getFromDB($values['actor_value']);
12971302
echo $img_user . ' <b>' . __('User') . ' </b> "' . $user->getName() . '"';
12981303
break;
1299-
case 'question_person' :
1304+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON :
13001305
$question = new PluginFormcreatorQuestion();
13011306
$question->getFromDB($values['actor_value']);
13021307
echo $img_user . ' <b>' . __('Person from the question', 'formcreator')
13031308
. '</b> "' . $question->getName() . '"';
13041309
break;
1305-
case 'group' :
1310+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP :
13061311
$group = new Group();
13071312
$group->getFromDB($values['actor_value']);
13081313
echo $img_user . ' <b>' . __('Group') . ' </b> "' . $group->getName() . '"';
13091314
break;
1310-
case 'question_group' :
1315+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP :
13111316
$question = new PluginFormcreatorQuestion();
13121317
$question->getFromDB($values['actor_value']);
13131318
echo $img_group . ' <b>' . __('Group from the question', 'formcreator')
13141319
. '</b> "' . $question->getName() . '"';
13151320
break;
1316-
case 'question_actors':
1321+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS:
13171322
$question = new PluginFormcreatorQuestion();
13181323
$question->getFromDB($values['actor_value']);
13191324
echo $img_user . ' <b>' . __('Actors from the question', 'formcreator')
@@ -1424,35 +1429,35 @@ protected function showActorsSettings() {
14241429
foreach ($actors['observer'] as $id => $values) {
14251430
echo '<div>';
14261431
switch ($values['actor_type']) {
1427-
case 'creator' :
1432+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_CREATOR :
14281433
echo $img_user . ' <b>' . __('Form requester', 'formcreator') . '</b>';
14291434
break;
1430-
case 'validator' :
1435+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_VALIDATOR :
14311436
echo $img_user . ' <b>' . __('Form validator', 'formcreator') . '</b>';
14321437
break;
1433-
case 'person' :
1438+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON :
14341439
$user = new User();
14351440
$user->getFromDB($values['actor_value']);
14361441
echo $img_user . ' <b>' . __('User') . ' </b> "' . $user->getName() . '"';
14371442
break;
1438-
case 'question_person' :
1443+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON :
14391444
$question = new PluginFormcreatorQuestion();
14401445
$question->getFromDB($values['actor_value']);
14411446
echo $img_user . ' <b>' . __('Person from the question', 'formcreator')
14421447
. '</b> "' . $question->getName() . '"';
14431448
break;
1444-
case 'group' :
1449+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP :
14451450
$group = new Group();
14461451
$group->getFromDB($values['actor_value']);
14471452
echo $img_user . ' <b>' . __('Group') . ' </b> "' . $group->getName() . '"';
14481453
break;
1449-
case 'question_group' :
1454+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP :
14501455
$question = new PluginFormcreatorQuestion();
14511456
$question->getFromDB($values['actor_value']);
14521457
echo $img_group . ' <b>' . __('Group from the question', 'formcreator')
14531458
. '</b> "' . $question->getName() . '"';
14541459
break;
1455-
case 'question_actors' :
1460+
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS :
14561461
$question = new PluginFormcreatorQuestion();
14571462
$question->getFromDB($values['actor_value']);
14581463
echo $img_user . ' <b>' . __('Actors from the question', 'formcreator')
@@ -1656,26 +1661,28 @@ protected function showLocationSettings(PluginFormcreatorForm $form, $rand) {
16561661
'on_change' => 'change_location()',
16571662
'rand' => $rand
16581663
]);
1659-
$script = <<<JAVASCRIPT
1664+
$locationRuleAnswer = self::CATEGORY_RULE_ANSWER;
1665+
$locationRuleSpecific = self::CATEGORY_RULE_SPECIFIC;
1666+
$script = <<<SCRIPT
16601667
function change_location() {
16611668
$('#location_specific_title').hide();
16621669
$('#location_specific_value').hide();
16631670
$('#location_question_title').hide();
16641671
$('#location_question_value').hide();
16651672
16661673
switch($('#dropdown_location_rule$rand').val()) {
1667-
case self::LOCATION_RULE_ANSWER :
1674+
case $locationRuleAnswer :
16681675
$('#location_question_title').show();
16691676
$('#location_question_value').show();
16701677
break;
1671-
case self::LOCATION_RULE_SPECIFIC:
1678+
case $locationRuleSpecific :
16721679
$('#location_specific_title').show();
16731680
$('#location_specific_value').show();
16741681
break;
16751682
}
16761683
}
16771684
change_location();
1678-
JAVASCRIPT;
1685+
SCRIPT;
16791686
echo Html::scriptBlock($script);
16801687
echo '</td>';
16811688
echo '<td width="15%">';

inc/targetticket.class.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ protected function showCompositeTicketSettings($rand) {
243243
'on_change' => 'updateCompositePeerType()',
244244
'rand' => $rand,
245245
]);
246-
$script = <<<EOS
246+
$script = <<<SCRIPT
247247
function updateCompositePeerType() {
248248
if ($('#dropdown__link_itemtype$rand').val() == 'Ticket') {
249249
$('#plugin_formcreator_link_ticket').show();
@@ -254,7 +254,7 @@ function updateCompositePeerType() {
254254
}
255255
}
256256
updateCompositePeerType();
257-
EOS;
257+
SCRIPT;
258258
echo Html::scriptBlock($script);
259259
// get already linked items
260260
$targetTicketId = $this->getID();
@@ -799,26 +799,28 @@ protected function showAssociateSettings($rand) {
799799
'on_change' => 'change_associate()',
800800
'rand' => $rand
801801
]);
802-
$script = <<<JAVASCRIPT
802+
$ruleAnswer = self::ASSOCIATE_RULE_ANSWER;
803+
$ruleSpecific = self::ASSOCIATE_RULE_SPECIFIC;
804+
$script = <<<SCRIPT
803805
function change_associate() {
804806
$('#associate_specific_title').hide();
805807
$('#associate_specific_value').hide();
806808
$('#associate_question_title').hide();
807809
$('#associate_question_value').hide();
808810
809811
switch($('#dropdown_associate_rule$rand').val()) {
810-
case self::ASSOCIATE_RULE_ANSWER :
812+
case $ruleAnswer:
811813
$('#associate_question_title').show();
812814
$('#associate_question_value').show();
813815
break;
814-
case self::ASSOCIATE_RULE_SPECIFIC:
816+
case $ruleSpecific:
815817
$('#associate_specific_title').show();
816818
$('#associate_specific_value').show();
817819
break;
818820
}
819821
}
820822
change_associate();
821-
JAVASCRIPT;
823+
SCRIPT;
822824
echo Html::scriptBlock($script);
823825
echo '</td>';
824826
echo '<td width="15%">';

0 commit comments

Comments
 (0)