• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CRM_Contact_DAO_RelationshipType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: del

 /**
  * Delete Relationship Types.
  *
  * @param int $relationshipTypeId
  *
  * @throws CRM_Core_Exception
  * @return mixed
  */
 public static function del($relationshipTypeId)
 {
     // make sure relationshipTypeId is an integer
     // @todo review this as most delete functions rely on the api & form layer for this
     // or do a find first & throw error if no find
     if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) {
         throw new CRM_Core_Exception(ts('Invalid relationship type'));
     }
     //check dependencies
     // delete all relationships
     $relationship = new CRM_Contact_DAO_Relationship();
     $relationship->relationship_type_id = $relationshipTypeId;
     $relationship->delete();
     // remove this relationship type from membership types
     $mems = civicrm_api3('MembershipType', 'get', array('relationship_type_id' => array('LIKE' => "%{$relationshipTypeId}%"), 'return' => array('id', 'relationship_type_id', 'relationship_direction')));
     foreach ($mems['values'] as $membershipTypeId => $membershipType) {
         $pos = array_search($relationshipTypeId, $membershipType['relationship_type_id']);
         // Api call may have returned false positives but currently the relationship_type_id uses
         // nonstandard serialization which makes anything more accurate impossible.
         if ($pos !== FALSE) {
             unset($membershipType['relationship_type_id'][$pos], $membershipType['relationship_direction'][$pos]);
             civicrm_api3('MembershipType', 'create', $membershipType);
         }
     }
     //fixed for CRM-3323
     $mappingField = new CRM_Core_DAO_MappingField();
     $mappingField->relationship_type_id = $relationshipTypeId;
     $mappingField->find();
     while ($mappingField->fetch()) {
         $mappingField->delete();
     }
     $relationshipType = new CRM_Contact_DAO_RelationshipType();
     $relationshipType->id = $relationshipTypeId;
     return $relationshipType->delete();
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:43,代码来源:RelationshipType.php


示例2: runImport

 public function runImport(&$form, $timeout = 55)
 {
     $mapper = $this->_mapper;
     $mapperFields = array();
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
     $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     //initialize mapper perperty value.
     $mapperPeroperties = array('mapperRelated' => 'mapperRelatedVal', 'mapperLocTypes' => 'mapperLocTypesVal', 'mapperPhoneTypes' => 'mapperPhoneTypesVal', 'mapperImProviders' => 'mapperImProvidersVal', 'mapperWebsiteTypes' => 'mapperWebsiteTypesVal', 'mapperRelatedContactType' => 'mapperRelatedContactTypeVal', 'mapperRelatedContactDetails' => 'mapperRelatedContactDetailsVal', 'mapperRelatedContactLocType' => 'mapperRelatedContactLocTypeVal', 'mapperRelatedContactPhoneType' => 'mapperRelatedContactPhoneTypeVal', 'mapperRelatedContactImProvider' => 'mapperRelatedContactImProviderVal', 'mapperRelatedContactWebsiteType' => 'mapperRelatedContactWebsiteTypeVal');
     foreach ($mapper as $key => $value) {
         //set respective mapper value to null.
         foreach (array_values($mapperPeroperties) as $perpertyVal) {
             ${$perpertyVal} = NULL;
         }
         $fldName = CRM_Utils_Array::value(0, $mapper[$key]);
         $header = array($this->_mapFields[$fldName]);
         $selOne = CRM_Utils_Array::value(1, $mapper[$key]);
         $selTwo = CRM_Utils_Array::value(2, $mapper[$key]);
         $selThree = CRM_Utils_Array::value(3, $mapper[$key]);
         $this->_mapperKeys[$key] = $fldName;
         //need to differentiate non location elements.
         if ($selOne && is_numeric($selOne)) {
             if ($fldName == 'url') {
                 $header[] = $websiteTypes[$selOne];
                 $mapperWebsiteTypesVal = $selOne;
             } else {
                 $header[] = $locationTypes[$selOne];
                 $mapperLocTypesVal = $selOne;
                 if ($selTwo && is_numeric($selTwo)) {
                     if ($fldName == 'phone') {
                         $header[] = $phoneTypes[$selTwo];
                         $mapperPhoneTypesVal = $selTwo;
                     } elseif ($fldName == 'im') {
                         $header[] = $imProviders[$selTwo];
                         $mapperImProvidersVal = $selTwo;
                     }
                 }
             }
         }
         $fldNameParts = explode('_', $fldName, 3);
         $id = $fldNameParts[0];
         $first = isset($fldNameParts[1]) ? $fldNameParts[1] : NULL;
         $second = isset($fldNameParts[2]) ? $fldNameParts[2] : NULL;
         if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
             $header[] = ucwords(str_replace("_", " ", $selOne));
             $relationType = new CRM_Contact_DAO_RelationshipType();
             $relationType->id = $id;
             $relationType->find(TRUE);
             $mapperRelatedContactTypeVal = $relationType->{"contact_type_{$second}"};
             $mapperRelatedVal = $fldName;
             if ($selOne) {
                 $mapperRelatedContactDetailsVal = $selOne;
                 if ($selTwo) {
                     if ($selOne == 'url') {
                         $header[] = $websiteTypes[$selTwo];
                         $mapperRelatedContactWebsiteTypeVal = $selTwo;
                     } else {
                         $header[] = $locationTypes[$selTwo];
                         $mapperRelatedContactLocTypeVal = $selTwo;
                         if ($selThree) {
                             if ($selOne == 'phone') {
                                 $header[] = $phoneTypes[$selThree];
                                 $mapperRelatedContactPhoneTypeVal = $selThree;
                             } elseif ($selOne == 'im') {
                                 $header[] = $imProviders[$selThree];
                                 $mapperRelatedContactImProviderVal = $selThree;
                             }
                         }
                     }
                 }
             }
         }
         $mapperFields[] = implode(' - ', $header);
         //set the respective mapper param array values.
         foreach ($mapperPeroperties as $mapperProKey => $mapperProVal) {
             $this->{"_{$mapperProKey}"}[$key] = ${$mapperProVal};
         }
     }
     $this->_parser = new CRM_Contact_Import_Parser_Contact($this->_mapperKeys, $this->_mapperLocTypes, $this->_mapperPhoneTypes, $this->_mapperImProviders, $this->_mapperRelated, $this->_mapperRelatedContactType, $this->_mapperRelatedContactDetails, $this->_mapperRelatedContactLocType, $this->_mapperRelatedContactPhoneType, $this->_mapperRelatedContactImProvider, $this->_mapperWebsiteTypes, $this->_mapperRelatedContactWebsiteType);
     $this->_parser->run($this->_tableName, $mapperFields, CRM_Import_Parser::MODE_IMPORT, $this->_contactType, $this->_primaryKeyName, $this->_statusFieldName, $this->_onDuplicate, $this->_statusID, $this->_totalRowCount, $this->_doGeocodeAddress, CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, $this->_contactSubType, $this->_dedupe);
     $contactIds = $this->_parser->getImportedContacts();
     //get the related contactIds. CRM-2926
     $relatedContactIds = $this->_parser->getRelatedImportedContacts();
     if ($relatedContactIds) {
         $contactIds = array_merge($contactIds, $relatedContactIds);
         if ($form) {
             $form->set('relatedCount', count($relatedContactIds));
         }
     }
     if ($this->_newGroupName || count($this->_groups)) {
         $groupAdditions = $this->_addImportedContactsToNewGroup($contactIds, $this->_newGroupName, $this->_newGroupDesc);
         if ($form) {
             $form->set('groupAdditions', $groupAdditions);
         }
     }
     if ($this->_newTagName || count($this->_tag)) {
         $tagAdditions = $this->_tagImportedContactsWithNewTag($contactIds, $this->_newTagName, $this->_newTagDesc);
         if ($form) {
             $form->set('tagAdditions', $tagAdditions);
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:ImportJob.php


示例3: addDisplayEnums

 /**
  * adds $value['foo_display'] for each $value['foo'] enum from civicrm_relationship_type
  *
  * @param array $values (reference)  the array up for enhancing
  * @return void
  */
 static function addDisplayEnums(&$values)
 {
     $enumFields =& CRM_Contact_DAO_RelationshipType::getEnums();
     foreach ($enumFields as $enum) {
         if (isset($values[$enum])) {
             $values[$enum . '_display'] = CRM_Contact_DAO_RelationshipType::tsEnum($enum, $values[$enum]);
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:15,代码来源:RelationshipType.php


示例4: checkRelationshipType

 /**
  * Function to check if the relationship type selected between two contacts is correct
  *
  * @param int $contact_a 1st contact id 
  * @param int $contact_b 2nd contact id 
  * @param int $relationshipTypeId relationship type id
  *
  * @return boolean  true if it is valid relationship else false
  * @access public
  * @static
  */
 static function checkRelationshipType($contact_a, $contact_b, $relationshipTypeId)
 {
     $relationshipType = new CRM_Contact_DAO_RelationshipType();
     $relationshipType->id = $relationshipTypeId;
     $relationshipType->selectAdd();
     $relationshipType->selectAdd('contact_type_a, contact_type_b, contact_sub_type_a, contact_sub_type_b');
     if ($relationshipType->find(true)) {
         require_once 'CRM/Contact/BAO/Contact.php';
         $contact_type_a = CRM_Contact_BAO_Contact::getContactType($contact_a);
         $contact_type_b = CRM_Contact_BAO_Contact::getContactType($contact_b);
         $contact_sub_type_a = CRM_Contact_BAO_Contact::getContactSubType($contact_a);
         $contact_sub_type_b = CRM_Contact_BAO_Contact::getContactSubType($contact_b);
         if ((!$relationshipType->contact_type_a || $relationshipType->contact_type_a == $contact_type_a) && (!$relationshipType->contact_type_b || $relationshipType->contact_type_b == $contact_type_b) && (!$relationshipType->contact_sub_type_a || $relationshipType->contact_sub_type_a == $contact_sub_type_a) && (!$relationshipType->contact_sub_type_b || $relationshipType->contact_sub_type_b == $contact_sub_type_b)) {
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:31,代码来源:Relationship.php


示例5: search

 /**
  * This function is to get the result of the search for contact in relationship form
  *
  * @param  array $params  This contains elements for search criteria
  *
  * @access public
  * @return None
  *
  */
 function search(&$params)
 {
     //max records that will be listed
     $searchValues = array();
     if (CRM_Utils_Array::value('rel_contact', $params)) {
         if (is_numeric($params['rel_contact_id'])) {
             $searchValues[] = array('contact_id', '=', $params['rel_contact_id'], 0, 1);
         } else {
             $searchValues[] = array('sort_name', 'LIKE', $params['rel_contact'], 0, 1);
         }
     }
     $contactTypeAdded = false;
     $excludedContactIds = array($this->_contactId);
     if ($params['relationship_type_id']) {
         $relationshipType = new CRM_Contact_DAO_RelationshipType();
         list($rid, $direction) = explode('_', $params['relationship_type_id'], 2);
         $relationshipType->id = $rid;
         if ($relationshipType->find(true)) {
             if ($direction == 'a_b') {
                 $type = $relationshipType->contact_type_b;
                 $subType = $relationshipType->contact_sub_type_b;
             } else {
                 $type = $relationshipType->contact_type_a;
                 $subType = $relationshipType->contact_sub_type_a;
             }
             $this->set('contact_type', $type);
             $this->set('contact_sub_type', $subType);
             if ($type == 'Individual' || $type == 'Organization' || $type == 'Household') {
                 $searchValues[] = array('contact_type', '=', $type, 0, 0);
                 $contactTypeAdded = true;
             }
             if ($subType) {
                 $searchValues[] = array('contact_sub_type', '=', $subType, 0, 0);
             }
         }
     }
     if (!$contactTypeAdded && CRM_Utils_Array::value('contact_type', $params)) {
         $searchValues[] = array('contact_type', '=', $params['contact_type'], 0, 0);
     }
     // get the count of contact
     $contactBAO = new CRM_Contact_BAO_Contact();
     $query = new CRM_Contact_BAO_Query($searchValues);
     $searchCount = $query->searchQuery(0, 0, null, true);
     $this->set('searchCount', $searchCount);
     if ($searchCount <= self::MAX_RELATIONSHIPS) {
         // get the result of the search
         $result = $query->searchQuery(0, 50, null);
         $config = CRM_Core_Config::singleton();
         $searchRows = array();
         //variable is set if only one record is foun and that record already has relationship with the contact
         $duplicateRelationship = 0;
         while ($result->fetch()) {
             $contactID = $result->contact_id;
             if (in_array($contactID, $excludedContactIds)) {
                 $duplicateRelationship++;
                 continue;
             }
             $duplicateRelationship = 0;
             $searchRows[$contactID]['id'] = $contactID;
             $searchRows[$contactID]['name'] = $result->sort_name;
             $searchRows[$contactID]['city'] = $result->city;
             $searchRows[$contactID]['state'] = $result->state_province;
             $searchRows[$contactID]['email'] = $result->email;
             $searchRows[$contactID]['phone'] = $result->phone;
             $contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
             require_once 'CRM/Contact/BAO/Contact/Utils.php';
             $searchRows[$contactID]['type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
         }
         $this->set('searchRows', $searchRows);
         $this->set('duplicateRelationship', $duplicateRelationship);
     } else {
         // resetting the session variables if many records are found
         $this->set('searchRows', null);
         $this->set('duplicateRelationship', null);
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:85,代码来源:Relationship.php


示例6: checkRelationshipType

 /**
  * Check if the relationship type selected between two contacts is correct.
  *
  * @param int $contact_a
  *   1st contact id.
  * @param int $contact_b
  *   2nd contact id.
  * @param int $relationshipTypeId
  *   Relationship type id.
  *
  * @return bool
  *   true if it is valid relationship else false
  */
 public static function checkRelationshipType($contact_a, $contact_b, $relationshipTypeId)
 {
     $relationshipType = new CRM_Contact_DAO_RelationshipType();
     $relationshipType->id = $relationshipTypeId;
     $relationshipType->selectAdd();
     $relationshipType->selectAdd('contact_type_a, contact_type_b, contact_sub_type_a, contact_sub_type_b');
     if ($relationshipType->find(TRUE)) {
         $contact_type_a = CRM_Contact_BAO_Contact::getContactType($contact_a);
         $contact_type_b = CRM_Contact_BAO_Contact::getContactType($contact_b);
         $contact_sub_type_a = CRM_Contact_BAO_Contact::getContactSubType($contact_a);
         $contact_sub_type_b = CRM_Contact_BAO_Contact::getContactSubType($contact_b);
         if ((!$relationshipType->contact_type_a || $relationshipType->contact_type_a == $contact_type_a) && (!$relationshipType->contact_type_b || $relationshipType->contact_type_b == $contact_type_b) && (!$relationshipType->contact_sub_type_a || in_array($relationshipType->contact_sub_type_a, $contact_sub_type_a)) && (!$relationshipType->contact_sub_type_b || in_array($relationshipType->contact_sub_type_b, $contact_sub_type_b))) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
     return FALSE;
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:32,代码来源:Relationship.php


示例7: import


//.........这里部分代码省略.........
                 $this->_retCode = CRM_IMPORT_PARSER_NO_MATCH;
             }
         }
         if (is_a($newContact, CRM_Contact_BAO_Contact)) {
             $relationship = true;
         } else {
             if (is_a($error, CRM_Core_Error)) {
                 $newContact = $error;
                 $relationship = true;
             }
         }
         if ($newContact && !is_a($newContact, CRM_Core_Error)) {
             $this->_newContacts[] = $newContact->id;
         }
     } else {
         $newContact = crm_create_contact_formatted($formatted, $onDuplicate);
         $relationship = true;
     }
     if ($relationship) {
         if (CRM_Import_Parser_Contact::isDuplicate($newContact)) {
             foreach ($newContact->_errors[0]['params'] as $cid) {
                 $primaryContactId = $cid;
             }
         } else {
             $primaryContactId = $newContact->id;
         }
         if (CRM_Import_Parser_Contact::isDuplicate($newContact) || is_a($newContact, CRM_Contact_BAO_Contact)) {
             //relationship contact insert
             foreach ($params as $key => $field) {
                 list($id, $first, $second) = explode('_', $key);
                 if (!($first == 'a' && $second == 'b') && !($first == 'b' && $second == 'a')) {
                     continue;
                 }
                 $relationType = new CRM_Contact_DAO_RelationshipType();
                 $relationType->id = $id;
                 $relationType->find(true);
                 $name_a_b = $relationType->name_a_b;
                 if ($params[$key]['contact_type']) {
                     $formatting = array('contact_type' => $params[$key]['contact_type']);
                 } else {
                     $fld = array_keys($params[$key]);
                     foreach (CRM_Core_SelectValues::contactType() as $cType => $val) {
                         if ($cType) {
                             $contactFields =& CRM_Contact_BAO_Contact::importableFields($cType);
                             if (array_key_exists($fld[0], $contactFields)) {
                                 $formatting['contact_type'] = $cType;
                                 $params[$key]['contact_type'] = $cType;
                                 $field['contact_type'] = $cType;
                                 break;
                             }
                         }
                     }
                 }
                 $contactFields = null;
                 if ($contactFields == null) {
                     require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $params[$key]['contact_type']) . ".php";
                     eval('$contactFields =& CRM_Contact_DAO_' . $params[$key]['contact_type'] . '::import();');
                 }
                 foreach ($field as $k => $v) {
                     if ($v == null || $v === '') {
                         continue;
                     }
                     if (is_array($v)) {
                         foreach ($v as $value) {
                             $break = false;
                             foreach ($value as $testForEmpty) {
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:67,代码来源:Contact.php


示例8: search

 /**
  * Get the result of the search for Add to * forms.
  *
  * @param CRM_Core_Form $form
  * @param array $params
  *   This contains elements for search criteria.
  */
 public function search(&$form, &$params)
 {
     //max records that will be listed
     $searchValues = array();
     if (!empty($params['rel_contact'])) {
         if (isset($params['rel_contact_id']) && is_numeric($params['rel_contact_id'])) {
             $searchValues[] = array('contact_id', '=', $params['rel_contact_id'], 0, 1);
         } else {
             $searchValues[] = array('sort_name', 'LIKE', $params['rel_contact'], 0, 1);
         }
     }
     $contactTypeAdded = FALSE;
     $excludedContactIds = array();
     if (isset($form->_contactId)) {
         $excludedContactIds[] = $form->_contactId;
     }
     if (!empty($params['relationship_type_id'])) {
         $relationshipType = new CRM_Contact_DAO_RelationshipType();
         list($rid, $direction) = explode('_', $params['relationship_type_id'], 2);
         $relationshipType->id = $rid;
         if ($relationshipType->find(TRUE)) {
             if ($direction == 'a_b') {
                 $type = $relationshipType->contact_type_b;
                 $subType = $relationshipType->contact_sub_type_b;
             } else {
                 $type = $relationshipType->contact_type_a;
                 $subType = $relationshipType->contact_sub_type_a;
             }
             $form->set('contact_type', $type);
             $form->set('contact_sub_type', $subType);
             if ($type == 'Individual' || $type == 'Organization' || $type == 'Household') {
                 $searchValues[] = array('contact_type', '=', $type, 0, 0);
                 $contactTypeAdded = TRUE;
             }
             if ($subType) {
                 $searchValues[] = array('contact_sub_type', '=', $subType, 0, 0);
             }
         }
     }
     if (!$contactTypeAdded && !empty($params['contact_type'])) {
         $searchValues[] = array('contact_type', '=', $params['contact_type'], 0, 0);
     }
     // get the count of contact
     $contactBAO = new CRM_Contact_BAO_Contact();
     $query = new CRM_Contact_BAO_Query($searchValues);
     $searchCount = $query->searchQuery(0, 0, NULL, TRUE);
     $form->set('searchCount', $searchCount);
     if ($searchCount <= 50) {
         // get the result of the search
         $result = $query->searchQuery(0, 50, NULL);
         $config = CRM_Core_Config::singleton();
         $searchRows = array();
         //variable is set if only one record is foun and that record already has relationship with the contact
         $duplicateRelationship = 0;
         while ($result->fetch()) {
             $query->convertToPseudoNames($result);
             $contactID = $result->contact_id;
             if (in_array($contactID, $excludedContactIds)) {
                 $duplicateRelationship++;
                 continue;
             }
             $duplicateRelationship = 0;
             $searchRows[$contactID]['id'] = $contactID;
             $searchRows[$contactID]['name'] = $result->sort_name;
             $searchRows[$contactID]['city'] = $result->city;
             $searchRows[$contactID]['state'] = $result->state_province;
             $searchRows[$contactID]['email'] = $result->email;
             $searchRows[$contactID]['phone'] = $result->phone;
             $contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
             $searchRows[$contactID]['type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
         }
         $form->set('searchRows', $searchRows);
         $form->set('duplicateRelationship', $duplicateRelationship);
     } else {
         // resetting the session variables if many records are found
         $form->set('searchRows', NULL);
         $form->set('duplicateRelationship', NULL);
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:86,代码来源:AddToParentClass.php


示例9: del

 /**
  * Function to delete Relationship Types
  *
  * @param int $relationshipTypeId
  * @static
  */
 static function del($relationshipTypeId)
 {
     // make sure relationshipTypeId is an integer
     if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) {
         CRM_Core_Error::fatal(ts('Invalid relationship type'));
     }
     //check dependencies
     // delete all relationships
     $relationship = new CRM_Contact_DAO_Relationship();
     $relationship->relationship_type_id = $relationshipTypeId;
     $relationship->delete();
     // set all membership_type to null
     $query = "\nUPDATE civicrm_membership_type\n  SET  relationship_type_id = NULL\n WHERE relationship_type_id = %1\n";
     $params = array(1 => array($relationshipTypeId, 'Integer'));
     CRM_Core_DAO::executeQuery($query, $params);
     //fixed for CRM-3323
     $mappingField = new CRM_Core_DAO_MappingField();
     $mappingField->relationship_type_id = $relationshipTypeId;
     $mappingField->find();
     while ($mappingField->fetch()) {
         $mappingField->delete();
     }
     $relationshipType = new CRM_Contact_DAO_RelationshipType();
     $relationshipType->id = $relationshipTypeId;
     return $relationshipType->delete();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:32,代码来源:RelationshipType.php


示例10: browse

 /**
  * browse all entities.
  *
  * @param int $action
  *
  * @return void
  * @access public
  */
 function browse()
 {
     $n = func_num_args();
     $action = $n > 0 ? func_get_arg(0) : NULL;
     $sort = $n > 0 ? func_get_arg(1) : NULL;
     $links =& $this->links();
     if ($action == NULL) {
         if (!empty($links)) {
             $action = array_sum(array_keys($links));
         }
     }
     if ($action & CRM_Core_Action::DISABLE) {
         $action -= CRM_Core_Action::DISABLE;
     }
     if ($action & CRM_Core_Action::ENABLE) {
         $action -= CRM_Core_Action::ENABLE;
     }
     $baoString = $this->getBAOName();
     $object = new $baoString();
     $values = array();
     /*
      * lets make sure we get the stuff sorted by name if it exists
      */
     $fields =& $object->fields();
     $key = '';
     if (CRM_Utils_Array::value('title', $fields)) {
         $key = 'title';
     } elseif (CRM_Utils_Array::value('label', $fields)) {
         $key = 'label';
     } elseif (CRM_Utils_Array::value('name', $fields)) {
         $key = 'name';
     }
     if (trim($sort)) {
         $object->orderBy($sort);
     } elseif ($key) {
         $object->orderBy($key . ' asc');
     }
     // find all objects
     $object->find();
     while ($object->fetch()) {
         if (!isset($object->mapping_type_id) || $object->mapping_type_id != 1) {
             $permission = CRM_Core_Permission::EDIT;
             if ($key) {
                 $permission = $this->checkPermission($object->id, $object->{$key});
             }
             if ($permission) {
                 $values[$object->id] = array();
                 CRM_Core_DAO::storeValues($object, $values[$object->id]);
                 CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]);
                 // populate action links
                 $this->action($object, $action, $values[$object->id], $links, $permission);
                 if (isset($object->mapping_type_id)) {
                     $mappintTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id');
                     $values[$object->id]['mapping_type'] = $mappintTypes[$object->mapping_type_id];
                 }
             }
         }
     }
     $this->assign('rows', $values);
 }
开发者ID:hguru,项目名称:224Civi,代码行数:68,代码来源:Basic.php


示例11: CRM_Contact_BAO_RelationshipType

 /**
  * class constructor
  */
 function CRM_Contact_BAO_RelationshipType()
 {
     parent::CRM_Contact_DAO_RelationshipType();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:7,代码来源:RelationshipType.php


示例12: browse

 /**
  * browse all entities.
  *
  * @param int $action
  *
  * @return void
  * @access public
  */
 function browse($action = null)
 {
     $links =& $this->links();
     if ($action == null) {
         $action = array_sum(array_keys($links));
     }
     if ($action & CRM_CORE_ACTION_DISABLE) {
         $action -= CRM_CORE_ACTION_DISABLE;
     }
     if ($action & CRM_CORE_ACTION_ENABLE) {
         $action -= CRM_CORE_ACTION_ENABLE;
     }
     eval('$object =& new ' . $this->getBAOName() . '( );');
     $values = array();
     /*
      * lets make sure we get the stuff sorted by name if it exists
      */
     $fields =& $object->fields();
     $key = '';
     if (CRM_Utils_Array::value('title', $fields)) {
         $key = 'title';
     } else {
         if (CRM_Utils_Array::value('label', $fields)) {
             $key = 'label';
         } else {
             if (CRM_Utils_Array::value('name', $fields)) {
                 $key = 'name';
             }
         }
     }
     if ($key) {
         $object->orderBy($key . ' asc');
     }
     // set the domain_id parameter
     $config =& CRM_Core_Config::singleton();
     $object->domain_id = $config->domainID();
     // find all objects
     $object->find();
     while ($object->fetch()) {
         $permission = CRM_CORE_PERMISSION_EDIT;
         if ($key) {
             $permission = $this->checkPermission($object->id, $object->{$key});
         }
         if ($permission) {
             $values[$object->id] = array();
             CRM_Core_DAO::storeValues($object, $values[$object->id]);
             CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]);
             // populate action links
             CRM_Core_Page_Basic::action($object, $action, $values[$object->id], $links, $permission);
         }
     }
     $this->assign('rows', $values);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:61,代码来源:Basic.php


示例13: array

 /**
  * Get all Relationship Types  from database.
  *
  * The static array group is returned, and if it's
  * called the first time, the <b>RelationshipType DAO</b> is used
  * to get all the relationship types.
  *
  * Note: any database errors will be trapped by the DAO.
  *
  * @param string $valueColumnName db column name/label.
  * @param boolean $reset          reset relationship types if true
  *
  * @access public
  * @static
  *
  * @return array - array reference of all relationship types.
  */
 public static function &relationshipType($valueColumnName = 'label', $reset = FALSE)
 {
     if (!CRM_Utils_Array::value($valueColumnName, self::$relationshipType) || $reset) {
         self::$relationshipType[$valueColumnName] = array();
         //now we have name/label columns CRM-3336
         $column_a_b = "{$valueColumnName}_a_b";
         $column_b_a = "{$valueColumnName}_b_a";
         $relationshipTypeDAO = new CRM_Contact_DAO_RelationshipType();
         $relationshipTypeDAO->selectAdd();
         $relationshipTypeDAO->selectAdd("id, {$column_a_b}, {$column_b_a}, contact_type_a, contact_type_b, contact_sub_type_a, contact_sub_type_b");
         $relationshipTypeDAO->is_active = 1;
         $relationshipTypeDAO->find();
         while ($relationshipTypeDAO->fetch()) {
             self::$relationshipType[$valueColumnName][$relationshipTypeDAO->id] = array('id' => $relationshipTypeDAO->id, $column_a_b => $relationshipTypeDAO->{$column_a_b}, $column_b_a => $relationshipTypeDAO->{$column_b_a}, 'contact_type_a' => "{$relationshipTypeDAO->contact_type_a}", 'contact_type_b' => "{$relationshipTypeDAO->contact_type_b}", 'contact_sub_type_a' => "{$relationshipTypeDAO->contact_sub_type_a}", 'contact_sub_type_b' => "{$relationshipTypeDAO->contact_sub_type_b}");
         }
     }
     return self::$relationshipType[$valueColumnName];
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:35,代码来源:PseudoConstant.php


示例14: browse

 /**
  * browse all entities.
  *
  * @param int $action
  *
  * @return void
  * @access public
  */
 function browse($action = null, $sort)
 {
     $links =& $this->links();
     if ($action == null) {
         if (!empty($links)) {
             $action = array_sum(array_keys($links));
         }
     }
     if ($action & CRM_Core_Action::DISABLE) {
         $action -= CRM_Core_Action::DISABLE;
     }
     if ($action & CRM_Core_Action::ENABLE) {
         $action -= CRM_Core_Action::ENABLE;
     }
     eval('$object =& new ' . $this->getBAOName() . '( );');
     $values = array();
     /*
      * lets make sure we get the stuff sorted by name if it exists
      */
     $fields =& $object->fields();
     $key = '';
     if (CRM_Utils_Array::value('title', $fields)) {
         $key = 'title';
     } else {
         if (CRM_Utils_Array::value('label', $fields)) {
             $key = 'label';
         } else {
             if (CRM_Utils_Array::value('name', $fields)) {
                 $key = 'name';
             }
         }
     }
     if (trim($sort)) {
         $object->orderBy($sort);
     } else {
         if ($key) {
             $object->orderBy($key . ' asc');
         }
     }
     // find all objects
     $object->find();
     while ($object->fetch()) {
         if (!isset($object->mapping_type_id) || $object->mapping_type_id != 1) {
             // "1 for Search Builder"
             $permission = CRM_Core_Permission::EDIT;
             if ($key) {
                 $permission = $this->checkPermission($object->id, $object->{$key});
             }
             if ($permission) {
                 $values[$object->id] = array();
                 CRM_Core_DAO::storeValues($object, $values[$object->id]);
                 require_once 'CRM/Contact/DAO/RelationshipType.php';
                 CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]);
                 // populate action links
                 $this->action($object, $action, $values[$object->id], $links, $permission);
                 if (isset($object->mapping_type_id)) {
                     require_once 'CRM/Core/PseudoConstant.php';
                     $mappintTypes = CRM_Core_PseudoConstant::mappingTypes();
                     $values[$object->id]['mapping_type'] = $mappintTypes[$object->mapping_type_id];
                 }
             }
             $this->assign('rows', $values);
         }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:73,代码来源:Basic.php


示例15: civicrm_relationship_types_get

/**
 * Function to get all relationship type
 * retruns  An array of Relationship_type
 * * @access  public
 */
function civicrm_relationship_types_get($params = null)
{
    _civicrm_initialize();
    require_once 'CRM/Contact/DAO/RelationshipType.php';
    $relationshipTypes = array();
    $relationshipType = array();
    $relationType = new CRM_Contact_DAO_RelationshipType();
    if (!empty($params) && is_array($params)) {
        $properties = array_keys($relationType->fields());
        foreach ($properties as $name) {
            if (array_key_exists($name, $params)) {
                $relationType->{$name} = $params[$name];
            }
        }
    }
    $relationType->find();
    while ($relationType->fetch()) {
        _civicrm_object_to_array(clone $relationType, $relationshipType);
        $relationshipTypes[] = $relationshipType;
    }
    return $relationshipTypes;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:27,代码来源:RelationshipType.php


示例16: import


//.........这里部分代码省略.........
         $dupeCount = count($dupeContactIDs);
         $contactID = array_pop($dupeContactIDs);
         // check to see if we had more than one duplicate contact id.
         // if we have more than one, the record will be rejected below
         if ($dupeCount == 1) {
             // there was only one dupe, we will continue normally...
             if (!in_array($contactID, $this->_newContacts)) {
                 $this->_newContacts[] = $contactID;
             }
         }
     }
     if ($contactID) {
         // call import hook
         $currentImportID = end($values);
         $hookParams = array('contactID' => $contactID, 'importID' => $currentImportID, 'importTempTable' => $this->_tableName, 'fieldHeaders' => $this->_mapperKeys, 'fields' => $this->_activeFields);
         CRM_Utils_Hook::import('Contact', 'process', $this, $hookParams);
     }
     if ($relationship) {
         $primaryContactId = NULL;
         if (CRM_Core_Error::isAPIError($newContact, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
             if (CRM_Utils_Rule::integer($newContact['error_message']['params'][0])) {
                 $primaryContactId = $newContact['error_message']['params'][0];
             }
         } else {
             $primaryContactId = $newContact->id;
         }
         if ((CRM_Core_Error::isAPIError($newContact, CRM_Core_ERROR::DUPLICATE_CONTACT) || is_a($newContact, 'CRM_Contact_BAO_Contact')) && $primaryContactId) {
             //relationship contact insert
             foreach ($params as $key => $field) {
                 list($id, $first, $second) = CRM_Utils_System::explode('_', $key, 3);
                 if (!($first == 'a' && $second == 'b') && !($first == 'b' && $second == 'a')) {
                     continue;
                 }
                 $relationType = new CRM_Contact_DAO_RelationshipType();
                 $relationType->id = $id;
                 $relationType->find(TRUE);
                 $direction = "contact_sub_type_{$second}";
                 $formatting = array('contact_type' => $params[$key]['contact_type']);
                 //set subtype for related contact CRM-5125
                 if (isset($relationType->{$direction})) {
                     //validation of related contact subtype for update mode
                     if ($relCsType = CRM_Utils_Array::value('contact_sub_type', $params[$key]) && $relCsType != $relationType->{$direction}) {
                         $errorMessage = ts("Mismatched or Invalid contact subtype found for this related contact.");
                         array_unshift($values, $errorMessage);
                         return CRM_Import_Parser::NO_MATCH;
                     } else {
                         $formatting['contact_sub_type'] = $relationType->{$direction};
                     }
                 }
                 $relationType->free();
                 $contactFields = NULL;
                 $contactFields = CRM_Contact_DAO_Contact::import();
                 //Relation on the basis of External Identifier.
                 if (empty($params[$key]['id']) && !empty($params[$key]['external_identifier'])) {
                     $params[$key]['id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$key]['external_identifier'], 'id', 'external_identifier');
                 }
                 // check for valid related contact id in update/fill mode, CRM-4424
                 if (in_array($onDuplicate, array(CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::DUPLICATE_FILL)) && !empty($params[$key]['id'])) {
                     $relatedContactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$key]['id'], 'contact_type');
                     if (!$relatedContactType) {
                         $errorMessage = ts("No contact found for this related contact ID: %1", array(1 => $params[$key]['id']));
                         array_unshift($values, $errorMessage);
                         return CRM_Import_Parser::NO_MATCH;
                     } else {
                         //validation of related contact subtype for update mode
                         //CRM-5125
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:67,代码来源:Contact.php


示例17: processOnBehalfOrganization

 /**
  * Function to add on behalf of organization and it's location
  *
  * @param $behalfOrganization array  array of organization info
  * @param $contactID          int    individual contact id. One
  * who is doing the process of signup / contribution.
  *
  * @param $values             array  form values array
  * @param $params
  * @param null $fields
  *
  * @return void
  * @access public
  */
 static function processOnBehalfOrganization(&$behalfOrganization, &$contactID, &$values, &$params, $fields = NULL)
 {
     $isCurrentEmployer = FALSE;
     $orgID = NULL;
     if (!empty($behalfOrganization['organization_id']) && !empty($behalfOrganization['org_option'])) {
         $orgID = $behalfOrganization['organization_id'];
         unset($behalfOrganization['organization_id']);
         $isCurrentEmployer = TRUE;
     }
     // formalities for creating / editing organization.
     $behalfOrganization['contact_type'] = 'Organization';
     // get the relationship type id
     $relType = new CRM_Contact_DAO_RelationshipType();
     $relType->name_a_b = 'Employee of';
     $relType->find(TRUE);
     $relTypeId = $relType->id;
     // keep relationship params ready
     $relParams['relationship_type_id'] = $relTypeId . '_a_b';
     $relParams['is_permission_a_b'] = 1;
     $relParams['is_active'] = 1;
     if (!$orgID) {
         // check if matching 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Contact_Form_Search类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Contact_DAO_Relationship类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap