function StartSurvey($data, $form)
 {
     try {
         $data = SQLDataCleaner::clean($data);
         $data['MembershipType'] = 'community';
         Session::set("FormInfo.{$form->FormName()}.data", $data);
         $profile_page = EditProfilePage::get()->first();
         $member = $this->member_manager->registerMobile($data, new MemberRegistrationSenderService());
         //Get profile page
         if (!is_null($profile_page)) {
             //Redirect to profile page with success message
             Session::clear("FormInfo.{$form->FormName()}.data");
             $request = Controller::curr()->getRequest();
             $back_url = $request->postVar('BackURL');
             $link = $profile_page->Link('?success=1');
             if (!empty($back_url)) {
                 $link .= "&BackURL=" . $back_url;
             }
             return OpenStackIdCommon::loginMember($member, $link);
         }
     } catch (EntityValidationException $ex1) {
         Form::messageForForm($form->FormName(), $ex1->getMessage(), 'bad');
         //Return back to form
         SS_Log::log($ex1->getMessage(), SS_Log::WARN);
         return Controller::curr()->redirectBack();
     } catch (Exception $ex) {
         Form::messageForForm($form->FormName(), "There was an error with your request, please contact your admin.", 'bad');
         //Return back to form
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return Controller::curr()->redirectBack();
     }
 }
Exemplo n.º 2
0
 function doRegister($data, $form)
 {
     if (!isset($data["Affiliations"]) || empty($data["Affiliations"])) {
         //Set error message
         $form->AddErrorMessage('Affiliations', "Sorry, You must at least enter one valid Affiliation.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_RegistrationForm.data", $data);
         //Return back to form
         return $this->redirectBack();
     }
     $new_affiliations = json_decode($data["Affiliations"]);
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_RegistrationForm.data", $data);
         //Return back to form
         return $this->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     if (isset($data['Gender'])) {
         $Gender = $data['Gender'];
         if ($Gender != 'Male' && $Gender != 'Female' && $Gender != 'Prefer not to say') {
             $Member->Gender = Convert::raw2sql($data['GenderSpecify']);
         }
     }
     $Member->write();
     if ($data['MembershipType'] == 'foundation') {
         $Member->upgradeToFoundationMember();
     } else {
         $Member->convert2SiteUser();
     }
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'users')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     foreach ($new_affiliations as $key => $newAffiliation) {
         $dbAffiliation = new Affiliation();
         $org_name = Convert::raw2sql($newAffiliation->OrgName);
         $org_name = trim($org_name);
         AffiliationController::Save($dbAffiliation, $newAffiliation, $org_name, $Member);
     }
     PublisherSubscriberManager::getInstance()->publish('new_user_registered', array($Member->ID));
     //Get profile page
     if ($ProfilePage = EditProfilePage::get()->first()) {
         //send Thank you email
         $config = SiteConfig::current_site_config();
         if ($config->RegistrationSendMail && !empty($config->RegistrationFromMessage) && !empty($config->RegistrationSubjectMessage) && !empty($config->RegistrationHTMLMessage) && !empty($config->RegistrationPlainTextMessage)) {
             $registration_email = new CustomEmail($config->RegistrationFromMessage, $Member->Email, $data['MembershipType'] == 'foundation' ? 'Thank you for becoming an OpenStack Foundation Member' : 'Thank you for becoming an OpenStack Community Member', $config->RegistrationHTMLMessage, $config->RegistrationPlainTextMessage);
             $registration_email->send();
         }
         //Redirect to profile page with success message
         return OpenStackIdCommon::loginMember($member, $ProfilePage->Link('?success=1'));
     }
 }
 public function getProfileAttendeeRegistrationLink()
 {
     $page = EditProfilePage::get()->first();
     if (!$page) {
         return '#';
     }
     return $page->Link("attendeeInfoRegistration");
 }
Exemplo n.º 4
0
 function doRegister($data, $form)
 {
     try {
         $data = SQLDataCleaner::clean($data, $non_check_keys = array('HiddenAffiliations'));
         Session::set("FormInfo.{$form->FormName()}.data", $data);
         $profile_page = EditProfilePage::get()->first();
         $member = $this->member_manager->register($data, $profile_page, new MemberRegistrationSenderService());
         //Get profile page
         if (!is_null($profile_page)) {
             //Redirect to profile page with success message
             Session::clear("FormInfo.{$form->FormName()}.data");
             return OpenStackIdCommon::loginMember($member, $profile_page->Link('?success=1'));
         }
     } catch (EntityValidationException $ex1) {
         Form::messageForForm('HoneyPotForm_RegistrationForm', $ex1->getMessage(), 'bad');
         //Return back to form
         SS_Log::log($ex1->getMessage(), SS_Log::ERR);
         return $this->redirectBack();
     } catch (Exception $ex) {
         Form::messageForForm('HoneyPotForm_RegistrationForm', "There was an error with your request, please contact your admin.", 'bad');
         //Return back to form
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->redirectBack();
     }
 }
Exemplo n.º 5
0
 function Link()
 {
     if ($ProfilePage = EditProfilePage::get()->first()) {
         return $ProfilePage->Link();
     }
 }
Exemplo n.º 6
0
 /**
  * Handles the registration. Validates and creates the member, then redirects
  * to the appropriate place
  *  
  * @param  array $data
  * @param  BootstrapForm $form
  * @return SSViewer
  */
 public function doRegister($data, $form)
 {
     try {
         $back_url = Session::get('BackURL');
         Session::set("FormInfo.{$form->getName()}.data", $data);
         $data = SQLDataCleaner::clean($data);
         $profile_page = EditProfilePage::get()->first();
         $speaker_registration_token = Session::get(SpeakerRegistrationRequest::ConfirmationTokenParamName);
         if (!empty($speaker_registration_token)) {
             $data[SpeakerRegistrationRequest::ConfirmationTokenParamName] = $speaker_registration_token;
         }
         $member = $this->member_manager->registerSpeaker($data, new MemberRegistrationSenderService());
         //Get profile page
         if (!is_null($profile_page)) {
             //Redirect to profile page with success message
             Session::clear("FormInfo.{$form->FormName()}.data");
             if ($back_url) {
                 $redirect = HTTP::setGetVar('welcome', 1, $back_url);
                 return OpenStackIdCommon::loginMember($member, $redirect);
             }
             $form->sessionMessage('Awesome! You should receive an email shortly.', 'good');
             Session::clear(SpeakerRegistrationRequest::ConfirmationTokenParamName);
             Session::clear('BackURL');
             return OpenStackIdCommon::loginMember($member, $this->redirectBackUrl());
         }
     } catch (EntityValidationException $ex1) {
         Form::messageForForm($form->FormName(), $ex1->getMessage(), 'bad');
         //Return back to form
         SS_Log::log($ex1->getMessage(), SS_Log::WARN);
         return $this->redirectBack();
     } catch (Exception $ex) {
         Form::messageForForm($form->FormName(), "There was an error with your request, please contact your admin.", 'bad');
         //Return back to form
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->redirectBack();
     }
 }