Skip to content

Conversation

@accognet
Copy link
Contributor

internal

@accognet accognet self-assigned this Sep 15, 2025
@accognet accognet added the internal Work made by Combodo label Sep 15, 2025
@Molkobain Molkobain requested a review from Copilot January 28, 2026 20:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements functionality to display read-only fields during state transitions in iTop's workflow management system. The change enables fields marked with the OPT_ATT_READONLY flag to be displayed to users during transitions, providing visibility into field values that cannot be edited.

Changes:

  • Added logic to handle OPT_ATT_READONLY flagged attributes in the DisplayStimulusForm method
  • Refactored variable initialization to move $oAttDef earlier in the code flow
  • Fixed code style issues with brace formatting
  • Removed redundant variable reassignments

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'value' => "<span id=\"field_att_$iFieldIndex\">$sHTMLValue</span>",
);
}
if (($iExpectCode & OPT_ATT_READONLY) ){
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here has a potential issue. When a field has both MUSTCHANGE/MUSTPROMPT flags AND READONLY flags, the first block (lines 3275-3324) will execute and create an editable form field, but then the second block (lines 3325-3332) will overwrite $aAttrib with a readonly display. This means the READONLY flag takes precedence, which may not be the intended behavior. Consider using 'else if' instead of a separate 'if' to ensure mutual exclusivity between editable and readonly display modes.

Suggested change
if (($iExpectCode & OPT_ATT_READONLY) ){
elseif (($iExpectCode & OPT_ATT_READONLY) ){

Copilot uses AI. Check for mistakes.
Comment on lines +3325 to +3332
if (($iExpectCode & OPT_ATT_READONLY) ){
$bIsPrompt = true;
$sHTMLValue = $this->GetAsHTML($sAttCode);
$aAttrib = array(
'label' => '<span>'.$oAttDef->GetLabel().'</span>',
'value' => "<span id=\"field_att_$iFieldIndex\">$sHTMLValue</span>",
);

}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a field has the OPT_ATT_READONLY flag, the variables $sInputId and $sInputType are undefined, but they are used later at lines 3346-3347 when $bIsPrompt is true. This will result in PHP notices or undefined variable errors. These variables need to be initialized before the readonly block, similar to how they are initialized in the first condition block at line 3306.

Copilot uses AI. Check for mistakes.
Comment on lines +3320 to 3331
$aAttrib = array(
'label' => '<span>'.$oAttDef->GetLabel().'</span>',
'value' => "<span id=\"field_att_$iFieldIndex\">$sHTMLValue</span>",
);
}
if (($iExpectCode & OPT_ATT_READONLY) ){
$bIsPrompt = true;
$sHTMLValue = $this->GetAsHTML($sAttCode);
$aAttrib = array(
'label' => '<span>'.$oAttDef->GetLabel().'</span>',
'value' => "<span id=\"field_att_$iFieldIndex\">$sHTMLValue</span>",
);
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is code duplication between lines 3320-3323 and lines 3328-3331. Both blocks create the same $aAttrib array structure with 'label' and 'value' keys. The only difference is how $sHTMLValue is obtained. Consider refactoring to avoid this duplication by computing $sHTMLValue conditionally and then constructing $aAttrib once.

Copilot uses AI. Check for mistakes.
);

}
if($bIsPrompt) {
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after 'if' keyword. The codebase follows a consistent style of having a space between 'if' and the opening parenthesis, as seen on lines 3275, 3280, 3299, and throughout the file.

Suggested change
if($bIsPrompt) {
if ($bIsPrompt) {

Copilot uses AI. Check for mistakes.
'value' => "<span id=\"field_att_$iFieldIndex\">$sHTMLValue</span>",
);
}
if (($iExpectCode & OPT_ATT_READONLY) ){
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space after opening parenthesis. The codebase consistently places the opening parenthesis immediately after the condition without a trailing space, as seen throughout the file (e.g., lines 3275, 3280, 3299).

Suggested change
if (($iExpectCode & OPT_ATT_READONLY) ){
if (($iExpectCode & OPT_ATT_READONLY)) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants