当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_BAO_RelationshipType::find方法代码示例

本文整理汇总了PHP中CRM_Contact_BAO_RelationshipType::find方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_RelationshipType::find方法的具体用法?PHP CRM_Contact_BAO_RelationshipType::find怎么用?PHP CRM_Contact_BAO_RelationshipType::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contact_BAO_RelationshipType的用法示例。


在下文中一共展示了CRM_Contact_BAO_RelationshipType::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: civicrm_membership_contact_get

/**
 * Get contact membership record.
 * 
 * This api is used for finding an existing membership record.
 * This api will also return the mebership records for the contacts
 * having mebership based on the relationship with the direct members.
 * 
 * @param  Array $params key/value pairs for contact_id and some
 *          options affecting the desired results; has legacy support
 *          for just passing the contact_id itself as the argument
 *
 * @return  Array of all found membership property values.
 * @access public
 */
function civicrm_membership_contact_get(&$params)
{
    _civicrm_initialize();
    $activeOnly = false;
    if (is_array($params)) {
        $contactID = CRM_Utils_Array::value('contact_id', $params);
        $activeOnly = CRM_Utils_Array::value('active_only', $params, false);
        if ($activeOnly == 1) {
            $activeOnly = true;
        } else {
            $activeOnly = false;
        }
    } elseif (CRM_Utils_Rule::integer($params)) {
        $contactID = $params;
    } else {
        return civicrm_create_error('Paramers can be only of type array or integer');
    }
    if (empty($contactID)) {
        return civicrm_create_error('Invalid value for ContactID.');
    }
    // get the membership for the given contact ID
    require_once 'CRM/Member/BAO/Membership.php';
    $membership = array('contact_id' => $contactID);
    $membershipValues = array();
    CRM_Member_BAO_Membership::getValues($membership, $membershipValues, $activeOnly);
    $recordCount = 0;
    if (empty($membershipValues)) {
        # No results is NOT an error!
        # return civicrm_create_error('No memberships for this contact.');
        $membershipValues['record_count'] = $recordCount;
        return $membershipValues;
    }
    $members[$contactID] = array();
    $relationships = array();
    foreach ($membershipValues as $membershipId => $values) {
        // populate the membership type name for the membership type id
        require_once 'CRM/Member/BAO/MembershipType.php';
        $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
        $membershipValues[$membershipId]['membership_name'] = $membershipType['name'];
        if (CRM_Utils_Array::value('relationship_type_id', $membershipType)) {
            $relationships[$membershipType['relationship_type_id']] = $membershipId;
        }
        // populating relationship type name.
        require_once 'CRM/Contact/BAO/RelationshipType.php';
        $relationshipType = new CRM_Contact_BAO_RelationshipType();
        $relationshipType->id = CRM_Utils_Array::value('relationship_type_id', $membershipType);
        if ($relationshipType->find(true)) {
            $membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b;
        }
        require_once 'CRM/Core/BAO/CustomGroup.php';
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Membership', CRM_Core_DAO::$_nullObject, $membershipId, false, $values['membership_type_id']);
        $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
        $defaults = array();
        CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
        if (!empty($defaults)) {
            foreach ($defaults as $key => $val) {
                $membershipValues[$membershipId][$key] = $val;
            }
        }
        $recordCount++;
    }
    $members[$contactID] = $membershipValues;
    // populating contacts in members array based on their relationship with direct members.
    require_once 'CRM/Contact/BAO/Relationship.php';
    if (!empty($relationships)) {
        foreach ($relationships as $relTypeId => $membershipId) {
            // As members are not direct members, there should not be
            // membership id in the result array.
            unset($membershipValues[$membershipId]['id']);
            $relationship = new CRM_Contact_BAO_Relationship();
            $relationship->contact_id_b = $contactID;
            $relationship->relationship_type_id = $relTypeId;
            if ($relationship->find()) {
                while ($relationship->fetch()) {
                    clone $relationship;
                    $membershipValues[$membershipId]['contact_id'] = $relationship->contact_id_a;
                    $members[$contactID][$relationship->contact_id_a] = $membershipValues[$membershipId];
                }
            }
            $recordCount++;
        }
    }
    $members['record_count'] = $recordCount;
    return $members;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:99,代码来源:MembershipContact.php

示例2: buildMappingForm


//.........这里部分代码省略.........
             foreach ($locationTypes as $key => $value) {
                 if (trim($key) != '') {
                     $sel4[$k]['phone'][$key] =& $phoneTypes;
                     $sel4[$k]['im'][$key] =& $imProviders;
                 }
             }
         }
     }
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             foreach ($mapperFields[$k] as $key => $value) {
                 if (isset($hasLocationTypes[$k][$key])) {
                     $sel3[$k][$key] = $locationTypes;
                 } else {
                     $sel3[$key] = NULL;
                 }
             }
         }
     }
     // Array for core fields and relationship custom data
     $relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE);
     if ($mappingType == 'Export') {
         foreach ($sel1 as $k => $sel) {
             if ($k) {
                 foreach ($mapperFields[$k] as $field => $dontCare) {
                     if (isset($hasRelationTypes[$k][$field])) {
                         list($id, $first, $second) = explode('_', $field);
                         // FIX ME: For now let's not expose custom data related to relationship
                         $relationshipCustomFields = array();
                         //$relationshipCustomFields    = self::getRelationTypeCustomGroupData( $id );
                         //asort($relationshipCustomFields);
                         $relationshipType = new CRM_Contact_BAO_RelationshipType();
                         $relationshipType->id = $id;
                         if ($relationshipType->find(TRUE)) {
                             $direction = "contact_sub_type_{$second}";
                             if (isset($relationshipType->{$direction})) {
                                 $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->{$direction}], (array) $relationshipCustomFields);
                             } else {
                                 $target_type = 'contact_type_' . $second;
                                 $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->{$target_type}], (array) $relationshipCustomFields);
                             }
                         }
                         $relationshipType->free();
                         asort($relatedFields);
                         $sel5[$k][$field] = $relatedFields;
                     }
                 }
             }
         }
         //Location Type for relationship fields
         foreach ($sel5 as $k => $v) {
             if ($v) {
                 foreach ($v as $rel => $fields) {
                     foreach ($fields as $field => $fieldLabel) {
                         if (isset($hasLocationTypes[$k][$field])) {
                             $sel6[$k][$rel][$field] = $locationTypes;
                         }
                     }
                 }
             }
         }
         //PhoneTypes for  relationship fields
         $sel7[''] = NULL;
         foreach ($sel6 as $k => $rel) {
             if ($k) {
                 foreach ($rel as $phonekey => $phonevalue) {
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:67,代码来源:Mapping.php

示例3: isErrorInCustomData


//.........这里部分代码省略.........
                 }
                 // need not check for label filed import
                 $htmlType = array('CheckBox', 'Multi-Select', 'AdvMulti-Select', 'Select', 'Radio', 'Multi-Select State/Province', 'Multi-Select Country');
                 if (!in_array($customFields[$customFieldID]['html_type'], $htmlType) || $customFields[$customFieldID]['data_type'] == 'Boolean' || $customFields[$customFieldID]['data_type'] == 'ContactReference') {
                     $valid = CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $value);
                     if (!$valid) {
                         self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                     }
                 }
                 // check for values for custom fields for checkboxes and multiselect
                 if ($customFields[$customFieldID]['html_type'] == 'CheckBox' || $customFields[$customFieldID]['html_type'] == 'AdvMulti-Select' || $customFields[$customFieldID]['html_type'] == 'Multi-Select') {
                     $value = trim($value);
                     $value = str_replace('|', ',', $value);
                     $mulValues = explode(',', $value);
                     $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
                     foreach ($mulValues as $v1) {
                         if (strlen($v1) == 0) {
                             continue;
                         }
                         $flag = FALSE;
                         foreach ($customOption as $v2) {
                             if (strtolower(trim($v2['label'])) == strtolower(trim($v1)) || strtolower(trim($v2['value'])) == strtolower(trim($v1))) {
                                 $flag = TRUE;
                             }
                         }
                         if (!$flag) {
                             self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                         }
                     }
                 } elseif ($customFields[$customFieldID]['html_type'] == 'Select' || $customFields[$customFieldID]['html_type'] == 'Radio' && $customFields[$customFieldID]['data_type'] != 'Boolean') {
                     $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
                     $flag = FALSE;
                     foreach ($customOption as $v2) {
                         if (strtolower(trim($v2['label'])) == strtolower(trim($value)) || strtolower(trim($v2['value'])) == strtolower(trim($value))) {
                             $flag = TRUE;
                         }
                     }
                     if (!$flag) {
                         self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                     }
                 } elseif ($customFields[$customFieldID]['html_type'] == 'Multi-Select State/Province') {
                     $mulValues = explode(',', $value);
                     foreach ($mulValues as $stateValue) {
                         if ($stateValue) {
                             if (self::in_value(trim($stateValue), CRM_Core_PseudoConstant::stateProvinceAbbreviation()) || self::in_value(trim($stateValue), CRM_Core_PseudoConstant::stateProvince())) {
                                 continue;
                             } else {
                                 self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                             }
                         }
                     }
                 } elseif ($customFields[$customFieldID]['html_type'] == 'Multi-Select Country') {
                     $mulValues = explode(',', $value);
                     foreach ($mulValues as $countryValue) {
                         if ($countryValue) {
                             CRM_Core_PseudoConstant::populate($countryNames, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
                             CRM_Core_PseudoConstant::populate($countryIsoCodes, 'CRM_Core_DAO_Country', TRUE, 'iso_code');
                             $config = CRM_Core_Config::singleton();
                             $limitCodes = $config->countryLimit();
                             $error = TRUE;
                             foreach (array($countryNames, $countryIsoCodes, $limitCodes) as $values) {
                                 if (in_array(trim($countryValue), $values)) {
                                     $error = FALSE;
                                     break;
                                 }
                             }
                             if ($error) {
                                 self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                             }
                         }
                     }
                 }
             }
         } elseif (is_array($params[$key]) && isset($params[$key]["contact_type"])) {
             //CRM-5125
             //supporting custom data of related contact subtypes
             $relation = NULL;
             if ($relationships) {
                 if (array_key_exists($key, $relationships)) {
                     $relation = $key;
                 } elseif (CRM_Utils_Array::key($key, $relationships)) {
                     $relation = CRM_Utils_Array::key($key, $relationships);
                 }
             }
             if (!empty($relation)) {
                 list($id, $first, $second) = CRM_Utils_System::explode('_', $relation, 3);
                 $direction = "contact_sub_type_{$second}";
                 $relationshipType = new CRM_Contact_BAO_RelationshipType();
                 $relationshipType->id = $id;
                 if ($relationshipType->find(TRUE)) {
                     if (isset($relationshipType->{$direction})) {
                         $params[$key]['contact_sub_type'] = $relationshipType->{$direction};
                     }
                 }
                 $relationshipType->free();
             }
             self::isErrorInCustomData($params[$key], $errorMessage, $csType, $relationships);
         }
     }
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:Contact.php

示例4: _civicrm_api3_membership_relationsship_get_customv2behaviour

/**
 * non-standard behaviour inherited from v2
* @param array $params parameters passed into get function
* @return array result for calling function
*/
function _civicrm_api3_membership_relationsship_get_customv2behaviour(&$params, $membershipValues, $contactID)
{
    $relationships = array();
    foreach ($membershipValues as $membershipId => $values) {
        // populate the membership type name for the membership type id
        $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
        $membershipValues[$membershipId]['membership_name'] = $membershipType['name'];
        if (!empty($membershipType['relationship_type_id'])) {
            $relationships[$membershipType['relationship_type_id']] = $membershipId;
        }
        // populating relationship type name.
        $relationshipType = new CRM_Contact_BAO_RelationshipType();
        $relationshipType->id = CRM_Utils_Array::value('relationship_type_id', $membershipType);
        if ($relationshipType->find(TRUE)) {
            $membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b;
        }
        _civicrm_api3_custom_data_get($membershipValues[$membershipId], 'Membership', $membershipId, NULL, $values['membership_type_id']);
    }
    $members = $membershipValues;
    // 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
            // membership id in the result array.
            unset($membershipValues[$membershipId]['id']);
            $relationship = new CRM_Contact_BAO_Relationship();
            $relationship->contact_id_b = $contactID;
            $relationship->relationship_type_id = $relTypeId;
            if ($relationship->find()) {
                while ($relationship->fetch()) {
                    clone $relationship;
                    $membershipValues[$membershipId]['contact_id'] = $relationship->contact_id_a;
                    $members[$membershipId]['related_contact_id'] = $relationship->contact_id_a;
                }
            }
        }
    }
    return $members;
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:44,代码来源:Membership.php

示例5: crm_get_contact_memberships

/**
 * Get conatct membership record.
 * 
 * This api is used for finding an existing membership record.
 * This api will also return the mebership records for the contacts
 * having mebership based on the relationship with the direct members.
 * 
 * @param  Int  $contactID  ID of a contact
 *
 * @return  Array of all found membership property values.
 * @access public
 */
function crm_get_contact_memberships($contactID)
{
    _crm_initialize();
    if (empty($contactID)) {
        return _crm_error('Invalid value for ContactID.');
    }
    // get the membership for the given contact ID
    require_once 'CRM/Member/BAO/Membership.php';
    $membership = array('contact_id' => $contactID);
    $membershipValues = array();
    CRM_Member_BAO_Membership::getValues($membership, $membershipValues);
    if (empty($membershipValues)) {
        return _crm_error('No memberships for this contact.');
    }
    foreach ($membershipValues as $membershipId => $values) {
        // populate the membership type name for the membership type id
        require_once 'CRM/Member/BAO/MembershipType.php';
        $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
        $membershipValues[$membershipId]['membership_name'] = $membershipType['name'];
        $relationships[$membershipType['relationship_type_id']] = $membershipId;
        // populating relationship type name.
        require_once 'CRM/Contact/BAO/RelationshipType.php';
        $relationshipType = new CRM_Contact_BAO_RelationshipType();
        $relationshipType->id = $membershipType['relationship_type_id'];
        if ($relationshipType->find(true)) {
            $membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b;
        }
    }
    $members[$contactID] = $membershipValues;
    // populating contacts in members array based on their relationship with direct members.
    require_once 'CRM/Contact/BAO/Relationship.php';
    foreach ($relationships as $relTypeId => $membershipId) {
        // As members are not direct members, there should not be
        // membership id in the result array.
        unset($membershipValues[$membershipId]['id']);
        $relationship = new CRM_Contact_BAO_Relationship();
        $relationship->contact_id_b = $contactID;
        $relationship->relationship_type_id = $relTypeId;
        if ($relationship->find()) {
            while ($relationship->fetch()) {
                clone $relationship;
                $membershipValues[$membershipId]['contact_id'] = $relationship->contact_id_a;
                $members[$contactID][$relationship->contact_id_a] = $membershipValues[$membershipId];
            }
        }
    }
    return $members;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:60,代码来源:Membership.php

示例6: civicrm_api3_membership_get

/**
 * Get contact membership record.
 *
 * This api will return the membership records for the contacts
 * having membership based on the relationship with the direct members.
 *
 * @param  Array $params key/value pairs for contact_id and some
 *          options affecting the desired results; has legacy support
 *          for just passing the contact_id itself as the argument
 *
 * @return  Array of all found membership property values.
 * @access public
 * @todo needs some love - basically only a get for a given contact right now
 * {@getfields membership_get}
 */
function civicrm_api3_membership_get($params)
{
    $contactID = $activeOnly = $membershipTypeId = $membershipType = NULL;
    $contactID = CRM_Utils_Array::value('contact_id', $params);
    if (is_array(CRM_Utils_Array::value('filters', $params)) && !empty($params['filters'])) {
        $activeOnly = CRM_Utils_Array::value('is_current', $params['filters'], FALSE);
    }
    $activeOnly = CRM_Utils_Array::value('active_only', $params, $activeOnly);
    //@todo replace this by handling in API layer - we should have enough info to do this
    // between pseudoconstant & fk - see comments in format_params
    $membershipTypeId = CRM_Utils_Array::value('membership_type_id', $params);
    if (!$membershipTypeId) {
        $membershipType = CRM_Utils_Array::value('membership_type', $params);
        if ($membershipType) {
            $membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $membershipType, 'id', 'name');
        }
    }
    if (CRM_Utils_Array::value('contact_id', $params)) {
        $membershipValues = _civicrm_api3_membership_get_customv2behaviour($params, $contactID, $membershipTypeId, $activeOnly);
    } else {
        //legacy behaviour only ever worked when contact_id passed in - use standard api function otherwise
        $membershipValues = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE);
    }
    if (empty($membershipValues)) {
        # No results is NOT an error!
        return civicrm_api3_create_success($membershipValues, $params);
    }
    $relationships = array();
    foreach ($membershipValues as $membershipId => $values) {
        // populate the membership type name for the membership type id
        $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
        $membershipValues[$membershipId]['membership_name'] = $membershipType['name'];
        if (CRM_Utils_Array::value('relationship_type_id', $membershipType)) {
            $relationships[$membershipType['relationship_type_id']] = $membershipId;
        }
        // populating relationship type name.
        $relationshipType = new CRM_Contact_BAO_RelationshipType();
        $relationshipType->id = CRM_Utils_Array::value('relationship_type_id', $membershipType);
        if ($relationshipType->find(TRUE)) {
            $membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b;
        }
        _civicrm_api3_custom_data_get($membershipValues[$membershipId], 'Membership', $membershipId, NULL, $values['membership_type_id']);
    }
    $members = $membershipValues;
    // 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
            // membership id in the result array.
            unset($membershipValues[$membershipId]['id']);
            $relationship = new CRM_Contact_BAO_Relationship();
            $relationship->contact_id_b = $contactID;
            $relationship->relationship_type_id = $relTypeId;
            if ($relationship->find()) {
                while ($relationship->fetch()) {
                    clone $relationship;
                    $membershipValues[$membershipId]['contact_id'] = $relationship->contact_id_a;
                    $members[$membershipId]['related_contact_id'] = $relationship->contact_id_a;
                }
            }
        }
    }
    return civicrm_api3_create_success($members, $params, 'membership', 'get');
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:79,代码来源:Membership.php


注:本文中的CRM_Contact_BAO_RelationshipType::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。