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


PHP CRM_Contact_BAO_Relationship::legacyCreateMultiple方法代码示例

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


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

示例1: relationship

 public static function relationship()
 {
     $relType = CRM_Utils_Request::retrieve('rel_type', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     $relContactID = CRM_Utils_Request::retrieve('rel_contact', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     $relationshipID = CRM_Utils_Request::retrieve('rel_id', 'Positive', CRM_Core_DAO::$_nullObject);
     // this used only to determine add or update mode
     $caseID = CRM_Utils_Request::retrieve('case_id', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     // check if there are multiple clients for this case, if so then we need create
     // relationship and also activities for each contacts
     // get case client list
     $clientList = CRM_Case_BAO_Case::getCaseClients($caseID);
     $ret = array('is_error' => 0);
     foreach ($clientList as $sourceContactID) {
         $relationParams = array('relationship_type_id' => $relType . '_a_b', 'contact_check' => array($relContactID => 1), 'is_active' => 1, 'case_id' => $caseID, 'start_date' => date("Ymd"));
         $relationIds = array('contact' => $sourceContactID);
         // check if we are editing/updating existing relationship
         if ($relationshipID && $relationshipID != 'null') {
             // here we need to retrieve appropriate relationshipID based on client id and relationship type id
             $caseRelationships = new CRM_Contact_DAO_Relationship();
             $caseRelationships->case_id = $caseID;
             $caseRelationships->relationship_type_id = $relType;
             $caseRelationships->contact_id_a = $sourceContactID;
             $caseRelationships->find();
             while ($caseRelationships->fetch()) {
                 $relationIds['relationship'] = $caseRelationships->id;
                 $relationIds['contactTarget'] = $relContactID;
             }
             $caseRelationships->free();
         }
         // create new or update existing relationship
         $return = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationParams, $relationIds);
         if (!empty($return[4][0])) {
             $relationshipID = $return[4][0];
             //create an activity for case role assignment.CRM-4480
             CRM_Case_BAO_Case::createCaseRoleActivity($caseID, $relationshipID, $relContactID);
         } else {
             $ret = array('is_error' => 1, 'error_message' => ts('The relationship type definition for the case role is not valid for the client and / or staff contact types. You can review and edit relationship types at <a href="%1">Administer >> Option Lists >> Relationship Types</a>.', array(1 => CRM_Utils_System::url('civicrm/admin/reltype', 'reset=1'))));
         }
     }
     CRM_Utils_JSON::output($ret);
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:41,代码来源:AJAX.php

示例2: processOnBehalfOrganization

 /**
  * Add on behalf of organization and it's location.
  *
  * This situation occurs when on behalf of is enabled for the contribution page and the person
  * signing up does so on behalf of an organization.
  *
  * @param array $behalfOrganization
  *   array of organization info.
  * @param int $contactID
  *   individual contact id. One.
  *   who is doing the process of signup / contribution.
  *
  * @param array $values
  *   form values array.
  * @param array $params
  * @param array $fields
  *   Array of fields from the onbehalf profile relevant to the organization.
  */
 public static function processOnBehalfOrganization(&$behalfOrganization, &$contactID, &$values, &$params, $fields = NULL)
 {
     $isNotCurrentEmployer = FALSE;
     $dupeIDs = array();
     $orgID = NULL;
     if (!empty($behalfOrganization['organization_id'])) {
         $orgID = $behalfOrganization['organization_id'];
         unset($behalfOrganization['organization_id']);
     } else {
         // get the Employee relationship type id
         $relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
         // keep relationship params ready
         $relParams['relationship_type_id'] = $relTypeId . '_a_b';
         $relParams['is_permission_a_b'] = 1;
         $relParams['is_active'] = 1;
         $isNotCurrentEmployer = TRUE;
     }
     // formalities for creating / editing organization.
     $behalfOrganization['contact_type'] = 'Organization';
     if (!$orgID) {
         // check if matching organization contact exists
         $dedupeParams = CRM_Dedupe_Finder::formatParams($behalfOrganization, 'Organization');
         $dedupeParams['check_permission'] = FALSE;
         $dupeIDs = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Organization', 'Unsupervised');
         // CRM-6243 says to pick the first org even if more than one match
         if (count($dupeIDs) >= 1) {
             $behalfOrganization['contact_id'] = $orgID = $dupeIDs[0];
             // don't allow name edit
             unset($behalfOrganization['organization_name']);
         }
     } else {
         // if found permissioned related organization, allow location edit
         $behalfOrganization['contact_id'] = $orgID;
         // don't allow name edit
         unset($behalfOrganization['organization_name']);
     }
     // handling for image url
     if (!empty($behalfOrganization['image_URL'])) {
         CRM_Contact_BAO_Contact::processImageParams($behalfOrganization);
     }
     // create organization, add location
     $orgID = CRM_Contact_BAO_Contact::createProfileContact($behalfOrganization, $fields, $orgID, NULL, NULL, 'Organization');
     // create relationship
     if ($isNotCurrentEmployer) {
         $relParams['contact_check'][$orgID] = 1;
         $cid = array('contact' => $contactID);
         CRM_Contact_BAO_Relationship::legacyCreateMultiple($relParams, $cid);
     }
     // if multiple match - send a duplicate alert
     if ($dupeIDs && count($dupeIDs) > 1) {
         $values['onbehalf_dupe_alert'] = 1;
         // required for IPN
         $params['onbehalf_dupe_alert'] = 1;
     }
     // make sure organization-contact-id is considered for recording
     // contribution/membership etc..
     if ($contactID != $orgID) {
         // take a note of contact-id, so we can send the
         // receipt to individual contact as well.
         // required for mailing/template display ..etc
         $values['related_contact'] = $contactID;
         //make this employee of relationship as current
         //employer / employee relationship,  CRM-3532
         if ($isNotCurrentEmployer && $orgID != CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'employer_id')) {
             $isNotCurrentEmployer = FALSE;
         }
         if (!$isNotCurrentEmployer && $orgID) {
             //build current employer params
             $currentEmpParams[$contactID] = $orgID;
             CRM_Contact_BAO_Contact_Utils::setCurrentEmployer($currentEmpParams);
         }
         // contribution / signup will be done using this
         // organization id.
         $contactID = $orgID;
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:94,代码来源:Confirm.php

示例3: testRelCreateWithinDiffTypeStudentSponsor

 public function testRelCreateWithinDiffTypeStudentSponsor()
 {
     //check for Student to Sponcer
     $relTypeParams = array('name_a_b' => 'StudentToSponsor', 'name_b_a' => 'SponsorToStudent', 'contact_type_a' => 'Individual', 'contact_sub_type_a' => $this->student, 'contact_type_b' => 'Organization', 'contact_sub_type_b' => $this->sponsor);
     $relTypeIds = array();
     $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
     $params = array('relationship_type_id' => $relType->id . '_a_b', 'is_active' => 1, 'contact_check' => array($this->organization_sponsor => 1));
     $ids = array('contact' => $this->indivi_student);
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
     $this->assertEquals($valid, 1);
     $this->assertEquals(empty($relationshipIds), FALSE);
     $this->relationshipTypeDelete($relType->id);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:13,代码来源:RelationshipTest.php

示例4: createCurrentEmployerRelationship

 /**
  * Create Current employer relationship for a individual.
  *
  * @param int $contactID
  *   Contact id of the individual.
  * @param $organization
  *   (id or name).
  * @param int $previousEmployerID
  * @param bool $newContact
  *
  */
 public static function createCurrentEmployerRelationship($contactID, $organization, $previousEmployerID = NULL, $newContact = FALSE)
 {
     //if organization name is passed. CRM-15368,CRM-15547
     if ($organization && !is_numeric($organization)) {
         $organizationParams['organization_name'] = $organization;
         $dedupeParams = CRM_Dedupe_Finder::formatParams($organizationParams, 'Organization');
         $dedupeParams['check_permission'] = FALSE;
         $dupeIDs = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Organization', 'Unsupervised');
         if (is_array($dupeIDs) && !empty($dupeIDs)) {
             // we should create relationship only w/ first org CRM-4193
             foreach ($dupeIDs as $orgId) {
                 $organization = $orgId;
                 break;
             }
         } else {
             //create new organization
             $newOrg = array('contact_type' => 'Organization', 'organization_name' => $organization);
             $org = CRM_Contact_BAO_Contact::create($newOrg);
             $organization = $org->id;
         }
     }
     if ($organization && is_numeric($organization)) {
         $cid = array('contact' => $contactID);
         // get the relationship type id of "Employee of"
         $relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
         if (!$relTypeId) {
             CRM_Core_Error::fatal(ts("You seem to have deleted the relationship type 'Employee of'"));
         }
         // create employee of relationship
         $relationshipParams = array('is_active' => TRUE, 'relationship_type_id' => $relTypeId . '_a_b', 'contact_check' => array($organization => TRUE));
         list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationshipParams, $cid);
         // In case we change employer, clean previous employer related records.
         if (!$previousEmployerID && !$newContact) {
             $previousEmployerID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'employer_id');
         }
         if ($previousEmployerID && $previousEmployerID != $organization) {
             self::clearCurrentEmployer($contactID, $previousEmployerID);
         }
         // set current employer
         self::setCurrentEmployer(array($contactID => $organization));
         $relationshipParams['relationship_ids'] = $relationshipIds;
         // Handle related memberships. CRM-3792
         self::currentEmployerRelatedMembership($contactID, $organization, $relationshipParams, $duplicate, $previousEmployerID);
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:56,代码来源:Utils.php

示例5: import


//.........这里部分代码省略.........
                         $updatedContact = $this->createContact($formatting, $contactFields, $onDuplicate, $matchedIDs[0]);
                     }
                 }
                 static $relativeContact = array();
                 if (CRM_Core_Error::isAPIError($relatedNewContact, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
                     if (count($matchedIDs) >= 1) {
                         $relContactId = $matchedIDs[0];
                         //add relative contact to count during update & fill mode.
                         //logic to make count distinct by contact id.
                         if ($this->_newRelatedContacts || !empty($relativeContact)) {
                             $reContact = array_keys($relativeContact, $relContactId);
                             if (empty($reContact)) {
                                 $this->_newRelatedContacts[] = $relativeContact[] = $relContactId;
                             }
                         } else {
                             $this->_newRelatedContacts[] = $relativeContact[] = $relContactId;
                         }
                     }
                 } else {
                     $relContactId = $relatedNewContact->id;
                     $this->_newRelatedContacts[] = $relativeContact[] = $relContactId;
                 }
                 if (CRM_Core_Error::isAPIError($relatedNewContact, CRM_Core_ERROR::DUPLICATE_CONTACT) || $relatedNewContact instanceof CRM_Contact_BAO_Contact) {
                     //fix for CRM-1993.Checks for duplicate related contacts
                     if (count($matchedIDs) >= 1) {
                         //if more than one duplicate contact
                         //found, create relationship with first contact
                         // now create the relationship record
                         $relationParams = array();
                         $relationParams = array('relationship_type_id' => $key, 'contact_check' => array($relContactId => 1), 'is_active' => 1, 'skipRecentView' => TRUE);
                         // we only handle related contact success, we ignore failures for now
                         // at some point wold be nice to have related counts as separate
                         $relationIds = array('contact' => $primaryContactId);
                         list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationParams, $relationIds);
                         if ($valid || $duplicate) {
                             $relationIds['contactTarget'] = $relContactId;
                             $action = $duplicate ? CRM_Core_Action::UPDATE : CRM_Core_Action::ADD;
                             CRM_Contact_BAO_Relationship::relatedMemberships($primaryContactId, $relationParams, $relationIds, $action);
                         }
                         //handle current employer, CRM-3532
                         if ($valid) {
                             $allRelationships = CRM_Core_PseudoConstant::relationshipType('name');
                             $relationshipTypeId = str_replace(array('_a_b', '_b_a'), array('', ''), $key);
                             $relationshipType = str_replace($relationshipTypeId . '_', '', $key);
                             $orgId = $individualId = NULL;
                             if ($allRelationships[$relationshipTypeId]["name_{$relationshipType}"] == 'Employee of') {
                                 $orgId = $relContactId;
                                 $individualId = $primaryContactId;
                             } elseif ($allRelationships[$relationshipTypeId]["name_{$relationshipType}"] == 'Employer of') {
                                 $orgId = $primaryContactId;
                                 $individualId = $relContactId;
                             }
                             if ($orgId && $individualId) {
                                 $currentEmpParams[$individualId] = $orgId;
                                 CRM_Contact_BAO_Contact_Utils::setCurrentEmployer($currentEmpParams);
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($this->_updateWithId) {
         //return warning if street address is unparsed, CRM-5886
         return $this->processMessage($values, $statusFieldName, $this->_retCode);
     }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:67,代码来源:Contact.php


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