CRM-13896, redirect to contact screen is contact is created and action is cancel
authorkurund <kurund@civicrm.org>
Wed, 4 Dec 2013 22:03:56 +0000 (14:03 -0800)
committerkurund <kurund@civicrm.org>
Wed, 4 Dec 2013 22:03:56 +0000 (14:03 -0800)
----------------------------------------
* CRM-13896: Fatal error on cancel action for new activity after new contact is created
  http://issues.civicrm.org/jira/browse/CRM-13896

CRM/Profile/Form/Edit.php

index 2bc5a0865f4519bdf22d25dc14b2717de1b4005d..b9fba0122b2677478a33b786b3e99853e9c40b24 100644 (file)
@@ -254,10 +254,7 @@ SELECT module
     if (($this->_multiRecord & CRM_Core_Action::DELETE) && $this->_recordExists) {
       $this->_deleteButtonName = $this->getButtonName('upload', 'delete');
 
-      $this->addElement('submit',
-        $this->_deleteButtonName,
-        ts('Delete')
-      );
+      $this->addElement('submit', $this->_deleteButtonName, ts('Delete'));
 
       $buttons[] = array(
         'type' => 'cancel',
@@ -310,6 +307,11 @@ SELECT module
 
     // this is special case when we create contact using Dialog box
     if ($this->_context == 'dialog') {
+      //replace the session stack for redirecting user to contact summary if new contact is created.
+      $contactViewURL = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_id}", FALSE, NULL, FALSE);
+      $session = CRM_Core_Session::singleton();
+      $session->replaceUserContext($contactViewURL);
+
       $displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'display_name');
       $sortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'sort_name');
       $returnArray = array(