/** * Approve the PIREP, and then update * the pilot's data */ protected function approve_pirep_post() { $pirepid = $this->post->id; if ($pirepid == '') { return; } $pirep_details = PIREPData::GetReportDetails($pirepid); # See if it's already been accepted if (intval($pirep_details->accepted) == PIREP_ACCEPTED) { return; } # Update pilot stats SchedulesData::IncrementFlownCount($pirep_details->code, $pirep_details->flightnum); PIREPData::ChangePIREPStatus($pirepid, PIREP_ACCEPTED); // 1 is accepted PilotData::UpdateFlightData($pirep_details->pilotid, $pirep_details->flighttime, 1); PilotData::UpdatePilotPay($pirep_details->pilotid, $pirep_details->flighttime); RanksData::CalculateUpdatePilotRank($pirep_details->pilotid); PilotData::GenerateSignature($pirep_details->pilotid); StatsData::UpdateTotalHours(); LogData::addLog(Auth::$userinfo->pilotid, 'Approved PIREP #' . $pirepid); # Call the event CodonEvent::Dispatch('pirep_accepted', 'PIREPAdmin', $pirep_details); }
protected function save_profile_post() { if (!Auth::LoggedIn()) { $this->set('message', 'You must be logged in to access this feature!'); $this->render('core_error.tpl'); return; } $userinfo = Auth::$userinfo; //TODO: check email validity if ($this->post->email == '') { return; } $params = array('code' => Auth::$userinfo->code, 'email' => $this->post->email, 'location' => $this->post->location, 'hub' => Auth::$userinfo->hub, 'bgimage' => $this->post->bgimage, 'retired' => false); PilotData::updateProfile($userinfo->pilotid, $params); PilotData::SaveFields($userinfo->pilotid, $_POST); # Generate a fresh signature PilotData::GenerateSignature($userinfo->pilotid); PilotData::SaveAvatar($userinfo->code, $userinfo->pilotid); $this->set('message', 'Profile saved!'); $this->render('core_success.tpl'); }
/** * Add a User * * $data = array( * 'firstname' => '', * 'lastname' => '', * 'email' => '', * 'password' => '', * 'code' => '', * 'location' => '', * 'hub' => '', * 'confirm' => false); */ public static function addUser($data) { /*$data = array( 'firstname' => '', 'lastname' => '', 'email' => '', 'password' => '', 'code' => '', 'location' => '', 'hub' => '', 'confirm' => false);*/ $exists = self::CheckUserEmail($data['email']); if (is_object($exists)) { self::$error = 'Email already exists'; return false; } //Set the password, add some salt $salt = md5(date('His')); $password = md5($data['password'] . $salt); //Stuff it into here, the confirmation email will use it. self::$salt = $salt; $code = DB::escape(strtoupper($data['code'])); $firstname = DB::escape(ucwords($data['firstname'])); $lastname = DB::escape(ucwords($data['lastname'])); $location = DB::escape(strtoupper($data['location'])); //Add this stuff in if ($data['confirm'] === true) { $confirm = 1; } else { $confirm = 0; } $sql = "INSERT INTO " . TABLE_PREFIX . "pilots (firstname, lastname, email,\n\t\t\t\t\tcode, location, hub, password, salt, confirmed, joindate, lastip)\n\t\t\t\t VALUES ('{$firstname}', '{$lastname}', '{$data['email']}', '{$code}',\n\t\t\t\t\t\t\t'{$location}', '{$data['hub']}', '{$password}', '{$salt}', {$confirm}, NOW(), '{$_SERVER['REMOTE_ADDR']}')"; $res = DB::query($sql); if (DB::errno() != 0) { if (DB::errno() == 1062) { self::$error = 'This email address is already registered'; return false; } self::$error = DB::error(); return false; } //Grab the new pilotid, we need it to insert those "custom fields" $pilotid = DB::$insert_id; RanksData::CalculateUpdatePilotRank($pilotid); PilotData::GenerateSignature($pilotid); /* Add them to the default group */ $defaultGroup = SettingsData::getSettingValue('DEFAULT_GROUP'); PilotGroups::addUsertoGroup($pilotid, $defaultGroup); // For later self::$pilotid = $pilotid; //Get customs fields $fields = self::GetCustomFields(); if (!$fields) { return true; } foreach ($fields as $field) { $value = Vars::POST($field->fieldname); $value = DB::escape($value); if ($value != '') { $sql = "INSERT INTO " . TABLE_PREFIX . "fieldvalues (fieldid, pilotid, value)\n\t\t\t\t\t\t\tVALUES ({$field->fieldid}, {$pilotid}, '{$value}')"; DB::query($sql); } } return true; }
/** * Maintenance::resetsignatures() * * @return */ public function resetsignatures() { CodonModule::checkPermission(MAINTENANCE); $allpilots = PilotData::GetAllPilots(); echo '<h3>Regenerating signatures</h3> <strong>Generating signatures...</strong><br />'; foreach ($allpilots as $pilot) { echo "Generating signature for {$pilot->firstname} {$pilot->lastname}<br />"; PilotData::GenerateSignature($pilot->pilotid); } echo "Done"; LogData::addLog(Auth::$userinfo->pilotid, 'Reset signatures'); }
public function approveall() { echo '<h3>Approve All</h3>'; $allpireps = PIREPData::findPIREPS(array('p.accepted' => PIREP_PENDING)); $total = count($allpireps); $count = 0; foreach ($allpireps as $pirep_details) { if ($pirep_details->aircraft == '') { continue; } # Update pilot stats SchedulesData::IncrementFlownCount($pirep_details->code, $pirep_details->flightnum); PIREPData::ChangePIREPStatus($pirep_details->pirepid, PIREP_ACCEPTED); // 1 is accepted //PilotData::UpdateFlightData($pirep_details->pilotid, $pirep_details->flighttime, 1); PilotData::UpdatePilotStats($pirep_details->pilotid); PilotData::UpdatePilotPay($pirep_details->pilotid, $pirep_details->flighttime); RanksData::CalculateUpdatePilotRank($pirep_details->pilotid); RanksData::CalculatePilotRanks(); PilotData::GenerateSignature($pirep_details->pilotid); StatsData::UpdateTotalHours(); $count++; } $skipped = $total - $count; echo "{$count} of {$total} were approved ({$skipped} has errors)"; }
} if ($version < 11441) { Installer::sql_file_update(SITE_ROOT . '/install/update_441.sql'); $version = 11441; } if ($version < 11458) { Installer::add_to_config('PAGE_ENCODING', 'ISO-8859-1', 'This is the page encoding'); Installer::add_to_config('PILOTID_LENGTH', 4, 'This is the length of the pilot ID. including leading zeros'); Installer::add_to_config('SIGNATURE_TEXT_COLOR', '#FFF'); Installer::add_to_config('SIGNATURE_SHOW_COPYRIGHT', true); # Update signatures for everyone $allpilots = PilotData::GetAllPilots(); echo "Generating signatures<br />"; foreach ($allpilots as $pilot) { echo "Generating signature for {$pilot->firstname} {$pilot->lastname}<br />"; PilotData::GenerateSignature($pilot->pilotid); } $version = 11458; } if ($version < 11628) { echo '<p>Adding new options to the core/local.config.php...</p>'; Installer::add_to_config('LOAD_FACTOR', '72'); Installer::add_to_config('CARGO_UNITS', 'lbs'); Installer::add_to_config('COMMENT', 'FSPassengers Settings'); Installer::add_to_config('COMMENT', 'Units settings'); Installer::add_to_config('WeightUnit', '1', '0=Kg 1=lbs'); Installer::add_to_config('DistanceUnit', '2', '0=KM 1= Miles 2=NMiles'); Installer::add_to_config('SpeedUnit', '1', '0=Km/H 1=Kts'); Installer::add_to_config('AltUnit', '1', '0=Meter 1=Feet'); Installer::add_to_config('LiquidUnit', '2', '0=liter 1=gal 2=kg 3=lbs'); Installer::add_to_config('WelcomeMessage', SITE_NAME . ' ACARS', 'Welcome Message');