getAllArray(); unset( $sslf ); //Get primary company data needs to be used when user isn't logged in as well. $clf->getByID( PRIMARY_COMPANY_ID ); if ( $clf->getRecordCount() == 1 ) { $primary_company = $clf->getCurrent(); } } catch ( Exception $e ) { //Database not initialized, or some error, redirect to Install page. throw new DBError( $e, 'DBInitialize' ); } } $permission = new Permission(); $authentication = new Authentication(); if ( isset( $authenticate ) && $authenticate === false ) { Debug::text( 'Bypassing Authentication', __FILE__, __LINE__, __METHOD__, 10 ); TTi18n::chooseBestLocale(); } else { if ( $authentication->Check( null, [ 'USER_NAME', 'USER_NAME_MULTI_FACTOR' ] ) === true ) { $profiler->startTimer( 'Interface.inc - Post-Authentication' ); /* * Get default interface data here. Things like User info, Company info etc... */ $current_user = $authentication->getObject(); Debug::text( 'User Authenticated: ' . $current_user->getUserName() . ' Created Date: ' . $authentication->getCreatedDate(), __FILE__, __LINE__, __METHOD__, 10 ); if ( isset( $primary_company ) && PRIMARY_COMPANY_ID == $current_user->getCompany() ) { $current_company = $primary_company; } else { $current_company = $clf->getByID( $current_user->getCompany() )->getCurrent(); } $current_user_prefs = $current_user->getUserPreferenceObject(); //If user doesnt have any preferences set, we need to bootstrap the preference object. if ( $current_user_prefs->getUser() == '' ) { $current_user_prefs->setUser( $current_user->getId() ); } /* * Check locale cookie, if it varies from UserPreference Language, * change user preferences to match. This could cause some unexpected behavior * as the change is happening behind the scenes, but if we don't change * the user prefs then they could login for weeks/months as a different * language from their preferences, therefore making the user preference * setting almost useless. Causing issues when printing pay stubs and in each * users language. */ Debug::text( 'Locale Cookie: ' . TTi18n::getLocaleCookie(), __FILE__, __LINE__, __METHOD__, 10 ); if ( $current_user_prefs->isNew() == false && TTi18n::getLocaleCookie() != '' && $current_user_prefs->getLanguage() !== TTi18n::getLanguageFromLocale( TTi18n::getLocaleCookie() ) ) { Debug::text( 'Changing User Preference Language to match cookie...', __FILE__, __LINE__, __METHOD__, 10 ); $current_user_prefs->setLanguage( TTi18n::getLanguageFromLocale( TTi18n::getLocaleCookie() ) ); if ( $current_user_prefs->isValid() ) { $current_user_prefs->Save( false ); } } else { Debug::text( 'User Preference Language matches cookie!', __FILE__, __LINE__, __METHOD__, 10 ); } if ( isset( $_GET['language'] ) && $_GET['language'] != '' ) { TTi18n::setLocale( $_GET['language'] ); //Sets master locale } else { TTi18n::setLanguage( $current_user_prefs->getLanguage() ); TTi18n::setCountry( $current_user->getCountry() ); TTi18n::setLocale(); //Sets master locale } //Debug::text('Current Company: '. $current_company->getName(), __FILE__, __LINE__, __METHOD__, 10); $profiler->stopTimer( 'Interface.inc - Post-Authentication' ); } else { Debug::text( 'User NOT Authenticated!', __FILE__, __LINE__, __METHOD__, 10 ); Redirect::Page( URLBuilder::getURL( null, Environment::GetBaseURL() . 'html5/' ) ); //exit; } } unset( $clf ); $profiler->startTimer( 'Main' ); ?>