Always assign noCid when the tpl is included
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 21 Sep 2023 05:19:43 +0000 (17:19 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 21 Sep 2023 05:19:43 +0000 (17:19 +1200)
Fixes notices by moving the assign out of the function that adds the form elements

This one only matters when smarty is in secure mode:

CRM/Contribute/Form/Contribution/Main.php
CRM/Core/Form.php
CRM/Event/Form/Registration/Register.php
templates/CRM/Member/Form/MembershipType.tpl
templates/CRM/common/cidzero.tpl

index 38f9126f70cfe26282a587fd32c4b41b3d4de98a..0c4c36bef11e535fd17ee11a9a70f1b4cc7c4ac0 100644 (file)
@@ -321,10 +321,9 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     $this->addPaymentProcessorFieldsToForm();
     $this->assign('is_pay_later', $this->getCurrentPaymentProcessor() === 0 && $this->_values['is_pay_later']);
     $this->assign('pay_later_text', $this->getCurrentPaymentProcessor() === 0 ? $this->getPayLaterLabel() : NULL);
-
+    $this->assign('nocid', $contactID === 0);
     if ($contactID === 0) {
       $this->addCidZeroOptions();
-
     }
 
     //build pledge block.
index d02840cd4425337884e0b3e80b0a1df4e16923ac..237c2af2dd1ce11b7801e620cd7b2e6579c77bdb 100644 (file)
@@ -2614,7 +2614,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    * and a dozen other small ones to be refactored into a shared parent with the reduction of much code duplication
    */
   public function addCIDZeroOptions() {
-    $this->assign('nocid', TRUE);
     $profiles = [];
     if ($this->_values['custom_pre_id']) {
       $profiles[] = $this->_values['custom_pre_id'];
index 82321a0cdeb1c86da78fe99a9c153bd5f1e1e5da..1a3e3adc149158c6a615ad70cddba7cb816bf18a 100644 (file)
@@ -430,8 +430,9 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
         $this->addPaymentProcessorFieldsToForm();
       }
     }
-
-    if ($contactID === 0 && !$this->_values['event']['is_multiple_registrations']) {
+    $isSelectContactID = ($contactID === 0 && !$this->_values['event']['is_multiple_registrations']);
+    $this->assign('nocid', $isSelectContactID);
+    if ($isSelectContactID) {
       //@todo we are blocking for multiple registrations because we haven't tested
       $this->addCIDZeroOptions();
     }
index e6106b044fd68af996f9eec0790d8d37dfdc499e..78dd2adb481a0745e1a7131cb78ee63ddea693a1 100644 (file)
     </fieldset>
 
     {include file="CRM/common/customDataBlock.tpl"}
-
     <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
   {/if}
     <div class="spacer"></div>
index 7e641a7fe95dbd6f8ecafe56481eb04f4820d658..eafe8c76fa2bb30cdb18b86675c7499be0484cd1 100644 (file)
@@ -1,4 +1,4 @@
-{if !empty($nocid)}
+{if $nocid}
   <div class="crm-other-contact-row messages status">
     <span>{ts}You are completing this form on behalf of someone else. Please enter their details.</span>{/ts}
   {if !empty($selectable)}