Fix delete event participant fatal error and display name if no email
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 16 Nov 2018 16:22:40 +0000 (16:22 +0000)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 16 Nov 2018 16:22:40 +0000 (16:22 +0000)
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Event/Page/Tab.php

index 86c92605d669ac7f298149b46832a24fa206cb48..987479f2598251ed45e8b21003fabbef7b29a5bc 100644 (file)
@@ -753,6 +753,9 @@ WHERE  contribution_id = {$id}
   protected function assignContactEmailDetails() {
     if ($this->_contactID) {
       list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
+      if (empty($this->userDisplayName)) {
+        $this->userDisplayName = civicrm_api3('contact', 'getvalue', ['id' => $this->_contactID, 'return' => 'display_name']);
+      }
       $this->assign('displayName', $this->userDisplayName);
     }
   }
index c0b1855dd598b62a8d3bebba8a14ae386e3ffd36..8b11dd5849a1a79878aa06e74a1b969b20fc92de 100644 (file)
@@ -118,6 +118,19 @@ class CRM_Event_Page_Tab extends CRM_Core_Page {
     return $controller->run();
   }
 
+  public function delete() {
+    $controller = new CRM_Core_Controller_Simple(
+      'CRM_Event_Form_Participant',
+      ts('Delete Participant'),
+      $this->_action
+    );
+
+    $controller->setEmbedded(TRUE);
+    $controller->set('id', $this->_id);
+    $controller->set('cid', $this->_contactId);
+    $controller->run();
+  }
+
   public function preProcess() {
     $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
@@ -167,13 +180,12 @@ class CRM_Event_Page_Tab extends CRM_Core_Page {
     if ($this->_action & CRM_Core_Action::VIEW) {
       $this->view();
     }
-    elseif ($this->_action & (CRM_Core_Action::UPDATE |
-        CRM_Core_Action::ADD |
-        CRM_Core_Action::DELETE
-      )
-    ) {
+    elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
       $this->edit();
     }
+    elseif ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::DETACH)) {
+      $this->delete();
+    }
     else {
       $this->browse();
     }