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


PHP CRM_Contact_BAO_Relationship::add方法代码示例

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


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

示例1: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     require_once 'CRM/Contact/Form/Relationship.php';
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     $this->set('searchDone', 0);
     if (CRM_Utils_Array::value('_qf_AddToOrganization_refresh', $_POST)) {
         $searchParams['contact_type'] = array('Organization' => 'Organization');
         $searchParams['rel_contact'] = $params['name'];
         CRM_Contact_Form_Relationship::search($searchParams);
         $this->set('searchDone', 1);
         return;
     }
     $data = array();
     //$params['relationship_type_id']='4_a_b';
     $data['relationship_type_id'] = $params['relationship_type_id'];
     $data['is_active'] = 1;
     $invalid = 0;
     $valid = 0;
     $duplicate = 0;
     if (is_array($this->_contactIds)) {
         foreach ($this->_contactIds as $value) {
             $ids = array();
             $ids['contact'] = $value;
             //contact b --> organization
             // contact a  -> individual
             $errors = CRM_Contact_BAO_Relationship::checkValidRelationship($params, $ids, $params['contact_check']);
             if ($errors) {
                 $invalid = $invalid + 1;
                 continue;
             }
             if (CRM_Contact_BAO_Relationship::checkDuplicateRelationship($params, CRM_Utils_Array::value('contact', $ids), $params['contact_check'])) {
                 // step 2
                 $duplicate++;
                 continue;
             }
             CRM_Contact_BAO_Relationship::add($data, $ids, $params['contact_check']);
             $valid++;
         }
         $status = array(ts('Added Contact(s) to Organization'), ts('Total Selected Contact(s): %1', array(1 => $valid + $invalid + $duplicate)));
         if ($valid) {
             $status[] = ts('New relationship record(s) created: %1.', array(1 => $valid)) . '<br/>';
         }
         if ($invalid) {
             $status[] = ts('Relationship record(s) not created due to invalid target contact type: %1.', array(1 => $invalid)) . '<br/>';
         }
         if ($duplicate) {
             $status[] = ts('Relationship record(s) not created - duplicate of existing relationship: %1.', array(1 => $duplicate)) . '<br/>';
         }
         CRM_Core_Session::setStatus($status);
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:58,代码来源:AddToOrganization.php

示例2: crm_update_relationship

/**
 * Function to update relationship
 *
 * @param object $relationship A valid Relationship object.
 * @param array  $params Associative array of property name/value pairs to be updated. See Data Model for available properties.
 *
 * @return updated relationship object 
 *
 * @access public
 *
 */
function crm_update_relationship(&$relationship, $params)
{
    $ids = array();
    if (!isset($relationship->id) && !isset($relationship->contact_id_a) && !isset($relationship->contact_id_b)) {
        return _crm_error("{$relationship} is not valid relationship type object");
    }
    $conactId = $relationship->contact_id_b;
    $params['relationship_type_id'] = $relationship->relationship_type_id . '_a_b';
    $ids['contact'] = $relationship->contact_id_a;
    $ids['relationship'] = $relationship->id;
    $ids['contactTarget'] = $relationship->contact_id_b;
    return CRM_Contact_BAO_Relationship::add($params, $ids, $conactId);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:24,代码来源:Relationship.php

示例3: handleSharedRelation

 /**
  * Function to Add/Edit/Delete the relation of individual with shared-household.
  *
  * @param integer $contactID  the input form values
  * @param array   $params     the input form values
  *
  * @return void
  * @access public
  * @static
  */
 static function handleSharedRelation($contactID, &$params)
 {
     if (CRM_Utils_Array::value('old_mail_to_household_id', $params) != $params['mail_to_household_id']) {
         require_once 'CRM/Contact/BAO/Relationship.php';
         $relID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Household Member of', 'id', 'name_a_b');
         if (CRM_Utils_Array::value('old_mail_to_household_id', $params)) {
             $relationship =& new CRM_Contact_DAO_Relationship();
             $relationship->contact_id_b = $params['old_mail_to_household_id'];
             $relationship->contact_id_a = $contactID;
             $relationship->relationship_type_id = $relID;
             if ($relationship->find(true)) {
                 $relationship->delete();
             }
         }
         if ($params['mail_to_household_id']) {
             $ids = array('contact' => $params['mail_to_household_id']);
             $relationshipParams = array();
             $relationshipParams['relationship_type_id'] = $relID . '_b_a';
             $relationshipParams['is_active'] = 1;
             $relationship =& new CRM_Contact_DAO_Relationship();
             $relationship->contact_id_b = $params['mail_to_household_id'];
             $relationship->contact_id_a = $contactID;
             $relationship->relationship_type_id = $relID;
             // if relationship already not present, add a new one
             if (!$relationship->find(true)) {
                 CRM_Contact_BAO_Relationship::add($relationshipParams, $ids, $contactID);
             }
         }
     }
     return;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:41,代码来源:Individual.php

示例4: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  *
  * @return None
  */
 public 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_AddToOrganization_refresh', $_POST)) {
         $searchParams['contact_type'] = array('Organization' => 'Organization');
         $searchParams['rel_contact'] = $params['name'];
         CRM_Contact_Form_Task_AddToHousehold::search($this, $searchParams);
         $this->set('searchDone', 1);
         return;
     }
     $data = array();
     $data['relationship_type_id'] = $params['relationship_type_id'];
     $data['is_active'] = 1;
     $invalid = 0;
     $valid = 0;
     $duplicate = 0;
     if (is_array($this->_contactIds)) {
         foreach ($this->_contactIds as $value) {
             $ids = array();
             $ids['contact'] = $value;
             $errors = CRM_Contact_BAO_Relationship::checkValidRelationship($params, $ids, $params['contact_check']);
             if ($errors) {
                 $invalid++;
                 continue;
             }
             if (CRM_Contact_BAO_Relationship::checkDuplicateRelationship($params, CRM_Utils_Array::value('contact', $ids), $params['contact_check'])) {
                 $duplicate++;
                 continue;
             }
             CRM_Contact_BAO_Relationship::add($data, $ids, $params['contact_check']);
             $valid++;
         }
         $org = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['contact_check'], 'display_name');
         list($rtype, $a_b) = explode('_', $data['relationship_type_id'], 2);
         $relationship = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $rtype, "label_{$a_b}");
         $status = array(ts('%count %2 %3 relationship created', array('count' => $valid, 'plural' => '%count %2 %3 relationships created', 2 => $relationship, 3 => $org)));
         if ($duplicate) {
             $status[] = ts('%count was skipped because the contact is already %2 %3', array('count' => $duplicate, 'plural' => '%count were skipped because the contacts are already %2 %3', 2 => $relationship, 3 => $org));
         }
         if ($invalid) {
             $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array('count' => $invalid, 'plural' => '%count relationships were not created because the contact is not of the right type for this relationship'));
         }
         $status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
         CRM_Core_Session::setStatus($status, ts('Relationship Created', array('count' => $valid, 'plural' => 'Relationships Created')), 'success', array('expires' => 0));
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:55,代码来源:AddToOrganization.php

示例5: crm_update_relationship

/**
 * Function to update relationship
 *
 * @param object $relationship A valid Relationship object.
 * @param array  $params Associative array of property name/value pairs to be updated. See Data Model for available properties.
 *
 * @return updated relationship object 
 *
 * @access public
 *
 */
function crm_update_relationship(&$relationship, $params)
{
    $ids = array();
    if (!isset($relationship->id) && !isset($relationship->contact_id_a) && !isset($relationship->contact_id_b)) {
        return _crm_error('$relationship is not valid relationship type object');
    }
    $conactId = $relationship->contact_id_b;
    $params['relationship_type_id'] = $relationship->relationship_type_id . '_a_b';
    $ids['contact'] = $relationship->contact_id_a;
    $ids['relationship'] = $relationship->id;
    $ids['contactTarget'] = $relationship->contact_id_b;
    $relationship = CRM_Contact_BAO_Relationship::add($params, $ids, $conactId);
    if (CRM_Core_Permission::access('CiviMember')) {
        $params['contact_check'] = array($relationship->contact_id_b => 1);
        CRM_Contact_BAO_Relationship::relatedMemberships($relationship->contact_id_a, $params, $ids, CRM_Core_Action::ADD);
    }
    return $relationship;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:29,代码来源:Relationship.php

示例6: create

 /**
  * takes an associative array and creates a relationship object 
  *
  *
  * @param array $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contact_BAO_Relationship object 
  * @access public
  * @static
  */
 function create(&$params, &$ids)
 {
     $valid = $invalid = $duplicate = $saved = 0;
     $relationshipId = CRM_Utils_Array::value('relationship', $ids);
     if (!$relationshipId) {
         // creating a new relationship
         $dataExists = CRM_Contact_BAO_Relationship::dataExists($params);
         if (!$dataExists) {
             return null;
         }
         foreach ($params['contact_check'] as $key => $value) {
             $errors = '';
             // check if the realtionship is valid between contacts.
             // step 1: check if the relationship is valid if not valid skip and keep the count
             // step 2: check the if two contacts already have a relationship if yes skip and keep the count
             // step 3: if valid relationship then add the relation and keep the count
             $errors = CRM_Contact_BAO_Relationship::checkValidRelationship($params, $ids, $key);
             // step 1
             if ($errors) {
                 $invalid++;
                 continue;
             }
             if (CRM_Contact_BAO_Relationship::checkDuplicateRelationship($params, CRM_Utils_Array::value('contact', $ids), $key)) {
                 // step 2
                 $duplicate++;
                 continue;
             }
             $relationship = CRM_Contact_BAO_Relationship::add($params, $ids, $key);
             $valid++;
         }
         //return array( $valid, $invalid, $duplicate, $saved );
     } else {
         //editing the relationship
         // check for duplicate relationship
         if (CRM_Contact_BAO_Relationship::checkDuplicateRelationship($params, CRM_Utils_Array::value('contact', $ids), $ids['contactTarget'], $relationshipId)) {
             $duplicate++;
             return array($valid, $invalid, $duplicate);
         }
         // editing an existing relationship
         CRM_Contact_BAO_Relationship::add($params, $ids, $ids['contactTarget']);
         $saved++;
         //return array( $valid, $invalid, $duplicate, $saved );
     }
     return array($valid, $invalid, $duplicate, $saved);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:56,代码来源:Relationship.php


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