}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
*
+ * Note that in edit/view mode
+ * the default values are retrieved from the database
*
* @return void
*/
}
/**
+ * Wrangle financial type ID.
+ *
* This wrangling of the financialType ID was happening in a shared function rather than in the form it relates to & hence has been moved to that form
* Pledges are not relevant to the membership code so that portion will not go onto the membership form.
*
- * Comments from previous refactor indicate doubt as to what was going on
+ * Comments from previous refactor indicate doubt as to what was going on.
+ *
* @param int $contributionTypeId
*
* @return null|string
}
/**
- * Process the form
+ * Process the form.
*
* @param array $premiumParams
* @param $contribution
- *
- * @return void
*/
public function postProcessPremium($premiumParams, $contribution) {
$hour = $minute = $second = 0;
}
/**
- * Process the contribution
+ * Process the contribution.
*
* @param CRM_Core_Form $form
* @param array $params
* @param object $contributionSoft
* Contribution object.
*/
-
public static function pcpNotifyOwner($contribution, $contributionSoft) {
$params = array('id' => $contributionSoft->pcp_id);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
}
/**
- * Function used to se pcp related defaults / params
- * This is used by contribution and also event pcps
+ * Function used to se pcp related defaults / params.
+ *
+ * This is used by contribution and also event PCPs
*
* @param CRM_Core_Form $page
* Form object.
}
/**
+ * Process membership.
+ *
* @param array $membershipParams
* @param int $contactID
* @param array $customFieldsFormatted
}
/**
- * Are we going to do 2 financial transactions?
- * ie the membership block supports a separate transactions AND the contribution form has been configured for a contribution
- * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style)
+ * Are we going to do 2 financial transactions.
*
+ * Ie the membership block supports a separate transactions AND the contribution form has been configured for a
+ * contribution
+ * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style)
*
* @param int $formID
* @param bool $amountBlockActiveOnForm
}
/**
- * This function sets the fields
+ * This function sets the fields.
+ *
* - $this->_params['amount_level']
* - $this->_params['selectMembership']
* And under certain circumstances sets
$this->_params['selectMembership'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue',
$this->_params["price_{$priceField->id}"], 'membership_type_id');
}
- } // if separate payment we set contribution amount to be null, so that it will not show contribution amount same as membership amount.
+ }
+ // If separate payment we set contribution amount to be null, so that it will not show contribution amount same
+ // as membership amount.
// @todo - this needs more documentation - it appears the setting to null is tied up with separate membership payments
// but the circumstances are very confusing. Many of these conditions are repeated in the next conditional
// so we should merge them together
}
/**
+ * Submit function.
+ *
* @param array $params
*
* @throws CiviCRM_API3_Exception
}
/**
- * Helper function for static submit function - set relevant params - help us to build up an array that we can pass in
+ * Helper function for static submit function - set relevant params - help us to build up an array that we can pass
+ * in.
+ *
* @param int $id
* @param array $params
*
function civicrm_api3_membership_create($params) {
// check params for membership id during update
if (!empty($params['id']) && !isset($params['skipStatusCal'])) {
- //don't calculate status on exisiting membership - expect API use to pass them in
- // or leave unchanged
+ // Don't calculate status on existing membership - expect API use to pass them in
+ // or leave unchanged.
$params['skipStatusCal'] = 1;
}
else {
'type' => CRM_Utils_Type::T_INT,
);
}
+
/**
* Adjust Metadata for Get action.
*
*/
function _civicrm_api3_membership_get_spec(&$params) {
$params['membership_type_id']['api.aliases'] = array('membership_type');
+ $params['active_only'] = array(
+ 'title' => 'Only retrieve active memberships',
+ 'type' => CRM_Utils_Type::T_BOOLEAN,
+ );
}
/**
$members = $membershipValues;
- // populating contacts in members array based on their relationship with direct members.
+ // Populating contacts in members array based on their relationship with direct members.
if (!empty($relationships)) {
foreach ($relationships as $relTypeId => $membershipId) {
// As members are not direct members, there should not be
$this->useTransaction(TRUE);
}
+ /**
+ * Test creating location block.
+ */
public function testCreateLocBlock() {
$email = $this->callAPISuccess('email', 'create', array(
'contact_id' => 'null',
- 'location_type_id' => 1,
'email' => 'test@loc.block',
));
$phone = $this->callAPISuccess('phone', 'create', array(
$description = 'Create locBlock with existing entities';
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'simpleCreate');
$id = $result['id'];
- $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
- $this->assertNotNull($result['values'][$id]['id'], 'In line ' . __LINE__);
+ $this->assertEquals(1, $result['count']);
+ $this->assertNotNull($result['values'][$id]['id']);
$this->getAndCheck($params, $id, $this->_entity);
}
+ /**
+ * Test creating location block entities.
+ */
public function testCreateLocBlockEntities() {
$params = array(
'email' => array(
$description = "Create entities and locBlock in 1 api call";
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'createEntities');
$id = $result['id'];
- $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
+ $this->assertEquals(1, $result['count']);
- // Now check our results using the return param 'all'
+ // Now check our results using the return param 'all'.
$getParams = array(
'id' => $id,
'return' => 'all',
);
- // Can't use callAPISuccess with getsingle
+ // Can't use callAPISuccess with getsingle.
$result = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call', 'getEntities', 'get');
$result = array_pop($result['values']);
- $this->assertNotNull($result['email_id'], 'In line ' . __LINE__);
- $this->assertNotNull($result['phone_id'], 'In line ' . __LINE__);
- $this->assertNotNull($result['phone_2_id'], 'In line ' . __LINE__);
- $this->assertNotNull($result['address_id'], 'In line ' . __LINE__);
- $this->assertEquals($params['email']['email'], $result['email']['email'], 'In line ' . __LINE__);
- $this->assertEquals($params['phone_2']['phone'], $result['phone_2']['phone'], 'In line ' . __LINE__);
- $this->assertEquals($params['address']['street_address'], $result['address']['street_address'], 'In line ' . __LINE__);
- // Delete block
- $result = $this->callAPISuccess($this->_entity, 'delete', array('id' => $id));
+ $this->assertNotNull($result['email_id']);
+ $this->assertNotNull($result['phone_id']);
+ $this->assertNotNull($result['phone_2_id']);
+ $this->assertNotNull($result['address_id']);
+ $this->assertEquals($params['email']['email'], $result['email']['email']);
+ $this->assertEquals($params['phone_2']['phone'], $result['phone_2']['phone']);
+ $this->assertEquals($params['address']['street_address'], $result['address']['street_address']);
+
+ $this->callAPISuccess($this->_entity, 'delete', array('id' => $id));
}
}