Hi
I'm trying to patch up the getProfilesMatch function in /inc/classes/BxDolPofileFields.php as I'm having a problem with certain sex/lookingfor combinations aren't matching up, specifically, one match who is male and looking for a man or woman doesn't match up with another member who is female and looking for a man or woman when actually these profiles should match because they do if I set the first member to a man looking for a woman!
This is what I have modified it to so far but not sure if I'm barking up the right tree or not?
function getProfilesMatch( $aProf1, $aProf2 ) {
if( !$this -> aArea )
return 0;
$aFields1 = $this -> aBlocks[0]['Items'];
$aFields2 = $this -> aCache[100][0]['Items'];
$iMyPercent = 0;
$iTotalPercent = 0;
foreach( $aFields1 as $aField1 ) {
$aField2 = $aFields2[ $aField1['MatchField'] ];
if( !$aField2 )
continue;
$iTotalPercent += $aField1['MatchPercent'];
$sVal1 = $aProf1[ $aField1['Name'] ];
$sVal2 = $aProf2[ $aField2['Name'] ];
if( !strlen($sVal1) or !strlen($sVal2) )
continue;
$iAddPart = 0;
switch( "{$aField1['Type']} {$aField2['Type']}" ) {
case 'select_set select_one':
if ($aField1['Name']=='Sex' || $aField1['Name']=='LookingFor' || $aField2['Name']=='Sex' || $aField2['Name']=='LookingFor'){
$aVal1 = explode( ',', $sVal1 );
if( in_array( $sVal2, $aVal1 ) )
$iAddPart = 1;
$aVal2 = explode( ',', $sVal2 );
if( in_array( $sVal1, $aVal2 ) )
$iAddPart = 1;
} else {
$aVal1 = explode( ',', $sVal1 );
if( in_array( $sVal2, $aVal1 ) )
$iAddPart = 1;
}
break;
case 'select_one select_set':
if ($aField1['Name']=='Sex' || $aField1['Name']=='LookingFor' || $aField2['Name']=='Sex' || $aField2['Name']=='LookingFor'){
$aVal1 = explode( ',', $sVal1 );
if( in_array( $sVal2, $aVal1 ) )
$iAddPart = 1;
$aVal2 = explode( ',', $sVal2 );
if( in_array( $sVal1, $aVal2 ) )
$iAddPart = 1;
} else {
$aVal2 = explode( ',', $sVal2 );
if( in_array( $sVal1, $aVal2 ) )
$iAddPart = 1;
}
break;
case 'select_set select_set':
$aVal1 = explode( ',', $sVal1 );
$aVal2 = explode( ',', $sVal2 );
$iFound = 0;
foreach( $aVal1 as $sTempVal1 ) {
if( in_array( $sTempVal1, $aVal2 ) )
$iFound ++;
}
$iAddPart = $iFound / count( $aVal1 );
break;
case 'range num':
$aVal1 = explode( ',', $sVal1 );
$sVal2 = (int)$sVal2;
if( (int)$aVal1[0] <= $sVal2 and $sVal2 <= (int)$aVal1[0] )
$iAddPart = 1;
break;
case 'range date':
$aVal1 = explode( ',', $sVal1 );
$aDate = explode( '-', $sVal2 );
$sVal2 = sprintf( '%d/%d/%d', $aDate[2], $aDate[1], $aDate[0] );
$sAge = $this -> getAge( $sVal2 );
if( (int)$aVal1[0] <= $sVal2 and $sVal2 <= (int)$aVal1[0] )
$iAddPart = 1;
break;
default:
if ($aField1['Name']=='Sex' || $aField1['Name']=='LookingFor' || $aField2['Name']=='Sex' || $aField2['Name']=='LookingFor'){
$aVal1 = explode( ',', $sVal1 );
if( in_array( $sVal2, $aVal1 ) )
$iAddPart = 1;
$aVal2 = explode( ',', $sVal2 );
if( in_array( $sVal1, $aVal2 ) )
$iAddPart = 1;
} else {
if( $sVal1 == $sVal2 )
$iAddPart = 1;
}
}
$iMyPercent += round( $aField1['MatchPercent'] * $iAddPart );
}
if( $iTotalPercent != 100 && $iTotalPercent != 0 )
$iMyPercent = (int)( ( $iMyPercent / $iTotalPercent ) * 100 );
return $iMyPercent;
}