Bugfix - getting id from hash (#14508)
authorbrianPHMatemachani <matema002@gmail.com>
Thu, 13 Jun 2019 18:34:27 +0000 (19:34 +0100)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 13 Jun 2019 18:34:27 +0000 (14:34 -0400)
* 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
CRM/Mailing/Page/View.php

index dcc8d46d55d3366fe195974b3b1bf3b03628ff72..9a24f8a9a821fff24f22d26346cd1a306dbd5d44 100644 (file)
@@ -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);
     }
   }
index a6f03660f2be884beae482f9fa07989ccfb9215b..878434004ea5d9b30c4aa23fe393b885621d41dc 100644 (file)
@@ -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;