Mysterious Pilot Posted December 12, 2010 Report Share Posted December 12, 2010 Since I am not the developer nor I have the intention to start browsing through all the code I would like to make a consultation regarding the registration workflow. Currently a pilot registers and I believe a confirmation email is sent prior to activation of the account, right? I don't have yet any other hires so I don't know. I won't be open until Jan. 1st. My consultation is with regards to how to integrate alternate workflows without breaking phpVMS nor losing all my changes (and work) during the next upgrade process. The situation (and idea) is this: I don't want pilots to register and become immediately active at the lowest rank (many airlines do), I want quality hires even if that means less recruits. For that purpose I thought of seeing how I could do this without breaking the system (or losing my work). I want for example that candidates (not "new hires" yet) register into the system. This registration would actually have the same workflow as phpVMS currently has, the difference is that the ID assigned in this process would not be that of the airline (or airlines registered in the system schedules), for example TRA (Trainee). To these trainees I would assign 4 levels of ranking (different than pilot ranks). I want the pilot ranks used in the defined airlines to be automatic (based on the number of hours) but the ranking of trainees to be done manually. The trainees would go through a 3 or 4 phase process: - Application (get TRAxxxx account code and base rank) - Upon successful termination of a theoretical exam, the Trainee (TRAxxxx) is assigned the next trainee rank (not yet pilot). - Upon successful completion of an interview the trainee gets upped to the next phase - At last (but sometimes could be omitted) an in-flight examination. After completion of steps 3 or 4 (depending on how "strict" I want to be in the airline application process, the trainee's account is marked as free (for reasignment to another candidate or just leave unused until I reset the trainee pool) and the trainee becomes a "New Hire", in other words it is at this point that the trainee gets assigned an airline code (use an ID from the pool of defined airlines). This can be done either by the admin or by providing the graduated trainee with a link and a confirmation code to make his formal application into the ranks of new hires and start his career to attain promotion to new pilot ranks. Like I said, I would like to see if I can implement this but I don't want to break existing functionality, nor have to redo everything after phpVMS is upgraded. Nabeel, your input on this is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted December 12, 2010 Moderators Report Share Posted December 12, 2010 It seems as if you are wanting to use the system as it was not intended but as a add on to your existing setup? If I understand you right you can set ranks up with qualifying hours so when pilots join they can be assigned a rank based on their experience, you can choose pilots to become automatically active or you can have an admin approve the account its up to you. For validation you could setup XZY airline where all pilots would register to, you can also edit the registration form to remove the airline choice from the pilot and create multipul airlines and manually assign them upon completion of their exams etc. All these changes are simple and wont break on an update. 1 Quote Link to comment Share on other sites More sharing options...
Mysterious Pilot Posted December 12, 2010 Author Report Share Posted December 12, 2010 It seems as if you are wanting to use the system as it was not intended but as a add on to your existing setup? Nope, I am relying exclusively on phpVMS, not using anything else (other than myself of course). I am using it for what it was intended, perhaps I am pushing it to its limits. If I understand you right you can set ranks up with qualifying hours so when pilots join they can be assigned a rank based on their experience, you can choose pilots to become automatically active or you can have an admin approve the account its up to you. That I understand, have currently set it up for auto-active and disabled auto-approve. For validation you could setup XZY airline where all pilots would register to, you can also edit the registration form to remove the airline choice from the pilot and create multipul airlines and manually assign them upon completion of their exams etc. Thought about that myself but I don't know if manually editing the airline prefix (from TRA to say FSX) to assign them to the actual airline would cause referential integrity problems. Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted December 13, 2010 Moderators Report Share Posted December 13, 2010 OK i have a bit of time so here is what i have, when pilots register the selection of the dropdown is disabled all pilots go in to one airline. In your admin you need to create your three VA's from there you can assign pilots new numbers based on your criteria. The code for the registration form is, registration_mainform.tpl <h3>Registration</h3> <p>Welcome to the registration form for <?php echo SITE_NAME; ?>. After you register, you will be notified by a staff member about your membership.</p> <form method="post" action="<?php echo url('/registration');?>"> <dl> <dt>First Name: *</dt> <dd><input type="text" name="firstname" value="<?php echo Vars::POST('firstname');?>" /> <?php if($firstname_error == true) echo '<p class="error">Please enter your first name</p>'; ?> </dd> <dt>Last Name: *</dt> <dd><input type="text" name="lastname" value="<?php echo Vars::POST('lastname');?>" /> <?php if($lastname_error == true) echo '<p class="error">Please enter your last name</p>'; ?> </dd> <dt>Email Address: *</dt> <dd><input type="text" name="email" value="<?php echo Vars::POST('email');?>" /> <?php if($email_error == true) echo '<p class="error">Please enter your email address</p>'; ?> </dd> <dt>Hub: *</dt> <dd> <select name="hub" id="hub"> <?php foreach($allhubs as $hub) { echo '<option value="'.$hub->icao.'">'.$hub->icao.' - ' . $hub->name .'</option>'; } ?> </select> </dd> <dt>Location: *</dt> <dd><select name="location"> <?php foreach($countries as $countryCode=>$countryName) { if(Vars::POST('location') == $countryCode) $sel = 'selected="selected"'; else $sel = ''; echo '<option value="'.$countryCode.'" '.$sel.'>'.$countryName.'</option>'; } ?> </select> <?php if($location_error == true) echo '<p class="error">Please enter your location</p>'; ?> </dd> <dt>Password: *</dt> <dd><input id="password" type="password" name="password1" value="" /></dd> <dt>Enter your password again: *</dt> <dd><input type="password" name="password2" value="" /> <?php if($password_error != '') echo '<p class="error">'.$password_error.'</p>'; ?> </dd> <?php //Put this in a seperate template. Shows the Custom Fields for registration Template::Show('registration_customfields.tpl'); ?> <dt>ReCaptcha</dt> <dd> <script type="text/javascript"> var RecaptchaOptions = { theme : 'white' }; </script> <?php echo recaptcha_get_html(Config::Get('RECAPTCHA_PUBLIC_KEY'), $captcha_error); ?> </dd> <dt></dt> <dd><p>By clicking register, you're agreeing to the terms and conditions <a href="http://www.easyjetva.com/index.php/pages/terms" target="_blank">Here</a></p><p class="error">Please ensure you understand this is a virtual airline and we are not connected in any way<br />to easyJet or the easyJet group of companies.<br /><br />Registration is purely for Flight simulation use only.</p></dd> <dt></dt> <dd><input type="submit" name="submit" value="Register!" /></dd> </dl> </form> The other code you need to edit is in the core>modules>Registration <?php /** * phpVMS - Virtual Airline Administration Software * Copyright (c) 2008 Nabeel Shahzad * For more information, visit www.phpvms.net * Forums: http://www.phpvms.net/forum * Documentation: http://www.phpvms.net/docs * * phpVMS is licenced under the following license: * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/ * * @author Nabeel Shahzad * @copyright Copyright (c) 2008, Nabeel Shahzad * @link http://www.phpvms.net * @license http://creativecommons.org/licenses/by-nc-sa/3.0/ */ class Registration extends CodonModule { public function HTMLHead() { /*Show our password strength checker */ if($this->get->page == 'register') { $this->renderTemplate('registration_javascript.tpl'); } } public function index() { require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php'; if(Auth::LoggedIn()) // Make sure they don't over-ride it { $this->render('login_already.tpl'); return; } if(isset($_POST['submit'])) { $this->ProcessRegistration(); } else { $this->ShowForm(); } } protected function ShowForm() { $this->set('extrafields', RegistrationData::GetCustomFields()); $this->set('allairlines', OperationsData::GetAllAirlines(true)); $this->set('allhubs', OperationsData::GetAllHubs()); $this->set('countries', Countries::getAllCountries()); $this->render('registration_mainform.tpl'); } protected function ProcessRegistration() { // Yes, there was an error if(!$this->VerifyData()) { $this->ShowForm(); } else { $data = array( 'firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'password' => $this->post->password1, 'code' => 'ABC', //"PUT YOUR AIRLINE CODE IN HERE, Replace ABC" 'location' => $this->post->location, 'hub' => $this->post->hub, 'confirm' => false ); if(CodonEvent::Dispatch('registration_precomplete', 'Registration', $_POST) == false) { return false; } $ret = RegistrationData::CheckUserEmail($data['email']); if($ret) { $this->set('error', Lang::gs('email.inuse')); $this->render('registration_error.tpl'); return false; } $val = RegistrationData::AddUser($data); if($val == false) { $this->set('error', RegistrationData::$error); $this->render('registration_error.tpl'); return; } else { $pilotid = RegistrationData::$pilotid; /* Automatically confirm them if that option is set */ if(Config::Get('PILOT_AUTO_CONFIRM') == true) { PilotData::AcceptPilot($pilotid); RanksData::CalculatePilotRanks(); $pilot = PilotData::GetPilotData($pilotid); $this->set('pilot', $pilot); $this->render('registration_autoconfirm.tpl'); } /* Otherwise, wait until an admin confirms the registration */ else { RegistrationData::SendEmailConfirm($email, $firstname, $lastname); $this->render('registration_sentconfirmation.tpl'); } } CodonEvent::Dispatch('registration_complete', 'Registration', $_POST); // Registration email/show user is waiting for confirmation $sub = 'A user has registered'; $message = "The user {$data['firstname']} {$data['lastname']} ({$data['email']}) has registered, and is awaiting confirmation."; $email = Config::Get('EMAIL_NEW_REGISTRATION'); if(empty($email)) { $email = ADMIN_EMAIL; } Util::SendEmail($email, $sub, $message); // Send email to user $this->set('firstname', $data['firstname']); $this->set('lastname', $data['lastname']); $this->set('userinfo', $data); $message = Template::Get('email_registered.tpl', true); Util::SendEmail($data['email'], 'Registration at '.SITE_NAME, $message); $rss = new RSSFeed('Latest Pilot Registrations', SITE_URL, 'The latest pilot registrations'); $allpilots = PilotData::GetLatestPilots(); foreach($allpilots as $pilot) { $rss->AddItem('Pilot '.PilotData::GetPilotCode($pilot->code, $pilot->pilotid) . ' ('.$pilot->firstname .' ' . $pilot->lastname.')', SITE_URL.'/admin/index.php?admin=pendingpilots','',''); } $rss->BuildFeed(LIB_PATH.'/rss/latestpilots.rss'); } } /* * Process all the registration data */ protected function VerifyData() { $error = false; $resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if(!$resp->is_valid) { $error = true; $this->set('captcha_error', $resp->error); } else $this->set('captcha_error', ''); /* Check the firstname and last name */ if($this->post->firstname == '') { $error = true; $this->set('firstname_error', true); } else $this->set('firstname_error', ''); /* Check the last name */ if($this->post->lastname == '') { $error = true; $this->set('lastname_error', true); } else $this->set('lastname_error', ''); /* Check the email address */ if(filter_var($this->post->email, FILTER_VALIDATE_EMAIL) == false) { $error = true; $this->set('email_error', true); } else $this->set('email_error', ''); /* Check the location */ if($this->post->location == '') { $error = true; $this->set('location_error', true); } else $this->set('location_error', ''); // Check password length if(strlen($this->post->password1) <= 5) { $error = true; $this->set('password_error', 'The password is too short!'); } else $this->set('password_error', ''); // Check is passwords are the same if($this->post->password1 != $this->post->password2) { $error = true; $this->set('password_error', 'The passwords do not match!'); } else $this->set('password_error', ''); /* Check if they agreed to the statement if(!$_POST['agree']) { $error = true; $this->set('agree_error', true); } else $this->set('agree_error', ''); */ if($error == true) { return false; } return true; } } You will need to place this is a skins folder, if your using the default skin then just copy all the files to a new folder and edit them from with in there, plus don't forget to rename the folder and select is in the admin section of the site. Quote Link to comment Share on other sites More sharing options...
Mysterious Pilot Posted December 13, 2010 Author Report Share Posted December 13, 2010 Thanks a milllion mark1million, my workflow can be automated just a bit more but that irons out a lot of the nitty gritty phpVMS details that I would have probably broken in the process :-) Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted December 13, 2010 Administrators Report Share Posted December 13, 2010 You can code a module, and use a post-registration hook to change any details: http://forum.phpvms.net/page/index.html?record=28 Also, using the API, and not directly editing the database, will make sure there are no integrity issues: http://docs.phpvms.net/api/ Quote Link to comment Share on other sites More sharing options...
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.