From: Tim Otten Date: Tue, 6 Jan 2015 22:15:06 +0000 (-0800) Subject: INFRA-132 - CRM/Contact - Misc X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=51ccfbbea3adab11200800e01f1233cddc7e5272;p=civicrm-core.git INFRA-132 - CRM/Contact - Misc --- diff --git a/CRM/Contact/BAO/Contact/Permission.php b/CRM/Contact/BAO/Contact/Permission.php index 6b3d162984..ca887e15cc 100644 --- a/CRM/Contact/BAO/Contact/Permission.php +++ b/CRM/Contact/BAO/Contact/Permission.php @@ -158,7 +158,8 @@ ON DUPLICATE KEY UPDATE * @return boolean * @static */ - static function hasContactsInCache($type = CRM_Core_Permission::VIEW, + static function hasContactsInCache( + $type = CRM_Core_Permission::VIEW, $contactID = NULL ) { if (!$contactID) { @@ -324,7 +325,8 @@ WHERE (( contact_id_a = %1 AND contact_id_b = %2 AND is_permission_a_b = 1 ) OR AND ( civicrm_relationship.is_active = 1 ) "; } - $params = array(1 => array($contactID, 'Integer'), + $params = array( + 1 => array($contactID, 'Integer'), 2 => array($selectedContactID, 'Integer'), ); return CRM_Core_DAO::singleValueQuery($query, $params); diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index eb3260b1ad..2529eb6146 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -220,7 +220,7 @@ WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL {$ctWHERE} * @param bool $ignoreCache * * @return array of all subtypes OR list of subtypes associated to - *a given basic contact type + * a given basic contact type * @static */ public static function subTypes($contactType = NULL, $all = FALSE, $columnName = 'name', $ignoreCache = FALSE) { @@ -374,7 +374,8 @@ WHERE type.name IS NOT NULL * * @return mixed */ - static function getSelectElements($all = FALSE, + static function getSelectElements( + $all = FALSE, $isSeparator = TRUE, $separator = '__' ) { @@ -460,9 +461,9 @@ AND ( p.is_active = 1 OR p.id IS NULL ) /** * Retrieve the basic contact type associated with given subType. * - *@param array/string $subType contact subType. - *@return array/string of basicTypes. - *@static + * @param array/string $subType contact subType. + * @return array/string of basicTypes. + * @static * */ public static function getBasicType($subType) { @@ -872,7 +873,8 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause); * * @return bool */ - static function deleteCustomSetForSubtypeMigration($contactID, + static function deleteCustomSetForSubtypeMigration( + $contactID, $contactType, $oldSubtypeSet = array(), $newSubtypeSet = array() diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 2f6c79a7c4..ef0851b29f 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5057,10 +5057,11 @@ SELECT COUNT( conts.total_amount ) as cancel_count, * @param $fieldTitle * @param null $options */ - function numberRangeBuilder(&$values, - $tableName, $fieldName, - $dbFieldName, $fieldTitle, - $options = NULL + function numberRangeBuilder( + &$values, + $tableName, $fieldName, + $dbFieldName, $fieldTitle, + $options = NULL ) { list($name, $op, $value, $grouping, $wildcard) = $values; diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index bf3d1bce47..19021ce59e 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -404,7 +404,8 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { * * @return array - array reference of all relationship types with context to current contact. */ - static function getContactRelationshipType($contactId = NULL, + static function getContactRelationshipType( + $contactId = NULL, $contactSuffix = NULL, $relationshipId = NULL, $contactType = NULL, @@ -1051,7 +1052,8 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id) * @return array|int * @static */ - static function getRelationship($contactId = NULL, + static function getRelationship( + $contactId = NULL, $status = 0, $numRelationship = 0, $count = 0, $relationshipId = 0, $links = NULL, $permissionMask = NULL, diff --git a/CRM/Contact/Form/Edit/TagsAndGroups.php b/CRM/Contact/Form/Edit/TagsAndGroups.php index 8c6cd87974..95e103fbbe 100644 --- a/CRM/Contact/Form/Edit/TagsAndGroups.php +++ b/CRM/Contact/Form/Edit/TagsAndGroups.php @@ -65,7 +65,8 @@ class CRM_Contact_Form_Edit_TagsAndGroups { * * @static */ - static function buildQuickForm(&$form, + static function buildQuickForm( + &$form, $contactId = 0, $type = self::ALL, $visibility = FALSE, @@ -197,7 +198,7 @@ class CRM_Contact_Form_Edit_TagsAndGroups { self::climbtree($form, $varValue['children'], $elements); } } - return $elements; + return $elements; } /** diff --git a/CRM/Contact/Form/Search/Custom/ActivitySearch.php b/CRM/Contact/Form/Search/Custom/ActivitySearch.php index 036cd1203f..b94cd426ff 100644 --- a/CRM/Contact/Form/Search/Custom/ActivitySearch.php +++ b/CRM/Contact/Form/Search/Custom/ActivitySearch.php @@ -75,7 +75,6 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch implements CRM_Contact_Form_ NULL, '', NULL ); - //use simplified formatted groupTree $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $form); @@ -131,7 +130,6 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch implements CRM_Contact_Form_ $form->addDate('start_date', ts('Activity Date From'), FALSE, array('formatType' => 'custom')); $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom')); - // Contact Name field $form->add('text', 'sort_name', ts('Contact Name')); @@ -155,7 +153,8 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch implements CRM_Contact_Form_ /** * Construct the search query */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index 9b608900cc..559e2f36a3 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -107,7 +107,8 @@ class CRM_Contact_Form_Search_Custom_ContributionAggregate implements CRM_Contac /** * Construct the search query */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { diff --git a/CRM/Contact/Form/Search/Custom/DateAdded.php b/CRM/Contact/Form/Search/Custom/DateAdded.php index 65d4e1a248..1adb3d454c 100644 --- a/CRM/Contact/Form/Search/Custom/DateAdded.php +++ b/CRM/Contact/Form/Search/Custom/DateAdded.php @@ -121,7 +121,8 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C * * @return string */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { diff --git a/CRM/Contact/Form/Search/Custom/EmployerListing.php b/CRM/Contact/Form/Search/Custom/EmployerListing.php index a2166045ff..88e51f7aab 100644 --- a/CRM/Contact/Form/Search/Custom/EmployerListing.php +++ b/CRM/Contact/Form/Search/Custom/EmployerListing.php @@ -104,7 +104,8 @@ class CRM_Contact_Form_Search_Custom_EmployerListing implements CRM_Contact_Form /** * Construct the search query */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { if ($justIDs) { diff --git a/CRM/Contact/Form/Search/Custom/EventAggregate.php b/CRM/Contact/Form/Search/Custom/EventAggregate.php index ae56dd85e6..06f71fa0f6 100644 --- a/CRM/Contact/Form/Search/Custom/EventAggregate.php +++ b/CRM/Contact/Form/Search/Custom/EventAggregate.php @@ -103,7 +103,8 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea /** * Construct the search query */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { // SELECT clause must include contact_id as an alias for civicrm_contact.id if you are going to use "tasks" like export etc. @@ -271,7 +272,6 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea on (civicrm_entity_financial_trxn.entity_id = civicrm_participant_payment.contribution_id and civicrm_entity_financial_trxn.entity_table='civicrm_contribution')"; } - $where = $this->where(); $sql = " diff --git a/CRM/Contact/Form/Search/Custom/PostalMailing.php b/CRM/Contact/Form/Search/Custom/PostalMailing.php index f218102b8e..fded896cd0 100644 --- a/CRM/Contact/Form/Search/Custom/PostalMailing.php +++ b/CRM/Contact/Form/Search/Custom/PostalMailing.php @@ -75,7 +75,8 @@ class CRM_Contact_Form_Search_Custom_PostalMailing extends CRM_Contact_Form_Sear * * @return string */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { if ($justIDs) { @@ -83,7 +84,7 @@ class CRM_Contact_Form_Search_Custom_PostalMailing extends CRM_Contact_Form_Sear $sort = 'contact_a.id'; } else { - $selectClause = " + $selectClause = " DISTINCT contact_a.id as contact_id , contact_a.contact_type as contact_type, contact_a.sort_name as sort_name, diff --git a/CRM/Contact/Form/Search/Custom/PriceSet.php b/CRM/Contact/Form/Search/Custom/PriceSet.php index 9b5dba02e8..fb54e99841 100644 --- a/CRM/Contact/Form/Search/Custom/PriceSet.php +++ b/CRM/Contact/Form/Search/Custom/PriceSet.php @@ -276,7 +276,8 @@ AND p.entity_id = e.id * * @return string */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { if ($justIDs) { @@ -340,7 +341,8 @@ INNER JOIN {$this->_tableName} tempTable ON ( tempTable.contact_id = contact_a.i /** * @param $row */ - public function alterRow(&$row) {} + public function alterRow(&$row) { + } /** * @param $title diff --git a/CRM/Contact/Form/Search/Custom/Proximity.php b/CRM/Contact/Form/Search/Custom/Proximity.php index b88eeb5d39..ffa29d149c 100644 --- a/CRM/Contact/Form/Search/Custom/Proximity.php +++ b/CRM/Contact/Form/Search/Custom/Proximity.php @@ -170,7 +170,8 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C * * @return string */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { if ($justIDs) { @@ -287,7 +288,8 @@ AND cgc.group_id = {$this->_group} /** * @param $row */ - public function alterRow(&$row) {} + public function alterRow(&$row) { + } /** * @param $title diff --git a/CRM/Contact/Form/Search/Custom/RandomSegment.php b/CRM/Contact/Form/Search/Custom/RandomSegment.php index 172e96b5e8..6b37c6b050 100644 --- a/CRM/Contact/Form/Search/Custom/RandomSegment.php +++ b/CRM/Contact/Form/Search/Custom/RandomSegment.php @@ -131,7 +131,8 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear * * @return string */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { if ($justIDs) { diff --git a/CRM/Contact/Form/Search/Custom/Sample.php b/CRM/Contact/Form/Search/Custom/Sample.php index 49c0784d04..93169bcd03 100644 --- a/CRM/Contact/Form/Search/Custom/Sample.php +++ b/CRM/Contact/Form/Search/Custom/Sample.php @@ -106,7 +106,8 @@ class CRM_Contact_Form_Search_Custom_Sample extends CRM_Contact_Form_Search_Cust * * @return string */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { if ($justIDs) { diff --git a/CRM/Contact/Form/Search/Custom/TagContributions.php b/CRM/Contact/Form/Search/Custom/TagContributions.php index 0b64f0f891..e2172f16cf 100644 --- a/CRM/Contact/Form/Search/Custom/TagContributions.php +++ b/CRM/Contact/Form/Search/Custom/TagContributions.php @@ -71,7 +71,6 @@ class CRM_Contact_Form_Search_Custom_TagContributions implements CRM_Contact_For * Define the search form fields here */ - $form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom')); $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom')); $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); @@ -94,7 +93,8 @@ class CRM_Contact_Form_Search_Custom_TagContributions implements CRM_Contact_For /** * Construct the search query */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $onlyIDs = FALSE ) { diff --git a/CRM/Contact/Form/Search/Custom/ZipCodeRange.php b/CRM/Contact/Form/Search/Custom/ZipCodeRange.php index 927d6ceea4..767eec099b 100644 --- a/CRM/Contact/Form/Search/Custom/ZipCodeRange.php +++ b/CRM/Contact/Form/Search/Custom/ZipCodeRange.php @@ -96,7 +96,8 @@ class CRM_Contact_Form_Search_Custom_ZipCodeRange extends CRM_Contact_Form_Searc * * @return string */ - function all($offset = 0, $rowcount = 0, $sort = NULL, + function all( + $offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE ) { if ($justIDs) { @@ -154,7 +155,8 @@ LEFT JOIN civicrm_email email ON ( email.contact_id = contact_a.id AND } $where = "ROUND(address.postal_code) >= %1 AND ROUND(address.postal_code) <= %2"; - $params = array(1 => array(trim($low), 'Integer'), + $params = array( + 1 => array(trim($low), 'Integer'), 2 => array(trim($high), 'Integer'), ); diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 8f43dd2858..a6e0823133 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -699,12 +699,14 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { ); //set respective mapper params to array. - foreach (array_keys($mapperParams) as $mapperParam) { $$mapperParam = 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; + foreach (array_values($mapperParams) as $mapperParam) { + $$mapperParam = NULL; } $fldName = CRM_Utils_Array::value(0, $mapperKeys[$i]); diff --git a/CRM/Contact/Import/ImportJob.php b/CRM/Contact/Import/ImportJob.php index a9264e1d7c..84e2a176dd 100644 --- a/CRM/Contact/Import/ImportJob.php +++ b/CRM/Contact/Import/ImportJob.php @@ -118,7 +118,8 @@ class CRM_Contact_Import_ImportJob { 'mapperRelatedContactImProvider', 'mapperRelatedContactWebsiteType', ); - foreach ($properties as $property) { $this->{"_$property"} = array(); + foreach ($properties as $property) { + $this->{"_$property"} = array(); } } @@ -191,7 +192,8 @@ class CRM_Contact_Import_ImportJob { foreach ($mapper as $key => $value) { //set respective mapper value to null. - foreach (array_values($mapperPeroperties) as $perpertyVal) { $$perpertyVal = NULL; + foreach (array_values($mapperPeroperties) as $perpertyVal) { + $$perpertyVal = NULL; } $fldName = CRM_Utils_Array::value(0, $mapper[$key]); @@ -346,7 +348,8 @@ class CRM_Contact_Import_ImportJob { * * @return array|bool */ - private function _addImportedContactsToNewGroup($contactIds, + private function _addImportedContactsToNewGroup( + $contactIds, $newGroupName, $newGroupDesc ) { @@ -399,7 +402,8 @@ class CRM_Contact_Import_ImportJob { * * @return array|bool */ - private function _tagImportedContactsWithNewTag($contactIds, + private function _tagImportedContactsWithNewTag( + $contactIds, $newTagName, $newTagDesc ) { diff --git a/CRM/Contact/Import/Parser.php b/CRM/Contact/Import/Parser.php index 24006dc196..d275d0eb92 100644 --- a/CRM/Contact/Import/Parser.php +++ b/CRM/Contact/Import/Parser.php @@ -103,7 +103,8 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { * * @return mixed */ - function run($tableName, + function run( + $tableName, &$mapper, $mode = self::MODE_PREVIEW, $contactType = self::CONTACT_INDIVIDUAL, @@ -647,7 +648,8 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { * @param string $dataPattern * @param bool $hasLocationType */ - function addField($name, $title, $type = CRM_Utils_Type::T_INT, + function addField( + $name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//', $hasLocationType = FALSE ) { diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 1aa47bb11f..6ba3beb7a4 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -102,7 +102,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { /** * Class constructor */ - function __construct(&$mapperKeys, $mapperLocType = NULL, $mapperPhoneType = NULL, $mapperImProvider = NULL, $mapperRelated = NULL, $mapperRelatedContactType = NULL, $mapperRelatedContactDetails = NULL, $mapperRelatedContactLocType = NULL, $mapperRelatedContactPhoneType = NULL, $mapperRelatedContactImProvider = NULL, + function __construct( + &$mapperKeys, $mapperLocType = NULL, $mapperPhoneType = NULL, $mapperImProvider = NULL, $mapperRelated = NULL, $mapperRelatedContactType = NULL, $mapperRelatedContactDetails = NULL, $mapperRelatedContactLocType = NULL, $mapperRelatedContactPhoneType = NULL, $mapperRelatedContactImProvider = NULL, $mapperWebsiteType = NULL, $mapperRelatedContactWebsiteType = NULL ) { parent::__construct(); @@ -166,7 +167,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { if (!empty($relationshipType)) { $fields = array_merge($fields, array( 'related' => array( - 'title' => ts('- related contact info -'), + 'title' => ts('- related contact info -'), ), ), $relationshipType); } @@ -233,9 +234,10 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $this->_updateWithId = FALSE; if (in_array('id', $this->_mapperKeys) || ($this->_externalIdentifierIndex >= 0 && in_array($this->_onDuplicate, array( - CRM_Import_Parser::DUPLICATE_UPDATE, - CRM_Import_Parser::DUPLICATE_FILL, - )))) { + CRM_Import_Parser::DUPLICATE_UPDATE, + CRM_Import_Parser::DUPLICATE_FILL, + ))) + ) { $this->_updateWithId = TRUE; } @@ -481,9 +483,10 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { //check if external identifier exists in database if (!empty($params['external_identifier']) && (!empty($params['id']) || in_array($onDuplicate, array( - CRM_Import_Parser::DUPLICATE_SKIP, - CRM_Import_Parser::DUPLICATE_NOCHECK, - )))) { + CRM_Import_Parser::DUPLICATE_SKIP, + CRM_Import_Parser::DUPLICATE_NOCHECK, + ))) + ) { if ($internalCid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) { if ($internalCid != CRM_Utils_Array::value('id', $params)) { @@ -562,8 +565,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $this->_retCode = CRM_Import_Parser::NO_MATCH; } else { - $newContact = $this->createContact($formatted, $contactFields, $onDuplicate, $contactId, FALSE, $this->_dedupeRuleGroupID); - $updateflag = FALSE; + $newContact = $this->createContact($formatted, $contactFields, $onDuplicate, $contactId, FALSE, $this->_dedupeRuleGroupID); + $updateflag = FALSE; $this->_retCode = CRM_Import_Parser::VALID; } } @@ -684,7 +687,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $relationship = TRUE; # see CRM-10433 - might return comma separate list of all dupes - $dupeContactIDs = explode(',',$newContact['error_message']['params'][0]); + $dupeContactIDs = explode(',', $newContact['error_message']['params'][0]); $dupeCount = count($dupeContactIDs); $contactID = array_pop($dupeContactIDs); // check to see if we had more than one duplicate contact id. @@ -764,9 +767,10 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } // 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'])) { + 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'])); @@ -782,7 +786,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } if (!empty($relatedCsType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params[$key]['id'], $relatedCsType) && - $relatedCsType != CRM_Utils_Array::value('contact_sub_type', $formatting))) { + $relatedCsType != CRM_Utils_Array::value('contact_sub_type', $formatting)) + ) { $errorMessage = ts("Mismatched or Invalid contact subtype found for this related contact.") . ' ' . ts("ID: %1", array(1 => $params[$key]['id'])); array_unshift($values, $errorMessage); return CRM_Import_Parser::NO_MATCH; @@ -846,9 +851,9 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } // update/fill related contact after getting matching Contact Ids, CRM-4424 if (in_array($onDuplicate, array( - CRM_Import_Parser::DUPLICATE_UPDATE, - CRM_Import_Parser::DUPLICATE_FILL, - ))) { + CRM_Import_Parser::DUPLICATE_UPDATE, + CRM_Import_Parser::DUPLICATE_FILL, + ))) { //validation of related contact subtype for update mode //CRM-5125 $relatedCsType = NULL; @@ -922,12 +927,12 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { if ($valid) { $allRelationships = CRM_Core_PseudoConstant::relationshipType('name'); $relationshipTypeId = str_replace(array( - '_a_b', - '_b_a', - ), array( - '', - '', - ), $key); + '_a_b', + '_b_a', + ), array( + '', + '', + ), $key); $relationshipType = str_replace($relationshipTypeId . '_', '', $key); $orgId = $individualId = NULL; if ($allRelationships[$relationshipTypeId]["name_{$relationshipType}"] == 'Employee of') { @@ -1090,7 +1095,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { * * @return void */ - public function fini() {} + public function fini() { + } /** * Check if an error in custom data @@ -1126,8 +1132,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { self::addToErrorMsg(ts('field ID'), $errorMessage); } // validate null values for required custom fields of type boolean - if (!empty($customFields[$customFieldID]['is_required']) && (empty($params['custom_'.$customFieldID]) && !is_numeric($params['custom_'.$customFieldID])) && $customFields[$customFieldID]['data_type'] == 'Boolean') { - self::addToErrorMsg($customFields[$customFieldID]['label'].'::'.$customFields[$customFieldID]['groupTitle'], $errorMessage); + if (!empty($customFields[$customFieldID]['is_required']) && (empty($params['custom_' . $customFieldID]) && !is_numeric($params['custom_' . $customFieldID])) && $customFields[$customFieldID]['data_type'] == 'Boolean') { + self::addToErrorMsg($customFields[$customFieldID]['label'] . '::' . $customFields[$customFieldID]['groupTitle'], $errorMessage); } //For address custom fields, we do get actual custom field value as an inner array of @@ -1151,7 +1157,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') { if (CRM_Utils_String::strtoboolstr($value) === FALSE) { - self::addToErrorMsg($customFields[$customFieldID]['label'].'::'.$customFields[$customFieldID]['groupTitle'], $errorMessage); + self::addToErrorMsg($customFields[$customFieldID]['label'] . '::' . $customFields[$customFieldID]['groupTitle'], $errorMessage); } } // need not check for label filed import @@ -1173,9 +1179,9 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { // check for values for custom fields for checkboxes and multiselect if ($customFields[$customFieldID]['html_type'] == 'CheckBox' || $customFields[$customFieldID]['html_type'] == 'AdvMulti-Select' || $customFields[$customFieldID]['html_type'] == 'Multi-Select') { - $value = trim($value); - $value = str_replace('|', ',', $value); - $mulValues = explode(',', $value); + $value = trim($value); + $value = str_replace('|', ',', $value); + $mulValues = explode(',', $value); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); foreach ($mulValues as $v1) { if (strlen($v1) == 0) { @@ -1230,10 +1236,10 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $error = TRUE; foreach (array( - $countryNames, - $countryIsoCodes, - $limitCodes, - ) as $values) { + $countryNames, + $countryIsoCodes, + $limitCodes, + ) as $values) { if (in_array(trim($countryValue), $values)) { $error = FALSE; break; @@ -1398,7 +1404,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { foreach ($value as $stateValue) { if ($stateValue['state_province']) { if (self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvinceAbbreviation()) || - self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvince())) { + self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvince()) + ) { continue; } else { @@ -1633,7 +1640,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $newContact = NULL; if (is_null($contactId) && ($onDuplicate != CRM_Import_Parser::DUPLICATE_NOCHECK)) { - $dupeCheck = (bool)($onDuplicate); + $dupeCheck = (bool) ($onDuplicate); } //get the prefix id etc if exists @@ -1739,10 +1746,10 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { continue; } elseif (in_array($key, array( - 'email_greeting', - 'postal_greeting', - 'addressee', - ))) { + 'email_greeting', + 'postal_greeting', + 'addressee', + ))) { // CRM-4575, need to null custom if ($params["{$key}_id"] != 4) { $params["{$key}_custom"] = 'null'; @@ -1864,7 +1871,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { foreach ($params as $key => $val) { $customFieldID = CRM_Core_BAO_CustomField::getKeyID($key); if ($customFieldID && - !array_key_exists($customFieldID, $addressCustomFields)) { + !array_key_exists($customFieldID, $addressCustomFields) + ) { //we should not update Date to null, CRM-4062 if ($val && ($customFields[$customFieldID]['data_type'] == 'Date')) { self::formatCustomDate($params, $formatted, $dateType, $key); @@ -1879,21 +1887,21 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } } - if ($key == 'birth_date' && $val) { - CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key); - } - elseif ($key == 'deceased_date' && $val) { - CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key); - } - elseif ($key == 'is_deceased' && $val) { - $params[$key] = CRM_Utils_String::strtoboolstr($val); - } - elseif ($key == 'gender') { - //CRM-4360 - $params[$key] = $this->checkGender($val); + if ($key == 'birth_date' && $val) { + CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key); + } + elseif ($key == 'deceased_date' && $val) { + CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key); + } + elseif ($key == 'is_deceased' && $val) { + $params[$key] = CRM_Utils_String::strtoboolstr($val); + } + elseif ($key == 'gender') { + //CRM-4360 + $params[$key] = $this->checkGender($val); + } } } - } //now format custom data. foreach ($params as $key => $field) { @@ -1948,57 +1956,61 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { //Handling Custom Data // note: Address custom fields will be handled separately inside _civicrm_api3_deprecated_add_formatted_param if (($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) && - array_key_exists($customFieldID, $customFields) && - !array_key_exists($customFieldID, $addressCustomFields)) { + array_key_exists($customFieldID, $customFields) && + !array_key_exists($customFieldID, $addressCustomFields) + ) { $extends = CRM_Utils_Array::value('extends', $customFields[$customFieldID]); - $htmlType = CRM_Utils_Array::value( 'html_type', $customFields[$customFieldID] ); - switch ( $htmlType ) { - case 'Select': - case 'Radio': - case 'Autocomplete-Select': - if ($customFields[$customFieldID]['data_type'] == 'String') { - $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); - foreach ($customOption as $customFldID => $customValue) { - $val = CRM_Utils_Array::value('value', $customValue); - $label = CRM_Utils_Array::value('label', $customValue); - $label = strtolower($label); - $value = strtolower(trim($formatted[$key])); - if (($value == $label) || ($value == strtolower($val))) { - $params[$key] = $formatted[$key] = $val; + $htmlType = CRM_Utils_Array::value('html_type', $customFields[$customFieldID]); + switch ($htmlType) { + case 'Select': + case 'Radio': + case 'Autocomplete-Select': + if ($customFields[$customFieldID]['data_type'] == 'String') { + $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); + foreach ($customOption as $customFldID => $customValue) { + $val = CRM_Utils_Array::value('value', $customValue); + $label = CRM_Utils_Array::value('label', $customValue); + $label = strtolower($label); + $value = strtolower(trim($formatted[$key])); + if (($value == $label) || ($value == strtolower($val))) { + $params[$key] = $formatted[$key] = $val; + } } } - } - break; - case 'CheckBox': - case 'AdvMulti-Select': - case 'Multi-Select': - - if (!empty($formatted[$key]) && !empty($params[$key])) { - $mulValues = explode( ',', $formatted[$key] ); - $customOption = CRM_Core_BAO_CustomOption::getCustomOption( $customFieldID, true ); - $formatted[$key] = array( ); - $params[$key] = array( ); - foreach ( $mulValues as $v1 ) { - foreach ( $customOption as $v2 ) { - if ( ( strtolower( $v2['label'] ) == strtolower( trim( $v1 ) ) ) || - ( strtolower( $v2['value'] ) == strtolower( trim( $v1 ) ) ) ) { - if ( $htmlType == 'CheckBox' ) { - $params[$key][$v2['value']] = $formatted[$key][$v2['value']] = 1; - } else { - $params[$key][] = $formatted[$key][] = $v2['value']; + break; + case 'CheckBox': + case 'AdvMulti-Select': + case 'Multi-Select': + + if (!empty($formatted[$key]) && !empty($params[$key])) { + $mulValues = explode(',', $formatted[$key]); + $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); + $formatted[$key] = array(); + $params[$key] = array(); + foreach ($mulValues as $v1) { + foreach ($customOption as $v2) { + if ((strtolower($v2['label']) == strtolower(trim($v1))) || + (strtolower($v2['value']) == strtolower(trim($v1))) + ) { + if ($htmlType == 'CheckBox') { + $params[$key][$v2['value']] = $formatted[$key][$v2['value']] = 1; + } + else { + $params[$key][] = $formatted[$key][] = $v2['value']; + } } } } } - } - break; + break; } } } if (($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) && array_key_exists($customFieldID, $customFields) && - !array_key_exists($customFieldID, $addressCustomFields)) { + !array_key_exists($customFieldID, $addressCustomFields) + ) { // @todo calling api functions directly is not supported _civicrm_api3_custom_format_params($params, $formatted, $extends); } @@ -2006,10 +2018,10 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { // to check if not update mode and unset the fields with empty value. if (!$this->_updateWithId && array_key_exists('custom', $formatted)) { foreach ($formatted['custom'] as $customKey => $customvalue) { - if (empty($formatted['custom'][$customKey][- 1]['is_required'])) { + if (empty($formatted['custom'][$customKey][-1]['is_required'])) { $formatted['custom'][$customKey][-1]['is_required'] = $customFields[$customKey]['is_required']; } - $emptyValue = CRM_Utils_Array::value('value', $customvalue[ - 1]); + $emptyValue = CRM_Utils_Array::value('value', $customvalue[-1]); if (!isset($emptyValue)) { unset($formatted['custom'][$customKey]); }