Jump to content

Help for hub move option


OA01

Recommended Posts

Hi all.

I would like to give pilots the option to move hubs from the pilot centre>Edit My Profile, Email and Avatar page. (profile_edit.tpl).

If someone could help me with the required code, I would be very grateful?

Link to comment
Share on other sites

  • Moderators

Follow these steps:

1. Open "profile_edit.tpl" and add the following code at the end:

<dt>Hub:</dt>
<dd>
 <select name="hub">
 <?php
 $allhubs = OperationsData::GetAllHubs();
 foreach($allhubs as $hub)
  {
   if($pilotinfo->hub == $hub->icao)
   $sel = ' selected';
   else
   $sel = '';
  echo '<option value="'.$hub->icao.'" '.$sel.'>'.$hub->icao.' - ' . $hub->name .'</option>';
  }
 ?>    
</select>
</dd>

2. Open "profile.php" in core/modules/profile and change the following:

protected function save_profile_post()
   {
       if(!Auth::LoggedIn()) {
           $this->set('message', 'You must be logged in to access this feature!');
           $this->render('core_error.tpl');
           return;
       }

       $pilot = Auth::$pilot;

       //TODO: check email validity
       if($this->post->email == '') {
           return;
       }

       $params = array(
           'code' => $pilot->code,
           'email' => $this->post->email,
           'location' => $this->post->location,
           'hub' => $pilot->hub,
           'bgimage' => $this->post->bgimage,
           'retired' => false
       );

       PilotData::updateProfile($pilot->pilotid, $params);
       PilotData::SaveFields($pilot->pilotid, $_POST);

       # Generate a fresh signature
       PilotData::GenerateSignature($pilot->pilotid);

       PilotData::SaveAvatar($pilot->code, $pilot->pilotid, $_FILES);

       $this->set('message', 'Profile saved!');
       $this->render('core_success.tpl');
   }

To this:

protected function save_profile_post()
   {
       if(!Auth::LoggedIn()) {
           $this->set('message', 'You must be logged in to access this feature!');
           $this->render('core_error.tpl');
           return;
       }

       $pilot = Auth::$pilot;

       //TODO: check email validity
       if($this->post->email == '') {
           return;
       }

       $params = array(
           'code' => $pilot->code,
           'email' => $this->post->email,
           'location' => $this->post->location,
           'hub' => $this->post->hub,
           'bgimage' => $this->post->bgimage,
           'retired' => false
       );

       PilotData::updateProfile($pilot->pilotid, $params);
       PilotData::SaveFields($pilot->pilotid, $_POST);

       # Generate a fresh signature
       PilotData::GenerateSignature($pilot->pilotid);

       PilotData::SaveAvatar($pilot->code, $pilot->pilotid, $_FILES);

       $this->set('message', 'Profile saved!');
       $this->render('core_success.tpl');
   }

3. Done! :D

  • Like 1
Link to comment
Share on other sites

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