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;
 }
Beispiel #2
0
 public function index()
 {
     if (!Auth::LoggedIn()) {
         $this->set('message', 'You must be logged in to access this feature!');
         $this->render('core_error.tpl');
         return;
     }
     /*
      * This is from /profile/editprofile
      */
     if (isset($this->post->action)) {
         if ($this->post->action == 'saveprofile') {
             $this->save_profile_post();
         }
         /* this comes from /profile/changepassword
          */
         if ($this->post->action == 'changepassword') {
             $this->change_password_post();
         }
     }
     if (Config::Get('TRANSFER_HOURS_IN_RANKS') == true) {
         $totalhours = intval(Auth::$userinfo->totalhours) + intval(Auth::$userinfo->transferhours);
     } else {
         $totalhours = Auth::$userinfo->totalhours;
     }
     $this->set('pilotcode', PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid));
     $this->set('report', PIREPData::GetLastReports(Auth::$userinfo->pilotid));
     $this->set('nextrank', RanksData::GetNextRank($totalhours));
     $this->set('allawards', AwardsData::GetPilotAwards(Auth::$userinfo->pilotid));
     $this->set('userinfo', Auth::$userinfo);
     $this->set('pilot_hours', $totalhours);
     $this->render('profile_main.tpl');
     CodonEvent::Dispatch('profile_viewed', 'Profile');
 }
Beispiel #3
0
 protected function ProcessRegistration()
 {
     // Yes, there was an error
     if (!$this->VerifyData()) {
         $this->ShowForm();
     } else {
         $data = array('firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'password' => $this->post->password1, 'code' => $this->post->code, 'location' => $this->post->location, 'hub' => $this->post->hub, 'confirm' => false);
         if (CodonEvent::Dispatch('registration_precomplete', 'Registration', $_POST) == false) {
             return false;
         }
         $ret = RegistrationData::CheckUserEmail($data['email']);
         if ($ret) {
             $this->set('error', Lang::gs('email.inuse'));
             $this->render('registration_error.tpl');
             return false;
         }
         $val = RegistrationData::AddUser($data);
         if ($val == false) {
             $this->set('error', RegistrationData::$error);
             $this->render('registration_error.tpl');
             return;
         } else {
             $pilotid = RegistrationData::$pilotid;
             /* Automatically confirm them if that option is set */
             if (Config::Get('PILOT_AUTO_CONFIRM') == true) {
                 PilotData::AcceptPilot($pilotid);
                 RanksData::CalculatePilotRanks();
                 $pilot = PilotData::GetPilotData($pilotid);
                 $this->set('pilot', $pilot);
                 $this->render('registration_autoconfirm.tpl');
             } else {
                 RegistrationData::SendEmailConfirm($email, $firstname, $lastname);
                 $this->render('registration_sentconfirmation.tpl');
             }
         }
         CodonEvent::Dispatch('registration_complete', 'Registration', $_POST);
         // Registration email/show user is waiting for confirmation
         $sub = 'A user has registered';
         $message = "The user {$data['firstname']} {$data['lastname']} ({$data['email']}) has registered, and is awaiting confirmation.";
         $email = Config::Get('EMAIL_NEW_REGISTRATION');
         if (empty($email)) {
             $email = ADMIN_EMAIL;
         }
         Util::SendEmail($email, $sub, $message);
         // Send email to user
         $this->set('firstname', $data['firstname']);
         $this->set('lastname', $data['lastname']);
         $this->set('userinfo', $data);
         $message = Template::Get('email_registered.tpl', true);
         Util::SendEmail($data['email'], 'Registration at ' . SITE_NAME, $message);
         $rss = new RSSFeed('Latest Pilot Registrations', SITE_URL, 'The latest pilot registrations');
         $allpilots = PilotData::GetLatestPilots();
         foreach ($allpilots as $pilot) {
             $rss->AddItem('Pilot ' . PilotData::GetPilotCode($pilot->code, $pilot->pilotid) . ' (' . $pilot->firstname . ' ' . $pilot->lastname . ')', SITE_URL . '/admin/index.php?admin=pendingpilots', '', '');
         }
         $rss->BuildFeed(LIB_PATH . '/rss/latestpilots.rss');
     }
 }
Beispiel #4
0
 protected function edit_rank_post()
 {
     if ($this->post->minhours == '' || $this->post->rank == '') {
         $this->set('message', 'Hours and Rank must be blank');
         $this->render('core_error.tpl');
         return;
     }
     if (!is_numeric($this->post->minhours)) {
         $this->set('message', 'The hours must be a number');
         $this->render('core_error.tpl');
         return;
     }
     $this->post->payrate = abs($this->post->payrate);
     $ret = RanksData::UpdateRank($this->post->rankid, $this->post->rank, $this->post->minhours, $this->post->rankimage, $this->post->payrate);
     if (DB::errno() != 0) {
         $this->set('message', 'Error updating the rank: ' . DB::error());
         $this->render('core_error.tpl');
         return;
     }
     $this->set('message', 'Rank Added!');
     $this->render('core_success.tpl');
     LogData::addLog(Auth::$userinfo->pilotid, 'Edited the rank "' . $this->post->rank . '"');
 }
 /**
  * Add a ranking. This will automatically call
  * CalculatePilotRanks() at the end
  */
 public static function addRank($title, $minhours, $imageurl, $payrate)
 {
     $minhours = intval($minhours);
     $payrate = floatval($payrate);
     $sql = "INSERT INTO " . TABLE_PREFIX . "ranks (rank, rankimage, minhours, payrate)\n\t\t\t\t\tVALUES('{$title}', '{$imageurl}', '{$minhours}', {$payrate})";
     $ret = DB::query($sql);
     if (DB::$errno == 1062) {
         self::$lasterror = 'This already exists';
         return false;
     }
     CodonCache::delete('all_ranks');
     self::CalculatePilotRanks();
     return true;
 }
Beispiel #6
0
 /**
  * Operations::editaircraft()
  * 
  * @return
  */
 public function editaircraft()
 {
     $this->checkPermission(EDIT_FLEET);
     $id = $this->get->id;
     $this->set('aircraft', OperationsData::GetAircraftInfo($id));
     $this->set('title', 'Edit Aircraft');
     $this->set('action', 'editaircraft');
     $this->set('allranks', RanksData::getAllRanks());
     $this->render('ops_aircraftform.php');
 }
 /**
  * PilotData::updatePilotRankLevels()
  * 
  * @return void
  */
 public static function updatePilotRankLevels()
 {
     $all_pilots = self::findPilots(array());
     foreach ($all_pilots as $pilot) {
         $rank_level = RanksData::getRankLevel($pilot->rankid);
         self::updateProfile($pilot->pilotid, array('ranklevel' => $rank_level));
     }
 }
Beispiel #8
0
 /**
  * Change the status of a PIREP. For the status, use the constants:
  * PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS
  * 
  * Also handle paying the pilot, and handle PIREP rejection, etc
  * 
  * @param int $pirepid The PIREP ID of status to change
  * @param int $status Use consts: PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS
  * @return bool
  */
 public static function changePIREPStatus($pirepid, $status)
 {
     # Look up the status of the PIREP of previous
     $pirep_details = PIREPData::getReportDetails($pirepid);
     if (!$pirep_details) {
         return false;
     }
     if ($pirep_details->accepted == $status) {
         return true;
     }
     $ret = self::editPIREPFields($pirepid, array('accepted' => $status));
     # Do something if the PIREP was previously marked as pending
     if ($pirep_details->accepted == PIREP_PENDING) {
         if ($status == PIREP_ACCEPTED) {
             self::calculatePIREPPayment($pirepid);
             SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '+1');
         } elseif ($status == PIREP_REJECTED) {
             // Do nothing, since nothing in the PIREP was actually counted
         }
     } elseif ($pirep_details->accepted == PIREP_ACCEPTED) {
         # If already accepted
         if ($status == PIREP_REJECTED) {
             LedgerData::deletePaymentByPIREP($pirep_details->pirepid);
             PilotData::resetPilotPay($pirep_details->pilotpay);
             SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '-1');
         }
     }
     PilotData::updatePilotStats($pirep_details->pilotid);
     RanksData::calculateUpdatePilotRank($pirep_details->pilotid);
     PilotData::generateSignature($pirep_details->pilotid);
     StatsData::updateTotalHours();
     return $ret;
 }
Beispiel #9
0
<?php

include dirname(__FILE__) . '/bootstrap.inc.php';
echo '<pre>';
$pilot = PilotData::findPilots(array('p.totalflights > 0'));
$idx = rand(0, count($pilot) - 1);
$pilot = $pilot[$idx];
RanksData::calculateUpdatePilotRank($pilot->pilotid);
Beispiel #10
0
 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::UpdatePilotStats($pirep_details->pilotid);
         #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)";
 }
Beispiel #11
0
    } else {
        $sel = '';
    }
    echo '<option value="' . $hub->icao . '" ' . $sel . '>' . $hub->icao . ' - ' . $hub->name . '</option>';
}
?>
	
		</select>
	</td>
</tr>
<tr>
	<td>Current Rank</td>
	<td>
	<?php 
if (Config::Get('RANKS_AUTOCALCULATE') == false) {
    $allranks = RanksData::GetAllRanks();
    echo '<select name="rank">';
    foreach ($allranks as $rank) {
        $selected = $pilotinfo->rank == $rank->rank ? "selected=\"selected\"" : '';
        echo "<option value=\"{$rank->rankid}\" {$selected}>{$rank->rank}</option>";
    }
    echo '</select>';
} else {
    echo $pilotinfo->rank;
}
?>
</td>
</tr>
<tr>
	<td>Date Joined</td>
	<td><?php 
Beispiel #12
0
 protected function ApprovePilot()
 {
     PilotData::AcceptPilot($this->post->id);
     RanksData::CalculatePilotRanks();
     $pilot = PilotData::GetPilotData($this->post->id);
     # Send pilot notification
     $subject = Lang::gs('email.register.accepted.subject');
     $this->set('pilot', $pilot);
     $message = Template::GetTemplate('email_registrationaccepted.tpl', true, true, true);
     Util::SendEmail($pilot->email, $subject, $message);
     CodonEvent::Dispatch('pilot_approved', 'PilotAdmin', $pilot);
     LogData::addLog(Auth::$userinfo->pilotid, 'Approved ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' - ' . $pilot->firstname . ' ' . $pilot->lastname);
 }
Beispiel #13
0
 /**
  * Change the status of a PIREP. For the status, use the constants:
  * PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS
  * 
  * Also handle paying the pilot, and handle PIREP rejection, etc
  * 
  * @deprecated Use editPIREPFields instead
  */
 public static function changePIREPStatus($pirepid, $status)
 {
     # Look up the status of the PIREP of previous
     $pirep_details = PIREPData::getReportDetails($pirepid);
     if (!$pirep_details) {
         return false;
     }
     if ($pirep_details->accepted == $status) {
         return true;
     }
     $ret = self::editPIREPFields($pirepid, array('accepted' => $status));
     # Do something if the PIREP was previously marked as pending
     if ($pirep_details->accepted == PIREP_PENDING) {
         if ($status == PIREP_ACCEPTED) {
             # Pay per-schedule
             if (!empty($pirep_details->payforflight)) {
                 $sql = 'UPDATE ' . TABLE_PREFIX . "pilots \n            \t\t\t\tSET totalpay=totalpay+{$pirep_details->payforflight} \n            \t\t\t\tWHERE pilotid={$pirep_details->pilotid}";
                 DB::query($sql);
             } else {
                 # Pay by hour
                 PilotData::updatePilotPay($pirep_details->pilotid, $pirep_details->flighttime, true);
             }
             SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '+1');
         } elseif ($status == PIREP_REJECTED) {
             // Do nothing, since nothing in the PIREP was actually counted
         }
     } elseif ($pirep_details->accepted == PIREP_ACCEPTED) {
         # If already accepted
         if ($status == PIREP_REJECTED) {
             # Subtract their pay for the rejected flight
             if (!empty($pirep_details->payforflight)) {
                 $sql = 'UPDATE ' . TABLE_PREFIX . "pilots \n            \t\t\t\tSET totalpay=totalpay-{$pirep_details->payforflight} \n            \t\t\t\tWHERE pilotid={$pirep_details->pilotid}";
                 DB::query($sql);
             } else {
                 PilotData::updatePilotPay($pirep_details->pilotid, $pirep_details->flighttime, false);
             }
             SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '-1');
         }
     }
     PilotData::updatePilotStats($pirep_details->pilotid);
     RanksData::calculateUpdatePilotRank($pirep_details->pilotid);
     PilotData::generateSignature($pirep_details->pilotid);
     StatsData::updateTotalHours();
     return $ret;
 }
 /**
  * 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;
 }
Beispiel #15
0
 public function calculateranks()
 {
     echo '<h3>Resetting Ranks</h3>';
     RanksData::CalculatePilotRanks();
     echo 'Done!';
     LogData::addLog(Auth::$userinfo->pilotid, 'Recalculated ranks');
 }
Beispiel #16
0
 public function editaircraft()
 {
     $id = $this->get->id;
     $this->set('aircraft', OperationsData::GetAircraftInfo($id));
     $this->set('title', 'Edit Aircraft');
     $this->set('action', 'editaircraft');
     $this->set('allranks', RanksData::getAllRanks());
     $this->render('ops_aircraftform.tpl');
 }
Beispiel #17
0
    public function importaircraft()
    {
        if (!file_exists($_FILES['uploadedfile']['tmp_name'])) {
            $this->render('import_aircraftform.tpl');
            return;
        }
        echo '<h3>Processing Import</h3>';
        # Get the column headers
        $allaircraft = OperationsData::getAllAircraft(false);
        $headers = array();
        $dbcolumns = DB::get_cols();
        foreach ($dbcolumns as $col) {
            if ($col->name == 'id' || $col->name == 'minrank' || $col->name == 'ranklevel') {
                continue;
            }
            $headers[] = $col->name;
        }
        # Open the import file
        # Fix for bug VMS-325
        $temp_name = $_FILES['uploadedfile']['tmp_name'];
        $new_name = CACHE_PATH . $_FILES['uploadedfile']['name'];
        move_uploaded_file($temp_name, $new_name);
        $fp = fopen($new_name, 'r');
        if (isset($_POST['header'])) {
            $skip = true;
        }
        $added = 0;
        $updated = 0;
        $total = 0;
        echo '<div style="overflow: auto; height: 400px; 
					border: 1px solid #666; margin-bottom: 20px; 
					padding: 5px; padding-top: 0px; padding-bottom: 20px;">';
        while ($fields = fgetcsv($fp, 1000, ',')) {
            // Skip the first line
            if ($skip == true) {
                $skip = false;
                continue;
            }
            # Map the read in values to the columns
            $aircraft = array();
            $aircraft = @array_combine($headers, $fields);
            if (empty($aircraft)) {
                continue;
            }
            # Enabled or not
            if ($aircraft['enabled'] == '1') {
                $aircraft['enabled'] = true;
            } else {
                $aircraft['enabled'] = false;
            }
            # Get the rank ID
            $rank = RanksData::getRankByName($aircraft['rank']);
            $aircraft['minrank'] = $rank->rankid;
            unset($aircraft['rank']);
            # Does this aircraft exist?
            $ac_info = OperationsData::getAircraftByReg($aircraft['registration']);
            if ($ac_info) {
                echo "Editing {$aircraft['name']} - {$aircraft['registration']}<br>";
                $aircraft['id'] = $ac_info->id;
                OperationsData::editAircraft($aircraft);
                $updated++;
            } else {
                echo "Adding {$aircraft['name']} - {$aircraft['registration']}<br>";
                OperationsData::addAircraft($aircraft);
                $added++;
            }
            $total++;
        }
        unlink($new_name);
        echo "The import process is complete, added {$added} aircraft, updated {$updated}, for a total of {$total}<br />";
    }
 public static function updateAircraftRankLevels()
 {
     $all_aircraft = self::getAllAircraft(false);
     if (!$all_aircraft) {
         return;
     }
     foreach ($all_aircraft as $aircraft) {
         $rank_level = RanksData::getRankLevel($aircraft->minrank);
         $sql = "UPDATE " . TABLE_PREFIX . "aircraft\n\t\t\t\t\tSET `ranklevel`={$rank_level}\n\t\t\t\t\tWHERE `id`={$aircraft->id}";
         DB::query($sql);
     }
 }
Beispiel #19
0
 public static function SiteSetup()
 {
     /*$_POST['SITE_NAME'] == '' || $_POST['firstname'] == '' || $_POST['lastname'] == ''
     		|| $_POST['email'] == '' ||  $_POST['password'] == '' || $_POST['vaname'] == ''
     		|| $_POST['vacode'] == ''*/
     // first add the airline
     $_POST['vacode'] = strtoupper($_POST['vacode']);
     if (!OperationsData::AddAirline($_POST['vacode'], $_POST['vaname'])) {
         self::$error = DB::$error;
         return false;
     }
     // Add an initial airport/hub, because I love KJFK so much
     $data = array('icao' => 'KJFK', 'name' => 'Kennedy International', 'country' => 'USA', 'lat' => '40.6398', 'lng' => '-73.7787', 'hub' => false, 'fuelprice' => 0);
     $ret = OperationsData::AddAirport($data);
     // Add the user
     $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], l, 'password' => $_POST['password'], 'code' => $_POST['vacode'], 'location' => 'US', 'hub' => 'KJFK', 'confirm' => true);
     if (!RegistrationData::AddUser($data)) {
         self::$error = DB::$error;
         return false;
     }
     // Add a rank
     RanksData::updateRank(1, 'New Hire', 0, fileurl('/lib/images/ranks/newhire.jpg'), 18.0);
     # Add to admin group
     $pilotdata = PilotData::GetPilotByEmail($_POST['email']);
     if (!PilotGroups::AddUsertoGroup($pilotdata->pilotid, 'Administrators')) {
         self::$error = DB::$error;
         return false;
     }
     # Add the final settings in
     SettingsData::SaveSetting('SITE_NAME', $_POST['SITE_NAME']);
     SettingsData::SaveSetting('ADMIN_EMAIL', $_POST['email']);
     SettingsData::SaveSetting('GOOGLE_KEY', $_POST['googlekey']);
     return true;
 }
Beispiel #20
0
 /**
  * Reject the report, and then send them the comment
  * that was entered into the report
  */
 protected function reject_pirep_post()
 {
     $pirepid = $this->post->pirepid;
     $comment = $this->post->comment;
     if ($pirepid == '' || $comment == '') {
         return;
     }
     PIREPData::ChangePIREPStatus($pirepid, PIREP_REJECTED);
     // 2 is rejected
     $pirep_details = PIREPData::GetReportDetails($pirepid);
     // If it was previously accepted, subtract the flight data
     if (intval($pirep_details->accepted) == PIREP_ACCEPTED) {
         PilotData::UpdateFlightData($pirep_details->pilotid, -1 * floatval($pirep->flighttime), -1);
     }
     //PilotData::UpdatePilotStats($pirep_details->pilotid);
     RanksData::CalculateUpdatePilotRank($pirep_details->pilotid);
     PilotData::resetPilotPay($pirep_details->pilotid);
     StatsData::UpdateTotalHours();
     // Send comment for rejection
     if ($comment != '') {
         $commenter = Auth::$userinfo->pilotid;
         // The person logged in commented
         PIREPData::AddComment($pirepid, $commenter, $comment);
         // Send them an email
         $this->set('firstname', $pirep_details->firstname);
         $this->set('lastname', $pirep_details->lastname);
         $this->set('pirepid', $pirepid);
         $message = Template::GetTemplate('email_commentadded.tpl', true);
         Util::SendEmail($pirep_details->email, 'Comment Added', $message);
     }
     LogData::addLog(Auth::$userinfo->pilotid, 'Rejected PIREP #' . $pirepid);
     # Call the event
     CodonEvent::Dispatch('pirep_rejected', 'PIREPAdmin', $pirep_details);
 }
Beispiel #21
0
 /**
  * Maintenance::calculateranks()
  * 
  * @return
  */
 public function calculateranks()
 {
     CodonModule::checkPermission(MAINTENANCE);
     echo '<h3>Resetting Ranks</h3>';
     RanksData::CalculatePilotRanks();
     echo 'Done!';
     LogData::addLog(Auth::$userinfo->pilotid, 'Recalculated ranks');
 }
Beispiel #22
0
 /**
  * Installer::SiteSetup()
  * 
  * @return
  */
 public static function SiteSetup()
 {
     /*$_POST['SITE_NAME'] == '' || $_POST['firstname'] == '' || $_POST['lastname'] == ''
     		|| $_POST['email'] == '' ||  $_POST['password'] == '' || $_POST['vaname'] == ''
     		|| $_POST['vacode'] == ''*/
     // first add the airline
     $_POST['vacode'] = strtoupper($_POST['vacode']);
     if (!OperationsData::addAirline($_POST['vacode'], $_POST['vaname'])) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     // Add the user
     $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], l, 'password' => $_POST['password'], 'code' => $_POST['vacode'], 'location' => 'US', 'hub' => 'KJFK', 'confirm' => true);
     if (!RegistrationData::addUser($data)) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     RanksData::calculatePilotRanks();
     # Add to admin group
     $pilotdata = PilotData::getPilotByEmail($_POST['email']);
     if (!PilotGroups::addUsertoGroup($pilotdata->pilotid, 'Administrators')) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     # Add the final settings in
     SettingsData::SaveSetting('SITE_NAME', $_POST['SITE_NAME']);
     SettingsData::SaveSetting('ADMIN_EMAIL', $_POST['email']);
     SettingsData::SaveSetting('GOOGLE_KEY', $_POST['googlekey']);
     return true;
 }
Beispiel #23
0
 /**
  * PilotAdmin::ApprovePilot()
  * 
  * @return
  */
 protected function ApprovePilot()
 {
     $this->checkPermission(MODERATE_REGISTRATIONS);
     PilotData::AcceptPilot($this->post->id);
     RanksData::CalculatePilotRanks();
     $pilot = PilotData::getPilotData($this->post->id);
     # Send pilot notification
     $subject = Lang::gs('email.register.accepted.subject');
     $this->set('pilot', $pilot);
     $oldPath = Template::setTemplatePath(TEMPLATES_PATH);
     $oldSkinPath = Template::setSkinPath(ACTIVE_SKIN_PATH);
     $message = Template::getTemplate('email_registrationaccepted.php', true, true, true);
     Template::setTemplatePath($oldPath);
     Template::setSkinPath($oldSkinPath);
     Util::SendEmail($pilot->email, $subject, $message);
     CodonEvent::Dispatch('pilot_approved', 'PilotAdmin', $pilot);
     LogData::addLog(Auth::$userinfo->pilotid, 'Approved ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' - ' . $pilot->firstname . ' ' . $pilot->lastname);
 }