Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ref] Remove another instance of fatal() #17549

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions CRM/Friend/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/

/**
* This class generates form components for Tell A Friend Form For End User
*
Expand Down Expand Up @@ -76,7 +68,7 @@ public function preProcess() {
$this->_title = $values['title'] ?? NULL;
$this->_campaignId = $values['campaign_id'] ?? NULL;
$this->_entityTable = 'civicrm_contribution_page';
if ($pcomponent == 'event') {
if ($pcomponent === 'event') {
$this->_entityTable = 'civicrm_event';
$isShare = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_entityId, 'is_share');
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_entityId, 'title');
Expand All @@ -87,7 +79,7 @@ public function preProcess() {
// Tell Form.tpl whether to include SocialNetwork.tpl for social media sharing
$this->assign('isShare', $isShare);
}
elseif ($pcomponent == 'pcp') {
elseif ($pcomponent === 'pcp') {
$this->_pcpBlockId = CRM_Utils_Request::retrieve('blockId', 'Positive', $this, TRUE);

$values = [];
Expand Down Expand Up @@ -122,14 +114,13 @@ public function preProcess() {
}
$this->assign('context', $pcomponent);

$session = CRM_Core_Session::singleton();
$this->_contactID = $session->get('userID');
$this->_contactID = CRM_Core_Session::getLoggedInContactID();
if (!$this->_contactID) {
$this->_contactID = $session->get('transaction.userID');
$this->_contactID = CRM_Core_Session::singleton()->get('transaction.userID');
}

if (!$this->_contactID) {
CRM_Core_Error::fatal(ts('Could not get the contact ID'));
CRM_Core_Error::statusBounce(ts('Could not get the contact ID'));
}

// we do not want to display recently viewed items, so turn off
Expand All @@ -140,7 +131,7 @@ public function preProcess() {
* Set default values for the form.
*
*
* @return void
* @return array
*/
public function setDefaultValues() {
$defaults = [];
Expand Down Expand Up @@ -190,7 +181,7 @@ public function buildQuickForm() {
$this->add('wysiwyg', 'suggested_message', ts('Your Message'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'suggested_message'));
$friend = [];
$mailLimit = self::NUM_OPTION;
if ($this->_entityTable == 'civicrm_pcp') {
if ($this->_entityTable === 'civicrm_pcp') {
$mailLimit = $this->_mailLimit;
}
$this->assign('mailLimit', $mailLimit + 1);
Expand Down Expand Up @@ -258,8 +249,8 @@ public static function formRule($fields) {
/**
* Process the form submission.
*
*
* @return void
* @throws \CRM_Core_Exception
*/
public function postProcess() {
// get the submitted form values.
Expand All @@ -281,11 +272,11 @@ public function postProcess() {
$defaults['entity_table'] = $this->_entityTable;

CRM_Friend_BAO_Friend::getValues($defaults);
if ($this->_entityTable == 'civicrm_pcp') {
if ($this->_entityTable === 'civicrm_pcp') {
$defaults['thankyou_text'] = $defaults['thankyou_title'] = ts('Thank you for your support');
$defaults['thankyou_text'] = ts('Thanks for supporting this campaign by spreading the word to your friends.');
}
elseif ($this->_entityTable == 'civicrm_contribution_page') {
elseif ($this->_entityTable === 'civicrm_contribution_page') {
// If this is tell a friend after contributing, give donor link to create their own fundraising page
if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($defaults['entity_id'], $defaults['entity_table'])) {

Expand All @@ -298,7 +289,7 @@ public function postProcess() {
$this->assign('linkText', $linkText);
}
}
elseif ($this->_entityTable == 'civicrm_event') {
elseif ($this->_entityTable === 'civicrm_event') {
// If this is tell a friend after registering for an event, give donor link to create their own fundraising page
require_once 'CRM/PCP/BAO/PCP.php';
if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($defaults['entity_id'], $defaults['entity_table'])) {
Expand Down