From 68660dd360f3a6fa91f948ddbbdc72b5e05fa68a Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sat, 24 Sep 2022 13:58:17 +0100 Subject: [PATCH] Migrate single note view to API4, avoid PHP warnings --- CRM/Contact/Page/View/Note.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/CRM/Contact/Page/View/Note.php b/CRM/Contact/Page/View/Note.php index 64e810112894..0caffd6f3171 100644 --- a/CRM/Contact/Page/View/Note.php +++ b/CRM/Contact/Page/View/Note.php @@ -30,19 +30,16 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { * View details of a note. */ public function view() { - $note = new CRM_Core_DAO_Note(); - $note->id = $this->_id; - if ($note->find(TRUE)) { - - CRM_Core_DAO::storeValues($note, $this->values); - $this->values['privacy'] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Note', 'privacy', $this->values['privacy']); - $this->assign('note', $this->values); - } - - $comments = CRM_Core_BAO_Note::getNoteTree($this->values['id'], 1); - if (!empty($comments)) { - $this->assign('comments', $comments); - } + $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);