From: colemanw Date: Tue, 12 Dec 2023 01:26:45 +0000 (-0500) Subject: Fix dev/core#4852 - View notes renders as form instead of page X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b2dc9b3e3e33eccfcc2e8a99ecce832384239aab;p=civicrm-core.git Fix dev/core#4852 - View notes renders as form instead of page --- 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 *}