From d51b4af603bdbe09f3244a6d23859007a7f23284 Mon Sep 17 00:00:00 2001 From: brianPHMatemachani Date: Thu, 13 Jun 2019 19:34:27 +0100 Subject: [PATCH] Bugfix - getting id from hash (#14508) * Bugfix - getting id from hash * Styling changes, using single quotes as preferred. * Correcting public link when hashed url is set * Bugfix : correcting if statement. Public link setting the hash instead of id when 'hashed' setting is on. * Coding standards changes. Spacing after close parenthesis and space after keyword --- CRM/Mailing/BAO/Mailing.php | 7 +++++++ CRM/Mailing/Page/View.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index dcc8d46d55..9a24f8a9a8 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -3064,6 +3064,13 @@ ORDER BY civicrm_mailing.name"; 'id' => $id, 'return' => 'visibility', ])) === 'Public Pages') { + + // if hash setting is on then we change the public url into a hash + $hash = CRM_Mailing_BAO_Mailing::getMailingHash($id); + if (!empty($hash)) { + $id = $hash; + } + return CRM_Utils_System::url('civicrm/mailing/view', ['id' => $id], $absolute, NULL, TRUE, TRUE); } } diff --git a/CRM/Mailing/Page/View.php b/CRM/Mailing/Page/View.php index a6f03660f2..878434004e 100644 --- a/CRM/Mailing/Page/View.php +++ b/CRM/Mailing/Page/View.php @@ -113,7 +113,14 @@ class CRM_Mailing_Page_View extends CRM_Core_Page { $this->_mailing = new CRM_Mailing_BAO_Mailing(); if (!is_numeric($this->_mailingID)) { + + //lets get the id from the hash + $result_id = civicrm_api3('Mailing', 'get', [ + 'return' => ['id'], + 'hash' => $this->_mailingID, + ]); $this->_mailing->hash = $this->_mailingID; + $this->_mailingID = $result_id['id']; } elseif (is_numeric($this->_mailingID)) { $this->_mailing->id = $this->_mailingID; -- 2.25.1