Skip to content

Commit

Permalink
fix(AclField): detect if comments are closed when editing entry
Browse files Browse the repository at this point in the history
  • Loading branch information
J9rem committed Jan 17, 2023
1 parent a3adfbb commit b9937ac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/bazar/fields/AclField.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AclField extends BazarField
'non' => 'NO',
];
public const OPTION_YES = 'oui';
public const OPTION_NO = 'non';

protected const FIELD_ENTRY_READ_RIGHT = 1;
protected const FIELD_ENTRY_WRITE_RIGHT = 2;
Expand Down Expand Up @@ -70,9 +71,14 @@ protected function filterNotEmptyString(array $data, string $key, ?string $defau

protected function renderInput($entry)
{
$commentsAlreadyClosed = false;
if (!empty($entry['id_fiche'])){
$currentCommentAcl = $this->aclService->load($entry['id_fiche'], 'comment', false);
$commentsAlreadyClosed = (!empty($currentCommentAcl['list']) && $currentCommentAcl['list'] == 'comments-closed');
}
return ($this->askIfActivateComments)
? $this->render('@bazar/inputs/comments.twig', [
'value' => $this->getValue($entry),
'value' => $commentsAlreadyClosed ? self::OPTION_NO : $this->getValue($entry),
'options' => $this->getOptions(),
'showAlertForCommentsNotActivated' =>
in_array($this->getCommentsType(), ['','yeswiki']) &&
Expand Down

0 comments on commit b9937ac

Please sign in to comment.