function postInstall() { global $cache; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); $cjlf = new CronJobListFactory(); $cjlf->getAll(); if ($cjlf->getRecordCount() > 0) { foreach ($cjlf as $cj_obj) { Debug::text('Original Command: ' . $cj_obj->getCommand(), __FILE__, __LINE__, __METHOD__, 9); $retval = preg_match('/([A-Za-z0-9]+\\.php)/i', $cj_obj->getCommand(), $matches); if (isset($matches[0]) and $matches[0] != '') { Debug::text('New Command: ' . $matches[0], __FILE__, __LINE__, __METHOD__, 9); $cj_obj->setCommand($matches[0]); if ($cj_obj->isValid()) { $cj_obj->Save(); } } } } return TRUE; }
unset($sslf); //Handle station functionality 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); } } //Debug::Arr($current_station, 'Current Station Object: ', __FILE__, __LINE__, __METHOD__, 10); //Debug::text('Current Company: '. $current_company->getName(), __FILE__, __LINE__, __METHOD__, 10); //Make sure CronJobs are running correctly. $cjlf = new CronJobListFactory(); $cjlf->getMostRecentlyRun(); if ($cjlf->getRecordCount() > 0) { //Is last run job more then 48hrs old? $cj_obj = $cjlf->getCurrent(); if (PRODUCTION == TRUE and DEMO_MODE == FALSE and $cj_obj->getLastRunDate() < time() - 172800 and $cj_obj->getCreatedDate() < time() - 172800) { $cron_out_of_date = 1; } else { $cron_out_of_date = 0; } } unset($cjlf, $cj_obj); } else { Debug::text('User NOT! Authenticated', __FILE__, __LINE__, __METHOD__, 10); if (isset($enable_wap) and $enable_wap == TRUE) { Redirect::Page(URLBuilder::getURL(NULL, Environment::GetBaseURL() . 'wap/wap_login.php'));
/** * Returns array of notifications message to be displayed to the user. * @param string $action Action that is being performed, possible values: 'login', 'preference', 'notification', 'pay_period' * @return array */ function getNotifications($action = FALSE) { global $config_vars, $disable_database_connection; $retarr = FALSE; //Skip this step if disable_database_connection is enabled or the user is going through the installer still switch (strtolower($action)) { case 'login': 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. $sslf = new SystemSettingListFactory(); $system_settings = $sslf->getAllArray(); } unset($sslf); //Check license validity if ((DEPLOYMENT_ON_DEMAND == FALSE and $this->getCurrentCompanyObject()->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $this->getCurrentCompanyObject()->getId() == $config_vars['other']['primary_company_id']) and getTTProductEdition() > 10) { if (!isset($system_settings['license'])) { $system_settings['license'] = NULL; } $license = new TTLicense(); $license_validate = $license->validateLicense($system_settings['license']); $license_message = $license->getFullErrorMessage($license_validate, TRUE); if ($license_message != '') { $destination_url = 'http://www.timetrex.com/r.php?id=899'; if ($license_validate === TRUE) { //License likely expires soon. $retarr[] = array('delay' => 0, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('WARNING: %1', $license_message), 'destination' => $destination_url); } else { //License error. $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1', $license_message), 'destination' => $destination_url); } } unset($license, $license_validate, $license_message, $destination); } //System Requirements not being met. if (isset($system_settings['valid_install_requirements']) and DEPLOYMENT_ON_DEMAND == FALSE and (int) $system_settings['valid_install_requirements'] == 0) { $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1 system requirement check has failed! Please contact your %1 administrator immediately to re-run the %1 installer to correct the issue.', APPLICATION_NAME), 'destination' => NULL); } //Check version mismatch if (isset($system_settings['system_version']) and DEPLOYMENT_ON_DEMAND == FALSE and APPLICATION_VERSION != $system_settings['system_version']) { $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1 application version does not match database version. Please re-run the %1 installer to complete the upgrade process.', APPLICATION_NAME), 'destination' => NULL); } //Only display message to the primary company. if (time() - (int) APPLICATION_VERSION_DATE > 86400 * 475 and ($this->getCurrentCompanyObject()->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $this->getCurrentCompanyObject()->getId() == $config_vars['other']['primary_company_id'])) { //~1yr and 3mths $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: This %1 version (v%2) is severely out of date and may no longer be supported. Please upgrade to the latest version as soon as possible as invalid calculations may already be occurring.', array(APPLICATION_NAME, APPLICATION_VERSION)), 'destination' => NULL); } //New version available notification. if (DEMO_MODE == FALSE and (isset($system_settings['new_version']) and $system_settings['new_version'] == 1) and ($this->getCurrentCompanyObject()->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $this->getCurrentCompanyObject()->getId() == $config_vars['other']['primary_company_id'])) { //Only display this every two weeks. $new_version_available_notification_arr = UserSettingFactory::getUserSetting($this->getCurrentUserObject()->getID(), 'new_version_available_notification'); if (!isset($new_version_available_notification_arr['value']) or isset($new_version_available_notification_arr['value']) and $new_version_available_notification_arr['value'] <= time() - 86400 * 14) { UserSettingFactory::setUserSetting($this->getCurrentUserObject()->getID(), 'new_version_available_notification', time()); $retarr[] = array('delay' => -1, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('NOTICE: A new version of %1 available, it is highly recommended that you upgrade as soon as possible. Click here to download the latest version.', array(APPLICATION_NAME)), 'destination' => getTTProductEdition() == TT_PRODUCT_COMMUNITY ? 'http://www.timetrex.com/r.php?id=19' : 'http://www.timetrex.com/r.php?id=9'); } unset($new_version_available_notification); } //Check for major new version. $new_version_notification_arr = UserSettingFactory::getUserSetting($this->getCurrentUserObject()->getID(), 'new_version_notification'); if (DEMO_MODE == FALSE and (!isset($config_vars['branding']['application_name']) or ($this->getCurrentCompanyObject()->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $this->getCurrentCompanyObject()->getId() == $config_vars['other']['primary_company_id'])) and $this->getPermissionObject()->getLevel() >= 20 and $this->getCurrentUserObject()->getCreatedDate() <= APPLICATION_VERSION_DATE and (!isset($new_version_notification_arr['value']) or isset($new_version_notification_arr['value']) and Misc::MajorVersionCompare(APPLICATION_VERSION, $new_version_notification_arr['value'], '>'))) { UserSettingFactory::setUserSetting($this->getCurrentUserObject()->getID(), 'new_version_notification', APPLICATION_VERSION); $retarr[] = array('delay' => -1, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('NOTICE: Your instance of %1 has been upgraded to v%2, click here to see whats new.', array(APPLICATION_NAME, APPLICATION_VERSION)), 'destination' => 'http://www.timetrex.com/r.php?id=300'); } unset($new_version_notification); //Check installer enabled. if (isset($config_vars['other']['installer_enabled']) and $config_vars['other']['installer_enabled'] == 1) { $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1 is currently in INSTALL MODE. Please go to your timetrex.ini.php file and set "installer_enabled" to "FALSE".', APPLICATION_NAME), 'destination' => NULL); } //Make sure CronJobs are running correctly. $cjlf = new CronJobListFactory(); $cjlf->getMostRecentlyRun(); if ($cjlf->getRecordCount() > 0) { //Is last run job more then 48hrs old? $cj_obj = $cjlf->getCurrent(); if (PRODUCTION == TRUE and DEMO_MODE == FALSE and $cj_obj->getLastRunDate() < time() - 172800 and $cj_obj->getCreatedDate() < time() - 172800) { $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: Critical maintenance jobs have not run in the last 48hours. Please contact your %1 administrator immediately.', APPLICATION_NAME), 'destination' => NULL); } } unset($cjlf, $cj_obj); //Check if any pay periods are past their transaction date and not closed. if (DEMO_MODE == FALSE and $this->getPermissionObject()->Check('pay_period_schedule', 'enabled') and $this->getPermissionObject()->Check('pay_period_schedule', 'view')) { $pplf = TTnew('PayPeriodListFactory'); $pplf->getByCompanyIdAndStatusAndTransactionDate($this->getCurrentCompanyObject()->getId(), array(10, 30), TTDate::getBeginDayEpoch(time())); //Open or Post Adjustment pay periods. if ($pplf->getRecordCount() > 0) { foreach ($pplf as $pp_obj) { if ($pp_obj->getCreatedDate() < time() - 86400 * 40) { //Ignore pay period schedules newer than 40 days. They are automatically closed after 45 days. $retarr[] = array('delay' => 0, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: Pay periods past their transaction date have not been closed yet. It\'s critical that these pay periods are closed to prevent data loss, click here to close them now.'), 'destination' => array('menu_name' => 'Pay Periods')); break; } } } unset($pplf, $pp_obj); } //CHeck for unread messages $mclf = new MessageControlListFactory(); $unread_messages = $mclf->getNewMessagesByCompanyIdAndUserId($this->getCurrentCompanyObject()->getId(), $this->getCurrentUserObject()->getId()); Debug::text('UnRead Messages: ' . $unread_messages, __FILE__, __LINE__, __METHOD__, 10); if ($unread_messages > 0) { $retarr[] = array('delay' => 25, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('NOTICE: You have %1 new message(s) waiting, click here to read them now.', $unread_messages), 'destination' => array('menu_name' => 'Messages')); } unset($mclf, $unread_messages); if (DEMO_MODE == FALSE) { $elf = new ExceptionListFactory(); $elf->getFlaggedExceptionsByUserIdAndPayPeriodStatus($this->getCurrentUserObject()->getId(), 10); $display_exception_flag = FALSE; if ($elf->getRecordCount() > 0) { foreach ($elf as $e_obj) { if ($e_obj->getColumn('severity_id') == 30) { $display_exception_flag = 'red'; } break; } } if (isset($display_exception_flag) and $display_exception_flag !== FALSE) { Debug::Text('Exception Flag to Display: ' . $display_exception_flag, __FILE__, __LINE__, __METHOD__, 10); $retarr[] = array('delay' => 30, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('NOTICE: You have critical severity exceptions pending, click here to view them now.'), 'destination' => array('menu_name' => 'Exceptions')); } unset($elf, $e_obj, $display_exception_flag); } if (DEMO_MODE == FALSE and $this->getPermissionObject()->getLevel() >= 20 and ($this->getCurrentUserObject()->getWorkEmail() == '' and $this->getCurrentUserObject()->getHomeEmail() == '')) { $retarr[] = array('delay' => 30, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: Please click here and enter an email address for your account, this is required to receive important notices and prevent your account from being locked out.'), 'destination' => array('menu_name' => 'Contact Information')); } break; default: break; } //Check timezone is proper. $current_user_prefs = $this->getCurrentUserObject()->getUserPreferenceObject(); if ($current_user_prefs->setDateTimePreferences() == FALSE) { //Setting timezone failed, alert user to this fact. //WARNING: %1 was unable to set your time zone. Please contact your %1 administrator immediately.{/t} {if $permission->Check('company','enabled') AND $permission->Check('company','edit_own')}<a href="http://forums.timetrex.com/viewtopic.php?t=40">{t}For more information please click here.{/t}</a>{/if} if ($this->getPermissionObject()->Check('company', 'enabled') and $this->getPermissionObject()->Check('company', 'edit_own')) { $destination_url = 'http://www.timetrex.com/r.php?id=1010'; $sub_message = TTi18n::getText('For more information please click here.'); } else { $destination_url = NULL; $sub_message = NULL; } $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1 was unable to set your time zone. Please contact your %1 administrator immediately.', APPLICATION_NAME) . ' ' . $sub_message, 'destination' => $destination_url); unset($destination_url, $sub_message); } return $retarr; }
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php'; //Debug::setVerbosity(5); $execution_time = time(); $clf = new CompanyListFactory(); $clf->getAll(); $x = 0; if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() != 30) { $company_start_time = microtime(TRUE); Debug::text('Company: ' . $c_obj->getName() . '(' . $c_obj->getId() . ')', __FILE__, __LINE__, __METHOD__, 5); //Recalculate at least the last two days. $start_date = TTDate::getMiddleDayEpoch($execution_time) - 86400 * 2; $end_date = TTDate::getMiddleDayEpoch(time()) - 86400; //Get the last time cron ran this script. $cjlf = new CronJobListFactory(); $cjlf->getByName('calcExceptions'); if ($cjlf->getRecordCount() > 0) { foreach ($cjlf as $cj_obj) { $tmp_start_date = $cj_obj->getLastRunDate(); if ($tmp_start_date < $start_date) { $start_date = $tmp_start_date; Debug::text(' CRON Job hasnt run in more then 48hrs, reducing Start Date to: ' . TTDate::getDate('DATE+TIME', $start_date), __FILE__, __LINE__, __METHOD__, 5); } } } unset($cjlf, $cj_obj, $tmp_start_date); //Get maximum shift time for each pay period schedule, so we know how far back //we have to recalculate days at the minimum. $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByCompanyId($c_obj->getId());
* */ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php'; if (isset($config_vars['other']['installer_enabled']) and $config_vars['other']['installer_enabled'] == TRUE) { Debug::text('CRON: Installer is enabled, skipping cron jobs for now...', __FILE__, __LINE__, __METHOD__, 0); } else { //$current_epoch = strtotime('28-Mar-08 1:30 PM'); $current_epoch = TTDate::getTime(); $executed_jobs = 0; $cjlf = new CronJobListFactory(); $job_arr = $cjlf->getArrayByListFactory($cjlf->getAll()); $total_jobs = count($job_arr); foreach ($job_arr as $job_id => $job_name) { //Get each cronjob row again individually incase the status has changed. $cjlf = new CronJobListFactory(); $cjlf->getById($job_id); //Let Execute determine if job is running or not so it can find orphans. if ($cjlf->getRecordCount() > 0) { foreach ($cjlf as $cjf_obj) { //Debug::text('Checking if Job ID: '. $job_id .' is scheduled to run...', __FILE__, __LINE__, __METHOD__, 0); if ($cjf_obj->isScheduledToRun($current_epoch) == TRUE) { $executed_jobs++; $cjf_obj->Execute($config_vars['path']['php_cli'], dirname(__FILE__)); } } } } echo "NOTE: Jobs are scheduled to run at specific times each day, therefore it is normal for only some jobs to be executed each time this file is run.\n"; echo "Jobs Executed: {$executed_jobs} of {$total_jobs}\n"; Debug::text('CRON: Jobs Executed: ' . $executed_jobs . ' of ' . $total_jobs, __FILE__, __LINE__, __METHOD__, 0);