/** * If a user is logged, get "approximately" the relative age for better and more intuitive search. * * @param object \PH7\UserCoreModel $oUserModel * @param object \PH7\Framework\Session\Session $oSession * @return array 'min_age' and 'max_age' which is the approximately age the user is looking for. */ protected static function getAgeVals(UserCoreModel $oUserModel, Session $oSession) { $iMinAge = (int) DbConfig::getSetting('minAgeRegistration'); $iMaxAge = (int) DbConfig::getSetting('maxAgeRegistration'); if (UserCore::auth()) { $sBirthDate = $oUserModel->getBirthDate($oSession->get('member_id')); $aAge = explode('-', $sBirthDate); $iAge = (new Year($aAge[0], $aAge[1], $aAge[2]))->get(); $iMinAge = $iAge - 5 < $iMinAge ? $iMinAge : $iAge - 5; $iMaxAge = $iAge + 5 > $iMaxAge ? $iMaxAge : $iAge + 5; } return ['min_age' => $iMinAge, 'max_age' => $iMaxAge]; }