Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Dev #112

Closed
wants to merge 15 commits into from
66 changes: 36 additions & 30 deletions admin/modules/PIREPAdmin/PIREPAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function post_action() {
public function viewpending() {
$this->checkPermission(MODERATE_PIREPS);
$this->post_action();

$this->set('title', 'Pending Reports');

if (isset($this->get->hub) && $this->get->hub != '') {
Expand Down Expand Up @@ -197,7 +197,11 @@ public function editpirep() {
$this->set('fielddata', PIREPData::GetFieldData($this->get->pirepid));
$this->set('pirepfields', PIREPData::GetAllFields());
$this->set('comments', PIREPData::GetComments($this->get->pirepid));


if ($this->get->directPirepEdit && strtolower($this->get->directPirepEdit) !== "false") {
$this->set('directPirepEdit', true);
}

$this->render('pirep_edit.php');
}

Expand Down Expand Up @@ -356,61 +360,63 @@ protected function reject_pirep_post() {
CodonEvent::Dispatch('pirep_rejected', 'PIREPAdmin', $pirep_details);
}

protected function edit_pirep_post() {
if ($this->post->code == '' || $this->post->flightnum == ''
|| $this->post->depicao == '' || $this->post->arricao == ''
|| $this->post->aircraft == '' || $this->post->flighttime == ''
public function edit_pirep_post($postData = null) {
$postData = ($postData == null) ? $this->post : $postData;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change to $postData from $this->post?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was done during a mass find/replace. It's been a while but I don't believe it changed functionality. Had more to do with keeping things uniform

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I remember, I added a default parameter, so this could be called from another function without using the Vars class. Adding API functionality and all that jazz.

$this->checkPermission(MODERATE_PIREPS);
if ($postData->code == '' || $postData->flightnum == ''
|| $postData->depicao == '' || $postData->arricao == ''
|| $postData->aircraft == '' || $postData->flighttime == ''
) {

$this->set('message', 'You must fill out all of the required fields!');
$this->render('core_error.php');
return false;
}

$pirepInfo = PIREPData::getReportDetails($this->post->pirepid);
$pirepInfo = PIREPData::getReportDetails($postData->pirepid);
if (!$pirepInfo) {
$this->set('message', 'Invalid PIREP!');
$this->render('core_error.php');
return false;
}

$this->post->fuelused = str_replace(' ', '', $this->post->fuelused);
$this->post->fuelused = str_replace(',', '', $this->post->fuelused);
$fuelcost = $this->post->fuelused * $this->post->fuelunitcost;
$postData->fuelused = str_replace(' ', '', $postData->fuelused);
$postData->fuelused = str_replace(',', '', $postData->fuelused);
$fuelcost = $postData->fuelused * $postData->fuelunitcost;

# form the fields to submit
$data = array(
'pirepid' => $this->post->pirepid,
'code' => $this->post->code,
'flightnum' => $this->post->flightnum,
'depicao' => $this->post->depicao,
'arricao' => $this->post->arricao,
'aircraft' => $this->post->aircraft,
'flighttime' => $this->post->flighttime,
'load' => $this->post->load,
'price' => $this->post->price,
'pilotpay' => $this->post->pilotpay,
'fuelused' => $this->post->fuelused,
'fuelunitcost' => $this->post->fuelunitcost,
'pirepid' => $postData->pirepid,
'code' => $postData->code,
'flightnum' => $postData->flightnum,
'depicao' => $postData->depicao,
'arricao' => $postData->arricao,
'aircraft' => $postData->aircraft,
'flighttime' => $postData->flighttime,
'load' => $postData->load,
'price' => $postData->price,
'pilotpay' => $postData->pilotpay,
'fuelused' => $postData->fuelused,
'fuelunitcost' => $postData->fuelunitcost,
'fuelprice' => $fuelcost,
'expenses' => $this->post->expenses
'expenses' => $postData->expenses
);

if (!PIREPData::updateFlightReport($this->post->pirepid, $data)) {
if (!PIREPData::updateFlightReport($postData->pirepid, $data)) {
$this->set('message', 'There was an error editing your PIREP');
$this->render('core_error.php');
return false;
}

PIREPData::SaveFields($this->post->pirepid, $_POST);
PIREPData::SaveFields($postData->pirepid, $_POST);

//Accept or reject?
$this->post->id = $this->post->pirepid;
$submit = strtolower($this->post->submit_pirep);
$postData->id = $postData->pirepid;
$submit = strtolower($postData->submit_pirep);

// Add a comment
if (trim($this->post->comment) != '' && $submit != 'reject pirep') {
PIREPData::AddComment($this->post->pirepid, Auth::$userinfo->pilotid, $this->post->comment);
if (trim($postData->comment) != '' && $submit != 'reject pirep') {
PIREPData::AddComment($postData->pirepid, Auth::$userinfo->pilotid, $postData->comment);
}

if ($submit == 'accept pirep') {
Expand All @@ -425,7 +431,7 @@ protected function edit_pirep_post() {
# $pirepInfo = PIREPData::getReportDetails($this->post_action->pirepid);
PilotData::updatePilotStats($pirepInfo->pilotid);

LogData::addLog(Auth::$userinfo->pilotid, 'Edited PIREP #' . $this->post->id);
LogData::addLog(Auth::$userinfo->pilotid, 'Edited PIREP #' . $postData->id);
return true;
}
}
30 changes: 18 additions & 12 deletions admin/modules/PilotAdmin/PilotAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public function viewpilots() {

break;

case 'editpirep':
$editor = new PIREPAdmin();
$editor->edit_pirep_post($this->post);
break;

case 'deletepilot':

$pilotid = $this->post->pilotid;
Expand Down Expand Up @@ -110,7 +115,7 @@ public function viewpilots() {
return;

break;

case 'removegroup':

$this->RemovePilotGroup();
Expand Down Expand Up @@ -470,19 +475,20 @@ protected function ViewPilotDetails() {
PilotGroups::group_has_perm(Auth::$usergroups, EDIT_AWARDS) ||
PilotGroups::group_has_perm(Auth::$usergroups, MODERATE_PIREPS)
) {
$this->set('pilotinfo', PilotData::GetPilotData($this->get->pilotid));
$this->set('customfields', PilotData::GetFieldData($this->get->pilotid, true));
$this->set('allawards', AwardsData::GetPilotAwards($this->get->pilotid));
$this->set('pireps', PIREPData::GetAllReportsForPilot($this->get->pilotid));
$this->set('countries', Countries::getAllCountries());

$this->SetGroupsData($this->get->pilotid);
$this->set('pilotinfo', PilotData::GetPilotData($this->get->pilotid));
$this->set('customfields', PilotData::GetFieldData($this->get->pilotid, true));
$this->set('allawards', AwardsData::GetPilotAwards($this->get->pilotid));
$this->set('pireps', PIREPData::GetAllReportsForPilot($this->get->pilotid));
$this->set('countries', Countries::getAllCountries());
$this->set('directPirepEdit', true);

$this->SetGroupsData($this->get->pilotid);

// For the PIREP list
$this->set('pending', false);
$this->set('load', 'pilotpireps');
// For the PIREP list
$this->set('pending', false);
$this->set('load', 'pilotpireps');

$this->render('pilots_detailtabs.php');
$this->render('pilots_detailtabs.php');
}else{
Debug::showCritical('Unauthorized access - Invalid Permissions.');
die();
Expand Down
2 changes: 1 addition & 1 deletion admin/templates/core_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)
{
?>
<li style="padding: 0; margin; 0;"><a class="menu" href="#">
<li style="padding: 0; margin: 0;"><a class="menu" href="#">
<img src="<?php echo fileurl('/admin/lib/layout/images/site_icon.png');?>" />News & Content
</a>
<ul style="padding: 0; margin: 0;">
Expand Down
8 changes: 7 additions & 1 deletion admin/templates/pirep_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
if(isset($message))
echo '<div id="error">'.$message.'</div>';
?>
<form action="<?php echo SITE_URL?>/admin/index.php/pirepadmin/viewpending" method="post">
<form action="<?php
if($directPirepEdit){
echo SITE_URL."/admin/index.php/pilotadmin/viewpilots?action=viewoptions&pilotid=".$pirep->pilotid."#pireps";
}else{
echo SITE_URL."/admin/index.php/pirepadmin/viewpending?directPirepEdit=true";
}
?>" method="post">
<table width="100%" class="tablesorter">
<tr><td colspan="2" style="border: none;"><h4>PIREP Basics</h4></td></tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion admin/templates/pireps_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
href="<?php echo SITE_URL?>/admin/action.php/pirepadmin/rejectpirep?pirepid=<?php echo $pirep->pirepid;?>&pilotid=<?php echo $pirep->pilotid; ?>">Reject</button>

<button class="{button:{icons:{primary:'ui-icon-wrench'}}}"
onclick="window.location = '<?php echo SITE_URL?>/admin/index.php/pirepadmin/editpirep?pirepid=<?php echo $pirep->pirepid;?>&pilotid=<?php echo $pirep->pilotid?>'">Edit</button>
onclick="window.location = '<?php echo SITE_URL?>/admin/index.php/pirepadmin/editpirep?pirepid=<?php echo $pirep->pirepid;?>&pilotid=<?php echo $pirep->pilotid; if($directPirepEdit){echo "&directPirepEdit=true";}?>'">Edit</button>

<button href="<?php echo SITE_URL?>/admin/action.php/pirepadmin/<?php echo $load; ?>?pilotid=<?php echo $pirep->pilotid?>" action="deletepirep"
id="<?php echo $pirep->pirepid;?>" class="deleteitem {button:{icons:{primary:'ui-icon-trash'}}}">Delete</button>
Expand Down
8 changes: 3 additions & 5 deletions admin/templates/route_map.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
<div class="mapcenter" align="center">
<div id="routemap" style="width:600px; height: 480px"></div>
</div>
<?php $mapdata = ($mapdata != null) ? $mapdata : null; ?>
<p><strong>Route: </strong><?php echo $mapdata->route;?></p>
<script type="text/javascript">
var options = {
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true
}
};

var map = new google.maps.Map(document.getElementById("routemap"), options);

Expand Down Expand Up @@ -65,10 +66,7 @@
title: "<?php echo $mapdata->arrname;?>"
});

var flightPath = new google.maps.Polyline({
path: [dep_location, <?php if(count($list) > 0) { echo implode(',', $list).','; }?> arr_location],
strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2
}).setMap(map);
var flightPath = new google.maps.Polyline({path: [dep_location, <?php if(count($list) > 0) { echo implode(',', $list).','; }?> arr_location], strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2}).setMap(map);

map.fitBounds(bounds);
</script>
31 changes: 15 additions & 16 deletions core/app.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,32 +585,31 @@
$permission_set = array(
/*'NO_ADMIN_ACCESS' => 0,*/
'ACCESS_ADMIN' => 0x1,
'EDIT_NEWS' => 0x2,
'EDIT_NEWS' => 0x2,
'EDIT_PAGES' => 0x4,
'EDIT_DOWNLOADS' => 0x8,
'EMAIL_PILOTS' => 0x10,
'EDIT_AIRLINES' => 0x20,
'EMAIL_PILOTS' => 0x10,
'EDIT_AIRLINES' => 0x20,
'EDIT_FLEET' => 0x40,
'EDIT_SCHEDULES' => 0x80,
'IMPORT_SCHEDULES' => 0x100,
'MODERATE_REGISTRATIONS' => 0x200,
'IMPORT_SCHEDULES' => 0x100,
'MODERATE_REGISTRATIONS' => 0x200,
'EDIT_PILOTS' => 0x400,
'EDIT_GROUPS' => 0x800,
'EDIT_RANKS' => 0x1000,
'EDIT_AWARDS' => 0x2000,
'MODERATE_PIREPS' => 0x4000,
'EDIT_PIREPS_FIELDS' => 0x8000,
'VIEW_FINANCES' => 0x10000,
'EDIT_EXPENSES' => 0x20000,
'EDIT_SETTINGS' => 0x40000,
'EDIT_PROFILE_FIELDS' => 0x80000,
'EDIT_PIREPS_FIELDS' => 0x8000,
'VIEW_FINANCES' => 0x10000,
'EDIT_EXPENSES' => 0x20000,
'EDIT_SETTINGS' => 0x40000,
'EDIT_PROFILE_FIELDS' => 0x80000,
'EDIT_VACENTRAL' => 0x100000,
'MAINTENANCE' => 0x2000000,
//'CUSTOM_PERM1' => 0x4000000,
//'CUSTOM_PERM2' => 0x8000000,
//'CUSTOM_PERM3' => 0x10000000,
//'FULL_ADMIN' => 2147483647 // This is the supposed maximum, however it's still working!
'FULL_ADMIN' => 0x1FFFFFFF
'MAINTENANCE' => 0x2000000,
//'CUSTOM_PERM1' => 0x4000000,
//'CUSTOM_PERM2' => 0x8000000,
//'CUSTOM_PERM3' => 0x10000000,
'FULL_ADMIN' => 0x7FFFFFFF // == 2147483647 == Maximum 32bits
);
# Discriptions for permission sets
$permission_discription = array(
Expand Down
8 changes: 4 additions & 4 deletions core/classes/CodonModule.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
*/
class CodonModule
{
public static $post;
public static $get;
public static $controller;
public static $activeModule;
public $post;
public $get;
public $controller;
public $activeModule;
public $action;

public $title;
Expand Down
2 changes: 1 addition & 1 deletion core/common/OFCharts.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static function create_line_graph($title) {
self::show_chart($title);
}

protected function show_chart($title) {
protected static function show_chart($title) {
$title = new title($title);

self::$chart->set_title($title);
Expand Down
19 changes: 16 additions & 3 deletions core/common/StatsData.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function getTotalForCol($params) {
), $params
);

if($params['table'] == '' || $params['table'] == '') {
if($params['table'] == '') {
return false;
}

Expand Down Expand Up @@ -71,8 +71,21 @@ public static function getTotalForCol($params) {

$sql .= DB::build_where($params['where']);
$total = DB::get_row($sql);

if(!$total) {

/*
if(is_object($total)){
$checker = false;
foreach($total as $totaler){
if($totaler != null){
$checker += (int)$totaler;
}
}
}else{
$checker = true;
}
*/

if(!$total || $total == null || empty($total) || $total->total == null) {
$total = 0;
} else {
$total = $total->total;
Expand Down
12 changes: 5 additions & 7 deletions core/templates/route_map.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
* And for reference, you want to tinker:
* http://code.google.com/apis/maps/documentation/v3/basics.html
*/

//$pirep = ($pirep != null) ? $pirep : null;
//$schedule = ($schedule != null) ? $schedule : null;
if(isset($pirep))
$mapdata = $pirep;
if(isset($schedule))
Expand Down Expand Up @@ -68,7 +69,7 @@
<script type="text/javascript">
var options = {
mapTypeId: google.maps.MapTypeId.ROADMAP
}
};

var map = new google.maps.Map(document.getElementById("routemap"), options);
var dep_location = new google.maps.LatLng(<?php echo $mapdata->deplat?>,<?php echo $mapdata->deplng;?>);
Expand Down Expand Up @@ -116,7 +117,7 @@
icon: "<?php echo $icon; ?>",
title: "<?php echo $route->title; ?>",
infowindow_content: v<?php echo $route->name?>_navpoint_info
})
});

bounds.extend(v<?php echo $route->name?>_coords);

Expand Down Expand Up @@ -144,10 +145,7 @@
title: "<?php echo $mapdata->arrname;?>"
});

var flightPath = new google.maps.Polyline({
path: [dep_location, <?php if(count($list) > 0) { echo implode(',', $list).','; }?> arr_location],
strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2
}).setMap(map);
var flightPath = new google.maps.Polyline({path: [dep_location, <?php if(count($list) > 0) { echo implode(',', $list).','; }?> arr_location], strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2}).setMap(map);

// Resize the view to fit it all in
map.fitBounds(bounds);
Expand Down
2 changes: 1 addition & 1 deletion install/fixtures/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ INSERT INTO `phpvms_airports` (`id`, `icao`, `name`, `country`, `lat`, `lng`, `h

INSERT INTO `phpvms_ranks` VALUES(1, 'New Hire', '', 0, 18.0);

INSERT INTO `phpvms_groups` (`name`, `permissions`, `core`) VALUES ('Administrators', '35651519', 1);
INSERT INTO `phpvms_groups` (`name`, `permissions`, `core`) VALUES ('Administrators', '2147483647', 1);
INSERT INTO `phpvms_groups` (`name`, `permissions`, `core`) VALUES ('Active Pilots', '0', 1);
INSERT INTO `phpvms_groups` (`name`, `permissions`, `core`) VALUES ('Inactive Pilots', '0', 1);

Expand Down
Loading