<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
// current contribution page id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (!$this->_id) {
- $pastContributionID = $session->get('pastContributionID');
- if (!$pastContributionID) {
- CRM_Core_Error::fatal(ts('We can\'t load the requested web page due to an incomplete link. This can be caused by using your browser\'s Back button or by using an incomplete or invalid link.'));
- }
- else {
- CRM_Core_Error::fatal(ts('An error occurred during form submission. This page requires form data to be submitted for processing and no form data was submitted or processed. We are sorry for any inconvience. Please click <a href=\'%1\'>here</a> to visit the contribution page and re-start the contribution process.', array(1 => CRM_Utils_System::url('civicrm/contribute/transact', 'reset=1&id=' . $pastContributionID))));
- }
- }
- else {
- $session->set('pastContributionID', $this->_id);
+ // seems like the session is corrupted and/or we lost the id trail
+ // lets just bump this to a regular session error and redirect user to main page
+ $this->controller->invalidKeyRedirect();
}
+
// this was used prior to the cleverer this_>getContactID - unsure now
$this->_userID = $session->get('userID');
if ($membership->find(TRUE)) {
$this->_defaultMemTypeId = $membership->membership_type_id;
if ($membership->contact_id != $this->_contactID) {
+ $validMembership = FALSE;
$employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
- if (array_key_exists($membership->contact_id, $employers)) {
+ if (!empty($employers) && array_key_exists($membership->contact_id, $employers)) {
$this->_membershipContactID = $membership->contact_id;
$this->assign('membershipContactID', $this->_membershipContactID);
$this->assign('membershipContactName', $employers[$this->_membershipContactID]['name']);
+ $validMembership = TRUE;
+ } else {
+ $membershipType = new CRM_Member_BAO_MembershipType();
+ $membershipType->id = $membership->membership_type_id;
+ if ($membershipType->find(TRUE)) {
+ // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
+ // Convert to commma separated list.
+ $inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
+ $permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
+ if (array_key_exists($membership->contact_id, $permContacts)) {
+ $this->_membershipContactID = $membership->contact_id;
+ $validMembership = TRUE;
+ }
+ }
}
- else {
+ if (!$validMembership) {
CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
}
}
// also check for billing informatin
// get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
+ $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
// CRM-8108 remove ts around Billing location type
//$this->_bltID = array_search( ts('Billing'), $locationTypes );
$this->_bltID = array_search('Billing', $locationTypes);
$this->_params[$v] = $frequencyUnits[$this->_params[$v]];
}
}
- if ($v == "amount") {
- $this->_params[$v] = CRM_Utils_Money::format($this->_params[$v], ' ');
+ if ($v == "amount" && $this->_params[$v] === 0) {
+ $this->_params[$v] = CRM_Utils_Money::format($this->_params[$v], NULL, NULL, TRUE);
}
$this->assign($v, $this->_params[$v]);
}