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


PHP CRM_Contact_BAO_Relationship::getRelationshipByID方法代码示例

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


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

示例1: postProcess

 /**
  * This function is called when the form is submitted.
  */
 public function postProcess()
 {
     // Store the submitted values in an array.
     $params = $this->controller->exportValues($this->_name);
     // CRM-14612 - Don't use adv-checkbox as it interferes with the form js
     $params['is_permission_a_b'] = CRM_Utils_Array::value('is_permission_a_b', $params, 0);
     $params['is_permission_b_a'] = CRM_Utils_Array::value('is_permission_b_a', $params, 0);
     // action is taken depending upon the mode
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Contact_BAO_Relationship::del($this->_relationshipId);
         // CRM-15881 UPDATES
         // Since the line above nullifies the organization_name and employer_id fiels in the contact record, we need to reload all blocks to reflect this chage on the user interface.
         $this->ajaxResponse['reloadBlocks'] = array('#crm-contactinfo-content');
         return;
     }
     $relationshipTypeParts = explode('_', $params['relationship_type_id']);
     $params['relationship_type_id'] = $relationshipTypeParts[0];
     if (!$this->_rtype) {
         // Do we need to wrap this in an if - when is rtype used & is relationship_type_id always set then?
         $this->_rtype = $params['relationship_type_id'];
     }
     $params['contact_id_' . $relationshipTypeParts[1]] = $this->_contactId;
     // Update mode (always single)
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $update = TRUE;
         $params['id'] = $this->_relationshipId;
         $ids['relationship'] = $this->_relationshipId;
         $relation = CRM_Contact_BAO_Relationship::getRelationshipByID($this->_relationshipId);
         if ($relation->contact_id_a == $this->_contactId) {
             // I couldn't replicate this path in testing. See below.
             $params['contact_id_a'] = $this->_contactId;
             $params['contact_id_b'] = array($params['related_contact_id']);
             $outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $relationshipTypeParts[1]);
             $relationshipIds = $outcome['relationship_ids'];
         } else {
             // The only reason we have changed this to use the api & not the above is that this was broken.
             // Recommend extracting all of update into a function that uses the api
             // and ensuring api / bao take care of 'other stuff' in this form
             // the contact_id_a & b can't be changed on this form so don't really need setting.
             $params['contact_id_b'] = $this->_contactId;
             $params['contact_id_a'] = $params['related_contact_id'];
             $result = civicrm_api3('relationship', 'create', $params);
             $relationshipIds = array($result['id']);
         }
         $ids['contactTarget'] = $relation->contact_id_a == $this->_contactId ? $relation->contact_id_b : $relation->contact_id_a;
         // @todo this belongs in the BAO.
         if ($this->_isCurrentEmployer) {
             // if relationship type changes, relationship is disabled, or "current employer" is unchecked,
             // clear the current employer. CRM-3235.
             $relChanged = $params['relationship_type_id'] != $this->_values['relationship_type_id'];
             if (!$params['is_active'] || !$params['is_current_employer'] || $relChanged) {
                 // CRM-15881 UPDATES
                 // If not is_active then is_current_employer needs to be set false as well! Logically a contact cannot be a current employee of a disabled employer relationship.
                 // If this is not done, then the below process will go ahead and disable the organization_name and employer_id fields in the contact record (which is what is wanted) but then further down will be re-enabled becuase is_current_employer is not false, therefore undoing what was done correctly.
                 if (!$params['is_active']) {
                     $params['is_current_employer'] = FALSE;
                 }
                 CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($this->_values['contact_id_a']);
                 // Refresh contact summary if in ajax mode
                 $this->ajaxResponse['reloadBlocks'] = array('#crm-contactinfo-content');
             }
         }
         if (empty($outcome['saved']) && !empty($update)) {
             $outcome['saved'] = $update;
         }
         $this->setMessage($outcome);
     } else {
         $params['contact_id_' . $relationshipTypeParts[2]] = explode(',', $params['related_contact_id']);
         $outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $relationshipTypeParts[1]);
         $relationshipIds = $outcome['relationship_ids'];
         if (empty($outcome['saved']) && !empty($update)) {
             $outcome['saved'] = $update;
         }
         $this->setMessage($outcome);
     }
     // if this is called from case view,
     //create an activity for case role removal.CRM-4480
     // @todo this belongs in the BAO.
     if ($this->_caseId) {
         CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $relationshipIds, $params['contact_check'], $this->_contactId);
     }
     // Save notes
     // @todo this belongs in the BAO.
     if ($this->_action & CRM_Core_Action::UPDATE || $params['note']) {
         foreach ($relationshipIds as $id) {
             $noteParams = array('entity_id' => $id, 'entity_table' => 'civicrm_relationship');
             $existing = civicrm_api3('note', 'get', $noteParams);
             if (!empty($existing['id'])) {
                 $noteParams['id'] = $existing['id'];
             }
             $noteParams['note'] = $params['note'];
             $noteParams['contact_id'] = $this->_contactId;
             if (!empty($existing['id']) || $params['note']) {
                 $action = $params['note'] ? 'create' : 'delete';
                 civicrm_api3('note', $action, $noteParams);
             }
         }
//.........这里部分代码省略.........
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:Relationship.php

示例2: setContactIDs

 /**
  * Given the relationship id, compute the contact id
  * since its used for things like send email
  */
 public function setContactIDs()
 {
     $this->_contactIds = array();
     foreach ($this->_relationshipIds as $key => $relId) {
         $rel = CRM_Contact_BAO_Relationship::getRelationshipByID($relId);
         $this->_contactIds[] = $rel->contact_id_a;
         $this->_contactIds[] = $rel->contact_id_b;
     }
 }
开发者ID:Chirojeugd-Vlaanderen,项目名称:civicrm-relationship-entity,代码行数:13,代码来源:Task.php


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