function setCompany($id) { $id = trim($id); $clf = new CompanyListFactory(); if ($this->Validator->isResultSetWithRows('company', $clf->getByID($id), TTi18n::gettext('Company is invalid'))) { $this->data['company_id'] = $id; return TRUE; } return FALSE; }
} else { //Increase timeout on WAP devices, so they don't have to login as often. if (isset($enable_wap) and $enable_wap == TRUE) { $authentication->setIdle(32400); //9hrs } elseif (isset($config_vars['other']['web_session_timeout']) and $config_vars['other']['web_session_timeout'] != '') { $authentication->setIdle((int) $config_vars['other']['web_session_timeout']); } if ($authentication->Check() === TRUE) { /* * 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); $clf = new CompanyListFactory(); $current_company = $clf->getByID($current_user->getCompany())->getCurrent(); unset($clf); //Check to make sure the logged in user's information is all up to date. //Make sure they also have permissions to edit information, otherwise don't redirect them. if ($current_user->isInformationComplete() == FALSE and (!stristr($_SERVER['SCRIPT_NAME'], 'permissiondenied') and !stristr($_SERVER['SCRIPT_NAME'], 'logout') and !stristr($_SERVER['SCRIPT_NAME'], 'about') and !stristr($_SERVER['SCRIPT_NAME'], 'punch.php') and !stristr($_SERVER['SCRIPT_NAME'], 'ajax_server') and !stristr($_SERVER['SCRIPT_NAME'], 'global.js') and !stristr($_SERVER['SCRIPT_NAME'], 'menu.js') and !stristr($_SERVER['SCRIPT_NAME'], 'embeddeddocument')) and !isset($_GET['incomplete']) and !isset($_POST['incomplete']) and ($permission->Check('user', 'enabled') and ($permission->Check('user', 'edit') or $permission->Check('user', 'edit_own') or $permission->Check('user', 'edit_child')))) { Redirect::Page(URLBuilder::getURL(array('id' => $current_user->getID(), 'incomplete' => 1), Environment::GetBaseURL() . 'users/EditUser.php')); } $db_time_zone_error = FALSE; $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()); } if ($current_user_prefs->setDateTimePreferences() == FALSE) { //Setting timezone failed, alert user to this fact. $db_time_zone_error = TRUE;
function getCompanyObject() { $clf = new CompanyListFactory(); $current_company = $clf->getByID($this->getUserObject()->getCompany())->getCurrent(); return $current_company; }
/** * Get about data . * */ function getAboutData($ytd = 0, $all_companies = FALSE) { global $config_vars; $clf = new CompanyListFactory(); $sslf = new SystemSettingListFactory(); $system_settings = $sslf->getAllArray(); $clf->getByID(PRIMARY_COMPANY_ID); if ($clf->getRecordCount() == 1) { $primary_company = $clf->getCurrent(); } $current_user = $this->getCurrentUserObject(); if (isset($primary_company) and 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(); $data = $system_settings; if (isset($data['new_version']) and $data['new_version'] == TRUE) { $data['new_version'] = TRUE; } else { $data['new_version'] = FALSE; } $data['product_edition'] = Option::getByKey(DEPLOYMENT_ON_DEMAND == TRUE ? $current_company->getProductEdition() : getTTProductEdition(), $current_company->getOptions('product_edition')); $data['application_name'] = APPLICATION_NAME; $data['organization_url'] = ORGANIZATION_URL; //Get Employee counts for this month, and last month $month_of_year_arr = TTDate::getMonthOfYearArray(); //This month if (isset($ytd) and $ytd == 1) { $begin_month_epoch = strtotime('-2 years'); } else { $begin_month_epoch = TTDate::getBeginMonthEpoch(TTDate::getBeginMonthEpoch(time()) - 86400); } $cuclf = TTnew('CompanyUserCountListFactory'); if (isset($config_vars['other']['primary_company_id']) and $current_company->getId() == $config_vars['other']['primary_company_id'] and $all_companies == TRUE) { $cuclf->getTotalMonthlyMinAvgMaxByCompanyStatusAndStartDateAndEndDate(10, $begin_month_epoch, TTDate::getEndMonthEpoch(time()), NULL, NULL, NULL, array('date_stamp' => 'desc')); } else { $cuclf->getMonthlyMinAvgMaxByCompanyIdAndStartDateAndEndDate($current_company->getId(), $begin_month_epoch, TTDate::getEndMonthEpoch(time()), NULL, NULL, NULL, array('date_stamp' => 'desc')); } Debug::Text('Company User Count Rows: ' . $cuclf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($cuclf->getRecordCount() > 0) { foreach ($cuclf as $cuc_obj) { $data['user_counts'][] = array('label' => $month_of_year_arr[TTDate::getMonth(TTDate::strtotime($cuc_obj->getColumn('date_stamp')))] . ' ' . TTDate::getYear(TTDate::strtotime($cuc_obj->getColumn('date_stamp'))), 'max_active_users' => $cuc_obj->getColumn('max_active_users'), 'max_inactive_users' => $cuc_obj->getColumn('max_inactive_users'), 'max_deleted_users' => $cuc_obj->getColumn('max_deleted_users')); } } if (isset($data['user_counts']) == FALSE) { $data['user_counts'] = array(); } $cjlf = TTnew('CronJobListFactory'); $cjlf->getMostRecentlyRun(); if ($cjlf->getRecordCount() > 0) { $cj_obj = $cjlf->getCurrent(); $data['cron'] = array('last_run_date' => $cj_obj->getLastRunDate() == FALSE ? TTi18n::getText('Never') : TTDate::getDate('DATE+TIME', $cj_obj->getLastRunDate())); } $data['show_license_data'] = FALSE; if ((DEPLOYMENT_ON_DEMAND == FALSE and $current_company->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $current_company->getId() == $config_vars['other']['primary_company_id']) and getTTProductEdition() > 10) { if (!isset($system_settings['license'])) { $system_settings['license'] = NULL; } $data['show_license_data'] = TRUE; //Set this so the license upload area at least shows up regardles of edition. $data['license_data'] = array(); $license = new TTLicense(); $retval = $license->validateLicense($system_settings['license']); if ($retval == TRUE) { $data['license_data'] = array('organization_name' => $license->getOrganizationName(), 'major_version' => $license->getMajorVersion(), 'minor_version' => $license->getMinorVersion(), 'product_name' => $license->getProductName(), 'active_employee_licenses' => $license->getActiveEmployeeLicenses(), 'issue_date' => TTDate::getDate('DATE', $license->getIssueDate()), 'expire_date' => $license->getExpireDate(), 'expire_date_display' => TTDate::getDate('DATE', $license->getExpireDate()), 'registration_key' => $license->getRegistrationKey(), 'message' => $license->getFullErrorMessage($retval), 'retval' => $retval); } } //Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__,10); return $this->returnHandler($data); }
$validator = new Validator(); $action = Misc::findSubmitButton(); switch ($action) { case 'submit': //Debug::setVerbosity( 11 ); Debug::Text('User Name: ' . $user_name, __FILE__, __LINE__, __METHOD__, 10); if ($authentication->Login($user_name, $password)) { $authentication->Check(); Debug::text('Login Language: ' . $language, __FILE__, __LINE__, __METHOD__, 10); TTi18n::setCountry(TTi18n::getCountryFromLocale()); TTi18n::setLanguage($language); TTi18n::setLocale(); TTi18n::setLocaleCookie(); Debug::text('Locale: ' . TTi18n::getLocale(), __FILE__, __LINE__, __METHOD__, 10); $clf = new CompanyListFactory(); $clf->getByID($authentication->getObject()->getCompany()); $current_company = $clf->getCurrent(); unset($clf); $create_new_station = FALSE; //If this is a new station, insert it now. if (isset($_COOKIE['StationID'])) { Debug::text('Station ID Cookie found! ' . $_COOKIE['StationID'], __FILE__, __LINE__, __METHOD__, 10); $slf = new StationListFactory(); $slf->getByStationIdandCompanyId($_COOKIE['StationID'], $current_company->getId()); $current_station = $slf->getCurrent(); unset($slf); if ($current_station->isNew()) { Debug::text('Station ID is NOT IN DB!! ' . $_COOKIE['StationID'], __FILE__, __LINE__, __METHOD__, 10); $create_new_station = TRUE; } } else {
header('Pragma: public'); } //Do not overwrite a previously sent content-type header, this breaks WAP. if (!isset($enable_wap)) { header('Content-Type: text/html; charset=UTF-8'); } //Skip this step if disable_database_connection is enabled or the user is going through the installer still $clf = new CompanyListFactory(); if ((!isset($disable_database_connection) or isset($disable_database_connection) and $disable_database_connection != TRUE) and (!isset($config_vars['other']['installer_enabled']) or isset($config_vars['other']['installer_enabled']) and $config_vars['other']['installer_enabled'] != TRUE)) { //Get all system settings, so they can be used even if the user isn't logged in, such as the login page. try { $sslf = new SystemSettingListFactory(); $system_settings = $sslf->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) and $authenticate === FALSE) { Debug::text('Bypassing Authentication', __FILE__, __LINE__, __METHOD__, 10); TTi18n::chooseBestLocale(); } else { //Increase timeout on WAP devices, so they don't have to login as often.