(REF) civicrm/mailing/unsubscribe - Add page-controller in front of form-controller
authorTim Otten <totten@civicrm.org>
Wed, 10 Jan 2024 21:54:41 +0000 (13:54 -0800)
committerTim Otten <totten@civicrm.org>
Fri, 12 Jan 2024 21:46:37 +0000 (13:46 -0800)
Before: `civicrm/mailing/unsubscribe` points directly to `CRM_Mailing_Form_Unsubscribe`

After: `civicrm/mailing/unsubscribe` points to `CRM_Mailing_Page_Unsubscribe`, which MAY delegate
to `CRM_Mailing_Form_Unsubscribe`

Comments:

* This is a step toward supporting one-click subscribe.
    * The problem is that one-click unsubscribe MUST receive a POST on the same URL
      as a user-visible form.
    * In Quickform (esp `CRM_Mailing_Form_Unsubscribe`), every POST MUST give a `qfKey`.
    * We need a place to process the one-click POST *without* requiring `qfKey`.
* There is a pre-existing class `CRM_Mailing_Page_Unsubscribe`. This was dead code.
  The patch co-opts/re-uses the class for its own purpose.
    * The old `Page` class was not referenced anywhere (by routes or other classes).
    * What appears to have happened: this screen was originally a `Page`; then it was
      renamed/converted to a `Form`; then shortly after, the original `Page` was re-imported
      verbatim by a gsoc student. Their commit doesn't appear to make substantive use of
      the `Page`. This smells like mistake in handling branches/merges/rebases.

CRM/Mailing/Page/Unsubscribe.php
CRM/Mailing/xml/Menu/Mailing.xml

index 349ee59d2a7afa9513ce00b7a1312cd35c19e06d..3db0708a20a12c0c2aecca61dbd8374379f13044 100644 (file)
@@ -14,7 +14,7 @@
  * @package CRM
  * @copyright CiviCRM LLC https://civicrm.org/licensing
  */
-class CRM_Mailing_Page_Unsubscribe extends CRM_Mailing_Page_Common {
+class CRM_Mailing_Page_Unsubscribe extends CRM_Core_Page {
 
   /**
    * Run page.
@@ -25,8 +25,8 @@ class CRM_Mailing_Page_Unsubscribe extends CRM_Mailing_Page_Common {
    * @throws Exception
    */
   public function run() {
-    $this->_type = 'unsubscribe';
-    return parent::run();
+    $wrapper = new CRM_Utils_Wrapper();
+    return $wrapper->run('CRM_Mailing_Form_Unsubscribe', $this->_title);
   }
 
 }
index f3267235d3b0e63651ed96864091c427d07cb84f..7942323fad17df99e2e3f0314443020042dbd53e 100644 (file)
   <item>
     <path>civicrm/mailing/unsubscribe</path>
     <title>Unsubscribe</title>
-    <page_callback>CRM_Mailing_Form_Unsubscribe</page_callback>
+    <page_callback>CRM_Mailing_Page_Unsubscribe</page_callback>
     <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
     <is_public>true</is_public>
     <weight>640</weight>