Jump to content

Recommended Posts

Posted

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

  • Administrators
Posted

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

Posted

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 :D

Guest lorathon
Posted

Even though I was given undue credit in the first post :D 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

post-451-029157300 1275702785_thumb.jpg

Posted

Even though I was given undue credit in the first post :D 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?

Guest lorathon
Posted

This is what I use in my customized search results page

at the top. This gets the pilot information of the searching pilot

<?php
$pilotid = Auth::PilotID();
$user = PilotData::getPilotData($pilotid);
?>

In the loop to display the schedule at the bottom is the code to add bid. I replaced it with the following.

<?php
if ($info->ranklevel > $user->ranklevel)
{?>
   <td align = "center"><b><font color="#FF0000">Above your rank!</font></b></td>
<?php	}
else
{?>					
   <td align = "center"><b><a id="<?php echo $result->id; ?>" class="addbid" href="<?php echo SITE_URL?>/action.php/Schedules/addbid/">Add to Bid</a></b></td>
<?php 	}?>

  • 11 months later...
Posted

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.

  • 1 year later...
Posted

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

  • Moderators
Posted

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

  • Moderators
Posted

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  
}
}
?>

Posted

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

  • Moderators
Posted

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);

Posted

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

  • Like 1
  • 7 months later...
Posted

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

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 :lol:

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 :rolleyes:

<?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>

  • Moderators
Posted

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. :D

  • Moderators
Posted

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

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

  • Moderators
Posted

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. :D

Posted

Wuhu - Perfect :D

Thank you so much - really appreciate your help :D

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

  • Moderators
Posted

gr8 :D yw

Wuhu - Perfect :D

Thank you so much - really appreciate your help :D

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

Yes, But you'll need to apply this inside the <td> tag that contains the "Add Bid" link. If you paste that part I can apply it for you. ;)

Posted

So that would be somewhere in here ?

<a id="<?php echo $route->id; ?>" class="addbid"
								    href="<?php echo url('/schedules/addbid');?>"><strong>Book Flight</strong></a>
<?php }?>
    </td>

  • Moderators
Posted

Here it is:

<?php
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)
                   {
                       echo 'Sorry rank too low!';
                   }
               else
                   {    
?>
                       <a id="<?php echo $route->id; ?>" class="addbid" href="<?php echo url('/schedules/addbid');?>"><strong>Book Flight</strong></a>
<?php
                   }
?>

Posted

I'm not sure why, but i don't quite get it :unsure:

This is what my .tpl says, beginning from "if aircraftrank > pilotrank"

Doesn't it say -> if the aircraftrank is higher than your rank then continue (ignore the rank) ?

if($aircraftrank > $pilotrank)
{
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>

But then your lines

if($aircraftrank > $pilotrank)
								 {
										 echo 'Sorry rank too low!';
								 }
						 else
								 {	

say if the aircraftrank is higher than your rank, show "Sorry rank too low"

If not, then go on ?

I tried putting in your code, but i messed up somewhere as i only get a syntax error - "unexpected end blabla" :lol:

  • 10 months later...
Posted

Hi at all,

i have want made a restriction not by Rank but by Rating, but all what i do would fail didnt know what i can do!!! anyone here, they want help me to fix that iam a total noob and dont really know what iam doing :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...