本文整理汇总了PHP中CRM_Member_BAO_MembershipType::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_MembershipType::retrieve方法的具体用法?PHP CRM_Member_BAO_MembershipType::retrieve怎么用?PHP CRM_Member_BAO_MembershipType::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_MembershipType
的用法示例。
在下文中一共展示了CRM_Member_BAO_MembershipType::retrieve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRetrieve
function testRetrieve()
{
$ids = array('memberOfContact' => $this->_orgContactID);
$params = array('name' => 'General', 'description' => null, 'minimum_fee' => 100, 'duration_unit' => 'year', 'period_type' => 'fixed', 'duration_interval' => 1, 'contribution_type_id' => $this->_contributionTypeId, 'relationship_type_id' => $this->_relationshipTypeId, 'visibility' => 'Public');
CRM_Member_BAO_MembershipType::add($params, $ids);
$params = array('name' => 'General');
$default = array();
$result = CRM_Member_BAO_MembershipType::retrieve($params, $default);
$this->assertEquals($result->name, 'General', 'Verify membership type name.');
}
示例2: testRetrieve
/**
* check function retrive()
*
*/
public function testRetrieve()
{
$ids = array();
$params = array('name' => 'General', 'description' => NULL, 'domain_id' => 1, 'minimum_fee' => 100, 'duration_unit' => 'year', 'period_type' => 'fixed', 'member_of_contact_id' => $this->_orgContactID, 'duration_interval' => 1, 'financial_type_id' => $this->_financialTypeId, 'relationship_type_id' => $this->_relationshipTypeId, 'visibility' => 'Public');
$membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
$params = array('name' => 'General');
$default = array();
$result = CRM_Member_BAO_MembershipType::retrieve($params, $default);
$this->assertEquals($result->name, 'General', 'Verify membership type name.');
$this->membershipTypeDelete(array('id' => $membershipType->id));
}
示例3: getContactMembership
/**
* Return a current membership of given contact.
*
* NB: if more than one membership meets criteria, a randomly selected one is returned.
*
* @param int $contactID
* Contact id.
* @param int $memType
* Membership type, null to retrieve all types.
* @param int $isTest
* @param int $membershipId
* If provided, then determine if it is current.
* @param bool $onlySameParentOrg
* True if only Memberships with same parent org as the $memType wanted, false otherwise.
*
* @return array|bool
*/
public static function getContactMembership($contactID, $memType, $isTest, $membershipId = NULL, $onlySameParentOrg = FALSE)
{
//check for owner membership id, if it exists update that membership instead: CRM-15992
if ($membershipId) {
$ownerMemberId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membershipId, 'owner_membership_id', 'id');
if ($ownerMemberId) {
$membershipId = $ownerMemberId;
$contactID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membershipId, 'contact_id', 'id');
}
}
$dao = new CRM_Member_DAO_Membership();
if ($membershipId) {
$dao->id = $membershipId;
}
$dao->contact_id = $contactID;
$dao->membership_type_id = $memType;
//fetch proper membership record.
if ($isTest) {
$dao->is_test = $isTest;
} else {
$dao->whereAdd('is_test IS NULL OR is_test = 0');
}
//avoid pending membership as current membership: CRM-3027
$statusIds[] = array_search('Pending', CRM_Member_PseudoConstant::membershipStatus());
if (!$membershipId) {
// CRM-15475
$statusIds[] = array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus(NULL, " name = 'Cancelled' ", 'name', FALSE, TRUE));
}
$dao->whereAdd('status_id NOT IN ( ' . implode(',', $statusIds) . ')');
// order by start date to find most recent membership first, CRM-4545
$dao->orderBy('start_date DESC');
// CRM-8141
if ($onlySameParentOrg && $memType) {
// require the same parent org as the $memType
$params = array('id' => $memType);
$membershipType = array();
if (CRM_Member_BAO_MembershipType::retrieve($params, $membershipType)) {
$memberTypesSameParentOrg = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($membershipType['member_of_contact_id']);
$memberTypesSameParentOrgList = implode(',', array_keys($memberTypesSameParentOrg));
$dao->whereAdd('membership_type_id IN (' . $memberTypesSameParentOrgList . ')');
}
}
if ($dao->find(TRUE)) {
$membership = array();
CRM_Core_DAO::storeValues($dao, $membership);
$membership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $membership['status_id'], 'is_current_member', 'id');
$ownerMemberId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membership['id'], 'owner_membership_id', 'id');
if ($ownerMemberId) {
$membership['id'] = $membership['membership_id'] = $ownerMemberId;
$membership['membership_contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membership['id'], 'contact_id', 'id');
}
return $membership;
}
// CRM-8141
if ($onlySameParentOrg && $memType) {
// see if there is a membership that has same parent as $memType but different parent than $membershipID
if ($dao->id && CRM_Core_Permission::check('edit memberships')) {
// CRM-10016, This is probably a backend renewal, and make sure we return the same membership thats being renewed.
$dao->whereAdd();
} else {
unset($dao->id);
}
unset($dao->membership_type_id);
if ($dao->find(TRUE)) {
$membership = array();
CRM_Core_DAO::storeValues($dao, $membership);
$membership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $membership['status_id'], 'is_current_member', 'id');
return $membership;
}
}
return FALSE;
}