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

CRM-15861 - minor cleanups towards this implementation #9386

Merged
merged 2 commits into from
Nov 15, 2016
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
5 changes: 1 addition & 4 deletions CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions CRM/Member/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 0 additions & 4 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 0 additions & 4 deletions CRM/Member/Form/MembershipRenewal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down