From e22ec6537c9244a7245d10fae3be00f49f9b3fb6 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 8 Nov 2019 20:50:45 +1300 Subject: [PATCH] Swap some fatals on form & page classes for statusBounces --- CRM/Batch/Form/Entry.php | 4 ++-- CRM/Campaign/Form/Search.php | 2 +- CRM/Case/Form/Activity.php | 8 ++++---- CRM/Case/Form/Case.php | 10 +++++----- CRM/Contribute/Form/ContributionView.php | 2 +- CRM/Event/Cart/Page/AddToCart.php | 2 +- CRM/Event/Form/ManageEvent.php | 2 +- CRM/Event/Form/Participant.php | 6 +++--- CRM/Event/Page/EventInfo.php | 3 +-- CRM/PCP/Form/PCP.php | 4 +++- CRM/Profile/Form/Edit.php | 6 +++--- 11 files changed, 25 insertions(+), 24 deletions(-) diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 46f4e5c4abc0..4988cc95b70a 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -139,7 +139,7 @@ public function setBatchID($id) { */ public function buildQuickForm() { if (!$this->_profileId) { - CRM_Core_Error::fatal(ts('Profile for bulk data entry is missing.')); + CRM_Core_Error::statusBounce(ts('Profile for bulk data entry is missing.')); } $this->addElement('hidden', 'batch_id', $this->_batchId); @@ -265,7 +265,7 @@ public function buildQuickForm() { $offset = 50; if ((count($this->_elementIndex) + $offset) > ini_get("max_input_vars")) { // Avoiding 'ts' for obscure messages. - CRM_Core_Error::fatal('Batch size is too large. Increase value of php.ini setting "max_input_vars" (current val = ' . ini_get("max_input_vars") . ')'); + CRM_Core_Error::statusBounce('Batch size is too large. Increase value of php.ini setting "max_input_vars" (current val = ' . ini_get("max_input_vars") . ')'); } $this->assign('fields', $this->_fields); diff --git a/CRM/Campaign/Form/Search.php b/CRM/Campaign/Form/Search.php index acbc6101ce1e..abfa2fa313a2 100644 --- a/CRM/Campaign/Form/Search.php +++ b/CRM/Campaign/Form/Search.php @@ -405,7 +405,7 @@ public function fixFormValues() { $surveyId = key(CRM_Campaign_BAO_Survey::getSurveys(TRUE, TRUE)); } if (!$surveyId) { - CRM_Core_Error::fatal('Could not find valid Survey Id.'); + CRM_Core_Error::statusBounce('Could not find valid Survey Id.'); } $this->_formValues['campaign_survey_id'] = $this->_formValues['campaign_survey_id'] = $surveyId; diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index cda691957669..78f14d286bd5 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -97,12 +97,12 @@ public function preProcess() { if (!$this->_caseId || (!$this->_activityId && !$this->_activityTypeId) ) { - CRM_Core_Error::fatal('required params missing.'); + CRM_Core_Error::statusBounce('required params missing.'); } //check for case activity access. if (!CRM_Case_BAO_Case::accessCiviCase()) { - CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); + CRM_Core_Error::statusBounce(ts('You are not authorized to access this page.')); } //validate case id. if ($this->_caseId && @@ -111,7 +111,7 @@ public function preProcess() { $params = ['type' => 'any']; $allCases = CRM_Case_BAO_Case::getCases(TRUE, $params); if (count(array_intersect($this->_caseId, array_keys($allCases))) == 0) { - CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); + CRM_Core_Error::statusBounce(ts('You are not authorized to access this page.')); } } @@ -123,7 +123,7 @@ public function preProcess() { $this->_activityTypeId ); if (!$valid) { - CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); + CRM_Core_Error::statusBounce(ts('You are not authorized to access this page.')); } } diff --git a/CRM/Case/Form/Case.php b/CRM/Case/Form/Case.php index 9dc1484af3c7..1a8cb664ad95 100644 --- a/CRM/Case/Form/Case.php +++ b/CRM/Case/Form/Case.php @@ -145,7 +145,7 @@ public function preProcess() { //CRM-4418 if (!CRM_Core_Permission::checkActionPermission('CiviCase', $this->_action)) { - CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); + CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) { @@ -161,7 +161,7 @@ public function preProcess() { foreach ($caseAttributes as $key => $label) { if (!CRM_Case_BAO_Case::buildOptions($key, 'create')) { - CRM_Core_Error::fatal(ts('You do not have any active %1', [1 => $label])); + CRM_Core_Error::statusBounce(ts('You do not have any active %1', [1 => $label])); } } } @@ -169,20 +169,20 @@ public function preProcess() { if ($this->_action & CRM_Core_Action::ADD) { $this->_activityTypeId = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case'); if (!$this->_activityTypeId) { - CRM_Core_Error::fatal(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.')); + CRM_Core_Error::statusBounce(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.')); } } //check for case permissions. if (!CRM_Case_BAO_Case::accessCiviCase()) { - CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); + CRM_Core_Error::statusBounce(ts('You are not authorized to access this page.')); } if (($this->_action & CRM_Core_Action::ADD) && (!CRM_Core_Permission::check('access all cases and activities') && !CRM_Core_Permission::check('add cases') ) ) { - CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); + CRM_Core_Error::statusBounce(ts('You are not authorized to access this page.')); } if ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index f04d0f6973a1..f717ff221d78 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -57,7 +57,7 @@ public function preProcess() { $this->assign('canDelete', TRUE); } if (!CRM_Core_Permission::check('view contributions of type ' . $financialTypeID)) { - CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); + CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } } elseif ($this->_action & CRM_Core_Action::VIEW) { diff --git a/CRM/Event/Cart/Page/AddToCart.php b/CRM/Event/Cart/Page/AddToCart.php index 494a594e6e6f..e9d9b60c366c 100644 --- a/CRM/Event/Cart/Page/AddToCart.php +++ b/CRM/Event/Cart/Page/AddToCart.php @@ -15,7 +15,7 @@ public function run() { $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'register for events')) { - CRM_Core_Error::fatal(ts('You do not have permission to register for this event')); + CRM_Core_Error::statusBounce(ts('You do not have permission to register for this event')); } $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session(); diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index cdac4d6a2348..73ec055e2f74 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -143,7 +143,7 @@ public function preProcess() { // its an update mode, do a permission check if (!CRM_Event_BAO_Event::checkPermission($this->_id, CRM_Core_Permission::EDIT)) { - CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); + CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } $participantListingID = CRM_Utils_Array::value('participant_listing_id', $eventInfo); diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 047b120a1e7f..8df783458b9d 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -361,13 +361,13 @@ public function preProcess() { // check for edit permission if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) { - CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); + CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } if ($this->_action & CRM_Core_Action::DELETE) { // check delete permission for contribution if ($this->_id && $this->_paymentId && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { - CRM_Core_Error::fatal(ts("This Participant is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record.")); + CRM_Core_Error::statusBounce(ts("This Participant is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record.")); } return; } @@ -1136,7 +1136,7 @@ public function submit($params) { if ($this->_mode) { if (!$this->_isPaidEvent) { - CRM_Core_Error::fatal(ts('Selected Event is not Paid Event ')); + CRM_Core_Error::statusBounce(ts('Selected Event is not Paid Event ')); } $eventTitle diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index 8996841e2b81..8121be23a7fc 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -75,7 +75,6 @@ public function run() { CRM_Event_BAO_Event::retrieve($params, $values['event']); if (!$values['event']['is_active']) { - // form is inactive, die a fatal death CRM_Utils_System::setUFMessage(ts('The event you requested is currently unavailable (contact the site administrator for assistance).')); return CRM_Utils_System::permissionDenied(); } @@ -86,7 +85,7 @@ public function run() { if (!empty($values['event']['is_template'])) { // form is an Event Template - CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.')); + CRM_Core_Error::statusBounce(ts('The page you requested is currently unavailable.')); } // Add Event Type to $values in case folks want to display it diff --git a/CRM/PCP/Form/PCP.php b/CRM/PCP/Form/PCP.php index d53610a0087e..667754dd3007 100644 --- a/CRM/PCP/Form/PCP.php +++ b/CRM/PCP/Form/PCP.php @@ -42,12 +42,14 @@ class CRM_PCP_Form_PCP extends CRM_Core_Form { /** * Set variables up before form is built. + * + * @throws \CRM_Core_Exception */ public function preProcess() { if ($this->_action & CRM_Core_Action::DELETE) { //check permission for action. if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) { - CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); + CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); diff --git a/CRM/Profile/Form/Edit.php b/CRM/Profile/Form/Edit.php index c2c7e1ab8109..b12e2805cdb2 100644 --- a/CRM/Profile/Form/Edit.php +++ b/CRM/Profile/Form/Edit.php @@ -113,7 +113,7 @@ public function preProcess() { // CRM-16784: If there is no ID then this can't be an 'edit' else { - CRM_Core_Error::fatal(ts('No user/contact ID was specified, so the Profile cannot be used in edit mode.')); + CRM_Core_Error::statusBounce(ts('No user/contact ID was specified, so the Profile cannot be used in edit mode.')); } } @@ -141,7 +141,7 @@ public function preProcess() { //Remove need for Profile module type when using reserved profiles [CRM-14488] if (!$dao->N || (!$isProfile && !($dao->is_reserved && $canAdd))) { - CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is not configured to be used for \'Profile\' edit and view forms in its Settings. Contact the site administrator if you need assistance.', + CRM_Core_Error::statusBounce(ts('The requested Profile (gid=%1) is not configured to be used for \'Profile\' edit and view forms in its Settings. Contact the site administrator if you need assistance.', [1 => $this->_gid] )); } @@ -153,7 +153,7 @@ public function preProcess() { */ public function buildQuickForm() { if (empty($this->_ufGroup['id'])) { - CRM_Core_Error::fatal(); + CRM_Core_Error::statusBounce(ts('Invalid')); } // set the title