Jump to content

Recommended Posts

Posted

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);

Posted (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 by web541

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...