'; $_page['extra_js'] .= ''; $_page['extra_js'] .= ''; //init datepicker $iMinAge = (int)getParam( 'search_start_age' ); $iMaxAge = (int)getParam( 'search_end_age' ); $iCurYear = (int)date('Y'); $iMinYear = $iCurYear - $iMaxAge - 1; $iMaxYear = $iCurYear - $iMinAge; $iSelectedRel = ceil( $iMinAge * 365.25 ); //get relative days number for default date $sDatepickerInit = $oTemplConfig -> customize['join']['datepickerInit']; $sDatepickerInit = str_replace( '{min_year}', $iMinYear, $sDatepickerInit ); $sDatepickerInit = str_replace( '{max_year}', $iMaxYear, $sDatepickerInit ); $sDatepickerInit = str_replace( '{dfl_days}', $iSelectedRel, $sDatepickerInit ); $_page['extra_js'] .= ' '; check_logged(); $_page['header'] = _t( '_JOIN_H' ); $_page['header_text'] = _t( '_JOIN_H' ); if( $logged['member'] ) { $_page['name_index'] = 0; $_page_cont[0]['page_main_code'] = _t( '_Sorry, you\'re already joined' ); PageCode(); exit; } if ( getParam('reg_by_inv_only') == 'on' && getID($_COOKIE['idFriend'])==0 ) { $_page['name_index'] = 0; $_page_cont[0]['page_main_code'] = MsgBox(_t('registration by invitation only')); PageCode(); exit; } $oJoinProc = new BxDolJoinProcessor(); $_ni = $_page['name_index']; $_page_cont[$_ni]['page_main_code'] = $oJoinProc -> process(); PageCode(); class BxDolJoinProcessor { var $oPF; //profile fields var $iPage; //currently shown page var $aPages; //available pages var $aValues; //inputted values var $aErrors; //errors generated on page var $bAjaxMode; // defines if the script were requested by ajax var $bCoupleEnabled; var $aCoupleMutualItems; var $bCouple; function BxDolJoinProcessor() { $this -> aValues = array( 0 => array(), 1 => array() ); // double arrays (for couples) $this -> aErrors = array( 0 => array(), 1 => array() ); /* @var $this->oPF BxDolProfileFields */ $this -> oPF = new BxDolProfileFields(1); $this -> bAjaxMode = ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ); } function process() { if( !$this -> oPF -> aArea ) return 'Profile Fields cache not loaded. Cannot continue.'; $this -> aPages = array_keys( $this -> oPF -> aArea ); $this -> iPage = ( isset( $_POST['join_page'] ) ) ? $_POST['join_page'] : 0; // get current working page from POST if( $this -> iPage !== 'done' ) $this -> iPage = (int)$this -> iPage; $this -> getCoupleOptions(); $this -> processPostValues(); if( $this -> bAjaxMode ) { $this -> showErrorsJson(); exit; } else { ob_start(); if( $this -> iPage === 'done' ) { //if all pages are finished and no errors found list( $iMemID, $sStatus ) = $this -> registerMember(); if( !$iMemID ) $this -> showFailPage(); else $this -> showFinishPage( $iMemID, $sStatus ); } else $this -> showJoinForm(); return ob_get_clean(); } } function getCoupleOptions() { //find Couple item $aCoupleItem = false; foreach ($this -> aPages as $iPageInd => $iPage) { //cycle pages $aBlocks = $this -> oPF -> aArea[ $iPage ]; foreach ($aBlocks as $iBlockID => $aBlock) { //cycle blocks $aItems = $aBlock['Items']; foreach ($aItems as $iItemID => $aItem) { //cycle items if( $aItem['Name'] == 'Couple' ) { // we found it! $aCoupleItem = $aItem; break; } } if( $aCoupleItem ) // we already found it break; } if( $aCoupleItem ) // we already found it break; } if( $aCoupleItem ) { $this -> bCoupleEnabled = true; $this -> bCouple = ( isset( $_REQUEST['Couple'] ) and $_REQUEST['Couple'] == 'yes' ) ? true : false; } else { $this -> bCoupleEnabled = false; $this -> bCouple = false; } $this -> aCoupleMutualItems = $this -> oPF -> getCoupleMutualFields(); } function processPostValues() { foreach ($this -> aPages as $iPage) { //cycle pages if( $this -> iPage !== 'done' and $iPage >= $this -> iPage ) { $this -> iPage = $iPage; // we are on the current page. dont process these values, dont go further, just show form. break; } // process post values by Profile Fields class $this -> oPF -> processPostValues( $this -> bCouple, $this -> aValues, $this ->aErrors, $iPage ); if( !empty( $this -> aErrors[0] ) or ( $this -> bCouple and !empty( $this -> aErrors[1] ) ) ) { //we found errors on previous page // do not process further values, just go to erroneous page. $this -> iPage = $iPage; break; } } } function showErrorsJson() { header('Content-Type:text/javascript'); echo $this -> oPF -> genJsonErrors( $this -> aErrors, $this -> bCouple ); } function showJoinForm() { //echoDbg( $this -> aValues );exit; $aFormAttrs = array( 'id' => 'join_form', 'onsubmit' => 'return validateJoinForm(this);' ); $aTableAttrs = array( 'id' => 'join_form_table' ); $aFormParams = array( 'hidden' => $this -> genHiddenFieldsArray() ); $aTableParams = array( 'double' => $this ->bCoupleEnabled, 'second_enabled' => $this -> bCouple ); $aTableParams['headers'] = array( '', _t( '_First Person' ), _t( '_Second Person' ) ); $aTableParams['headers_add'] = 'class="header form_second_col"' . ( $this -> bCouple ? '' : ' style="display: none;"' ); $aButtons = array( array( 'type' => 'submit', 'value' => _t( '_Submit' ), 'class' => 'input_submit' ) ); /* @var $oForm BxTemplFormView */ $oForm = new BxTemplFormView( 'join_form' ); $oForm -> begin( $aFormAttrs, $aTableAttrs, $aFormParams, $aTableParams ); $aBlocks = $this -> oPF -> aArea[ $this -> iPage ]; foreach( $aBlocks as $aBlock ) { $oForm -> beginBlock( _t( $aBlock['Caption'] ) ); foreach( $aBlock['Items'] as $aItem ) { $aCol0 = array(); $aCol0['Type'] = $aItem['Type']; $aCol0['Name'] = ( $aItem['Type'] == 'system' ) ? $aItem['Name'] : ( $aItem['Name'] . '[0]' ); $aCol0['Mandatory'] = $aItem['Mandatory']; $aCol0['Control'] = $aItem['Control']; $aCol0['Values'] = $aItem['Values']; $aCol0['UseLKey'] = $aItem['UseLKey']; $aCol0['Caption'] = _t( $aItem['Caption'] ); $aCol0['Desc'] = _t( $aItem['Desc'], $aItem['Min'], $aItem['Max'] ); if( $aCol0['Desc'] == $aItem['Desc'] ) $aCol0['Desc'] = ''; // set value if( isset( $this -> aValues[0][ $aItem['Name'] ] ) ) $aCol0['Value'] = $this -> aValues[0][ $aItem['Name'] ]; elseif ( $aItem['Name'] == 'Couple' ) $aCol0['Value'] = $this -> bCouple; // set error if( isset( $this -> aErrors[0][ $aItem['Name'] ] ) ) $aCol0['Error'] = $this -> aErrors[0][ $aItem['Name'] ]; // check second person's field if( $this -> bCoupleEnabled and !in_array( $aItem['Name'], $this -> aCoupleMutualItems ) ) { $aCol1 = array(); $aCol1['Type'] = $aItem['Type']; $aCol1['Name'] = $aItem['Name'] . '[1]'; $aCol1['Control'] = $aItem['Control']; $aCol1['Values'] = $aItem['Values']; $aCol1['UseLKey'] = $aItem['UseLKey']; // set value if( isset( $this -> aValues[1][ $aItem['Name'] ] ) ) $aCol1['Value'] = $this -> aValues[1][ $aItem['Name'] ]; // set error if( isset( $this -> aErrors[1][ $aItem['Name'] ] ) ) $aCol1['Error'] = $this -> aValues[1][ $aItem['Name'] ]; $oForm -> addRow( $aCol0, $aCol1 ); } else $oForm -> addRow( $aCol0 ); } $oForm -> endBlock(); } $oForm -> end( $aButtons ); echo $oForm -> getCode(); //boonex id /* if( getParam( 'enable_get_boonex_id' ) ) { global $tmpl; echo "