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

Swap some fatals on form & page classes for statusBounces #15770

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions CRM/Batch/Form/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions CRM/Case/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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.'));
}
}

Expand All @@ -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.'));
}
}

Expand Down
10 changes: 5 additions & 5 deletions CRM/Case/Form/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -161,28 +161,28 @@ 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]));
}
}
}

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,
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ContributionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Cart/Page/AddToCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/ManageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions CRM/Event/Page/EventInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion CRM/PCP/Form/PCP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions CRM/Profile/Form/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
}

}
Expand Down Expand Up @@ -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]
));
}
Expand All @@ -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
Expand Down