X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FMapping.php;h=7857c4bfd5c9f7cff9015ed7d5ae517e951120d4;hb=16bd56a4590b6ded39eaa6abaa15e7904e410445;hp=83473b728cee991a502e8e1fac34c3fb51fb06ea;hpb=e9aca61e8b08d5ae372621c4397108b8f2ec28ba;p=civicrm-core.git diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index 83473b728c..7857c4bfd5 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -35,20 +35,22 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { /** - * Class constructor + * Class constructor. */ public function __construct() { parent::__construct(); } /** - * Fetch object based on array of properties + * 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 + * @param array $params + * (reference ) an assoc array of name/value pairs. + * @param array $defaults + * (reference ) an assoc array to hold the flattened values. * - * @return object CRM_Core_DAO_Mapping object on success, otherwise null - * @static + * @return object + * CRM_Core_DAO_Mapping object on success, otherwise NULL */ public static function retrieve(&$params, &$defaults) { $mapping = new CRM_Core_DAO_Mapping(); @@ -61,13 +63,12 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } /** - * Delete the mapping - * - * @param int $id mapping id + * Delete the mapping. * - * @return boolean - * @static + * @param int $id + * Mapping id. * + * @return bool */ public static function del($id) { // delete from mapping_field table @@ -88,16 +89,17 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } /** - * Takes an associative array and creates a contact object + * Takes an associative array and creates a contact object. * * The function extract all the params it needs to initialize the create a * contact object. the params array could contain additional unused name/value * pairs * - * @param array $params an array of name/value pairs + * @param array $params + * An array of name/value pairs. * - * @return object CRM_Core_DAO_Mapper object on success, otherwise null - * @static + * @return object + * CRM_Core_DAO_Mapper object on success, otherwise NULL */ public static function add($params) { $mapping = new CRM_Core_DAO_Mapping(); @@ -108,12 +110,13 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } /** - * Get the list of mappings + * Get the list of mappings. * - * @param string $mappingTypeId mapping type id + * @param string $mappingTypeId + * Mapping type id. * - * @return array $mapping array of mapping name - * @static + * @return array + * array of mapping name */ public static function getMappings($mappingTypeId) { $mapping = array(); @@ -129,12 +132,13 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } /** - * Get the mapping fields + * Get the mapping fields. * - * @param int $mappingId mapping id + * @param int $mappingId + * Mapping id. * - * @return array $mappingFields array of mapping fields - * @static + * @return array + * array of mapping fields */ public static function getMappingFields($mappingId) { //mapping is to be loaded from database @@ -180,18 +184,27 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } return array( - $mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, - $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue, $mappingWebsiteType, + $mappingName, + $mappingContactType, + $mappingLocation, + $mappingPhoneType, + $mappingImProvider, + $mappingRelation, + $mappingOperator, + $mappingValue, + $mappingWebsiteType, ); } /** - * Check Duplicate Mapping Name + * Check Duplicate Mapping Name. * - * @param $nameField string mapping Name - * @param $mapTypeId string mapping Type + * @param string $nameField + * mapping Name. + * @param string $mapTypeId + * mapping Type. * - * @return boolean + * @return bool */ public static function checkMapping($nameField, $mapTypeId) { $mapping = new CRM_Core_DAO_Mapping(); @@ -203,9 +216,11 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { /** * Function returns associated array of elements, that will be passed for search * - * @param int $smartGroupId smart group id + * @param int $smartGroupId + * Smart group id. * - * @return array $returnFields associated array of elements@static + * @return array + * associated array of elements */ public static function getFormattedFields($smartGroupId) { $returnFields = array(); @@ -230,17 +245,18 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } /** - * Build the mapping form + * Build the mapping form. * * @param CRM_Core_Form $form - * @param string $mappingType (Export/Import/Search Builder) + * @param string $mappingType + * (Export/Import/Search Builder). * @param int $mappingId * @param int $columnNo - * @param int $blockCount (no of blocks shown) - * @param null $exportMode + * @param int $blockCount + * (no of blocks shown). + * @param NULL $exportMode * * @return void - * @static */ public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL) { if ($mappingType == 'Export') { @@ -266,8 +282,8 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { else { $form->assign('loadedMapping', $mappingId); - $params = array('id' => $mappingId); - $temp = array(); + $params = array('id' => $mappingId); + $temp = array(); $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp); $form->assign('savedName', $mappingDetails->name); @@ -289,10 +305,10 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { ); } - $defaults = array(); + $defaults = array(); $hasLocationTypes = array(); $hasRelationTypes = array(); - $fields = array(); + $fields = array(); if ($mappingType == 'Export') { $required = TRUE; @@ -345,7 +361,10 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { //we need to unset groups, tags, notes for component export if ($exportMode != CRM_Export_Form_Select::CONTACT_EXPORT) { foreach (array( - 'groups', 'tags', 'notes') as $value) { + 'groups', + 'tags', + 'notes', + ) as $value) { unset($fields['Individual'][$value]); unset($fields['Household'][$value]); unset($fields['Organization'][$value]); @@ -359,23 +378,27 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { if (!empty($fields['Household'][$key]) && !empty($fields['Organization'][$key])) { $fields['Contact'][$key] = $value; unset($fields['Organization'][$key], - $fields['Household'][$key], - $fields['Individual'][$key]); + $fields['Household'][$key], + $fields['Individual'][$key]); } } if (array_key_exists('note', $fields['Contact'])) { $noteTitle = $fields['Contact']['note']['title']; $fields['Contact']['note']['title'] = $noteTitle . ': ' . ts('Body and Subject'); - $fields['Contact']['note_body'] = array( 'title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body' ); - $fields['Contact']['note_subject'] = array( 'title' => $noteTitle . ': ' . ts('Subject Only'), 'name' => 'note_subject' ); + $fields['Contact']['note_body'] = array('title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body'); + $fields['Contact']['note_subject'] = array( + 'title' => $noteTitle . ': ' . ts('Subject Only'), + 'name' => 'note_subject', + ); } } if (($mappingType == 'Search Builder') || ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT)) { if (CRM_Core_Permission::access('CiviContribute')) { $fields['Contribution'] = CRM_Contribute_BAO_Contribution::exportableFields(); - unset($fields['Contribution']['contribution_contact_id']); - unset($fields['Contribution']['contribution_status_id']); + foreach (array('contribution_contact_id', 'contribution_soft_credit_name', 'contribution_soft_credit_amount', 'contribution_soft_credit_type', 'contribution_soft_credit_contribution_id') as $element) { + unset($fields['Contribution'][$element]); + } $compArray['Contribution'] = ts('Contribution'); } } @@ -393,7 +416,6 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $fields['Participant'] = array_merge($fields['Participant'], $componentPaymentFields); } - unset($fields['Participant']['participant_contact_id']); $compArray['Participant'] = ts('Participant'); } } @@ -450,9 +472,9 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $csRelationships = array(); if ($mappingType == 'Export') { - $subTypeRelationshipTypes = - CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], - FALSE, 'label', TRUE, $subType); + $subTypeRelationshipTypes + = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], + FALSE, 'label', TRUE, $subType); foreach ($subTypeRelationshipTypes as $key => $var) { if (!array_key_exists($key, $fields[$val['parent']])) { @@ -545,9 +567,9 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } } - $sel3[''] = NULL; - $sel5[''] = NULL; - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); + $sel3[''] = NULL; + $sel5[''] = NULL; + $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); asort($phoneTypes); @@ -587,18 +609,18 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { // FIX ME: For now let's not expose custom data related to relationship $relationshipCustomFields = array(); //$relationshipCustomFields = self::getRelationTypeCustomGroupData( $id ); - //asort( $relationshipCustomFields ) ; + //asort($relationshipCustomFields); $relationshipType = new CRM_Contact_BAO_RelationshipType(); $relationshipType->id = $id; if ($relationshipType->find(TRUE)) { $direction = "contact_sub_type_$second"; if (isset($relationshipType->$direction)) { - $relatedFields = array_merge((array)$relatedMapperFields[$relationshipType->$direction], (array)$relationshipCustomFields); + $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->$direction], (array) $relationshipCustomFields); } else { $target_type = 'contact_type_' . $second; - $relatedFields = array_merge((array)$relatedMapperFields[$relationshipType->$target_type], (array)$relationshipCustomFields); + $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->$target_type], (array) $relationshipCustomFields); } } $relationshipType->free(); @@ -640,9 +662,19 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { //special fields that have location, hack for primary location $specialFields = array( - 'street_address', 'supplemental_address_1', 'supplemental_address_2', - 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', - 'state_province', 'country', 'phone', 'email', 'im', + 'street_address', + 'supplemental_address_1', + 'supplemental_address_2', + 'city', + 'postal_code', + 'postal_code_suffix', + 'geo_code_1', + 'geo_code_2', + 'state_province', + 'country', + 'phone', + 'email', + 'im', ); if (isset($mappingId)) { @@ -650,7 +682,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue - ) = CRM_Core_BAO_Mapping::getMappingFields($mappingId); + ) = CRM_Core_BAO_Mapping::getMappingFields($mappingId); $blkCnt = count($mappingName); if ($blkCnt >= $blockCount) { @@ -847,9 +879,9 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $js = "