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();
     }
 }
 function SendMemberVerificationEmail($data, $form)
 {
     try {
         if (!isset($data['Email'])) {
             throw new EntityValidationException('Missing Email!');
         }
         $email = trim($data['Email']);
         $this->member_manager->resendEmailVerification($email, new MemberRegistrationSenderService());
         return $this->renderWith(array('MemberVerification_resendOK', 'Page'), array('Email' => $email));
     } 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 (NotFoundEntityException $ex2) {
         Form::messageForForm($form->FormName(), "There was an error with your request, please contact your admin.", 'bad');
         //Return back to form
         SS_Log::log($ex2->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();
     }
 }
Пример #3
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();
     }
 }
 public function VerifyMemberEmail(SS_HTTPRequest $request)
 {
     try {
         $token = Convert::raw2sql($this->request->param('TOKEN'));
         if (is_null($token)) {
             throw new EntityValidationException(array('missing token!'));
         }
         $member = $this->member_manager->verify($token, new MemberRegistrationVerifiedSenderService());
         return $this->renderWith(array('MemberVerification_verified', 'Page'), array('Member' => $member));
     } catch (NotFoundEntityException $ex1) {
         SS_Log::log($ex1, SS_Log::WARN);
         return $this->renderWith(array('MemberVerification_error', 'Page'));
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::ERR);
         return $this->renderWith(array('MemberVerification_error', 'Page'));
     }
 }
 function SaveProfile($data, $form)
 {
     //Check for a logged in member
     $CurrentMember = Member::currentUser();
     if (!$CurrentMember) {
         return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
     }
     //Check for another member with the same email address
     if (Member::get()->filter(array('Email' => Convert::raw2sql($data['Email']), 'ID:not' => $CurrentMember->ID))->count() > 0) {
         $form->addErrorMessage("Email", 'Sorry, that email address already exists.', "bad");
         Session::set("FormInfo.Form_EditProfileForm.data", $data);
         return $this->redirect($this->Link('?error=1'));
     }
     //Otherwise save profile
     // Clean up bio
     if ($data["Bio"]) {
         $config = HTMLPurifier_Config::createDefault();
         // Remove any CSS or inline styles
         $config->set('CSS.AllowedProperties', array());
         $purifier = new HTMLPurifier($config);
         $cleanedBio = $purifier->purify($data["Bio"]);
     }
     $form->saveInto($CurrentMember);
     if (isset($cleanedBio)) {
         $CurrentMember->Bio = $cleanedBio;
     }
     if ($data['Gender'] == 'Specify') {
         $CurrentMember->Gender = $data['GenderSpecify'];
     }
     $email_updated = $CurrentMember->isChanged('Email');
     $CurrentMember->write();
     $speaker = PresentationSpeaker::get()->filter('MemberID', $CurrentMember->ID)->first();
     if ($speaker) {
         if ($data['ReplaceName'] == 1) {
             $speaker->FirstName = $data['FirstName'];
         }
         if ($data['ReplaceSurname'] == 1) {
             $speaker->Surname = $data['Surname'];
         }
         if ($data['ReplaceBio'] == 1) {
             $speaker->Bio = $data['Bio'];
         }
         $speaker->write();
     }
     // If they do not have a photo uploaded, but they have provided a twitter URL, attempt to grab a photo from twitter
     if ($CurrentMember->TwitterName && !$CurrentMember->Photo()->Exists()) {
         $this->ProfilePhotoFromTwitter($CurrentMember);
     }
     if ($email_updated) {
         $this->member_manager->resetEmailVerification($CurrentMember, new MemberRegistrationSenderService());
     }
     return $this->redirect($this->Link('?saved=1'));
 }
Пример #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();
     }
 }