}
/**
- * Build an array of available membership types.
+ * Build an array of available membership types in the current context.
+ *
+ * While core does not do anything context specific extensions may filter
+ * or alter amounts based on user details.
*
* @param CRM_Core_Form $form
* @param array $membershipTypeID
*/
public static function buildMembershipTypeValues($form, $membershipTypeID = [], $activeOnly = FALSE) {
$membershipTypeIDS = (array) $membershipTypeID;
- $membershipTypeValues = CRM_Member_BAO_MembershipType::getPermissionedMembershipTypes();
+ $membershipTypeValues = CRM_Member_BAO_MembershipType::getAllMembershipTypes();
// MembershipTypes are already filtered by domain, filter as appropriate by is_active & a passed in list of ids.
foreach ($membershipTypeValues as $id => $type) {
return self::getAllMembershipTypes()[$id];
}
- /**
- * Get an array of all membership types the contact is permitted to access.
- *
- * @throws \CiviCRM_API3_Exception
- */
- public static function getPermissionedMembershipTypes() {
- $types = self::getAllMembershipTypes();
- $financialTypes = NULL;
- $financialTypes = CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::ADD);
- foreach ($types as $id => $type) {
- if (!isset($financialTypes[$type['financial_type_id']])) {
- unset($types[$id]);
- }
- }
- return $types;
- }
-
}
}
}
+/**
+ * Remove unpermitted membership types from selection availability..
+ *
+ * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_membershipTypeValues
+ *
+ * @param \CRM_Core_Form $form
+ * @param array $membershipTypeValues
+ */
+function financialacls_civicrm_membershipTypeValues($form, &$membershipTypeValues) {
+ $financialTypes = NULL;
+ $financialTypes = CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::ADD);
+ foreach ($membershipTypeValues as $id => $type) {
+ if (!isset($financialTypes[$type['financial_type_id']])) {
+ unset($membershipTypeValues[$id]);
+ }
+ }
+}
+
// --- Functions below this ship commented out. Uncomment as required. ---
/**