Restirct Aircraft Available By Rank

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?

Thanks in advance!

Cory

Try the stock schedules viewer and see if that works with the rank restrictions, that would be a start to narrowing down the problem

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

That’s a good idea

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.

Any help would be great

Tylor

Any one to assist?

This was the pain in the butt for me as well. But I have got though it and made it work.

I’ll find the code for it and share it here

This should work, put in schedule_results.tpl

<?php
if(Auth::LoggedIn())
{
if($route->aircraftlevel > Auth::$userinfo->ranklevel)
{
?>
<b><font color="#FF0000">Above your rank!</font></b>
<?php
}
else
{
?>
<a id="<?php echo $route->id; ?>" class="addbid" href="<?php echo url('/schedules/addbid');?>">Add to Bid</a>
<?php  
}
}
?>

G’day Kyle,

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 ?

Thanks for digging up the code mate

Tylor

I think that the aircraft rank level restriction is part of the stable version.

Look in the app.config.php and it should be there.

This is what should be in your local.config.php

Config::Set('RESTRICT_AIRCRAFT_RANKS', true);

i didnt have that for some reason, i added it into my local.config.php and still no luck, it will still let me bid on those aircraft.

I’m running version 2.1.934

I’m not sure what’s going on but any help would be appreciated

Regards

Tylor

1 Like

I’m having the same problem, the rank keeps getting ignored, meaning any aircraft is bookable

I had a look at Kyle’s Code for the schedule_results.tpl but that actually confuses me more than it helps, i got no idea where to put it

I’ve edited the schedule_results.tpl before - i’m using Front Schedule.

I’d appreciate any help or suggestion how to actually make the ranks work

<?php
if(!$allroutes)
{
echo '<p align="center">No routes have been found!</p>';
return;
}
?>
<table id="tabledlist" class="tablesorter">
<thead>
<tr>
<th>Flight Info</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<?php
foreach($allroutes as $route)
{



/* THIS BEGINS ONE TABLE ROW */
?>
<tr>
<td>
 <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: </strong>'.$route->route.'<br />' ?>
 <?php echo ($route->notes=='') ? '' : '<strong>Notes: </strong>'.html_entity_decode($route->notes).'<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>
<?php if(!Auth::LoggedIn()) {echo 'Restricted Access';}
else {?>
<a href="<?php echo url('/schedules/brief/'.$route->id);?>">Pilot Brief</a><br/>
		    <?php if(Auth::LoggedIn())
				    {
						    if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn())
				    {
				    if($route->ranklevel > Auth::$userinfo->rankid)
				    {
				    continue;
				    }
		    }	  
    $route->daysofweek = str_replace('7', '0', $route->daysofweek);

    if(strpos($route->daysofweek, date('w')) === false)
		    continue;
    if(Auth::LoggedIn())
    {
		    $search = array(
				    'p.pilotid' => Auth::$userinfo->pilotid,
				    'p.accepted' => PIREP_ACCEPTED
		    );

		    $reports = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED);

		    if(is_object($reports))
		    {
				    # IF the arrival airport doesn't match the departure airport
				    if($reports->arricao != $route->depicao)
				    {
						    continue;
				    }
		    }
		    if(!$reports)
		    {
				    if (Auth::$userinfo->hub != $route->depicao)
				    {
				    continue;
				    }
		    }
    }
					 ?>
						    <a id="<?php echo $route->id; ?>" class="addbid"
								    href="<?php echo url('/schedules/addbid');?>"><strong>Book Flight</strong></a>
<?php }?>
    </td>
</tr>
<?php
/* END OF ONE TABLE ROW */
}}
?>
</tbody>
</table>
<hr>

Change this:

if(Auth::LoggedIn())
{
if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn())
{
if($route->ranklevel > Auth::$userinfo->rankid)
{
continue;
}

To this:

if(Auth::LoggedIn())
{
if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn())
{
if($route->aircraftlevel> Auth::$userinfo->rankid)//$route->ranklevel is changed to $route->aircraftlevel.
{
continue;
}

And that should resolve the issue.

Thank you for helping, but that didn’t change anything - even the default booking page doens’t work the way it should work

Do you have the following added to your local.config.php? If not you need to add that.

Config::Set('RESTRICT_AIRCRAFT_RANKS', true);

Yeap - i’ve checked that before, it was mentioned in the FrontSchedules thread.

Here is another approach:

if(Auth::LoggedIn())
{
if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn())
{
$aircraft = OperationsData::getAircraftByReg($route->registration);
$pilotrank = Auth::$userinfo->ranklevel;
$aircraftrank = $aircraft->ranklevel;

if($aircraftrank > $pilotrank)
{
continue;
}

And make sure you have set the aircraft ranking higher than your pilot ranking to see if it works.

Wuhu - Perfect

Thank you so much - really appreciate your help

// Is there a simple way to show some text ( _=_Sorry rank too low) instead of the (now not displayed) “Add Bid” Link ?