*
* @return CRM_Member_BAO_Membership
*/
- public static function add(&$params, $ids = array()) {
+ public static function add(&$params, $ids = []) {
$oldStatus = $oldType = NULL;
$params['id'] = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('membership', $ids));
if ($params['id']) {
$logStartDate = ($logStartDate) ? CRM_Utils_Date::isoToMysql($logStartDate) : CRM_Utils_Date::isoToMysql($membership->start_date);
$values = self::getStatusANDTypeValues($membership->id);
- $membershipLog = array(
+ $membershipLog = [
'membership_id' => $membership->id,
'status_id' => $membership->status_id,
'start_date' => $logStartDate,
'modified_date' => date('Ymd'),
'membership_type_id' => $values[$membership->id]['membership_type_id'],
'max_related' => $membership->max_related,
- );
+ ];
$session = CRM_Core_Session::singleton();
// If we have an authenticated session, set modified_id to that user's contact_id, else set to membership.contact_id
CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
$allStatus = CRM_Member_BAO_Membership::buildOptions('status_id', 'get');
- $activityParams = array(
+ $activityParams = [
'status_id' => CRM_Utils_Array::value('membership_activity_status', $params, 'Completed'),
- );
- if (in_array($allStatus[$membership->status_id], array('Pending', 'Grace'))) {
+ ];
+ if (in_array($allStatus[$membership->status_id], ['Pending', 'Grace'])) {
$activityParams['status_id'] = 'Scheduled';
}
$activityParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', $activityParams['status_id']);
CRM_Activity_BAO_Activity::addActivity($membership,
'Change Membership Status',
NULL,
- array(
+ [
'subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$membership->status_id]}",
'source_contact_id' => $membershipLog['modified_id'],
'priority_id' => 'Normal',
- )
+ ]
);
}
if (isset($membership->membership_type_id) && $membership->membership_type_id != $oldType) {
CRM_Activity_BAO_Activity::addActivity($membership,
'Change Membership Type',
NULL,
- array(
+ [
'subject' => "Type changed from {$membershipTypes[$oldType]} to {$membershipTypes[$membership->membership_type_id]}",
'source_contact_id' => $membershipLog['modified_id'],
'priority_id' => 'Normal',
- )
+ ]
);
}
- foreach (array('Membership Signup', 'Membership Renewal') as $activityType) {
+ foreach (['Membership Signup', 'Membership Renewal'] as $activityType) {
$activityParams['id'] = CRM_Utils_Array::value('id',
civicrm_api3('Activity', 'Get',
- array(
+ [
'source_record_id' => $membership->id,
'activity_type_id' => $activityType,
'status_id' => 'Scheduled',
- )
+ ]
)
);
// 1. Update Schedule Membership Signup/Renwal activity to completed on successful payment of pending membership
$membership->copyValues($params);
$membership->find();
- $memberships = array();
+ $memberships = [];
while ($membership->fetch()) {
if ($active &&
(!CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus',
// eg pay later membership, membership update cron CRM-3984
if (empty($params['is_override']) && empty($params['skipStatusCal'])) {
- $dates = array('start_date', 'end_date', 'join_date');
+ $dates = ['start_date', 'end_date', 'join_date'];
// 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) {
// however since we have no idea how (if) this is triggered we can't safely move / remove it
// NB I tried really hard to trigger this error from backoffice membership form in order to test it
// and am convinced form validation is complete on that form WRT this error.
- $errorParams = array(
+ $errorParams = [
'message_title' => ts('No valid membership status for given dates.'),
'legacy_redirect_path' => 'civicrm/contact/view',
'legacy_redirect_query' => "reset=1&force=1&cid={$params['contact_id']}&selectedChild=member",
- );
+ ];
throw new CRM_Core_Exception(ts(
"The membership cannot be saved because the status cannot be calculated for start_date: $start_date end_date $end_date join_date $join_date as at " . date('Y-m-d H:i:s')),
0,
//record contribution for this membership
if (!empty($params['contribution_status_id']) && empty($params['relate_contribution_id'])) {
- $memInfo = array_merge($params, array('membership_id' => $membership->id));
+ $memInfo = array_merge($params, ['membership_id' => $membership->id]);
$params['contribution'] = self::recordMembershipContribution($memInfo);
}
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$title = CRM_Contact_BAO_Contact::displayName($membership->contact_id) . ' - ' . ts('Membership Type:') . ' ' . $membershipTypes[$membership->membership_type_id];
- $recentOther = array();
+ $recentOther = [];
if (CRM_Core_Permission::checkActionPermission('CiviMember', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership',
"action=update&reset=1&id={$membership->id}&cid={$membership->contact_id}&context=home"
* array of contact_id of all related contacts.
*/
public static function checkMembershipRelationship($membershipTypeID, $contactId, $action = CRM_Core_Action::ADD) {
- $contacts = array();
+ $contacts = [];
$membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipTypeID);
- $relationships = array();
+ $relationships = [];
if (isset($membershipType['relationship_type_id'])) {
$relationships = CRM_Contact_BAO_Relationship::getRelationship($contactId,
CRM_Contact_BAO_Relationship::CURRENT
// check for each contact relationships
foreach ($relationships as $values) {
//get details of the relationship type
- $relType = array('id' => $values['civicrm_relationship_type_id']);
- $relValues = array();
+ $relType = ['id' => $values['civicrm_relationship_type_id']];
+ $relValues = [];
CRM_Contact_BAO_RelationshipType::retrieve($relType, $relValues);
// Check if contact's relationship type exists in membership type
- $relTypeDirs = array();
+ $relTypeDirs = [];
$relTypeIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $membershipType['relationship_type_id']);
$relDirections = explode(CRM_Core_DAO::VALUE_SEPARATOR, $membershipType['relationship_direction']);
$bidirectional = FALSE;
//get the membership status and type values.
$statusANDType = self::getStatusANDTypeValues($membership->id);
- foreach (array(
- 'status',
- 'membership_type',
- ) as $fld) {
+ foreach ([
+ 'status',
+ 'membership_type',
+ ] as $fld) {
$defaults[$fld] = CRM_Utils_Array::value($fld, $statusANDType[$membership->id]);
}
if (!empty($statusANDType[$membership->id]['is_current_member'])) {
* Array of key value pairs
*/
public static function getStatusANDTypeValues($membershipId) {
- $values = array();
+ $values = [];
if (!$membershipId) {
return $values;
}
INNER JOIN civicrm_membership_status status ON ( status.id = membership.status_id )
INNER JOIN civicrm_membership_type type ON ( type.id = membership.membership_type_id )
WHERE membership.id = %1';
- $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($membershipId, 'Positive')));
- $properties = array(
+ $dao = CRM_Core_DAO::executeQuery($sql, [1 => [$membershipId, 'Positive']]);
+ $properties = [
'status',
'status_id',
'membership_type',
'membership_type_id',
'is_current_member',
'relationship_type_id',
- );
+ ];
while ($dao->fetch()) {
foreach ($properties as $property) {
$values[$dao->id][$property] = $dao->$property;
*/
public static function deleteMembership($membershipId, $preserveContrib = FALSE) {
// CRM-12147, retrieve membership data before we delete it for hooks
- $params = array('id' => $membershipId);
- $memValues = array();
+ $params = ['id' => $membershipId];
+ $memValues = [];
$memberships = self::getValues($params, $memValues);
$membership = $memberships[$membershipId];
//delete activity record
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
- $params = array();
+ $params = [];
$deleteActivity = FALSE;
- $membershipActivities = array(
+ $membershipActivities = [
'Membership Signup',
'Membership Renewal',
'Change Membership Status',
'Change Membership Type',
'Membership Renewal Reminder',
- );
+ ];
foreach ($membershipActivities as $membershipActivity) {
$activityId = array_search($membershipActivity, $activityTypes);
if ($activityId) {
CRM_Utils_Hook::post('delete', 'Membership', $membership->id, $membership);
// delete the recently created Membership
- $membershipRecent = array(
+ $membershipRecent = [
'id' => $membershipId,
'type' => 'Membership',
- );
+ ];
CRM_Utils_Recent::del($membershipRecent);
return $results;
* array of memberships based on status
*/
public static function activeMembers($memberships, $status = 'active') {
- $actives = array();
+ $actives = [];
if ($status == 'active') {
foreach ($memberships as $f => $v) {
if (!empty($v['active'])) {
* @return array|null
*/
public static function getMembershipBlock($pageID) {
- $membershipBlock = array();
+ $membershipBlock = [];
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->entity_table = 'civicrm_contribution_page';
if (!is_array($membershipTypes)) {
return $membershipBlock;
}
- $memTypes = array();
+ $memTypes = [];
foreach ($membershipTypes as $key => $value) {
$membershipBlock['auto_renew'][$key] = $value;
$memTypes[$key] = $key;
}
//avoid pending membership as current membership: CRM-3027
- $statusIds = array(array_search('Pending', CRM_Member_PseudoConstant::membershipStatus()));
+ $statusIds = [array_search('Pending', CRM_Member_PseudoConstant::membershipStatus())];
if (!$membershipId) {
// CRM-15475
$statusIds[] = array_search(
// CRM-8141
if ($onlySameParentOrg && $memType) {
// require the same parent org as the $memType
- $params = array('id' => $memType);
- $membershipType = array();
+ $params = ['id' => $memType];
+ $membershipType = [];
if (CRM_Member_BAO_MembershipType::retrieve($params, $membershipType)) {
- $memberTypesSameParentOrg = civicrm_api3('MembershipType', 'get', array(
+ $memberTypesSameParentOrg = civicrm_api3('MembershipType', 'get', [
'member_of_contact_id' => $membershipType['member_of_contact_id'],
- 'options' => array(
+ 'options' => [
'limit' => 0,
- ),
- ));
- $memberTypesSameParentOrgList = implode(',', array_keys(CRM_Utils_Array::value('values', $memberTypesSameParentOrg, array())));
+ ],
+ ]);
+ $memberTypesSameParentOrgList = implode(',', array_keys(CRM_Utils_Array::value('values', $memberTypesSameParentOrg, [])));
$dao->whereAdd('membership_type_id IN (' . $memberTypesSameParentOrgList . ')');
}
}
if ($dao->find(TRUE)) {
- $membership = array();
+ $membership = [];
CRM_Core_DAO::storeValues($dao, $membership);
$membership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus',
$membership['status_id'],
unset($dao->membership_type_id);
if ($dao->find(TRUE)) {
- $membership = array();
+ $membership = [];
CRM_Core_DAO::storeValues($dao, $membership);
$membership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus',
$membership['status_id'],
public static function &importableFields($contactType = 'Individual', $status = TRUE) {
if (!self::$_importableFields) {
if (!self::$_importableFields) {
- self::$_importableFields = array();
+ self::$_importableFields = [];
}
if (!$status) {
- $fields = array('' => array('title' => '- ' . ts('do not import') . ' -'));
+ $fields = ['' => ['title' => '- ' . ts('do not import') . ' -']];
}
else {
- $fields = array('' => array('title' => '- ' . ts('Membership Fields') . ' -'));
+ $fields = ['' => ['title' => '- ' . ts('Membership Fields') . ' -']];
}
$tmpFields = CRM_Member_DAO_Membership::import();
$contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
// Using new Dedupe rule.
- $ruleParams = array(
+ $ruleParams = [
'contact_type' => $contactType,
'used' => 'Unsupervised',
- );
+ ];
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
- $tmpContactField = array();
+ $tmpContactField = [];
if (is_array($fieldsArray)) {
foreach ($fieldsArray as $value) {
$customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
$expFieldsMemType = CRM_Member_DAO_MembershipType::export();
$fields = array_merge($expFieldMembership, $expFieldsMemType);
$fields = array_merge($fields, $expFieldMembership);
- $membershipStatus = array(
- 'membership_status' => array(
+ $membershipStatus = [
+ 'membership_status' => [
'title' => ts('Membership Status'),
'name' => 'membership_status',
'type' => CRM_Utils_Type::T_STRING,
'where' => 'civicrm_membership_status.name',
- ),
- );
+ ],
+ ];
//CRM-6161 fix for customdata export
$fields = array_merge($fields, $membershipStatus, CRM_Core_BAO_CustomField::getFieldsForImport('Membership'));
return $fields;
$query .= ($isOwner) ? ' AND owner_membership_id IS NULL' : '';
- $params = array(
- 1 => array(self::$_signupActType, 'Integer'),
- 2 => array(self::$_renewalActType, 'Integer'),
- 3 => array($membershipTypeId, 'Integer'),
- );
+ $params = [
+ 1 => [self::$_signupActType, 'Integer'],
+ 2 => [self::$_renewalActType, 'Integer'],
+ 3 => [$membershipTypeId, 'Integer'],
+ ];
$memberCount = CRM_Core_DAO::singleValueQuery($query, $params);
return (int) $memberCount;
*/
public static function getMembershipCount($membershipTypeId, $date = NULL, $isTest = 0, $isOwner = 0) {
if (!CRM_Utils_Rule::date($date)) {
- CRM_Core_Error::fatal(ts('Invalid date "%1" (must have form yyyy-mm-dd).', array(1 => $date)));
+ CRM_Core_Error::fatal(ts('Invalid date "%1" (must have form yyyy-mm-dd).', [1 => $date]));
}
- $params = array(
- 1 => array($membershipTypeId, 'Integer'),
- 2 => array($isTest, 'Boolean'),
- );
+ $params = [
+ 1 => [$membershipTypeId, 'Integer'],
+ 2 => [$isTest, 'Boolean'],
+ ];
$query = "SELECT count(civicrm_membership.id ) as member_count
FROM civicrm_membership left join civicrm_membership_status on ( civicrm_membership.status_id = civicrm_membership_status.id )
WHERE civicrm_membership.membership_type_id = %1
return;
}
- $params = array(
- 1 => array($contribution->contribution_recur_id, 'Integer'),
- 2 => array($membership->id, 'Integer'),
- );
+ $params = [
+ 1 => [$contribution->contribution_recur_id, 'Integer'],
+ 2 => [$membership->id, 'Integer'],
+ ];
$sql = "UPDATE civicrm_membership SET contribution_recur_id = %1 WHERE id = %2";
CRM_Core_DAO::executeQuery($sql, $params);
);
$format = '%Y%m%d';
- $logParams = array(
+ $logParams = [
'membership_id' => $currentMembership['id'],
'status_id' => $status['id'],
'start_date' => CRM_Utils_Date::customFormat(
),
'membership_type_id' => $currentMembership['membership_type_id'],
'max_related' => CRM_Utils_Array::value('max_related', $currentMembership, 0),
- );
+ ];
$session = CRM_Core_Session::singleton();
// If we have an authenticated session, set modified_id to that user's contact_id, else set to membership.contact_id
CRM_Activity_BAO_Activity::addActivity($memberDAO,
'Change Membership Status',
NULL,
- array(
+ [
'subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$status['id']]}",
'source_contact_id' => $logParams['modified_id'],
'priority_id' => 'Normal',
- )
+ ]
);
CRM_Member_BAO_MembershipLog::add($logParams);
*/
public static function createRelatedMemberships(&$params, &$dao, $reset = FALSE) {
// CRM-4213 check for loops, using static variable to record contacts already processed.
- static $relatedContactIds = array();
+ static $relatedContactIds = [];
if ($reset) {
// We need a way to reset this static variable from the test suite.
// @todo consider replacing with Civi::$statics but note reset now used elsewhere: CRM-17723.
- $relatedContactIds = array();
+ $relatedContactIds = [];
return FALSE;
}
$expiredStatusId = array_search('Expired', CRM_Member_PseudoConstant::membershipStatus());
}
- $allRelatedContacts = array();
- $relatedContacts = array();
+ $allRelatedContacts = [];
+ $relatedContacts = [];
if (!is_a($membership, 'CRM_Core_Error')) {
$allRelatedContacts = CRM_Member_BAO_Membership::checkMembershipRelationship($membership->membership_type_id,
$membership->contact_id,
// Number of inherited memberships available - NULL is interpreted as unlimited, '0' as none
$numRelatedAvailable = ($membership->max_related == NULL ? PHP_INT_MAX : $membership->max_related);
// will be used to queue potential memberships to be created.
- $queue = array();
+ $queue = [];
foreach ($relatedContacts as $contactId => $relationshipStatus) {
//use existing membership record.
*
* @return array
*/
- public static function buildMembershipTypeValues(&$form, $membershipTypeID = array(), $activeOnly = FALSE) {
+ public static function buildMembershipTypeValues(&$form, $membershipTypeID = [], $activeOnly = FALSE) {
$whereClause = " WHERE domain_id = " . CRM_Core_Config::domainID();
$membershipTypeIDS = (array) $membershipTypeID;
";
$dao = CRM_Core_DAO::executeQuery($query);
- $membershipTypeValues = array();
- $membershipTypeFields = array(
+ $membershipTypeValues = [];
+ $membershipTypeFields = [
'id',
'minimum_fee',
'name',
'max_related',
'duration_unit',
'duration_interval',
- );
+ ];
while ($dao->fetch()) {
- $membershipTypeValues[$dao->id] = array();
+ $membershipTypeValues[$dao->id] = [];
foreach ($membershipTypeFields as $mtField) {
$membershipTypeValues[$dao->id][$mtField] = $dao->$mtField;
}
$cacheKeyString = "$mid";
$cacheKeyString .= $isNotCancelled ? '_1' : '_0';
- static $supportsCancel = array();
+ static $supportsCancel = [];
if (!array_key_exists($cacheKeyString, $supportsCancel)) {
$supportsCancel[$cacheKeyString] = FALSE;
FROM civicrm_contribution_recur cr
LEFT JOIN civicrm_membership mem ON ( cr.id = mem.contribution_recur_id )
WHERE mem.id = %1 LIMIT 1";
- $params = array(1 => array($mid, 'Integer'));
+ $params = [1 => [$mid, 'Integer']];
$statusId = CRM_Core_DAO::singleValueQuery($sql, $params);
$status = CRM_Contribute_PseudoConstant::contributionStatus($statusId, 'name');
if ($status == 'Cancelled') {
AND activity.activity_date_time >= '$startDate' AND activity.activity_date_time <= '$endDate 23:59:59'
AND {$testClause}";
- $params = array(
- 1 => array(self::$_signupActType, 'Integer'),
- 2 => array($membershipTypeId, 'Integer'),
- );
+ $params = [
+ 1 => [self::$_signupActType, 'Integer'],
+ 2 => [$membershipTypeId, 'Integer'],
+ ];
$memberCount = CRM_Core_DAO::singleValueQuery($query, $params);
AND activity.activity_date_time >= '$startDate' AND activity.activity_date_time <= '$endDate 23:59:59'
AND {$testClause}";
- $params = array(
- 1 => array(self::$_renewalActType, 'Integer'),
- 2 => array($membershipTypeId, 'Integer'),
- );
+ $params = [
+ 1 => [self::$_renewalActType, 'Integer'],
+ 2 => [$membershipTypeId, 'Integer'],
+ ];
$memberCount = CRM_Core_DAO::singleValueQuery($query, $params);
return (int) $memberCount;
* @return array
* @throws \CRM_Core_Exception
*/
- public static function processMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $campaignId, $formDates = array(), $contribution = NULL, $lineItems = array()) {
+ public static function processMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $campaignId, $formDates = [], $contribution = NULL, $lineItems = []) {
$renewalMode = $updateStatusId = FALSE;
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$format = '%Y%m%d';
$statusFormat = '%Y-%m-%d';
$membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipTypeID);
- $dates = array();
- $ids = array();
+ $dates = [];
+ $ids = [];
// CRM-7297 - allow membership type to be be changed during renewal so long as the parent org of new membershipType
// is the same as the parent org of an existing membership of the contact
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($contactID, $membershipTypeID,
// Do NOT do anything.
//1. membership with status : PENDING/CANCELLED (CRM-2395)
//2. Paylater/IPN renew. CRM-4556.
- if ($pending || in_array($currentMembership['status_id'], array(
- array_search('Pending', $allStatus),
- // CRM-15475
- array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus(NULL, " name = 'Cancelled' ", 'name', FALSE, TRUE)),
- ))) {
+ if ($pending || in_array($currentMembership['status_id'], [
+ array_search('Pending', $allStatus),
+ // CRM-15475
+ array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus(NULL, " name = 'Cancelled' ", 'name', FALSE, TRUE)),
+ ])) {
- $memParams = array(
+ $memParams = [
'id' => $currentMembership['id'],
'contribution' => $contribution,
'status_id' => $currentMembership['status_id'],
'membership_type_id' => $membershipTypeID,
'max_related' => !empty($membershipTypeDetails['max_related']) ? $membershipTypeDetails['max_related'] : NULL,
'membership_activity_status' => ($pending || $isPayLater) ? 'Scheduled' : 'Completed',
- );
+ ];
if ($contributionRecurID) {
$memParams['contribution_recur_id'] = $contributionRecurID;
}
// @todo stop passing $ids - it is empty
$membership = self::create($memParams, $ids);
- return array($membership, $renewalMode, $dates);
+ return [$membership, $renewalMode, $dates];
}
// Check and fix the membership if it is STALE
);
$currentMembership['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
- foreach (array('start_date', 'end_date') as $dateType) {
+ foreach (['start_date', 'end_date'] as $dateType) {
$currentMembership[$dateType] = CRM_Utils_Array::value($dateType, $formDates);
if (empty($currentMembership[$dateType])) {
$currentMembership[$dateType] = CRM_Utils_Array::value($dateType, $dates);
);
// Insert renewed dates for CURRENT membership
- $memParams = array();
+ $memParams = [];
$memParams['join_date'] = CRM_Utils_Date::isoToMysql($membership->join_date);
$memParams['start_date'] = CRM_Utils_Array::value('start_date', $formDates, CRM_Utils_Date::isoToMysql($membership->start_date));
$memParams['end_date'] = CRM_Utils_Array::value('end_date', $formDates);
}
else {
// NEW Membership
- $memParams = array(
+ $memParams = [
'contact_id' => $contactID,
'membership_type_id' => $membershipTypeID,
- );
+ ];
if (!$pending) {
$dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeID, NULL, NULL, NULL, $numRenewTerms);
- foreach (array('join_date', 'start_date', 'end_date') as $dateType) {
+ foreach (['join_date', 'start_date', 'end_date'] as $dateType) {
$memParams[$dateType] = CRM_Utils_Array::value($dateType, $formDates);
if (empty($memParams[$dateType])) {
$memParams[$dateType] = CRM_Utils_Array::value($dateType, $dates);
}
$status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate(CRM_Utils_Date::customFormat($dates['start_date'],
- $statusFormat
- ),
+ $statusFormat
+ ),
CRM_Utils_Date::customFormat($dates['end_date'],
$statusFormat
),
// related to: http://forum.civicrm.org/index.php/topic,11416.msg49072.html#msg49072
$membership->find(TRUE);
- return array($membership, $renewalMode, $dates);
+ return [$membership, $renewalMode, $dates];
}
/**
$priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
// The name of the price field corresponds to the membership_type organization contact.
- $params = array(
+ $params = [
'price_set_id' => $priceSetId,
'name' => $membershipOrg,
- );
- $results = array();
+ ];
+ $results = [];
CRM_Price_BAO_PriceField::retrieve($params, $results);
if (!empty($results)) {
$fields[$results['id']] = $priceSets['fields'][$results['id']];
$fid = $results['id'];
- $editedFieldParams = array(
+ $editedFieldParams = [
'price_field_id' => $results['id'],
'membership_type_id' => $membershipTypeID,
- );
- $results = array();
+ ];
+ $results = [];
CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $results);
$fields[$fid]['options'][$results['id']] = $priceSets['fields'][$fid]['options'][$results['id']];
if (!empty($total_amount)) {
}
$fieldID = key($fields);
- $returnParams = array(
+ $returnParams = [
'price_set_id' => $priceSetId,
'price_sets' => $priceSets,
'fields' => $fields,
- 'price_fields' => array(
+ 'price_fields' => [
'price_' . $fieldID => CRM_Utils_Array::value('id', $results),
- ),
- );
+ ],
+ ];
return $returnParams;
}
*
* @return int|int[]
* contribution id
+ * @todo we should get this off the line item
+ *
*/
public static function getMembershipContributionId($membershipId, $all = FALSE) {
$membershipPayment = new CRM_Member_DAO_MembershipPayment();
$membershipPayment->membership_id = $membershipId;
if ($all && $membershipPayment->find()) {
- $contributionIds = array();
+ $contributionIds = [];
while ($membershipPayment->fetch()) {
$contributionIds[] = $membershipPayment->contribution_id;
}
$query = $baseQuery . " AND (civicrm_membership.is_override = 0 OR civicrm_membership.is_override IS NULL)
AND civicrm_membership.status_id NOT IN (%1, %2, %3, %4)
AND civicrm_membership.owner_membership_id IS NULL ";
- $params = array(
- 1 => array($pendingStatusId, 'Integer'),
- 2 => array($cancelledStatusId, 'Integer'),
- 3 => array($expiredStatusId, 'Integer'),
- 4 => array($deceaseStatusId, 'Integer'),
- );
+ $params = [
+ 1 => [$pendingStatusId, 'Integer'],
+ 2 => [$cancelledStatusId, 'Integer'],
+ 3 => [$expiredStatusId, 'Integer'],
+ 4 => [$deceaseStatusId, 'Integer'],
+ ];
$dao2 = CRM_Core_DAO::executeQuery($query, $params);
while ($dao2->fetch()) {
$processCount++;
// Put common parameters into array for easy access
- $memberParams = array(
+ $memberParams = [
'id' => $dao2->membership_id,
'status_id' => $dao2->status_id,
'contact_id' => $dao2->contact_id,
'source' => $dao2->source,
'skipStatusCal' => TRUE,
'skipRecentView' => TRUE,
- );
+ ];
// CRM-7248: added excludeIsAdmin param to the following fn call to prevent moving to admin statuses
//get the membership status as per id.
$newStatus = civicrm_api('membership_status', 'calc',
- array(
+ [
'membership_id' => $dao2->membership_id,
'version' => 3,
'ignore_admin_only' => TRUE,
- ), TRUE
+ ], TRUE
);
$statusId = CRM_Utils_Array::value('id', $newStatus);
}
}
$result['is_error'] = 0;
- $result['messages'] = ts('Processed %1 membership records. Updated %2 records.', array(
+ $result['messages'] = ts('Processed %1 membership records. Updated %2 records.', [
1 => $processCount,
2 => $updateCount,
- ));
+ ]);
return $result;
}
$datesDifference = $todayDate->diff($overrideEndDate);
$daysDifference = (int) $datesDifference->format('%R%a');
if ($daysDifference <= 0) {
- $params = array(
+ $params = [
'id' => $membership->membership_id,
'is_override' => FALSE,
'status_override_end_date' => 'null',
- );
+ ];
civicrm_api3('membership', 'create', $params);
}
}
* @return array
*/
public static function getAllContactMembership($contactID, $isTest = FALSE, $onlyLifeTime = FALSE) {
- $contactMembershipType = array();
+ $contactMembershipType = [];
if (!$contactID) {
return $contactMembershipType;
}
$dao->find();
while ($dao->fetch()) {
- $membership = array();
+ $membership = [];
CRM_Core_DAO::storeValues($dao, $membership);
$contactMembershipType[$dao->membership_type_id] = $membership;
}
* @param array $params
* Array of submitted params.
* @param array $ids
- * (@deprecated) array of ids.
+ * (@return CRM_Contribute_BAO_Contribution
+ *
+ * @deprecated) array of ids.
*
- * @return CRM_Contribute_BAO_Contribution
*/
- public static function recordMembershipContribution(&$params, $ids = array()) {
+ public static function recordMembershipContribution(&$params, $ids = []) {
if (!empty($ids)) {
CRM_Core_Error::deprecatedFunctionWarning('no $ids array');
}
$membershipId = $params['membership_id'];
- $contributionParams = array();
+ $contributionParams = [];
$config = CRM_Core_Config::singleton();
$contributionParams['currency'] = $config->defaultCurrency;
$contributionParams['receipt_date'] = (CRM_Utils_Array::value('receipt_date', $params)) ? $params['receipt_date'] : 'null';
$contributionParams['skipCleanMoney'] = TRUE;
$contributionParams['payment_processor'] = CRM_Utils_Array::value('payment_processor_id', $params);
$contributionSoftParams = CRM_Utils_Array::value('soft_credit', $params);
- $recordContribution = array(
+ $recordContribution = [
'contact_id',
'fee_amount',
'total_amount',
'contribution_recur_id',
'pan_truncation',
'card_type_id',
- );
+ ];
foreach ($recordContribution as $f) {
$contributionParams[$f] = CRM_Utils_Array::value($f, $params);
}
*/
public static function getContactsCancelledMembership($contactID, $isTest = FALSE) {
if (!$contactID) {
- return array();
+ return [];
}
$query = 'SELECT membership_type_id FROM civicrm_membership WHERE contact_id = %1 AND status_id = %2 AND is_test = %3';
- $queryParams = array(
- 1 => array($contactID, 'Integer'),
- 2 => array(
+ $queryParams = [
+ 1 => [$contactID, 'Integer'],
+ 2 => [
// CRM-15475
array_search(
'Cancelled',
)
),
'Integer',
- ),
- 3 => array($isTest, 'Boolean'),
- );
+ ],
+ 3 => [$isTest, 'Boolean'],
+ ];
$dao = CRM_Core_DAO::executeQuery($query, $queryParams);
- $cancelledMembershipIds = array();
+ $cancelledMembershipIds = [];
while ($dao->fetch()) {
$cancelledMembershipIds[] = $dao->membership_type_id;
}
* Retrieve all memberships that belongs to each contacts and
* keep track of each membership type.
*/
- $mainContactMemberships = array();
- $otherContactMemberships = array();
+ $mainContactMemberships = [];
+ $otherContactMemberships = [];
$sql = "SELECT id, membership_type_id FROM civicrm_membership membership WHERE contact_id = %1";
- $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($mainContactID, "Integer")));
+ $dao = CRM_Core_DAO::executeQuery($sql, [1 => [$mainContactID, "Integer"]]);
while ($dao->fetch()) {
$mainContactMemberships[$dao->id] = $dao->membership_type_id;
}
- $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($otherContactID, "Integer")));
+ $dao = CRM_Core_DAO::executeQuery($sql, [1 => [$otherContactID, "Integer"]]);
while ($dao->fetch()) {
$otherContactMemberships[$dao->id] = $dao->membership_type_id;
}
* FIXME: what should we do if we have multiple memberships with
* the same type (currently we only take the first one)?
*/
- $newSql = array();
+ $newSql = [];
foreach ($otherContactMemberships as $otherMembershipId => $otherMembershipTypeId) {
if ($newMembershipId = array_search($otherMembershipTypeId, $mainContactMemberships)) {
$newMembership = CRM_Member_DAO_Membership::findById($newMembershipId);
$otherMembership = CRM_Member_DAO_Membership::findById($otherMembershipId);
- $updates = array();
+ $updates = [];
if (new DateTime($otherMembership->join_date) < new DateTime($newMembership->join_date)) {
$updates["join_date"] = $otherMembership->join_date;
}