/** Init the form
  * @return void
  * @access public
  */
 public function init()
 {
     $this->setMethod('post')->setAttrib('id', 'resetpassword');
     $username = $this->addElement('Text', 'username', array('label' => 'Username: '******'username')->setRequired(true)->addErrorMessage('You must enter a username')->addFilters(array('StringTrim', 'StripTags', 'Purifier'))->addValidator('Db_RecordExists', false, array('table' => 'users', 'field' => 'username'));
     $activationKey = $this->addElement('Text', 'activationKey', array('label' => 'Reset password key'));
     $activationKey = $this->getElement('activationKey')->setDescription('The reset key can be found in the email you ' . 'received when asking for a new password. ' . 'Check your spam filter')->setRequired(true)->addErrorMessage('You must enter a reset key')->addFilters(array('StringTrim', 'StripTags', 'Purifier'))->addValidator('Db_RecordExists', false, array('table' => 'users', 'field' => 'activationKey'));
     $password = $this->addElement('Text', 'password', array('label' => 'New password'));
     $password = $this->getElement('password')->setRequired(true)->setDescription('Password must be longer than 6 characters
                 and must include letters and numbers i.e. p4ssw0rd')->addFilters(array('StringTrim', 'StripTags', 'Purifier'))->addValidator('StringLength', true, array(6))->addValidator('Regex', true, array('/^(?=.*\\d)(?=.*[a-zA-Z]).{6,}$/'))->setRequired(true)->addErrorMessage('Please enter a valid password!');
     $password->getValidator('StringLength')->setMessage('Password is too short');
     $password->getValidator('Regex')->setMessage('Password does not contain letters and numbers');
     $email = $this->addElement('Text', 'email', array('label' => 'Email Address: ', 'size' => '30'))->email;
     $email->addValidator('EmailAddress')->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('Please enter a valid address!')->addValidator('Db_RecordExists', false, array('table' => 'users', 'field' => 'email'));
     $hash = new Zend_Form_Element_Hash('csrf');
     $hash->setValue($this->_salt)->setTimeout(4800);
     $this->addElement($hash);
     $recaptcha = new Zend_Service_ReCaptcha($this->_pubKey, $this->_privateKey);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => 'ReCaptcha', 'label' => 'Prove you are not a robot/spammer', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha, 'theme' => 'clean', 'ssl' => true)));
     $captcha->setDescription('Due to the surge in robotic activity, we have
         had to introduce this software. However, by filling in this captcha, 
         you help Carnegie Mellon University digitise old books.');
     $captcha->setDecorators(array(array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li'))));
     $captcha->addErrorMessage('You have not solved the captcha');
     $this->addElement($captcha);
     $submit = $this->addElement('submit', 'submit');
     $submit = $this->getElement('submit')->setLabel('Change my password');
     $this->addDisplayGroup(array('username', 'email', 'password', 'activationKey', 'captcha', 'submit'), 'details');
     $this->setLegend('Reset my password: ');
     parent::init();
 }
Example #2
0
 public function init()
 {
     $this->setAction($this->_actionUrl)->setMethod('post')->setAttrib('id', 'registerform');
     $this->addElementPrefixPath('Pas_Validate', 'Pas/Validate/', 'validate');
     $this->addPrefixPath('Pas_Form_Element', 'Pas/Form/Element/', 'element');
     $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'li')));
     $this->addElement('rawText', 'text1', array('value' => '<p class="info">By registering you agree to these <a href="#toc" rel="facebox">terms and conditions</a> of the database.</p>'));
     $username = $this->addElement('Text', 'username', array('label' => 'Username'))->username;
     $username = $this->getElement('username')->addValidator('UsernameUnique', true, array('id', 'username', 'id', 'Users'))->addValidator('StringLength', true, array(4))->addValidator('Alnum', false, array('allowWhiteSpace' => false))->setRequired(true)->addFilters(array('StringToLower', 'StringTrim', 'StripTags'))->addValidator('Db_NoRecordExists', false, array('table' => 'users', 'field' => 'username'))->setDescription('Username must be more than 3 characters and include only letters and numbers');
     $username->getValidator('Alnum')->setMessage('Your username must be letters and digits only');
     $username->setDecorators($decorators);
     $password = $this->addElement('Password', 'password', array('label' => 'Password'))->password;
     $password->setDescription('Password must be longer than 6 characters and must include 
 letters and numbers i.e. p4ssw0rd')->addValidator('StringLength', true, array(6))->addValidator('Regex', true, array('/^(?=.*\\d)(?=.*[a-zA-Z]).{6,}$/'))->setRequired(true)->addErrorMessage('Please enter a valid password!');
     $password->getValidator('StringLength')->setMessage('Password is too short');
     $password->getValidator('Regex')->setMessage('Password does not contain letters and numbers');
     $password->setDecorators($decorators);
     $firstName = $this->addElement('Text', 'first_name', array('label' => 'First Name', 'size' => '30'))->first_name;
     $firstName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a firstname');
     $firstName->setDecorators($decorators);
     $lastName = $this->addElement('Text', 'last_name', array('label' => 'Last Name', 'size' => '30'))->last_name;
     $lastName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a surname');
     $lastName->setDecorators($decorators);
     $preferredName = $this->addElement('Text', 'preferred_name', array('label' => 'Preferred Name', 'size' => '30'))->preferred_name;
     $preferredName->setDescription('e.g. Joe Brown rather than Joseph Brown')->setRequired(true)->addFilters(array('StringToLower', 'StringTrim', 'StripTags'))->addErrorMessage('You must enter your preferred name');
     $preferredName->setDecorators($decorators);
     $email = $this->addElement('Text', 'email', array('label' => 'Email Address', 'size' => '30'))->email;
     $email->addValidator('EmailAddress', false, array('mx' => true))->setRequired(true)->addFilters(array('StringToLower', 'StringTrim', 'StripTags'))->addValidator('Db_NoRecordExists', false, array('table' => 'users', 'field' => 'email'));
     $email->setDecorators($decorators);
     $hash = new Zend_Form_Element_Hash('csrf');
     $hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(4800);
     $this->addElement($hash);
     $privateKey = $config->recaptcha->privatekey;
     $pubKey = $config->recaptcha->pubkey;
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => 'ReCaptcha', 'label' => 'Prove you are not a robot by completing this.', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'privKey' => $this->_config->webservice->recaptcha->privatekey, 'pubKey' => $this->_config->webservice->recaptcha->pubkey, 'theme' => 'clean')));
     $captcha->setDescription('Due to the surge in robotic activity, we have 
     had to introduce this software. However, by filling in this captcha, you help Carnegie Mellon University digitise old books.');
     $captcha->setDecorators(array(array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li'))));
     $captcha->addErrorMessage('You have not solved the captcha');
     $this->addElement($captcha);
     //Submit button
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton')->setAttrib('class', 'large')->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setLabel('Register!');
     $this->addElement($submit);
     $this->addDisplayGroup(array('username', 'password', 'first_name', 'last_name', 'preferred_name', 'email', 'text1', 'captcha'), 'details');
     $this->details->setLegend('Register with the Scheme: ');
     $this->removeDecorator('DtDdWrapper');
     $this->removeDecorator('HtmlTag');
     $this->details->removeDecorator('DtDdWrapper');
     $this->addDisplayGroup(array('submit'), 'submit');
     $this->submit->removeDecorator('DtDdWrapper');
     $this->submit->removeDecorator('HtmlTag');
 }
Example #3
0
 /** Init the form
  * @access public
  * @return void
  */
 public function init()
 {
     $username = $this->addElement('Text', 'username', array('label' => 'Username'))->username;
     $username = $this->getElement('username')->addValidator('UsernameUnique', true, array('id', 'username', 'id', 'Users'))->addValidator('StringLength', true, array(4))->addValidator('Alnum', false, array('allowWhiteSpace' => false))->setRequired(true)->addFilters(array('StringToLower', 'StringTrim', 'StripTags'))->addValidator('Db_NoRecordExists', false, array('table' => 'users', 'field' => 'username'))->setDescription('Username must be more than 3 characters and include only letters and numbers');
     $username->getValidator('Alnum')->setMessage('Your username must be letters and digits only');
     $password = $this->addElement('Password', 'password', array('label' => 'Password'))->password;
     $password = $this->getElement('password');
     $password->setDescription('Password must be longer than 6 characters and must include
     letters and numbers i.e. p4ssw0rd')->addValidator('StringLength', true, array(6))->addValidator('Regex', true, array('/^(?=.*\\d)(?=.*[a-zA-Z]).{6,}$/'))->setRequired(true)->addErrorMessage('Please enter a valid password!');
     $password->getValidator('StringLength')->setMessage('Password is too short');
     $password->getValidator('Regex')->setMessage('Password does not contain letters and numbers');
     $firstName = $this->addElement('Text', 'first_name', array('label' => 'First Name', 'size' => '30'))->first_name;
     $firstName = $this->getElement('first_name');
     $firstName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a firstname');
     $lastName = $this->addElement('Text', 'last_name', array('label' => 'Last Name', 'size' => '30'))->last_name;
     $lastName = $this->getElement('last_name');
     $lastName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a surname');
     $preferredName = $this->addElement('Text', 'preferred_name', array('label' => 'Preferred Name', 'size' => '30'))->preferred_name;
     $preferredName = $this->getElement('preferred_name');
     $preferredName->setDescription('e.g. Joe Brown rather than Joseph Brown')->setRequired(true)->addFilters(array('StringToLower', 'StringTrim', 'StripTags'))->addErrorMessage('You must enter your preferred name');
     $email = $this->addElement('Text', 'email', array('label' => 'Email Address', 'size' => '30'))->email;
     $email = $this->getElement('email');
     $email->addValidator('EmailAddress', false, array('mx' => true))->setRequired(true)->addFilters(array('StringToLower', 'StringTrim', 'StripTags'))->addValidator('Db_NoRecordExists', false, array('table' => 'users', 'field' => 'email'));
     $hash = new Zend_Form_Element_Hash('csrf');
     $hash->setValue($this->_salt)->setTimeout(4800);
     $this->addElement($hash);
     $recaptcha = new Zend_Service_ReCaptcha($this->_pubKey, $this->_privateKey);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => 'ReCaptcha', 'label' => 'Prove you are not a robot/spammer', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha, 'theme' => 'clean', 'ssl' => true)));
     $captcha->setDescription('Due to the surge in robotic activity, we 
         have had to introduce this software. However, by filling in this 
         captcha, you help Carnegie Mellon University digitise old books.');
     $captcha->setDecorators(array(array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li'))));
     $captcha->addErrorMessage('You have not solved the captcha');
     $this->addElement($captcha);
     //Submit button
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Register!');
     $this->addElement($submit);
     $this->addDisplayGroup(array('username', 'password', 'first_name', 'last_name', 'preferred_name', 'email', 'captcha'), 'details');
     $this->details->setLegend('Register with the Scheme: ');
     $this->addDisplayGroup(array('submit'), 'buttons');
     parent::init();
 }
 /**
  *
  * Activate account form
  *
  */
 public function init()
 {
     $cname = explode('_', get_class());
     $this->preInit(end($cname), true, false);
     // use template file
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/ActivateAccount.phtml'))));
     // fields
     $confirm = new Zend_Form_Element_Checkbox('confirm');
     $confirm->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Accept Terms & Conditions'))->addValidator('GreaterThan', false, array(0))->setErrorMessages(array($this->translator->translate('Please Read and Agree to our Terms & Conditions')));
     $register = new Zend_Form_Element_Submit('activatesubmit');
     $register->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Create Account'))->setAttrib('class', 'submit btn btn-default');
     if (Zend_Registry::get('config')->get('recaptcha_active') == 1) {
         $privateKey = Zend_Registry::get('config')->get('recaptcha_privatekey');
         $publicKey = Zend_Registry::get('config')->get('recaptcha_publickey');
         $recaptcha = new Zend_Service_ReCaptcha($publicKey, $privateKey, array('ssl' => true));
         $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => '', 'captcha' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha)));
         $captcha->setDecorators(array('ViewHelper', 'Errors'));
         $this->addElements(array($captcha, $confirm, $register));
     } else {
         $this->addElements(array($confirm, $register));
     }
     $this->postInit();
 }