*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
/**
* Class constructor.
- *
- * @return \CRM_Member_DAO_Membership
- */
- /**
*/
public function __construct() {
parent::__construct();
}
/**
- * Given the list of params in the params array, fetch the object
- * and store the values in the values array
+ * Fetch the object and store the values in the values array.
*
* @param array $params
* Input parameters to find object.
* Do you want only active memberships to.
* be returned
* @param bool $relatedMemberships
- * @return CRM_Member_BAO_Membership|null the found object or null
+ *
+ * @return CRM_Member_BAO_Membership|null
+ * The found object or null
*/
public static function &getValues(&$params, &$values, $active = FALSE, $relatedMemberships = FALSE) {
if (empty($params)) {
if (empty($params['is_override']) && empty($params['skipStatusCal'])) {
$dates = array('start_date', 'end_date', 'join_date');
- $start_date = $end_date = $join_date = NULL; // declare these out of courtesy as IDEs don't pick up the setting of them below
+ // Declare these out of courtesy as IDEs don't pick up the setting of them below.
+ $start_date = $end_date = $join_date = NULL;
foreach ($dates as $date) {
$$date = $params[$date] = CRM_Utils_Date::processDate(CRM_Utils_Array::value($date, $params), NULL, TRUE, 'Ymd');
}
}
// data cleanup only: all verifications on number of related memberships are done upstream in:
- // CRM_Member_BAO_Membership::createRelatedMemberships()
- // CRM_Contact_BAO_Relationship::relatedMemberships()
+ // CRM_Member_BAO_Membership::createRelatedMemberships()
+ // CRM_Contact_BAO_Relationship::relatedMemberships()
if (isset($params['owner_membership_id'])) {
unset($params['max_related']);
}
$url = CRM_Utils_System::url('civicrm/contact/view/membership',
"action=view&reset=1&id={$membership->id}&cid={$membership->contact_id}&context=home"
);
- if (empty($membership->membership_type_id)) {// ie in an update situation
+ if (empty($membership->membership_type_id)) {
+ // ie in an update situation.
$membership->find(TRUE);
}
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
}
/**
- *
- * get membership status and membership type values
+ * Get membership status and membership type values.
*
* @param int $membershipId
* Membership id of values to return.
/**
* Delete membership.
+ *
* Wrapper for most delete calls. Use this unless you JUST want to delete related memberships w/o deleting the parent.
*
* @param int $membershipId
* Membership id that needs to be deleted.
*
- *
- * @return int $results id of deleted Membership on success, false otherwise
+ * @return int
+ * Id of deleted Membership on success, false otherwise.
*/
public static function del($membershipId) {
//delete related first and then delete parent.
* @param int $membershipId
* Membership id that needs to be deleted.
*
- *
- * @return int $results id of deleted Membership on success, false otherwise
+ * @return int
+ * Id of deleted Membership on success, false otherwise.
*/
public static function deleteMembership($membershipId) {
// CRM-12147, retrieve membership data before we delete it for hooks
*
* @return bool
* Is this a separate membership payment
- *
*/
public static function buildMembershipBlock(
&$form,
* Contribution page id.
*
* @return array|null
- *
*/
public static function getMembershipBlock($pageID) {
$membershipBlock = array();
/**
* Return a current membership of given contact.
+ *
* NB: if more than one membership meets criteria, a randomly selected one is returned.
*
* @param int $contactID
}
/**
- * Get membership joins/renewals for a specified membership
- * type. Specifically, retrieves a count of memberships whose "Membership
+ * Get membership joins/renewals for a specified membership type.
+ *
+ * Specifically, retrieves a count of memberships whose "Membership
* Signup" or "Membership Renewal" activity falls in the given date range.
* Dates match the pattern "yyyy-mm-dd".
*
}
/**
- * Get a count of membership for a specified membership type,
- * optionally for a specified date. The date must have the form yyyy-mm-dd.
+ * Get a count of membership for a specified membership type, optionally for a specified date.
+ *
+ * The date must have the form yyyy-mm-dd.
*
* If $date is omitted, this function counts as a member anyone whose
* membership status_id indicates they're a current member.
* @param bool $isPaidMembership
* @param array $membershipID
*
- * @param $isProcessSeparateMembershipTransaction
+ * @param bool $isProcessSeparateMembershipTransaction
*
* @param int $defaultContributionTypeID
* @param array $membershipLineItems
* Line items specific to membership payment that is separate to contribution.
- * @param $isPayLater
+ * @param bool $isPayLater
*
* @throws \CRM_Core_Exception
*/
}
/**
- * Function for updating a membership record's contribution_recur_id
+ * Function for updating a membership record's contribution_recur_id.
*
* @param CRM_Member_DAO_Membership $membership
* @param \CRM_Contribute_BAO_Contribution|\CRM_Contribute_DAO_Contribution $contribution
- *
- * @return void
*/
static public function updateRecurMembership(CRM_Member_DAO_Membership $membership, CRM_Contribute_BAO_Contribution $contribution) {
}
/**
+ * A wrapper for renewing memberships from a form.
+ *
* @deprecated
- * A wrapper for renewing memberships from a form - including the form in the membership processing adds complexity
+ * - including the form in the membership processing adds complexity
* as the forms are being forced to pretend similarity
* Try to call the renewMembership directly
* @todo - this form method needs to have the interaction with the form layer removed from it
* in the complete transaction function, called by all types of payment processor (removing assumptions
* about what they do & always doing a pending + a complete at the appropriate time).
*
- * @return
+ * @return CRM_Member_BAO_Membership|CRM_Core_Error
*/
public static function renewMembershipFormWrapper(
$contactID,
* Array of month, day, year.
* values in case today needs
* to be customised, null otherwise
- *
- * @return void
*/
public static function fixMembershipStatusBeforeRenew(&$currentMembership, $changeToday) {
$today = NULL;
/**
* Get list of membership fields for profile.
+ *
* For now we only allow custom membership fields to be in
* profile
*
}
/**
- * Create memberships for related contacts.
- * takes into account the maximum related memberships
+ * Create memberships for related contacts, taking into account the maximum related memberships.
*
* @param array $params
* Array of key - value pairs.
unset($params['max_related']);
// Number of inherited memberships available - NULL is interpreted as unlimited, '0' as none
$available = ($membership->max_related == NULL ? PHP_INT_MAX : $membership->max_related);
- $queue = array(); // will be used to queue potential memberships to be created
+ // will be used to queue potential memberships to be created.
+ $queue = array();
foreach ($relatedContacts as $contactId => $relationshipStatus) {
//use existing membership record.
}
/**
- * Check whether payment processor supports
- * cancellation of membership subscription
+ * Check whether payment processor supports cancellation of membership subscription.
*
* @param int $mid
* Membership id.
}
/**
- * Get membership joins for a specified membership
- * type. Specifically, retrieves a count of still current memberships whose
+ * Get membership joins for a specified membership type.
+ *
+ * Specifically, retrieves a count of still current memberships whose
* join_date and start_date are within a specified date range. Dates match
* the pattern "yyyy-mm-dd".
*
}
/**
- * Get membership renewals for a specified membership
- * type. Specifically, retrieves a count of still current memberships
+ * Get membership renewals for a specified membership type.
+ *
+ * Specifically, retrieves a count of still current memberships
* whose join_date is before and start_date is within a specified date
* range. Dates match the pattern "yyyy-mm-dd".
*
* @param int $contactID
* @param CRM_Contribute_Form_Contribution_Confirm $form
* @param array $tempParams
- * @param $isTest
+ * @param bool $isTest
* @param array $lineItems
* @param $minimumFee
* @param int $financialTypeID
* @param $customFieldsFormatted
* @param int $membershipID
* @param $memType
- * @param $isTest
- * @param $numTerms
+ * @param bool $isTest
+ * @param int $numTerms
* @param $membershipContribution
* @param CRM_Core_Form $form
*
* Process price set and line items.
*
* @param int $membershipId
- * @param $lineItem
- *
- * @return void
+ * @param array $lineItem
*/
public function processPriceSet($membershipId, $lineItem) {
//FIXME : need to move this too