From: Mikey O'Toole Date: Fri, 19 Mar 2021 14:51:41 +0000 (+0000) Subject: Explicitly throw an error/status bounce if no memberships are configured and we're... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9888df99e2eacd5f393ec0c4f239e070df176218;p=civicrm-core.git Explicitly throw an error/status bounce if no memberships are configured and we're trying to add/update. Remove stray whitespace and fix check to look for Active membership types. Checkstyle fix. Fix error in syntax Refine messaging --- diff --git a/CRM/Member/Page/Tab.php b/CRM/Member/Page/Tab.php index 3d418592fc..965354c365 100644 --- a/CRM/Member/Page/Tab.php +++ b/CRM/Member/Page/Tab.php @@ -261,6 +261,17 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { * @return null */ public function edit() { + // We're trying to edit existing memberships or create a new one so we'll first check that a membership + // type is configured and active, if we don't do this we instead show a permissions error and status bounce. + $membershipTypes = \Civi\Api4\MembershipType::get(TRUE) + ->addWhere('is_active', '=', TRUE) + // we only need one, more is great but a single result lets us proceed! + ->setLimit(1) + ->execute(); + if (empty($membershipTypes)) { + CRM_Core_Error::statusBounce(ts('You do not appear to have any active membership types configured, please add an active membership type and try again.')); + } + // set https for offline cc transaction $mode = CRM_Utils_Request::retrieve('mode', 'Alphanumeric', $this); if ($mode == 'test' || $mode == 'live') {