Skip to content

Commit

Permalink
fix(targetticket,targetchange): fix misuse of constants
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Aug 22, 2019
1 parent b9ad9a3 commit 04e6df0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 39 deletions.
73 changes: 40 additions & 33 deletions inc/targetbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,15 @@ protected function showCategorySettings(PluginFormcreatorForm $form, $rand) {
echo '<td width="15%">' . __('Ticket category', 'formcreator') . '</td>';
echo '<td width="25%">';
Dropdown::showFromArray(
'category_rule',
static::getEnumCategoryRule(),
[
'value' => $this->fields['category_rule'],
'on_change' => 'change_category()',
'rand' => $rand,
]);
$script = <<<EOS
'category_rule',
static::getEnumCategoryRule(),
[
'value' => $this->fields['category_rule'],
'on_change' => 'change_category()',
'rand' => $rand,
]
);
$script = <<<SCRIPT
function change_category() {
$('#category_specific_title').hide();
$('#category_specific_value').hide();
Expand All @@ -845,7 +846,7 @@ function change_category() {
}
}
change_category();
EOS;
SCRIPT;
echo Html::scriptBlock($script);
echo '</td>';
echo '<td width="15%">';
Expand Down Expand Up @@ -953,24 +954,28 @@ protected function showPluginTagsSettings(PluginFormcreatorForm $form, $rand) {
]
);

$script = <<<EOS
$tagTypeQuestions = self::TAG_TYPE_QUESTIONS;
$tagTypeSpecifics = self::TAG_TYPE_SPECIFICS;
$tagTypeQuestionAndSpecific = self::TAG_TYPE_QUESTIONS_AND_SPECIFIC;
$tagTypeQuestinOrSpecific = self::TAG_TYPE_QUESTIONS_OR_SPECIFIC;
$script = <<<SCRIPT
function change_tag_type() {
$('#tag_question_title').hide();
$('#tag_specific_title').hide();
$('#tag_question_value').hide();
$('#tag_specific_value').hide();
switch($('#dropdown_tag_type$rand').val()) {
case 'questions' :
case $tagTypeQuestions :
$('#tag_question_title').show();
$('#tag_question_value').show();
break;
case 'specifics' :
case $tagTypeSpecifics :
$('#tag_specific_title').show();
$('#tag_specific_value').show();
break;
case 'questions_and_specific' :
case 'questions_or_specific' :
case $tagTypeQuestionAndSpecific :
case $tagTypeQuestinOrSpecific :
$('#tag_question_title').show();
$('#tag_specific_title').show();
$('#tag_question_value').show();
Expand All @@ -979,7 +984,7 @@ function change_tag_type() {
}
}
change_tag_type();
EOS;
SCRIPT;

echo Html::scriptBlock($script);
echo '</td>';
Expand Down Expand Up @@ -1285,35 +1290,35 @@ protected function showActorsSettings() {
foreach ($actors['requester'] as $id => $values) {
echo '<div>';
switch ($values['actor_type']) {
case 'creator' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_CREATOR :
echo $img_user . ' <b>' . __('Form requester', 'formcreator') . '</b>';
break;
case 'validator' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_VALIDATOR :
echo $img_user . ' <b>' . __('Form validator', 'formcreator') . '</b>';
break;
case 'person' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON :
$user = new User();
$user->getFromDB($values['actor_value']);
echo $img_user . ' <b>' . __('User') . ' </b> "' . $user->getName() . '"';
break;
case 'question_person' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON :
$question = new PluginFormcreatorQuestion();
$question->getFromDB($values['actor_value']);
echo $img_user . ' <b>' . __('Person from the question', 'formcreator')
. '</b> "' . $question->getName() . '"';
break;
case 'group' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP :
$group = new Group();
$group->getFromDB($values['actor_value']);
echo $img_user . ' <b>' . __('Group') . ' </b> "' . $group->getName() . '"';
break;
case 'question_group' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP :
$question = new PluginFormcreatorQuestion();
$question->getFromDB($values['actor_value']);
echo $img_group . ' <b>' . __('Group from the question', 'formcreator')
. '</b> "' . $question->getName() . '"';
break;
case 'question_actors':
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS:
$question = new PluginFormcreatorQuestion();
$question->getFromDB($values['actor_value']);
echo $img_user . ' <b>' . __('Actors from the question', 'formcreator')
Expand Down Expand Up @@ -1424,35 +1429,35 @@ protected function showActorsSettings() {
foreach ($actors['observer'] as $id => $values) {
echo '<div>';
switch ($values['actor_type']) {
case 'creator' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_CREATOR :
echo $img_user . ' <b>' . __('Form requester', 'formcreator') . '</b>';
break;
case 'validator' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_VALIDATOR :
echo $img_user . ' <b>' . __('Form validator', 'formcreator') . '</b>';
break;
case 'person' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON :
$user = new User();
$user->getFromDB($values['actor_value']);
echo $img_user . ' <b>' . __('User') . ' </b> "' . $user->getName() . '"';
break;
case 'question_person' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON :
$question = new PluginFormcreatorQuestion();
$question->getFromDB($values['actor_value']);
echo $img_user . ' <b>' . __('Person from the question', 'formcreator')
. '</b> "' . $question->getName() . '"';
break;
case 'group' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP :
$group = new Group();
$group->getFromDB($values['actor_value']);
echo $img_user . ' <b>' . __('Group') . ' </b> "' . $group->getName() . '"';
break;
case 'question_group' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP :
$question = new PluginFormcreatorQuestion();
$question->getFromDB($values['actor_value']);
echo $img_group . ' <b>' . __('Group from the question', 'formcreator')
. '</b> "' . $question->getName() . '"';
break;
case 'question_actors' :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS :
$question = new PluginFormcreatorQuestion();
$question->getFromDB($values['actor_value']);
echo $img_user . ' <b>' . __('Actors from the question', 'formcreator')
Expand Down Expand Up @@ -1656,26 +1661,28 @@ protected function showLocationSettings(PluginFormcreatorForm $form, $rand) {
'on_change' => 'change_location()',
'rand' => $rand
]);
$script = <<<JAVASCRIPT
$locationRuleAnswer = self::CATEGORY_RULE_ANSWER;
$locationRuleSpecific = self::CATEGORY_RULE_SPECIFIC;
$script = <<<SCRIPT
function change_location() {
$('#location_specific_title').hide();
$('#location_specific_value').hide();
$('#location_question_title').hide();
$('#location_question_value').hide();
switch($('#dropdown_location_rule$rand').val()) {
case self::LOCATION_RULE_ANSWER :
case $locationRuleAnswer :
$('#location_question_title').show();
$('#location_question_value').show();
break;
case self::LOCATION_RULE_SPECIFIC:
case $locationRuleSpecific :
$('#location_specific_title').show();
$('#location_specific_value').show();
break;
}
}
change_location();
JAVASCRIPT;
SCRIPT;
echo Html::scriptBlock($script);
echo '</td>';
echo '<td width="15%">';
Expand Down
14 changes: 8 additions & 6 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ protected function showCompositeTicketSettings($rand) {
'on_change' => 'updateCompositePeerType()',
'rand' => $rand,
]);
$script = <<<EOS
$script = <<<SCRIPT
function updateCompositePeerType() {
if ($('#dropdown__link_itemtype$rand').val() == 'Ticket') {
$('#plugin_formcreator_link_ticket').show();
Expand All @@ -254,7 +254,7 @@ function updateCompositePeerType() {
}
}
updateCompositePeerType();
EOS;
SCRIPT;
echo Html::scriptBlock($script);
// get already linked items
$targetTicketId = $this->getID();
Expand Down Expand Up @@ -799,26 +799,28 @@ protected function showAssociateSettings($rand) {
'on_change' => 'change_associate()',
'rand' => $rand
]);
$script = <<<JAVASCRIPT
$ruleAnswer = self::ASSOCIATE_RULE_ANSWER;
$ruleSpecific = self::ASSOCIATE_RULE_SPECIFIC;
$script = <<<SCRIPT
function change_associate() {
$('#associate_specific_title').hide();
$('#associate_specific_value').hide();
$('#associate_question_title').hide();
$('#associate_question_value').hide();
switch($('#dropdown_associate_rule$rand').val()) {
case self::ASSOCIATE_RULE_ANSWER :
case $ruleAnswer:
$('#associate_question_title').show();
$('#associate_question_value').show();
break;
case self::ASSOCIATE_RULE_SPECIFIC:
case $ruleSpecific:
$('#associate_specific_title').show();
$('#associate_specific_value').show();
break;
}
}
change_associate();
JAVASCRIPT;
SCRIPT;
echo Html::scriptBlock($script);
echo '</td>';
echo '<td width="15%">';
Expand Down

0 comments on commit 04e6df0

Please sign in to comment.