diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 1805b76426d8..71f68a6ef479 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1094,12 +1094,9 @@ public static function getMembershipCount($membershipTypeId, $date = NULL, $isTe /** * Function check the status of the membership before adding membership for a contact. * - * @param int $contactId - * Contact id. - * * @return int */ - public static function statusAvailabilty($contactId) { + public static function statusAvailabilty() { $membership = new CRM_Member_DAO_MembershipStatus(); $membership->whereAdd('is_active=1'); return $membership->count(); diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 222fcb4c8f3f..65f7ae9a958a 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -96,6 +96,11 @@ public function preProcess() { if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } + if (!CRM_Member_BAO_Membership::statusAvailabilty()) { + // all possible statuses are disabled - redirect back to contact form + CRM_Core_Error::statusBounce(ts('There are no configured membership statuses. You cannot add this membership until your membership statuses are correctly configured')); + } + parent::preProcess(); $params = array(); $params['context'] = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'membership'); diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index e8b2b10c526a..53de647a0daf 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -187,10 +187,6 @@ public function preProcess() { } if ($this->_action & CRM_Core_Action::ADD) { - if (!CRM_Member_BAO_Membership::statusAvailabilty($this->_contactID)) { - // all possible statuses are disabled - redirect back to contact form - CRM_Core_Error::statusBounce(ts('There are no configured membership statuses. You cannot add this membership until your membership statuses are correctly configured')); - } if ($this->_contactID) { //check whether contact has a current membership so we can alert user that they may want to do a renewal instead $contactMemberships = array(); diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 319b30023f04..80e64e27d653 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -129,10 +129,6 @@ public function preProcess() { // This string makes up part of the class names, differentiating them (not sure why) from the membership fields. $this->assign('formClass', 'membershiprenew'); parent::preProcess(); - // check for edit permission - if (!CRM_Core_Permission::check('edit memberships')) { - CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); - } $this->assign('endDate', CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'end_date'