function _checkProfileMatch($iProfileId, $sAction)
 {
     $aProfile = getProfileInfo($iProfileId);
     if ($aProfile['Status'] == 'Active' && ($aProfile['UpdateMatch'] || $sAction == 'join')) {
         $oDb = new BxDolDb();
         // clear field "UpdateMatch"
         $oDb->query("UPDATE `Profiles` SET `UpdateMatch` = 0 WHERE `ID`= {$iProfileId}");
         // clear cache
         $oDb->query("DELETE FROM `sys_profiles_match`");
         // get send mails
         $aSendMails = $oDb->getRow("SELECT `profiles_match` FROM `sys_profiles_match_mails` WHERE `profile_id` = {$iProfileId}");
         $aSend = !empty($aSendMails) ? unserialize($aSendMails['profiles_match']) : array();
         $aProfiles = getMatchProfiles($iProfileId);
         foreach ($aProfiles as $iProfId) {
             if (!isset($aSend[(int) $iProfId])) {
                 $oEmailTemplate = new BxDolEmailTemplates();
                 $aMessage = $oEmailTemplate->parseTemplate('t_CupidMail', array('StrID' => $iProfId, 'MatchProfileLink' => getProfileLink($iProfileId)), $iProfId);
                 $aProfile = getProfileInfo($iProfId);
                 if (!empty($aProfile) && $aProfile['Status'] == 'Active') {
                     $oDb->query("INSERT INTO `sys_sbs_queue`(`email`, `subject`, `body`) VALUES('" . $aProfile['Email'] . "', '" . process_db_input($aMessage['subject'], BX_TAGS_NO_ACTION, BX_SLASHES_NO_ACTION) . "', '" . process_db_input($aMessage['body'], BX_TAGS_NO_ACTION, BX_SLASHES_NO_ACTION) . "')");
                 }
                 $aSend[(int) $iProfId] = 0;
             }
         }
         if (empty($aSendMails)) {
             $oDb->query("INSERT INTO `sys_profiles_match_mails`(`profile_id`, `profiles_match`) VALUES({$iProfileId}, '" . serialize($aSend) . "')");
         } else {
             $oDb->query("UPDATE `sys_profiles_match_mails` SET `profiles_match` = '" . serialize($aSend) . "' WHERE `profile_id` = {$iProfileId}");
         }
     }
 }
Exemple #2
0
 function showMatchProfiles($iBlockID)
 {
     $iProfileId = getLoggedId();
     if (!$iProfileId) {
         return array('', MsgBox(_t('_Empty')));
     }
     $sSort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'none';
     $aProfiles = getMatchProfiles($iProfileId, false, $sSort);
     if (empty($aProfiles)) {
         return array('', MsgBox(_t('_Empty')));
     }
     $sBaseUri = 'search.php?show=match';
     $sTopLinksUri = '';
     $sPaginateUri = '';
     foreach ($_REQUEST as $sKey => $sVal) {
         switch ($sKey) {
             case 'page':
                 $sPaginateUri .= '&page=' . $sVal;
                 break;
             case 'per_page':
                 $sPaginateUri .= '&per_page=' . $sVal;
                 break;
             case 'sort':
                 $sPaginateUri .= '&sort=' . $sVal;
                 break;
             case 'mode':
                 $sTopLinksUri .= '&mode=' . $sVal;
                 break;
         }
     }
     $aPaginate = array('page_url' => $sBaseUri . $sTopLinksUri . '&page={page}&per_page={per_page}&sort={sorting}', 'info' => true, 'page_links' => true, 'per_page' => isset($_REQUEST['per_page']) ? (int) $_REQUEST['per_page'] : 25, 'sorting' => $sSort, 'count' => count($aProfiles), 'page' => isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 1);
     $sMode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'simple';
     $oPaginate = new BxDolPaginate($aPaginate);
     $oSearchProfile = new BxBaseSearchProfile();
     $aExtendedCss = array('ext_css_class' => 'search_filled_block');
     $sTemplateName = $sMode == 'extended' ? 'search_profiles_ext.html' : 'search_profiles_sim.html';
     $iIndex = 0;
     $sOutputHtml = '';
     $sOutputMode = isset($_REQUEST['search_result_mode']) && $_REQUEST['search_result_mode'] == 'ext' ? 'ext' : 'sim';
     for ($i = ($aPaginate['page'] - 1) * $aPaginate['per_page']; $i < $aPaginate['page'] * $aPaginate['per_page'] && $i < $aPaginate['count']; $i++) {
         $aProfile = getProfileInfo($aProfiles[$i]);
         if ($aProfile['Couple']) {
             $aCoupleInfo = getProfileInfo($aProfile['Couple']);
             if (!($iIndex % 2)) {
                 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, $aCoupleInfo, null, $sTemplateName);
             } else {
                 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, $aCoupleInfo, $aExtendedCss, $sTemplateName);
             }
         } else {
             if (!($iIndex % 2)) {
                 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, '', null, $sTemplateName);
             } else {
                 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, '', $aExtendedCss, $sTemplateName);
             }
         }
         $iIndex++;
     }
     // gen sorting block ( type of : drop down );
     $sSortBlock = $oPaginate->getSorting(array('none' => _t('_None'), 'activity' => _t('_Latest activity'), 'date_reg' => _t('_FieldCaption_DateReg_View')));
     $sSortBlock = '<div class="ordered_block">' . $sSortBlock . '</div><div class="clear_both"></div>';
     $sContent = $GLOBALS['oSysTemplate']->parseHtmlByName('designbox_top_controls.html', array('top_controls' => $sSortBlock));
     $sContent .= $GLOBALS['oSysTemplate']->parseHtmlByName('view_profiles.html', array('margin_type' => $sOutputMode == 'sim' ? '-thd' : '', 'content' => $sOutputHtml)) . $oPaginate->getPaginate();
     $aLinks = array(_t('_Simple') => array('href' => $sBaseUri . $sPaginateUri . '&mode=simple', 'dynamic' => true, 'active' => $sMode == 'simple'), _t('_Extended') => array('href' => $sBaseUri . $sPaginateUri . '&mode=extended', 'dynamic' => true, 'active' => $sMode == 'extended'));
     return array($aLinks, $sContent);
 }