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


PHP CRM_Contact_DAO_RelationshipType::find方法代码示例

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


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

示例1: retrieve

 /**
  * Fetch object based on array of properties.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $defaults
  *   (reference ) an assoc array to hold the flattened values.
  *
  * @return CRM_Contact_BAO_RelationshipType
  */
 public static function retrieve(&$params, &$defaults)
 {
     $relationshipType = new CRM_Contact_DAO_RelationshipType();
     $relationshipType->copyValues($params);
     if ($relationshipType->find(TRUE)) {
         CRM_Core_DAO::storeValues($relationshipType, $defaults);
         $relationshipType->free();
         return $relationshipType;
     }
     return NULL;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:21,代码来源:RelationshipType.php

示例2: import


//.........这里部分代码省略.........
         $newContact = clone $newContact;
         $this->_newContacts[] = $newContact->id;
         //get return code if we create new contact in update mode, CRM-4148
         if ($this->_updateWithId) {
             $this->_retCode = CRM_Import_Parser::VALID;
         }
     } else {
         if (civicrm_duplicate($newContact)) {
             $relationship = true;
             $contactID = $newContact['error_message']['params'][0];
             if (!in_array($contactID, $this->_newContacts)) {
                 $this->_newContacts[] = $contactID;
             }
         }
     }
     if ($relationship) {
         $primaryContactId = null;
         if (civicrm_duplicate($newContact)) {
             if (CRM_Utils_Rule::integer($newContact['error_message']['params'][0])) {
                 $primaryContactId = $newContact['error_message']['params'][0];
             }
         } else {
             $primaryContactId = $newContact->id;
         }
         if ((civicrm_duplicate($newContact) || 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 (!CRM_Utils_Array::value('id', $params[$key]) && isset($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)) && CRM_Utils_Array::value('id', $params[$key])) {
                     $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
                         $relatedCsType = null;
                         if (CRM_Utils_Array::value('contact_sub_type', $formatting)) {
开发者ID:bhirsch,项目名称:voipdev,代码行数:67,代码来源:Contact.php

示例3: postProcessOld

 /**
  * Process the mapped fields and map it into the uploaded file
  * preview the file and extract some summary statistics
  *
  * @return void
  * @access public
  */
 public function postProcessOld()
 {
     $doGeocodeAddress = $this->controller->exportValue('DataSource', 'doGeocodeAddress');
     $invalidRowCount = $this->get('invalidRowCount');
     $conflictRowCount = $this->get('conflictRowCount');
     $onDuplicate = $this->get('onDuplicate');
     $newGroupName = $this->controller->exportValue($this->_name, 'newGroupName');
     $newGroupDesc = $this->controller->exportValue($this->_name, 'newGroupDesc');
     $groups = $this->controller->exportValue($this->_name, 'groups');
     $allGroups = $this->get('groups');
     $newTagName = $this->controller->exportValue($this->_name, 'newTagName');
     $newTagDesc = $this->controller->exportValue($this->_name, 'newTagDesc');
     $tag = $this->controller->exportValue($this->_name, 'tag');
     $allTags = $this->get('tag');
     $mapper = $this->controller->exportValue('MapField', 'mapper');
     $mapperKeys = array();
     $mapperLocTypes = array();
     $mapperPhoneTypes = array();
     $mapperRelated = array();
     $mapperRelatedContactType = array();
     $mapperRelatedContactDetails = array();
     $mapperRelatedContactLocType = array();
     $mapperRelatedContactPhoneType = array();
     foreach ($mapper as $key => $value) {
         $mapperKeys[$key] = $mapper[$key][0];
         if (is_numeric($mapper[$key][1])) {
             $mapperLocTypes[$key] = $mapper[$key][1];
         } else {
             $mapperLocTypes[$key] = NULL;
         }
         if (CRM_Utils_Array::value($key, $mapperKeys) == 'phone') {
             $mapperPhoneTypes[$key] = $mapper[$key][2];
         } else {
             $mapperPhoneTypes[$key] = NULL;
         }
         list($id, $first, $second) = explode('_', $mapper[$key][0]);
         if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
             $relationType = new CRM_Contact_DAO_RelationshipType();
             $relationType->id = $id;
             $relationType->find(TRUE);
             $fieldName = "contact_type_{$second}";
             $mapperRelatedContactType[$key] = $relationType->{$fieldName};
             $mapperRelated[$key] = $mapper[$key][0];
             $mapperRelatedContactDetails[$key] = $mapper[$key][1];
             $mapperRelatedContactLocType[$key] = $mapper[$key][2];
             $mapperRelatedContactPhoneType[$key] = $mapper[$key][3];
         } else {
             $mapperRelated[$key] = NULL;
             $mapperRelatedContactType[$key] = NULL;
             $mapperRelatedContactDetails[$key] = NULL;
             $mapperRelatedContactLocType[$key] = NULL;
             $mapperRelatedContactPhoneType[$key] = NULL;
         }
     }
     $parser = new CRM_Contact_Import_Parser_Contact($mapperKeys, $mapperLocTypes, $mapperPhoneTypes, $mapperRelated, $mapperRelatedContactType, $mapperRelatedContactDetails, $mapperRelatedContactLocType, $mapperRelatedContactPhoneType);
     $mapFields = $this->get('fields');
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     foreach ($mapper as $key => $value) {
         $header = array();
         list($id, $first, $second) = explode('_', $mapper[$key][0]);
         if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
             $relationType = new CRM_Contact_DAO_RelationshipType();
             $relationType->id = $id;
             $relationType->find(TRUE);
             $header[] = $relationType->name_a_b;
             $header[] = ucwords(str_replace("_", " ", $mapper[$key][1]));
             if (isset($mapper[$key][2])) {
                 $header[] = $locationTypes[$mapper[$key][2]];
             }
             if (isset($mapper[$key][3])) {
                 $header[] = $phoneTypes[$mapper[$key][3]];
             }
         } else {
             if (isset($mapFields[$mapper[$key][0]])) {
                 $header[] = $mapFields[$mapper[$key][0]];
                 if (isset($mapper[$key][1])) {
                     $header[] = $locationTypes[$mapper[$key][1]];
                 }
                 if (isset($mapper[$key][2])) {
                     $header[] = $phoneTypes[$mapper[$key][2]];
                 }
             }
         }
         $mapperFields[] = implode(' - ', $header);
     }
     $tableName = $this->get('importTableName');
     //print "Running parser on table: $tableName<br/>";
     $parser->run($tableName, $mapperFields, CRM_Import_Parser::MODE_IMPORT, $this->get('contactType'), $this->get('primaryKeyName'), $this->get('statusFieldName'), $onDuplicate, $this->get('statusID'), $this->get('totalRowCount'), $doGeocodeAddress, CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, $this->get('contactSubType'), $this->get('dedupe'));
     // add the new contacts to selected groups
     $contactIds =& $parser->getImportedContacts();
     // add the new related contacts to selected groups
     $relatedContactIds =& $parser->getRelatedImportedContacts();
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Preview.php

示例4: 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

示例5: postProcess

 /**
  * Process the mapped fields and map it into the uploaded file.
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues('MapField');
     //reload the mapfield if load mapping is pressed
     if (!empty($params['savedMapping'])) {
         $this->set('savedMapping', $params['savedMapping']);
         $this->controller->resetPage($this->_name);
         return;
     }
     $mapper = array();
     $mapperKeys = array();
     $mapperKeys = $this->controller->exportValue($this->_name, 'mapper');
     $mapperKeysMain = 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');
     //these mapper params need to set key as array and val as null.
     $mapperParams = array('related' => 'relatedVal', 'locations' => 'locationsVal', 'mapperLocType' => 'mapperLocTypeVal', 'mapperPhoneType' => 'mapperPhoneTypeVal', 'mapperImProvider' => 'mapperImProviderVal', 'mapperWebsiteType' => 'mapperWebsiteTypeVal', 'relatedContactType' => 'relatedContactTypeVal', 'relatedContactDetails' => 'relatedContactDetailsVal', 'relatedContactLocType' => 'relatedContactLocTypeVal', 'relatedContactPhoneType' => 'relatedContactPhoneTypeVal', 'relatedContactImProvider' => 'relatedContactImProviderVal', 'relatedContactWebsiteType' => 'relatedContactWebsiteTypeVal');
     //set respective mapper params to array.
     foreach (array_keys($mapperParams) as $mapperParam) {
         ${$mapperParam} = array();
     }
     for ($i = 0; $i < $this->_columnCount; $i++) {
         //set respective mapper value to null
         foreach (array_values($mapperParams) as $mapperParam) {
             ${$mapperParam} = NULL;
         }
         $fldName = CRM_Utils_Array::value(0, $mapperKeys[$i]);
         $selOne = CRM_Utils_Array::value(1, $mapperKeys[$i]);
         $selTwo = CRM_Utils_Array::value(2, $mapperKeys[$i]);
         $selThree = CRM_Utils_Array::value(3, $mapperKeys[$i]);
         $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]];
         $mapperKeysMain[$i] = $fldName;
         //need to differentiate non location elements.
         if ($selOne && is_numeric($selOne)) {
             if ($fldName == 'url') {
                 $mapperWebsiteTypeVal = $websiteTypes[$selOne];
             } else {
                 $locationsVal = $locationTypes[$selOne];
                 $mapperLocTypeVal = $selOne;
                 if ($selTwo && is_numeric($selTwo)) {
                     if ($fldName == 'phone') {
                         $mapperPhoneTypeVal = $phoneTypes[$selTwo];
                     } elseif ($fldName == 'im') {
                         $mapperImProviderVal = $imProviders[$selTwo];
                     }
                 }
             }
         }
         //relationship contact mapper info.
         list($id, $first, $second) = CRM_Utils_System::explode('_', $fldName, 3);
         if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
             $relatedVal = $this->_mapperFields[$fldName];
             if ($selOne) {
                 if ($selOne == 'url') {
                     $relatedContactWebsiteTypeVal = $websiteTypes[$selTwo];
                 } else {
                     $relatedContactLocTypeVal = CRM_Utils_Array::value($selTwo, $locationTypes);
                     if ($selThree) {
                         if ($selOne == 'phone') {
                             $relatedContactPhoneTypeVal = $phoneTypes[$selThree];
                         } elseif ($selOne == 'im') {
                             $relatedContactImProviderVal = $imProviders[$selThree];
                         }
                     }
                 }
                 //get the related contact type.
                 $relationType = new CRM_Contact_DAO_RelationshipType();
                 $relationType->id = $id;
                 $relationType->find(TRUE);
                 $relatedContactTypeVal = $relationType->{"contact_type_{$second}"};
                 $relatedContactDetailsVal = $this->_formattedFieldNames[$relatedContactTypeVal][$selOne];
             }
         }
         //set the respective mapper param array values.
         foreach ($mapperParams as $mapperParamKey => $mapperParamVal) {
             ${$mapperParamKey}[$i] = ${$mapperParamVal};
         }
     }
     $this->set('columnNames', $this->_columnNames);
     //set main contact properties.
     $properties = array('ims' => 'mapperImProvider', 'mapper' => 'mapper', 'phones' => 'mapperPhoneType', 'websites' => 'mapperWebsiteType', 'locations' => 'locations');
     foreach ($properties as $propertyName => $propertyVal) {
         $this->set($propertyName, ${$propertyVal});
     }
     //set related contact propeties.
     $relProperties = array('related', 'relatedContactType', 'relatedContactDetails', 'relatedContactLocType', 'relatedContactPhoneType', 'relatedContactImProvider', 'relatedContactWebsiteType');
     foreach ($relProperties as $relProperty) {
         $this->set($relProperty, ${$relProperty});
     }
     // store mapping Id to display it in the preview page
     $this->set('loadMappingId', CRM_Utils_Array::value('mappingId', $params));
     //Updating Mapping Records
     if (!empty($params['updateMapping'])) {
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
         $mappingFields = new CRM_Core_DAO_MappingField();
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:MapField.php

示例6: 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

示例7: 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 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'] = $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
     $relParams['contact_check'][$orgID] = 1;
     $cid = array('contact' => $contactID);
     CRM_Contact_BAO_Relationship::create($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;
         // required for IPN
         $params['related_contact'] = $contactID;
         //make this employee of relationship as current
         //employer / employee relationship,  CRM-3532
         if ($isCurrentEmployer && $orgID != CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'employer_id')) {
             $isCurrentEmployer = FALSE;
         }
         if (!$isCurrentEmployer && $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:archcidburnziso,项目名称:civicrm-core,代码行数:91,代码来源:Confirm.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: 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

示例10: 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

示例11: 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

示例12: relationshipContacts

 static function relationshipContacts()
 {
     $data = $searchValues = $searchRows = array();
     $addCount = 0;
     $relType = CRM_Utils_Type::escape($_REQUEST['relType'], 'String');
     $typeName = isset($_REQUEST['typeName']) ? CRM_Utils_Type::escape($_REQUEST['typeName'], 'String') : '';
     $relContact = CRM_Utils_Type::escape($_REQUEST['relContact'], 'String');
     $currentContactId = CRM_Utils_Type::escape($_REQUEST['cid'], 'Integer');
     if (in_array($typeName, array('Employee of', 'Employer of'))) {
         $addCount = 1;
     }
     $sortMapper = array(1 => 'sort_name', 2 + $addCount => 'city', 3 + $addCount => 'state_province', 4 + $addCount => 'email', 5 + $addCount => 'phone');
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
     $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
     $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
     $sort = isset($_REQUEST['iSortCol_0']) ? $sortMapper[CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer')] : 'sort_name';
     $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
     $searchValues[] = array('sort_name', 'LIKE', $relContact, 0, 1);
     list($rid, $direction) = explode('_', $relType, 2);
     $relationshipType = new CRM_Contact_DAO_RelationshipType();
     $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;
         }
         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);
         }
     }
     // exclude current contact
     $searchValues[] = array('contact_id', '!=', $currentContactId, 0, 0);
     $contactBAO = new CRM_Contact_BAO_Contact();
     $query = new CRM_Contact_BAO_Query($searchValues);
     $searchCount = $query->searchQuery(0, 0, NULL, TRUE);
     $iTotal = $searchCount;
     if ($searchCount > 0) {
         // get the result of the search
         $result = $query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, NULL, $sortOrder);
         $config = CRM_Core_Config::singleton();
         //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;
             $duplicateRelationship = 0;
             $contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
             $typeImage = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $contactID);
             $searchRows[$contactID]['id'] = $contactID;
             $searchRows[$contactID]['name'] = $typeImage . ' ' . $result->sort_name;
             $searchRows[$contactID]['city'] = $result->city;
             $searchRows[$contactID]['state'] = $result->state_province;
             $searchRows[$contactID]['email'] = $result->email;
             $searchRows[$contactID]['phone'] = $result->phone;
         }
     }
     foreach ($searchRows as $cid => $row) {
         $searchRows[$cid]['check'] = '<input type="checkbox" id="contact_check[' . $cid . ']" name="contact_check[' . $cid . ']" value=' . $cid . ' />';
         if ($typeName == 'Employee of') {
             $searchRows[$cid]['employee_of'] = '<input type="radio" name="employee_of" value=' . $cid . ' >';
         } elseif ($typeName == 'Employer of') {
             $searchRows[$cid]['employer_of'] = '<input type="checkbox"  name="employer_of[' . $cid . ']" value=' . $cid . ' />';
         }
     }
     $selectorElements = array('check', 'name');
     if ($typeName == 'Employee of') {
         $selectorElements[] = 'employee_of';
     } elseif ($typeName == 'Employer of') {
         $selectorElements[] = 'employer_of';
     }
     $selectorElements = array_merge($selectorElements, array('city', 'state', 'email', 'phone'));
     $iFilteredTotal = $iTotal;
     echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
     CRM_Utils_System::civiExit();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:81,代码来源:AJAX.php

示例13: import


//.........这里部分代码省略.........
         // 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
                         $relatedCsType = NULL;
                         if (!empty($formatting['contact_sub_type'])) {
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:67,代码来源:Contact.php

示例14: import


//.........这里部分代码省略.........
         }
         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) {
                                 if ($testForEmpty === '' || $testForEmpty == null) {
                                     $break = true;
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:67,代码来源:Contact.php

示例15: 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


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