Hello, I am trying to restrict the aircraft that can be flown by a pilot by their ranks. I have selected the rank they have to be in the fleet list area of the admin panel. I have also added the line of code to the local.config.php to restrict it and set it to true and it still doesn’t restrict pilots to fly certain aircraft. I am using Front Schedules put out by lorathon, and I tried adding the restriction code that is in the schedules_result.tpl, but that didn’t work. Any ideas?
Try the stock schedules viewer and see if that works with the rank restrictions, that would be a start to narrowing down the problem
OK the stock route system doesn’t display routes outside of your rank. I tried messing with the FrontSchedules php to see what I could do with no luck…maybe simpilot knows how to do this since he made the script
Even though I was given undue credit in the first post I wanted to comment on this.
We also restrict by aircraft. But instead of denying the pilot the ability to see the schedule I just deny them the ability to bid on the schedule.
If the aircraft is above there rank I replace the “Add to Bid” with “Above your Rank”. I personally think that it looks better. Then the lower ranked pilots can still see the whole schedule.
See screen shot
Yes, I was hoping to do this aswell…I’m just clueless when it comes to php…can anybody help me with this?
Somewhere I went wrong with this. The ADD TO BID still exists and is clickable. Here’s the page code.
<?php
$pilotid = Auth::PilotID();
$user = PilotData::getPilotData($pilotid); //HERE IS THE FIRST CODE YOU HAVE
?>
<?php
if(!$allroutes)
{
echo '<p align="center">No routes have been found!</p>';
return;
}
?>
<table align="center" border="1" width="100%">
<thead>
<tr>
<th bgcolor="#05305D" border="1"><span style="color: rgb(255, 255, 255);">Flight Schedule Information</span></th>
<th bgcolor="#05305D" border="1"><span style="color: rgb(255, 255, 255);">Options</span></th>
</tr>
</thead>
<tbody>
<?php
foreach($allroutes as $route)
{
/* Uncomment this code if you want only schedules which are from the last PIREP that
pilot filed */
if(Auth::LoggedIn())
{
$search = array(
'p.pilotid' => Auth::$userinfo->pilotid,
'p.accepted' => PIREP_ACCEPTED
);
$reports = PIREPData::findPIREPS($search, 1); // return only one
if(is_object($reports))
{
# IF the arrival airport doesn't match the departure airport
if($reports->arricao != $route->depicao)
{
continue;
}
}
}
/*
Skip over a route if it's not for this day of week
Left this here, so it can be omitted if your VA
doesn't use this.
Comment out these two lines if you don't want to.
*/
/* Check if a 7 is being used for Sunday, since PHP
thinks 0 is Sunday */
$route->daysofweek = str_replace('7', '0', $route->daysofweek);
if(strpos($route->daysofweek, date('w')) === false)
continue;
/* END DAY OF WEEK CHECK */
/*
This will skip over a schedule if it's been bid on
This only runs if the below setting is enabled
If you don't want it to skip, then comment out
this code below by adding // in front of each
line until the END DISABLE SCHEDULE comment below
If you do that, and want to show some text when
it's been bid on, see the comment below
*/
if(Config::Get('DISABLE_SCHED_ON_BID') == true && $route->bidid != 0)
{
continue;
}
/* END DISABLE SCHEDULE ON BID */
if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn())
{
if($route->aircraftlevel > Auth::$userinfo->ranklevel)
{
continue;
}
}
/* THIS BEGINS ONE TABLE ROW */
?>
<tr>
<td>
<img src="<?php echo fileurl('/images/airline/'.$route->code.'.gif'); ?>" alt="<?php echo $airline->name;?>" /><br />
<a href="<?php echo url('/schedules/details/'.$route->id);?>"><?php echo $route->code . $route->flightnum?>
<?php echo '('.$route->depicao.' - '.$route->arricao.')'?>
</a>
<br />
<strong>Departure: </strong><?php echo $route->deptime;?> <strong>Arrival: </strong><?php echo $route->arrtime;?><br />
<strong>Equipment: </strong><?php echo $route->aircraft; ?> (<?php echo $route->registration;?>) <strong>Distance: </strong><?php echo $route->distance . Config::Get('UNITS');?>
<br />
<strong>Days Flown: </strong><?php echo Util::GetDaysCompact($route->daysofweek); ?><br />
<?php echo ($route->route=='') ? '' : '<strong>Route: <FONT COLOR="#ff0000"></strong>'.$route->route.'<br /></FONT>' ?>
<?php echo ($route->notes=='') ? '' : '<strong>Airline: </strong>'.html_entity_decode($route->notes).'<br />' ?>
<?php echo '<strong>Flight Type: </strong>'; if($route->flighttype=='P')echo 'Passenger<br />'; elseif($route-flighttype=='C') echo 'Cargo<br />'; else echo 'Charter<br />'; ?>
<strong>Price: </strong>$<?php echo $route->price;?><br />
<?php
# Note: this will only show if the above code to
# skip the schedule is commented out
if($route->bidid != 0)
{
echo 'This route has been bid on';
}
?>
</td>
<td nowrap align="center">
<a href="<?php echo url('/schedules/details/'.$route->id);?>">View Details</a><br />
<a href="<?php echo url('/schedules/brief/'.$route->id);?>">Pilot Brief</a><br />
<?php
if ($info->ranklevel > $user->ranklevel)
{?>
<b><font color="#FF0000">Above your rank!</font></b> //HERE IS THE OTHER CODE
<?php }
else
{?>
<b><a id="<?php echo $route->id; ?>" class="addbid" href="<?php echo SITE_URL?>/action.php/Schedules/addbid/">Add to Bid</a></b>
<?php }?>
<br >
<a href="<?php echo SITE_URL?>/index.php/FrontSchedules">Create a New Search</a><br />
</td>
</tr>
<?php
/* END OF ONE TABLE ROW */
}
?>
</tbody>
</table>
<hr>
I changed
$result->id
to
$route->id;
because you couldn’t click the link to add the bid, it would just do nothing. No the text (ADD TO BID) is still there, it is just bold. All of my aircraft have rank restrictions for them, so not sure where I went wrong.
I have just stumbled across this and am also having trouble implementing it, i have fiddled with the php but cant seem to get it to work correctly, bidding on a flight for an aircraft ranked higher will simple continue to allow the bid to go through.
Just had a go at implementing the code you provided and it will still allow me to bid on an aircraft that is set for a higher rank that i currently am. I just took a look at my local.config.php file and there is no setting in there regarding the restriction of aircraft to ranks, so i may be missing that setting which is preventing it. Is there an actual setting for this in the local.config.php file ?