OA01 Posted June 23, 2013 Report Posted June 23, 2013 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? Quote
Moderators Parkho Posted June 23, 2013 Moderators Report Posted June 23, 2013 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! 1 Quote
OA01 Posted June 23, 2013 Author Report Posted June 23, 2013 Simple when you know how Thank you sir, you're a gentleman Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.