コード例 #1
0
ファイル: Registration.php プロジェクト: phpmods/phpvms_5.5.x
 /**
  * Registration::ProcessRegistration()
  *
  * @return
  */
 protected function ProcessRegistration()
 {
     // Yes, there was an error
     if (!$this->VerifyData()) {
         $this->ShowForm();
         return;
     }
     $data = array('firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'password' => $this->post->password1, 'code' => $this->post->code, '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');
         } else {
             /* Otherwise, wait until an admin confirms the registration */
             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');
     $pilot_list = PilotData::GetLatestPilots();
     foreach ($pilot_list 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');
 }
コード例 #2
0
 function testRegisterUser()
 {
     $firstname = 'Nabeel';
     $lastname = 'Shahzad';
     $email = '*****@*****.**';
     $code = 'VMS';
     $location = 'US';
     $hub = 'KJFK';
     $password = '******';
     $data = RegistrationData::AddUser($firstname, $lastname, $email, $code, $location, $hub, $password);
     $this->pilotid = DB::$insert_id;
     # See if it was written
     $this->pilot_data = PilotData::GetPilotData($this->pilotid);
     $this->assertTrue($this->pilot_data);
     echo '<br />';
     unset($data);
 }
コード例 #3
0
 public static function SiteSetup()
 {
     /*$_POST['SITE_NAME'] == '' || $_POST['firstname'] == '' || $_POST['lastname'] == ''
     		|| $_POST['email'] == '' ||  $_POST['password'] == '' || $_POST['vaname'] == ''
     		|| $_POST['vacode'] == ''*/
     // first add the airline
     $_POST['vacode'] = strtoupper($_POST['vacode']);
     if (!OperationsData::AddAirline($_POST['vacode'], $_POST['vaname'])) {
         self::$error = DB::$error;
         return false;
     }
     // Add an initial airport/hub, because I love KJFK so much
     $data = array('icao' => 'KJFK', 'name' => 'Kennedy International', 'country' => 'USA', 'lat' => '40.6398', 'lng' => '-73.7787', 'hub' => false, 'fuelprice' => 0);
     $ret = OperationsData::AddAirport($data);
     // Add the user
     $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], l, 'password' => $_POST['password'], 'code' => $_POST['vacode'], 'location' => 'US', 'hub' => 'KJFK', 'confirm' => true);
     if (!RegistrationData::AddUser($data)) {
         self::$error = DB::$error;
         return false;
     }
     // Add a rank
     RanksData::updateRank(1, 'New Hire', 0, fileurl('/lib/images/ranks/newhire.jpg'), 18.0);
     # Add to admin group
     $pilotdata = PilotData::GetPilotByEmail($_POST['email']);
     if (!PilotGroups::AddUsertoGroup($pilotdata->pilotid, 'Administrators')) {
         self::$error = DB::$error;
         return false;
     }
     # Add the final settings in
     SettingsData::SaveSetting('SITE_NAME', $_POST['SITE_NAME']);
     SettingsData::SaveSetting('ADMIN_EMAIL', $_POST['email']);
     SettingsData::SaveSetting('GOOGLE_KEY', $_POST['googlekey']);
     return true;
 }