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


PHP CRM_Contact_BAO_Relationship::getContactIds方法代码示例

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


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

示例1: postProcess

 /**
  *  This function is called when the form is submitted 
  *
  * @access public
  * @return None
  */
 function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     $this->set('searchDone', 0);
     if (CRM_Utils_Array::value('_qf_Relationship_refresh', $_POST)) {
         $this->search($params);
         $this->set('searchDone', 1);
         return;
     }
     // action is taken depending upon the mode
     $ids = array();
     $ids['contact'] = $this->_contactId;
     if ($this->_action & CRM_CORE_ACTION_DELETE) {
         CRM_Contact_BAO_Relationship::del($this->_relationshipId);
         return;
     }
     if ($this->_action & CRM_CORE_ACTION_UPDATE) {
         $ids['relationship'] = $this->_relationshipId;
         $relation = CRM_Contact_BAO_Relationship::getContactIds($this->_relationshipId);
         $ids['contactTarget'] = $relation->contact_id_a == $this->_contactId ? $relation->contact_id_b : $relation->contact_id_a;
     }
     list($valid, $invalid, $duplicate, $saved) = CRM_Contact_BAO_Relationship::create($params, $ids);
     $status = '';
     if ($valid) {
         $status .= ' ' . ts('%count new relationship record created.', array('count' => $valid, 'plural' => '%count new relationship records created.'));
     }
     if ($invalid) {
         $status .= ' ' . ts('%count relationship record not created due to invalid target contact type.', array('count' => $invalid, 'plural' => '%count relationship records not created due to invalid target contact type.'));
     }
     if ($duplicate) {
         $status .= ' ' . ts('%count relationship record not created - duplicate of existing relationship.', array('count' => $duplicate, 'plural' => '%count relationship records not created - duplicate of existing relationship.'));
     }
     if ($saved) {
         $status .= ts('Relationship record has been updated.');
     }
     CRM_Core_Session::setStatus($status);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:44,代码来源:Relationship.php

示例2: postProcess

 /**
  *  This function is called when the form is submitted
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $quickSave = FALSE;
     if (CRM_Utils_Array::value('_qf_Relationship_refresh_save', $_POST) || CRM_Utils_Array::value('_qf_Relationship_refresh_savedetails', $_POST)) {
         //CRM-15873
         //Parse custom file uploads
         $pageName = $this->getAttribute('name');
         $data =& $this->controller->container();
         foreach ($this->controller->get('uploadNames') as $name) {
             $this->controller->_actions['upload']->upload($this, $data, $pageName, $name);
         }
         $quickSave = TRUE;
     }
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     $this->set('searchDone', 0);
     $this->set('callAjax', FALSE);
     if (CRM_Utils_Array::value('_qf_Relationship_refresh', $_POST) || $quickSave) {
         if (is_numeric($params['contact_select_id'][1])) {
             if ($quickSave) {
                 $params['contact_check'] = array($params['contact_select_id'][1] => 1);
             }
         } else {
             $this->set('callAjax', TRUE);
             $this->set('relType', $params['relationship_type_id']);
             $this->set('relContact', $params['contact'][1]);
             $quickSave = FALSE;
         }
         $this->set('searchDone', 1);
         if (!$quickSave) {
             return;
         }
     }
     // action is taken depending upon the mode
     $ids = array();
     $ids['contact'] = $this->_contactId;
     // modify params for ajax call
     $this->modifyParams($params);
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Contact_BAO_Relationship::del($this->_relationshipId);
         return;
     }
     $relationshipTypeId = str_replace(array('_a_b', '_b_a'), array('', ''), $params['relationship_type_id']);
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $ids['relationship'] = $this->_relationshipId;
         $relation = CRM_Contact_BAO_Relationship::getContactIds($this->_relationshipId);
         $ids['contactTarget'] = $relation->contact_id_a == $this->_contactId ? $relation->contact_id_b : $relation->contact_id_a;
         //if relationship type change and previously it was
         //employer / emplyee relationship with current employer
         //than clear the current employer. CRM-3235.
         //make sure we has to have employer id before firing queries, CRM-7306
         $employerId = CRM_Utils_Array::value('current_employee_id', $this->_values);
         $isDisabled = TRUE;
         if (CRM_Utils_Array::value('is_active', $params)) {
             $isDisabled = FALSE;
         }
         $relChanged = TRUE;
         if ($relationshipTypeId == $this->_values['relationship_type_id']) {
             $relChanged = FALSE;
         }
         if ($employerId && ($isDisabled || $relChanged)) {
             CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($this->_values['current_employee_id']);
         }
         //if field key doesn't exists in params that means the user has unchecked checkbox,
         //hence fill FALSE to params
         $params['is_active'] = $isDisabled ? FALSE : TRUE;
         $params['is_permission_a_b'] = CRM_Utils_Array::value('is_permission_a_b', $params, FALSE);
         $params['is_permission_b_a'] = CRM_Utils_Array::value('is_permission_b_a', $params, FALSE);
     } elseif ($quickSave) {
         if (CRM_Utils_Array::value('add_current_employee', $params) && $this->_allRelationshipNames[$relationshipTypeId]['name_a_b'] == 'Employee of') {
             $params['employee_of'] = $params['contact_select_id'][1];
         } elseif (CRM_Utils_Array::value('add_current_employer', $params) && $this->_allRelationshipNames[$relationshipTypeId]['name_b_a'] == 'Employer of') {
             $params['employer_of'] = array($params['contact_select_id'][1] => 1);
         }
         if (!$this->_rtype) {
             $this->_rtype = str_replace($relationshipTypeId . '_', '', $params['relationship_type_id']);
         }
     }
     if (!$params['note']) {
         $params['note'] = 'null';
     }
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], NULL, TRUE);
     $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], NULL, TRUE);
     //special case to handle if all checkboxes are unchecked
     $customFields = CRM_Core_BAO_CustomField::getFields('Relationship', FALSE, FALSE, $relationshipTypeId);
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_relationshipId, 'Relationship');
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
     // if this is called from case view,
     //create an activity for case role removal.CRM-4480
     if ($this->_caseId) {
         CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $relationshipIds, $params['contact_check'], $this->_contactId);
     }
     $status = '';
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:Relationship.php

示例3: postProcess

 /**
  *  This function is called when the form is submitted 
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     $quickSave = false;
     if (CRM_Utils_Array::value('_qf_Relationship_refresh_save', $_POST) || CRM_Utils_Array::value('_qf_Relationship_refresh_savedetails', $_POST)) {
         $quickSave = true;
     }
     $this->set('searchDone', 0);
     $this->set('callAjax', false);
     if (CRM_Utils_Array::value('_qf_Relationship_refresh', $_POST) || $quickSave) {
         if (is_numeric($params['rel_contact_id'])) {
             if ($quickSave) {
                 $params['contact_check'] = array($params['rel_contact_id'] => 1);
             } else {
                 $this->search($params);
                 $quickSave = false;
             }
         } else {
             $this->set('callAjax', true);
             $this->set('relType', $params['relationship_type_id']);
             $this->set('relContact', $params['rel_contact']);
             $quickSave = false;
         }
         $this->set('searchDone', 1);
         if (!$quickSave) {
             return;
         }
     }
     // action is taken depending upon the mode
     $ids = array();
     $ids['contact'] = $this->_contactId;
     // modify params for ajax call
     $this->modifyParams($params);
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Contact_BAO_Relationship::del($this->_relationshipId);
         return;
     }
     $relationshipTypeId = str_replace(array('_a_b', '_b_a'), array('', ''), $params['relationship_type_id']);
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $ids['relationship'] = $this->_relationshipId;
         $relation = CRM_Contact_BAO_Relationship::getContactIds($this->_relationshipId);
         $ids['contactTarget'] = $relation->contact_id_a == $this->_contactId ? $relation->contact_id_b : $relation->contact_id_a;
         //if relationship type change and previously it was
         //employer / emplyee relationship with current employer
         //than clear the current employer. CRM-3235.
         //make sure we has to have employer id before firing queries, CRM-7306
         $employerId = CRM_Utils_Array::value('current_employee_id', $this->_values);
         $isDisabled = true;
         if (CRM_Utils_Array::value('is_active', $params)) {
             $isDisabled = false;
         }
         $relChanged = true;
         if ($relationshipTypeId == $this->_values['relationship_type_id']) {
             $relChanged = false;
         }
         if ($employerId && ($isDisabled || $relChanged)) {
             require_once 'CRM/Contact/BAO/Contact/Utils.php';
             CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($this->_values['current_employee_id']);
         }
     } elseif ($quickSave) {
         if ($params['add_current_employee'] && $this->_allRelationshipNames[$relationshipTypeId]["name_a_b"] == 'Employee of') {
             $params['employee_of'] = $params['rel_contact_id'];
         } elseif ($params['add_current_employer'] && $this->_allRelationshipNames[$relationshipTypeId]["name_b_a"] == 'Employer of') {
             $params['employer_of'] = array($params['rel_contact_id'] => 1);
         }
         if (!$this->_rtype) {
             $this->_rtype = str_replace($relationshipTypeId . '_', '', $params['relationship_type_id']);
         }
     }
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], null, true);
     $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], null, true);
     //special case to handle if all checkboxes are unchecked
     $customFields = CRM_Core_BAO_CustomField::getFields('Relationship', false, false, $relationshipTypeId);
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_relationshipId, 'Relationship');
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
     // if this is called from case view,
     //create an activity for case role removal.CRM-4480
     if ($this->_caseId) {
         require_once "CRM/Case/BAO/Case.php";
         CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $relationshipIds, $params['contact_check'], $this->_contactId);
     }
     $status = '';
     if ($valid) {
         $status .= ' ' . ts('%count new relationship record created.', array('count' => $valid, 'plural' => '%count new relationship records created.'));
     }
     if ($invalid) {
         $status .= ' ' . ts('%count relationship record not created due to invalid target contact type.', array('count' => $invalid, 'plural' => '%count relationship records not created due to invalid target contact type.'));
     }
     if ($duplicate) {
         $status .= ' ' . ts('%count relationship record not created - duplicate of existing relationship.', array('count' => $duplicate, 'plural' => '%count relationship records not created - duplicate of existing relationship.'));
     }
     if ($saved) {
         $status .= ts('Relationship record has been updated.');
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Relationship.php

示例4: postProcess

 /**
  *  This function is called when the form is submitted
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     // action is taken depending upon the mode
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Contact_BAO_Relationship::del($this->_relationshipId);
         return;
     }
     $ids = array('contact' => $this->_contactId);
     $relationshipTypeId = str_replace(array('_', 'a', 'b'), '', $params['relationship_type_id']);
     // 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);
     // Update mode (always single)
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $ids['relationship'] = $this->_relationshipId;
         $relation = CRM_Contact_BAO_Relationship::getContactIds($this->_relationshipId);
         $ids['contactTarget'] = $relation->contact_id_a == $this->_contactId ? $relation->contact_id_b : $relation->contact_id_a;
         if ($this->_isCurrentEmployer) {
             // if relationship type changes, relationship is disabled, or "current employer" is unchecked,
             // clear the current employer. CRM-3235.
             $relChanged = $relationshipTypeId != $this->_values['relationship_type_id'];
             if (!$params['is_active'] || !$params['is_current_employer'] || $relChanged) {
                 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');
             }
         }
     } else {
         // Fill up this weird param with contact ids like the weird relationship bao expects
         $params['contact_check'] = array_fill_keys(explode(',', $params['related_contact_id']), 1);
         if (!$this->_rtype) {
             list(, $this->_rtype) = explode('_', $params['relationship_type_id'], 2);
         }
     }
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], NULL, TRUE);
     $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], NULL, TRUE);
     // Process custom data
     $customFields = CRM_Core_BAO_CustomField::getFields('Relationship', FALSE, FALSE, $relationshipTypeId);
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_relationshipId, 'Relationship');
     // Save relationships
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
     // if this is called from case view,
     //create an activity for case role removal.CRM-4480
     if ($this->_caseId) {
         CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $relationshipIds, $params['contact_check'], $this->_contactId);
     }
     if ($valid) {
         CRM_Core_Session::setStatus(ts('Relationship created.', array('count' => $valid, 'plural' => '%count relationships created.')), ts('Saved'), 'success');
     }
     if ($invalid) {
         CRM_Core_Session::setStatus(ts('%count relationship record was not created due to an invalid contact type.', array('count' => $invalid, 'plural' => '%count relationship records were not created due to invalid contact types.')), ts('%count invalid relationship record', array('count' => $invalid, 'plural' => '%count invalid relationship records')));
     }
     if ($duplicate) {
         CRM_Core_Session::setStatus(ts('One relationship was not created because it already exists.', array('count' => $duplicate, 'plural' => '%count relationships were not created because they already exist.')), ts('%count duplicate relationship', array('count' => $duplicate, 'plural' => '%count duplicate relationships')));
     }
     if ($saved) {
         CRM_Core_Session::setStatus(ts('Relationship record has been updated.'), ts('Saved'), 'success');
     }
     // Save notes
     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);
             }
         }
     }
     // Membership for related contacts CRM-1657
     if (CRM_Core_Permission::access('CiviMember') && !$duplicate) {
         $params['relationship_ids'] = $relationshipIds;
         if ($this->_action & CRM_Core_Action::ADD) {
             CRM_Contact_BAO_Relationship::relatedMemberships($this->_contactId, $params, $ids, $this->_action);
         } elseif ($this->_action & CRM_Core_Action::UPDATE) {
             //fixes for CRM-7985
             //only if the relationship has been toggled to enable /disable
             if (CRM_Utils_Array::value('is_active', $params) != $this->_enabled) {
                 $active = !empty($params['is_active']) ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE;
                 CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_relationshipId, $active);
             }
         }
         // Refresh contact tabs with related data
         $this->ajaxResponse['updateTabs'] = array('#tab_member' => CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId));
     }
     // Set current employee/employer relationship, CRM-3532
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Relationship.php


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