Esempio n. 1
0
 /**
  * Create a new application
  * @param string $programShortName
  * @param string $cycleName
  * @return null
  */
 public function actionNew()
 {
     if ($this->_application->isByInvitationOnly()) {
         $this->addMessage('error', 'This application is by invitation only.  You cannot create an account.');
         $this->redirectApplyPath('');
     }
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->applyPath('applicant/new'));
     $field = new \Foundation\Form\Field($form);
     $field->setLegend('Create New Application');
     $form->addField($field);
     $element = $field->newElement('TextInput', 'first');
     $element->setLabel('First Name');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('TextInput', 'middle');
     $element->setLabel('Middle Name');
     $element = $field->newElement('TextInput', 'last');
     $element->setLabel('Last Name');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('TextInput', 'suffix');
     $element->setLabel('Suffix');
     $element->setFormat('Example: Jr., III');
     $element = $field->newElement('TextInput', 'email');
     $element->setLabel('Email Address');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addValidator(new \Foundation\Form\Validator\EmailAddress($element));
     $element->addFilter(new \Foundation\Form\Filter\Lowercase($element));
     $element = $field->newElement('PasswordInput', 'password');
     $element->setLabel('Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('PasswordInput', 'confirm-password');
     $element->setLabel('Confirm Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addValidator(new \Foundation\Form\Validator\SameAs($element, 'password'));
     if ($this->_config->getRecaptchaPrivateKey()) {
         //setup recaptcha element keys
         \Foundation\Form\Element\Captcha::setKeys($this->_config->getRecaptchaPrivateKey(), $this->_config->getRecaptchaPublicKey());
         $element = $field->newElement('Captcha', 'captcha');
     }
     $form->newButton('submit', 'Create Account');
     if ($input = $form->processInput($this->post)) {
         $duplicate = $this->_em->getRepository('Jazzee\\Entity\\Applicant')->findOneByEmailAndApplication($input->get('email'), $this->_application);
         if ($duplicate) {
             $this->addMessage('error', 'You have already started a ' . $this->_application->getProgram()->getName() . ' application.  Please login to retrieve it.');
             $this->redirectApplyPath('applicant/login');
         }
         $applicant = new \Jazzee\Entity\Applicant();
         $applicant->setApplication($this->_application);
         $applicant->setEmail($input->get('email'));
         $applicant->setPassword($input->get('password'));
         $applicant->setFirstName($input->get('first'));
         $applicant->setMiddleName($input->get('middle'));
         $applicant->setLastName($input->get('last'));
         $applicant->setSuffix($input->get('suffix'));
         $applicant->login();
         $this->_em->persist($applicant);
         //flush here to get the ID
         $this->_em->flush();
         $this->_store->expire();
         $this->_store->touchAuthentication();
         $this->_store->applicantID = $applicant->getId();
         $this->_authLog->info('New account login for applicant ' . $applicant->getId() . ' from ' . $_SERVER['REMOTE_ADDR']);
         $this->addMessage('success', 'Welcome to the ' . $this->_application->getProgram()->getName() . ' application.');
         $this->redirectApplyFirstPage();
     }
     $this->setVar('form', $form);
     if ($this->_config->getLoginMessage()) {
         $this->addMessage('error', $this->_config->getLoginMessage());
     }
 }
Esempio n. 2
0
 /**
  * Change applicant password
  */
 public function actionChangePassword()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->applyPath('account/changePassword'));
     $field = new \Foundation\Form\Field($form);
     $field->setLegend('Change Password');
     $form->addField($field);
     $element = $field->newElement('PasswordInput', 'password');
     $element->setLabel('Current Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('PasswordInput', 'newpassword');
     $element->setLabel('New Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('PasswordInput', 'confirm');
     $element->setLabel('Confirm Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addValidator(new \Foundation\Form\Validator\SameAs($element, 'newpassword'));
     $form->newButton('submit', 'Change Password');
     if ($input = $form->processInput($this->post)) {
         if ($this->_applicant->checkPassword($input->get('password'))) {
             $this->_applicant->setPassword($input->get('newpassword'));
             $this->_em->persist($this->_applicant);
             $this->addMessage('success', 'Your password was changed successfully.');
             $this->redirectApplyPath('account');
         } else {
             $form->getElementByName('password')->addMessage('Password Incorrect');
         }
     }
     $this->setVar('form', $form);
     $this->loadView($this->controllerName . '/form');
 }
Esempio n. 3
0
 public function testGetForm()
 {
     $form = $this->getMock('\\Foundation\\Form');
     $field = new \Foundation\Form\Field($form);
     $this->assertSame($form, $field->getForm());
 }