DesComm Posted September 14, 2016 Report Share Posted September 14, 2016 We have inactive set to 45 days. However it does not place members inactive, even though some have not filed a priep is over 90 days. This is our current settings in the local.config After how long to mark a pilot inactive, in days Config::Set('PILOT_AUTO_RETIRE', true); Config::Set('PILOT_INACTIVE_TIME', 45); Quote Link to comment Share on other sites More sharing options...
web541 Posted September 14, 2016 Report Share Posted September 14, 2016 (edited) This happened to me a while back and decided to dig deeper into the code. I have this working: Go into core/common/PilotData.class.php and find the function findRetiredPilots() and replace it with this one (back it up first) /** * Find and set any pilots as retired * * @return mixed This is the return value description * */ public static function findRetiredPilots() { $days = Config::Get('PILOT_INACTIVE_TIME'); if ($days == '') { $days = 90; } $sql = "SELECT * FROM ".TABLE_PREFIX."pilots WHERE DATE_SUB(CURDATE(), INTERVAL {$days} DAY) > `joindate` AND `totalflights` = 0 AND `retired` = '0' "; $results = DB::get_results($sql); $sql1 = "SELECT * FROM ".TABLE_PREFIX."pilots WHERE DATE_SUB(CURDATE(), INTERVAL {$days} DAY) > `lastpirep` AND `totalflights` > 0 AND `totalflights` <= 1 AND `retired` = '0' "; $results2 = DB::get_results($sql1); // messy but two queries, merge them both if (!is_array($results) && !is_array($results2)) { return false; } else { if (is_array($results) && is_array($results2)) { $results = array_merge($results, $results2); } if (!is_array($results) && is_array($results2)) { $results = $results2; } } if (!$results) { return false; } # Find the retired status $statuses = Config::get('PILOT_STATUS_TYPES'); foreach($statuses as $retired_id => $status) { if($status['autoretire'] == true) { break; } } foreach ($results as $row) { // Set them retired self::updateProfile($row->pilotid, array('retired' => $retired_id)); Template::Set('pilot', $row); $pilot_retired_template = Template::Get('email_pilot_retired.tpl', true, true, true); Util::SendEmail($row->email, Lang::get('email.pilot.retired.subject'), $pilot_retired_template); } } What the original code is doing, is it's looking for any pilots who have logged in and have filed a PIREP before. The updated code above checks the inactive time and cross-checks it with the "joindate" column in your database and checks if they have filed a PIREP or not. Edited September 14, 2016 by web541 Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted September 15, 2016 Members Report Share Posted September 15, 2016 You need also to ad a cron job to your server or riun the mentenance script your self Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.