From b2dc9b3e3e33eccfcc2e8a99ecce832384239aab Mon Sep 17 00:00:00 2001 From: colemanw Date: Mon, 11 Dec 2023 20:26:45 -0500 Subject: [PATCH] Fix dev/core#4852 - View notes renders as form instead of page --- CRM/Note/Form/Note.php | 24 ++++++++++++++++++++++ templates/CRM/Note/Form/Note.tpl | 35 +++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/CRM/Note/Form/Note.php b/CRM/Note/Form/Note.php index b243a2719a..9972cc6c3d 100644 --- a/CRM/Note/Form/Note.php +++ b/CRM/Note/Form/Note.php @@ -98,6 +98,10 @@ class CRM_Note_Form_Note extends CRM_Core_Form { * @return void */ public function buildQuickForm() { + if ($this->_action & CRM_Core_Action::VIEW) { + $this->view(); + return; + } if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons([ [ @@ -177,4 +181,24 @@ class CRM_Note_Form_Note extends CRM_Core_Form { CRM_Core_Session::setStatus(ts('Your Note has been saved.'), ts('Saved'), 'success'); } + /** + * View details of a note. + */ + private function view() { + $note = \Civi\Api4\Note::get() + ->addSelect('*', 'privacy:label') + ->addWhere('id', '=', $this->_id) + ->execute() + ->single(); + $note['privacy'] = $note['privacy:label']; + $this->assign('note', $note); + + $comments = CRM_Core_BAO_Note::getNoteTree($this->_id, 1); + $this->assign('comments', $comments); + + // add attachments part + $currentAttachmentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_note', $this->_id); + $this->assign('currentAttachmentInfo', $currentAttachmentInfo); + } + } diff --git a/templates/CRM/Note/Form/Note.tpl b/templates/CRM/Note/Form/Note.tpl index d458d25a95..b02126a449 100644 --- a/templates/CRM/Note/Form/Note.tpl +++ b/templates/CRM/Note/Form/Note.tpl @@ -7,8 +7,41 @@ | and copyright information, see https://civicrm.org/licensing | +--------------------------------------------------------------------+ *} +{* View action *} +{if ($action eq 4)} +
+ + + + + + + + {if $currentAttachmentInfo} + {include file="CRM/Form/attachment.tpl"} + {/if} +
{ts}Subject{/ts}{$note.subject}
{ts}Date:{/ts}{$note.note_date|crmDate}
{ts}Modified Date:{/ts}{$note.modified_date|crmDate}
{ts}Privacy:{/ts}{$note.privacy}
{ts}Note:{/ts}{$note.note|nl2br}
+
+ {crmButton class="cancel" icon="times" p='civicrm/contact/view' q="selectedChild=note&reset=1&cid=`$note.entity_id`"}{ts}Done{/ts}{/crmButton} +
+ + {if $comments} +
+ {ts}Comments{/ts} + + + + + {foreach from=$comments item=comment} + + {/foreach} +
{ts}Comment{/ts}{ts}Created By{/ts}{ts}Date{/ts}{ts}Modified Date{/ts}
{$comment.note}{$comment.createdBy}{$comment.note_date}{$comment.modified_date}
+
+ {/if} + +
{* Delete action *} -{if ($action eq 8)} +{elseif ($action eq 8)}
{ts}Are you sure you want to delete this note?{/ts}
{include file="CRM/common/formButtons.tpl" location=''}
{* Create/Update actions *} -- 2.25.1