Swap some fatals on form & page classes for statusBounces
authoreileen <emcnaughton@wikimedia.org>
Fri, 8 Nov 2019 07:50:45 +0000 (20:50 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 8 Nov 2019 07:50:45 +0000 (20:50 +1300)
CRM/Batch/Form/Entry.php
CRM/Campaign/Form/Search.php
CRM/Case/Form/Activity.php
CRM/Case/Form/Case.php
CRM/Contribute/Form/ContributionView.php
CRM/Event/Cart/Page/AddToCart.php
CRM/Event/Form/ManageEvent.php
CRM/Event/Form/Participant.php
CRM/Event/Page/EventInfo.php
CRM/PCP/Form/PCP.php
CRM/Profile/Form/Edit.php

index 46f4e5c4abc0f4d5d0808f761155b5a798dc929b..4988cc95b70ac0c344262d69c1947595cc3ddb4b 100644 (file)
@@ -139,7 +139,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
    */
   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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
     $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);
index acbc6101ce1eb63979918ed7f0de08b89de70c4d..abfa2fa313a2fd6dc9a9c907f7a2dad4c76497b1 100644 (file)
@@ -405,7 +405,7 @@ class CRM_Campaign_Form_Search extends CRM_Core_Form_Search {
       $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;
 
index cda6919576697c902f27a6883af1a6360e180aae..78f14d286bd5c64fc7fe8b73967b432b298f9c50 100644 (file)
@@ -97,12 +97,12 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
     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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
       $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
         $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.'));
       }
     }
 
index 9dc1484af3c7444c034538edd5bceee92533e7c7..1a8cb664ad95505388f433c7b83b6e607a126538 100644 (file)
@@ -145,7 +145,7 @@ class CRM_Case_Form_Case extends CRM_Core_Form {
 
     //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 @@ class CRM_Case_Form_Case extends CRM_Core_Form {
 
       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 @@ class CRM_Case_Form_Case extends CRM_Core_Form {
     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,
index f04d0f6973a179af39577d3b24c92132fad1542f..f717ff221d7837e8ab971f92dad234893b3e7a2e 100644 (file)
@@ -57,7 +57,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
         $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) {
index 494a594e6e6f62ebdb4238590c2b097f3626e6ce..e9d9b60c366c2e0d0aaf7ffb725a29cd5fef4a87 100644 (file)
@@ -15,7 +15,7 @@ class CRM_Event_Cart_Page_AddToCart extends CRM_Core_Page {
 
     $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();
index cdac4d6a23486754f04c99a08b1df1d287000820..73ec055e2f74a80dfa8fa08aff97e56f8277ecf6 100644 (file)
@@ -143,7 +143,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
 
       // 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);
index 047b120a1e7fe60dd78537271d3c3dc214679e5c..8df783458b9da801ff04eff34c79a4ca9e115e40 100644 (file)
@@ -361,13 +361,13 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
 
     // 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
 
     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
index 8996841e2b8123e0ed0f0f7947a3df8e63fb0f59..8121be23a7fcaaeaa4d69af8ae6c90d7af0eee64 100644 (file)
@@ -75,7 +75,6 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page {
     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 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page {
 
     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
index d53610a0087e106531cc460c328c62da3a7d2d5e..667754dd3007ede2d6055fd94f67b73023b6a18b 100644 (file)
@@ -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);
index c2c7e1ab8109fd6f590ba3174a090606a187682a..b12e2805cdb2515b423fa4cbca0dc601bcba3cee 100644 (file)
@@ -113,7 +113,7 @@ class CRM_Profile_Form_Edit extends CRM_Profile_Form {
 
       // 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 @@ SELECT module,is_reserved
 
     //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 @@ SELECT module,is_reserved
    */
   public function buildQuickForm() {
     if (empty($this->_ufGroup['id'])) {
-      CRM_Core_Error::fatal();
+      CRM_Core_Error::statusBounce(ts('Invalid'));
     }
 
     // set the title