public function savepro() { if ($this->post->firstname == '' || $this->post->lastname == '') { $this->set('message', 'The first or lastname cannot be blank!'); $this->render('core_error.tpl'); return; } $params = array('firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'hub' => $this->post->hub, 'retired' => $this->post->retired, 'totalflights' => $this->post->totalflights, 'totalpay' => floatval($this->post->totalpay), 'transferhours' => $this->post->transferhours); PilotData::updateProfile($this->post->pilotid, $params); PilotData::SaveFields($this->post->pilotid, $_POST); /* Don't calculate a pilot's rank if this is set */ if (Config::Get('RANKS_AUTOCALCULATE') == false) { PilotData::changePilotRank($this->post->pilotid, $this->post->rank); } else { RanksData::calculateUpdatePilotRank($this->post->pilotid); } StatsData::UpdateTotalHours(); $this->set('message', 'Profile updated successfully'); $this->render('core_success.tpl'); $this->set('pilots', PilotData::getAllPilots()); $this->render('/pm/pilot_manager.php'); if ($this->post->resend_email == 'true') { $this->post->id = $this->post->pilotid; $this->resendemail(false); } $pilot = PilotData::getPilotData($this->post->pilotid); LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname); return; break; }
/** * Go through each pilot, check their hours, and see where they * stand in the rankings. If they are above the minimum hours * for that rank level, then make $last_rank that text. At the * end, update that */ public static function calculatePilotRanks() { /* Don't calculate a pilot's rank if this is set */ if (Config::Get('RANKS_AUTOCALCULATE') === false) { return; } $allranks = self::getAllRanks(); $pilots = PilotData::getAllPilots(); if (count($pilots) == 0 || !is_array($pilots)) { return; } foreach ($pilots as $pilot) { $last_rank = ''; $pilothours = intval($pilot->totalhours); if (Config::Get('TRANSFER_HOURS_IN_RANKS') == true) { $pilothours += $pilot->transferhours; } $i = 1; foreach ($allranks as $rank) { if ($pilothours >= intval($rank->minhours)) { $rank_level = $i; $last_rank = $rank->rank; $last_rankid = $rank->rankid; } $i++; } $update = array('rankid' => $last_rankid, 'rank' => $last_rank, 'ranklevel' => $rank_level); PilotData::updateProfile($pilot->pilotid, $update); } }
} /* Run the update fixtures file */ echo '<h2>Populating Update Data...</h2>'; $sqlLines = Installer::readSQLFile(SITE_ROOT . '/install/fixtures/update.sql', TABLE_PREFIX); foreach ($sqlLines as $sql) { DB::query($sql['sql']); if (DB::errno() != 0 && DB::errno() != 1062) { echo '<div id="error" style="text-align: left;">Writing to "' . $sql['table'] . '" table... '; echo "<br /><br />" . DB::error(); echo '</div>'; } } OperationsData::updateAircraftRankLevels(); /* Add them to the default group */ $status_type_list = Config::get('PILOT_STATUS_TYPES'); $pilot_list = PilotData::getAllPilots(); foreach ($pilot_list as $pilot) { echo "Fixing settings for " . $pilot->firstname . " " . $pilot->lastname . "<br>"; PilotData::resetLedgerforPilot($pilot->pilotid); PilotGroups::addUsertoGroup($pilot->pilotid, DEFAULT_GROUP); # Reset the default groups $status = $status_type_list[$pilot->retired]; foreach ($status['group_add'] as $group) { PilotGroups::addUsertoGroup($pilot->pilotid, $group); } foreach ($status['group_remove'] as $group) { PilotGroups::removeUserFromGroup($pilot->pilotid, $group); } } SettingsData::saveSetting('PHPVMS_VERSION', $FULL_VERSION_STRING); # Don't count forced updates
/** * CentralData::send_pilots() * * @return */ public static function send_pilots() { if (!self::central_enabled()) { return false; } if (self::$debug === false) { $within_timelimit = CronData::check_hoursdiff('update_pilots', self::$limits['update_pilots']); if ($within_timelimit == true) { return false; } } if (!($allpilots = PilotData::getAllPilots())) { return false; } self::startBody('update_pilots'); self::addElement(null, 'total', count($allpilots)); foreach ($allpilots as $pilot) { $pc = self::addElement(null, 'pilot', null, array('pilotid' => PilotData::GetPilotCode($pilot->code, $pilot->pilotid), 'pilotname' => $pilot->firstname . ' ' . $pilot->lastname, 'location' => $pilot->location)); } CronData::set_lastupdate('update_pilots'); return self::sendToCentral(); }
/** * Go through each pilot, check their hours, and see where they * stand in the rankings. If they are above the minimum hours * for that rank level, then make $last_rank that text. At the * end, update that */ public static function calculatePilotRanks() { /* Don't calculate a pilot's rank if this is set */ if (Config::Get('RANKS_AUTOCALCULATE') === false) { return; } $ranks_list = self::getAllRanks(); $pilots = PilotData::getAllPilots(); if (count($pilots) == 0 || !is_array($pilots)) { return; } foreach ($pilots as $pilot) { self::calculateUpdatePilotRank($pilot->pilotid, $ranks_list); } }