| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
*/
class CRM_Dedupe_Merger {
- // FIXME: consider creating a common structure with cidRefs() and eidRefs()
- // FIXME: the sub-pages references by the URLs should
- // be loaded dynamically on the merge form instead
/**
+ * FIXME: consider creating a common structure with cidRefs() and eidRefs()
+ * FIXME: the sub-pages references by the URLs should
+ * be loaded dynamically on the merge form instead
* @return array
*/
public static function relTables() {
* Based on the provided two contact_ids and a set of tables, move the
* belongings of the other contact to the main one.
*
- * @static
*/
public static function moveContactBelongings($mainId, $otherId, $tables = FALSE, $tableOperations = array()) {
$cidRefs = self::cidRefs();
* Contact details.
*
* @return array
- * @static
*/
public static function findDifferences($main, $other) {
$result = array(
* Helps decide how to behave when there are conflicts.
* A 'safe' value skips the merge if there are any un-resolved conflicts.
* Does a force merge otherwise.
- * @param bool $autoFlipWether to let api decide which contact to retain and which to delete.
+ * @param bool $autoFlip to let api decide which contact to retain and which to delete.
* Wether to let api decide which contact to retain and which to delete.
* @param bool $redirectForPerformance
*
* @return array|bool
- * @static
*/
public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $autoFlip = TRUE, $redirectForPerformance = FALSE) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
* Helps decide how to behave when there are conflicts.
* A 'safe' value skips the merge if there are any un-resolved conflicts.
* Does a force merge otherwise (aggressive mode).
- * @param bool $autoFlipWether to let api decide which contact to retain and which to delete.
+ * @param bool $autoFlip to let api decide which contact to retain and which to delete.
* Wether to let api decide which contact to retain and which to delete.
*
*
* @param bool $redirectForPerformance
*
* @return array|bool
- * @static
*/
public static function merge($dupePairs = array(), $cacheParams = array(), $mode = 'safe',
- $autoFlip = TRUE, $redirectForPerformance = FALSE
+ $autoFlip = TRUE, $redirectForPerformance = FALSE
) {
$cacheKeyString = CRM_Utils_Array::value('cache_key_string', $cacheParams);
$resultStats = array('merged' => array(), 'skipped' => array());
* Does a force merge otherwise (aggressive mode).
*
* @return bool
- * @static
*/
public static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe') {
$conflicts = array();
}
elseif ((in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) or
substr($key, 0, 12) == 'move_custom_'
- ) and $val != NULL) {
+ ) and $val != NULL
+ ) {
// Rule: if both main-contact has other-contact, let $mode decide if to merge a
// particular field or not
if (!empty($migrationInfo['rows'][$key]['main'])) {
if ($fieldName == 'address') {
$mainNewLocTypeId = $migrationInfo['location'][$fieldName][$fieldCount]['locTypeId'];
if (!empty($migrationInfo['main_loc_address']) &&
- array_key_exists("main_{$mainNewLocTypeId}", $migrationInfo['main_loc_address'])) {
+ array_key_exists("main_{$mainNewLocTypeId}", $migrationInfo['main_loc_address'])
+ ) {
// main loc already has some address for the loc-type. Its a overwrite situation.
// look for next available loc-type
* Duplicate contact which would be deleted after merge operation.
*
* @return array|bool|int
- * @static
*/
public static function getRowsElementsAndInfo($mainId, $otherId) {
$qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
// Fetch contacts
foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) {
- $params = array('contact_id' => $cid, 'version' => 3, 'return' => array_merge(array('display_name'), self::getContactFields()));
+ $params = array(
+ 'contact_id' => $cid,
+ 'version' => 3,
+ 'return' => array_merge(array('display_name'), self::getContactFields()),
+ );
$result = civicrm_api('contact', 'get', $params);
if (empty($result['values'][$cid]['contact_type'])) {
$specialValues[$moniker]['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR;
}
$names = array(
- 'preferred_communication_method' =>
- array(
+ 'preferred_communication_method' => array(
'newName' => 'preferred_communication_method_display',
'groupName' => 'preferred_communication_method',
),
array(
1 => $block,
2 => $count,
- 3 => $allLocationTypes[$locTypeId]
+ 3 => $allLocationTypes[$locTypeId],
)
);
$js = array('onChange' => "mergeBlock('$name', this, $count );");
}
$elements[] = array(
- 'select', "location[{$name}][$count][locTypeId]", NULL,
- $defaultLocType + $locTypeValues, $js,
+ 'select',
+ "location[{$name}][$count][locTypeId]",
+ NULL,
+ $defaultLocType + $locTypeValues,
+ $js,
);
// keep location-type-id same as that of other-contact
$migrationInfo['location'][$name][$count]['locTypeId'] = $locTypeId;
* @param $migrationInfo
*
* @return bool
- * @static
*/
public static function moveAllBelongings($mainId, $otherId, $migrationInfo) {
if (empty($migrationInfo)) {
$value = '0';
}
if ((in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) ||
- substr($key, 0, 12) == 'move_custom_') &&
+ substr($key, 0, 12) == 'move_custom_') &&
$value != NULL
) {
$submitted[substr($key, 5)] = $value;
//keep state and country as array format.
//for checkbox and m-select format w/ VALUE_SEPARATOR
if (in_array($htmlType, array(
- 'CheckBox', 'Multi-Select', 'AdvMulti-Select'))) {
+ 'CheckBox',
+ 'Multi-Select',
+ 'AdvMulti-Select',
+ ))) {
$submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- $mergeValue
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ $mergeValue
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
}
else {
$submitted[$key] = $mergeValue;
}
}
elseif (in_array($htmlType, array(
- 'Multi-Select Country', 'Multi-Select State/Province'))) {
+ 'Multi-Select Country',
+ 'Multi-Select State/Province',
+ ))) {
//we require submitted values should be in array format
if ($value) {
$mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
if (CRM_Core_DAO::singleValueQuery("
SELECT id
FROM civicrm_entity_file
- WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}")) {
+ WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}")
+ ) {
$sql = "
UPDATE civicrm_entity_file
SET entity_id = {$mainId}
}
/**
- * @return array of field names which will be compared, so everything except ID.
+ * @return array
+ * Array of field names which will be compared, so everything except ID.
*/
public static function getContactFields() {
$contactFields = CRM_Contact_DAO_Contact::fields();
- $invalidFields = array('api_key', 'contact_is_deleted', 'created_date', 'display_name', 'hash', 'id', 'modified_date',
- 'primary_contact_id', 'sort_name', 'user_unique_id');
+ $invalidFields = array(
+ 'api_key',
+ 'contact_is_deleted',
+ 'created_date',
+ 'display_name',
+ 'hash',
+ 'id',
+ 'modified_date',
+ 'primary_contact_id',
+ 'sort_name',
+ 'user_unique_id',
+ );
foreach ($contactFields as $field => $value) {
if (in_array($field, $invalidFields)) {
unset($contactFields[$field]);
/**
* Added for CRM-12695
- * Based on the contactId provided
+ * Based on the contactID provided
* add/update membership(s) to related contacts
*
- * @param contactId
+ * @param int $contactID
*/
public static function addMembershipToRealtedContacts($contactID) {
$dao = new CRM_Member_DAO_Membership();
'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date),
'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date),
'source' => $dao->source,
- 'status_id' => $dao->status_id
+ 'status_id' => $dao->status_id,
);
// create/update membership(s) for related contact(s)
CRM_Member_BAO_Membership::createRelatedMemberships($membershipParams, $dao);
} // end of if relationshipTypeId
}
}
+
}