Go to the documentation of this file.
8 require_once(CH_DIRECTORY_PATH_CLASSES .
'ChWsbProfileFields.php');
14 return $oDb->fromCache(
'sys_profile_match_fields',
'getAllWithKey',
15 'SELECT `ID`, `Name`, `MatchField`, `MatchPercent`, `Type` FROM `sys_profile_fields` WHERE `MatchPercent` > 0',
33 $aMatch =
$oDb->getRow(
"SELECT `profiles_match` FROM `sys_profiles_match` WHERE `profile_id` = ? AND `sort` = ?",
35 if (!
empty($aMatch)) {
36 return unserialize($aMatch[
'profiles_match']);
39 $oDb->query(
"DELETE FROM `sys_profiles_match` WHERE `profile_id` = $iProfileId");
49 $iAge = (int)
$oDb->getOne(
"SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), '{$aProf['DateOfBirth']}')), '%Y') + 0 AS age");
53 $aMathFields[$sKey][
'profiles'] = array();
55 if ($aProf[
$aFields[
'Name']] && $aMathFields[
$aFields[
'MatchField']][
'Name']) {
56 if ($aMathFields[
$aFields[
'MatchField']][
'Name'] ==
'DateOfBirth') {
58 $sCond =
"(DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), `DateOfBirth`)), '%Y') + 0) = $iAge";
60 } elseif ($aMathFields[
$aFields[
'MatchField']][
'Type'] ==
'select_set' &&
$aFields[
'Type'] !=
'select_set') {
63 } elseif ($aMathFields[
$aFields[
'MatchField']][
'Type'] !=
'select_set' &&
$aFields[
'Type'] ==
'select_set') {
64 $sCond =
"FIND_IN_SET(`{$aMathFields[$aFields['MatchField']]['Name']}`, '" .
process_db_input($aProf[
$aFields[
'Name']],
66 } elseif ($aMathFields[
$aFields[
'MatchField']][
'Type'] ==
'select_set' &&
$aFields[
'Type'] ==
'select_set') {
67 $a = explode(
',', $aProf[
$aFields[
'Name']]);
70 foreach ($a
as $sVal) {
74 $sCond = rtrim($sCond,
' OR');
77 } elseif ($aMathFields[
$aFields[
'MatchField']][
'Name']) {
82 $aMathFields[$sKey][
'profiles'] =
$oDb->getAllWithKey(
"SELECT `ID` FROM `Profiles` WHERE `Status` = 'Active' AND `ID` != ? AND $sCond",
89 if (
$sSort ==
'activity') {
90 $sCondSort =
'ORDER BY `DateLastNav` DESC';
92 if (
$sSort ==
'date_reg') {
93 $sCondSort =
'ORDER BY `DateReg` DESC';
97 $iPercentThreshold =
getParam(
'match_percent');
98 $aProfiles =
$oDb->getColumn(
"SELECT `ID` FROM `Profiles` WHERE `Status` = 'Active' AND `ID` != $iProfileId $sCondSort");
104 $iPercent += (int)
$aFields[
'MatchPercent'];
108 if ($iPercent >= $iPercentThreshold) {
113 $oDb->query(
"INSERT INTO `sys_profiles_match`(`profile_id`, `sort`, `profiles_match`) VALUES(?, ?, ?)", [
128 $iPID1 = (int)$iPID1;
129 $iPID2 = (int)$iPID2;
131 if (!$iPID1
or !$iPID2) {
135 if ($iPID1 == $iPID2) {
152 if ($aMathFields[
$aFields[
'MatchField']][
'Name'] ==
'DateOfBirth') {
153 $bRes =
age($aProf1[
'DateOfBirth']) ==
age($aProf2[
'DateOfBirth']);
154 } elseif ($aMathFields[
$aFields[
'MatchField']][
'Type'] ==
'select_set' ||
$aFields[
'Type'] ==
'select_set') {
155 $a1 = explode(
',', $aProf1[
$aFields[
'Name']]);
156 $a2 = explode(
',', $aProf2[$aMathFields[
$aFields[
'MatchField']][
'Name']]);
157 $bRes = array_intersect($a1, $a2);
159 $bRes = $aProf1[
$aFields[
'Name']] == $aProf2[$aMathFields[
$aFields[
'MatchField']][
'Name']];
164 $iMatch += (int)
$aFields[
'MatchPercent'];
process_db_input($sText, $iStripTags=0)
getProfilesMatch($iPID1=0, $iPID2=0)
const CH_SLASHES_NO_ACTION
getParam($sParamName, $bUseCache=true)
getMatchProfiles($iProfileId, $bForce=false, $sSort='none')
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Attr AllowedRel this is empty
if( $sMembersList) $iProfileId
Voluntary License Schemes The Licensor waives the right to collect whether individually or