public function ceospeaksAction() { $request = $this->getRequest(); if ($request->isPost()) { // action body $emails_str = str_replace(" ", "", $request->getParam('emails')); // strips whitespace from string $emails = explode(",", $emails_str); // splits string into an array using comma to split $validator = new Zend_Validate_EmailAddress(); foreach ($emails as $email) { if (!$validator->isValid($email)) { array_shift($emails); // Remove invalid emails } } $mail = new Zend_Mail(); $mail->setFrom('*****@*****.**', 'winsandwants.com'); $mail->setReplyTo('*****@*****.**', 'winsandwants.com'); $mail->addTo($emails); $mail->setSubject('Sharing winsandwants.com'); $txt = "A friend would like to share with you this wonderful free site on goal-setting and the mastermind concept. Please visit: http://winsandwants.com"; $mail->setBodyText($txt, 'UTF-8'); $mail->send(); $this->view->msg = "Thank you for sharing this site. A link to this site has been sent to the following emails: " . implode(",", $emails) . "."; } }
public function init() { $this->setMethod('post'); // Email entry $this->addElement('text', 'email', array('label' => 'Email address', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your email address')))), 'attribs' => array('data-ctfilter' => 'yes'))); // Modify email error messages & add validator $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address")); $this->getElement('email')->addValidator($emailValidator); // Password entry $this->addElement('password', 'password', array('required' => true, 'label' => 'Password', 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your password')))), 'attribs' => array('data-ctfilter' => 'yes'))); // Set up the element decorators $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors', array('HtmlTag', array('tag' => 'div')))); // Add the submit button $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Login', 'class' => 'button noalt')); // Add a forgotten password button $this->addElement('submit', 'forgottenPassword', array('ignore' => true, 'label' => 'Resend Password', 'class' => 'button noalt')); // Remove the label from the submit button $element = $this->getElement('submit'); $element->removeDecorator('label'); $element = $this->getElement('forgottenPassword'); $element->removeDecorator('label'); // Set up the decorator on the form and add in decorators which are removed $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'form_section one-col'))->addDecorator('Form'); }
public function init() { // Type of organisation Element $this->addElement('select', 'organisation_type', array('label' => 'What sort of organisation are you?', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', LettingAgents_Object_CompanyTypes::LimitedCompany => 'Limited Company', LettingAgents_Object_CompanyTypes::Partnership => 'Partnership', LettingAgents_Object_CompanyTypes::SoleTrader => 'Sole Trader', LettingAgents_Object_CompanyTypes::LimitedLiabilityPartnership => 'Limited liability partnership'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'What sort of organisation are you?', 'notEmptyInvalid' => 'What sort of organisation are you?')))))); // date_firm_established Element $this->addElement('text', 'date_established', array('id' => 'theDate', 'label' => 'When were you established?', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'When were you established?', 'notEmptyInvalid' => 'You have entered an invalid date for when were you established?')))))); // Append Javascripts //Grab view and add the date picker JavaScript files into the page head $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'); $view->headLink()->appendStylesheet('/assets/cms/css/datePicker.css', 'screen'); $view->headScript()->appendFile('/assets/vendor/js/date.js', 'text/javascript')->appendFile('/assets/cms/js/jquery.datePicker.js', 'text/javascript')->appendFile('/assets/cms/js/letting-agents/DatePicker.js', 'text/javascript'); // is_associated Element $this->addElement('select', 'is_associated', array('label' => 'Is your company associated with any other letting business?', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', '1' => 'Yes', '0' => 'No'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Is your company associated with any other company?', 'notEmptyInvalid' => 'Is your company associated with any other company?')))))); // if_yes Element $this->addElement('text', 'associated_text', array('label' => 'If yes please state', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'If yes please state', 'notEmptyInvalid' => 'If yes please state')))))); // contact_name Element $this->addElement('text', 'contact_name', array('label' => 'Your contact name', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Enter a contact name', 'notEmptyInvalid' => 'Invalid entry for contact name')))))); // contact_name Element $this->addElement('text', 'contact_number', array('label' => 'Your phone number', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A uk phone number is required', 'notEmptyInvalid' => 'Enter a valid uk phone number')))))); $phoneValidator = new Zend_Validate_TelephoneNumber(); $phoneValidator->setMessages(array(Zend_Validate_TelephoneNumber::INVALID => "Enter a valid uk phone number")); $this->getElement('contact_number')->addValidator($phoneValidator); // General Email Element $this->addElement('text', 'general_email', array('label' => 'Your general email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A general email address is required', 'notEmptyInvalid' => 'Enter a valid email address for the general email address')))))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address")); $this->getElement('general_email')->addValidator($emailValidator); // Strip all tags to prevent XSS errors $this->setElementFilters(array('StripTags')); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/personal-details.phtml')))); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); }
public function init() { // contactnameElement $this->addElement('text', 'contactname', array('label' => 'Please give us a head office contact name', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please give us a head office contact name', 'notEmptyInvalid' => 'Invalid contact name')))))); // telephone_numberl Element $this->addElement('text', 'telephone_number', array('label' => 'Head office phone number', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Enter your Head Office telephone number', 'notEmptyInvalid' => 'Invalid UK telephone number for Head Office')))))); $phoneValidator = new Zend_Validate_TelephoneNumber(); $phoneValidator->setMessages(array(Zend_Validate_TelephoneNumber::INVALID => "Invalid UK telephone number for Head Office")); $this->getElement('telephone_number')->addValidator($phoneValidator); // head_office_email_address Email Element $this->addElement('text', 'head_office_email_address', array('label' => 'Head office email address', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Enter your head office email address', 'notEmptyInvalid' => 'Head office email address is invalid')))))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address")); $this->getElement('head_office_email_address')->addValidator($emailValidator); // head_office_fax_number Element $this->addElement('text', 'head_office_fax_number', array('label' => 'Head office fax number', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Enter your Head Office fax number', 'notEmptyInvalid' => 'Head Office Fax number is not a valid UK telephone number')))))); $faxValidator = new Zend_Validate_TelephoneNumber(); $faxValidator->setMessages(array(Zend_Validate_TelephoneNumber::INVALID => "Head Office Fax number is not a valid UK telephone number")); $this->getElement('head_office_fax_number')->addValidator($faxValidator); // Strip all tags to prevent XSS errors $this->setElementFilters(array('StripTags')); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/head-office.phtml')))); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); }
/** * Make sure the user is valid * * @return void */ public function isValid($value) { $valid = true; $this->_user = $value; $namePartsValidator = new Zend_Validate(); $namePartsValidator->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->addValidator(new Zend_Validate_Alpha(array('allowWhiteSpace' => true)))->addValidator(new Zend_Validate_StringLength(array('min' => 2))); if (!$namePartsValidator->isValid($this->_user->getFirstName())) { $valid = false; $this->_error($this->_view->translate('The first name must have at least 2 characters and consist only of letters')); } if (!$namePartsValidator->isValid($this->_user->getLastName())) { $valid = false; $this->_error($this->_view->translate('The last name must have at least 2 characters and consist only of letters')); } $emailValidator = new Zend_Validate_EmailAddress(); if (!$emailValidator->isValid($this->_user->getEmail())) { $valid = false; $this->_error($this->_view->translate('You must entre a valid email')); } if ($this->_user->isNew()) { $usernameValidator = new Zend_Validate(); $usernameValidator->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => false)))->addValidator(new Zend_Validate_StringLength(array('min' => 5))); if (!$usernameValidator->isValid($this->_user->getUsername())) { $this->_error($this->_view->translate('The username must have at least 5 characters and contains no white spaces')); } } return $valid; }
/** * Create insurance customer search form. * * @return void */ public function init() { $this->setMethod('get'); // Add first name element $this->addElement('text', 'firstName', array('label' => 'Customer First Name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z\\-\\ \']+$/i', 'messages' => 'Customer First Name must contain alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add last name element $this->addElement('text', 'lastName', array('label' => 'Customer Last Name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z\\-\\ \']+$/i', 'messages' => 'Customer Last Name must contain alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add line 1 property address element $this->addElement('text', 'address1', array('label' => 'Street Address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z0-9\\-\\ \'\\,\\.]+$/i', 'messages' => 'Street Address must contain alphanumeric characters and only basic punctuation (hyphen, space, single quote, comma and full stop)'))))); // Add line 2 property address element $this->addElement('text', 'address2', array('label' => 'Town/City', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z0-9\\-\\ \'\\,\\.]+$/i', 'messages' => 'Town/City must contain alphanumeric characters and only basic punctuation (hyphen, space, single quote, comma and full stop)'))))); // Add postcode element $this->addElement('text', 'postcode', array('label' => 'Post Code', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z0-9\\ ]+$/i', 'messages' => 'Post Code must only contain alphanumeric characters and spaces'))))); // Add telephone element $this->addElement('text', 'telephone', array('label' => 'Telephone', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^((\\+44\\s?\\(0\\)\\s?\\d{2,4})|(\\+44\\s?(01|02|03|07|08)\\d{2,3})|(\\+44\\s?(1|2|3|7|8)\\d{2,3})|(\\(\\+44\\)\\s?\\d{3,4})|(\\(\\d{5}\\))|((01|02|03|07|08)\\d{2,3})|(\\d{5}))(\\s|-|.)(((\\d{3,4})(\\s|-)(\\d{3,4}))|((\\d{6,7})))$/', 'messages' => 'Not a valid phone number'))))); // Add e-mail element $this->addElement('text', 'email', array('label' => 'Email', 'required' => false, 'filters' => array('StringTrim'))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in email address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid email address')); $this->getElement('email')->addValidator($emailValidator); // Set up the element decorators $this->setElementDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div')))); // Add search button $this->addElement('submit', 'search', array('label' => 'Search')); }
/** * Create property subform * * @return void */ public function init() { // Add title element $this->addElement('select', 'title', array('label' => 'Title', 'required' => true, 'multiOptions' => array('Mr' => 'Mr', 'Mrs' => 'Mrs', 'Ms' => 'Ms', 'Miss' => 'Miss', 'Sir' => 'Sir', 'Mr and Mrs' => 'Mr and Mrs', 'Doctor' => 'Dr', 'Professor' => 'Professor', 'Reverend' => 'Rev', 'Other' => 'Other'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your title', 'notEmptyInvalid' => 'Please select landlord title')))))); // Add first name element $this->addElement('text', 'first_name', array('label' => 'First name', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your first name', 'notEmptyInvalid' => 'Please enter landlord first name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'First name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add last name element $this->addElement('text', 'last_name', array('label' => 'Last name', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter landlord last name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Last name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add e-mail element $this->addElement('text', 'email_address', array('label' => 'Email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter landlord email address')))))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address")); $this->getElement('email_address')->addValidator($emailValidator); // Add confirm e-mail element $this->addElement('text', 'confirm_email_address', array('label' => 'Confirm email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please confirm landlord email address')))))); // Add phone number element $this->addElement('text', 'phone_number', array('label' => 'Phone number', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter landlord phone number')))))); // Add Question-1 element $this->addElement('radio', 'question1', array('label' => 'Are you aware of any circumstances which may give rise to a claim?', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to question: Are you aware of any circumstances which may give rise to a claim?', 'notEmptyInvalid' => 'Please select answer to question: Are you aware of any circumstances which may give rise to a claim?')))))); // Additional claim information element - textarea box $this->addElement('textarea', 'claiminfo', array('label' => 'Additional information', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please provide additional claim information.', 'notEmptyInvalid' => 'Please enter additional claim information')))))); // Add Question-2 element $this->addElement('radio', 'question2', array('label' => 'Will only permitted occupiers be living in the property?', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to question: Will only permitted occupiers be living in the property?', 'notEmptyInvalid' => 'Please select answer to question: Will only permitted occupiers be living in the property?')))))); // Add Question-3 element $this->addElement('radio', 'question3', array('label' => 'Any tenancy disputes, including late payment of rent?', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to question: Any tenancy disputes, including late payment of rent?', 'notEmptyInvalid' => 'Please select answer to question: Any tenancy disputes, including late payment of rent?')))))); // Add agreement element $this->addElement('radio', 'agreement', array('label' => 'Type of tenancy agreement', 'required' => true, 'multiOptions' => array('AST' => 'AST', 'Company' => 'Company'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to Type of tenancy agreement', 'notEmptyInvalid' => 'Please select answer to Type of tenancy agreement')))))); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'rentguarantee/subforms/rent-recovery-plus-application-landlord.phtml')))); $this->setElementFilters(array('StripTags')); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_FieldLogin(); $elements = array(); // Add email field $input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email')); $validator = new Zend_Validate_EmailAddress(); $validator->setOptions(array('domain' => false)); $input->addValidators(array($validator, new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add password field $input = new Zend_Form_Element_Password('password', array('required' => true, 'label' => 'Password:'******'id' => 'password', 'class' => 'form-control', 'placeholder' => 'Your password..')); $input->addValidators(array(new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add checkbox field $input = new Zend_Form_Element_Checkbox('rememberMe', array('label' => 'Remember me', 'id' => 'rememberMe', 'class' => 'checkbox', 'type' => 'checkbox')); $decoratorCheckBox = new My_Decorator_CheckBox(); $input->addDecorator($decoratorCheckBox); $elements[] = $input; $input = new Zend_Form_Element('resetpass', array('label' => 'Reset your password', 'id' => 'resetpass', 'class' => 'form-control', 'value' => 'resetpass')); $input->addDecorator(new My_Decorator_AnchoraForm()); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Login')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('email', 'password', 'resetpass', 'rememberMe', 'submit'), 'displgrp', array('decorators' => array('FormElements', 'Fieldset'))); }
/** * Create user details form (single user). * * @return void */ public function init() { // Invoke the agent user manager $agentUserManager = new Manager_Core_Agent_User(); // Create array of possible security questions $securityQuestions = array('' => '--- please select ---'); $securityQuestions += $agentUserManager->getUserSecurityAllQuestions(); // Add real name element $this->addElement('text', 'realname', array('label' => 'Full name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your full name', 'notEmptyInvalid' => 'Please enter your full name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add username element $this->addElement('text', 'username', array('label' => 'Username', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your username', 'notEmptyInvalid' => 'Please enter your username'))), array('regex', true, array('pattern' => '/^[a-z0-9]{1,64}$/i', 'messages' => 'Username must contain between 1 and 64 alphanumeric characters'))))); if ($this->_role == Model_Core_Agent_UserRole::MASTER) { $this->getElement('username')->setRequired(true); } else { $this->getElement('username')->setAttrib('disabled', 'disabled'); } // Add password1 element $passwordElement1 = new Zend_Form_Element_Password('password1'); $passwordElement1->setRequired(false); $passwordElement1->setLabel('New password:'******'password2'); $validator->setMessage('Passwords are not the same', Zend_Validate_Identical::NOT_SAME); $passwordElement1->addValidator($validator); $passwordElement2 = new Zend_Form_Element_Password('password2'); $passwordElement2->setRequired(false); $passwordElement2->setLabel('New password (again)'); $this->addElement($passwordElement2); // Add e-mail element $this->addElement('text', 'email', array('label' => 'E-mail address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your e-mail address')))))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid e-mail address')); $this->getElement('email')->addValidator($emailValidator); if ($this->_role == Model_Core_Agent_UserRole::MASTER) { $this->getElement('email')->setRequired(true); } else { $this->getElement('email')->setAttrib('disabled', 'disabled'); } // Add e-mail element $this->addElement('text', 'emailcopyto', array('label' => 'Copy e-mail to', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a copy-to e-mail address')))))); $emailCopyToValidator = new Zend_Validate_EmailAddress(); $emailCopyToValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in copy-to e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid copy-to e-mail address')); $this->getElement('emailcopyto')->addValidator($emailCopyToValidator); // Add security question element $this->addElement('select', 'question', array('label' => 'Security question', 'required' => false, 'multiOptions' => $securityQuestions)); // Add security answer element $this->addElement('text', 'answer', array('label' => 'Security answer', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[\\w\\ \\.\\-\'\\,]{2,}$/i', 'messages' => 'Security answer must contain at least two characters and only basic punctuation (hyphen, apostrophe, comma, full stop and space)'))))); // Add master user element $this->addElement('checkbox', 'master', array('label' => 'Master user', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); // Add agent reports element $this->addElement('checkbox', 'reports', array('label' => 'Agent reports', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); // Add status element $this->addElement('checkbox', 'status', array('label' => 'Active', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'settings/subforms/useraccount.phtml', 'role' => $this->_role)))); $this->setElementFilters(array('StripTags')); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); }
/** * Returns an avatar from gravatar's service. * * @link http://en.gravatar.com/site/implement/images/php/ * @throws Zend_View_Exception * * @param string|null $email Valid email adress * @param array $options Options * 'imgSize' height of img to return * 'defaultImg' img to return if email adress has not found * 'rating' rating parametr for avatar * @param array $attribs Attribs for img tag (title, alt etc.) * @param bool $flag Use HTTPS? Default false. * @return string */ public function gravatar($email = null, $options = array(), $attribs = array(), $flag = false) { if ($email === null) { return ''; } if (count($options) > 0) { if (isset($options['imgSize'])) { $this->setImgSize($options['imgSize']); } if (isset($options['defaultImg'])) { $this->setDefaultImg($options['defaultImg']); } if (isset($options['rating'])) { $this->setRating($options['rating']); } } $validatorEmail = new Zend_Validate_EmailAddress(); $validatorResult = $validatorEmail->isValid($email); if ($validatorResult === false) { throw new Zend_View_Exception(current($validatorEmail->getMessages())); } $hashEmail = md5($email); $src = $this->getGravatarUrl($flag) . '/' . $hashEmail . '?s=' . $this->getImgSize() . '&d=' . $this->getDefaultImg() . '&r=' . $this->getRating(); $attribs['src'] = $src; $html = '<img' . $this->_htmlAttribs($attribs) . $this->getClosingBracket(); return $html; }
/** * Returns an avatar from gravatar's service. * * @link http://pl.gravatar.com/site/implement/url * @throws Zend_View_Exception * * @param string|null $email Valid email adress * @param null|array $options Options * 'imgSize' height of img to return * 'defaultImg' img to return if email adress has not found * 'rating' rating parameter for avatar * @param null|array $attribs Attribs for img tag (title, alt etc.) * @param null|bool Use HTTPS? Default false. * @link http://pl.gravatar.com/site/implement/url More information about gravatar's service. * @return string|Zend_View_Helper_Gravatar */ public function gravatar($email = null, $options = array(), $attribs = array(), $flag = false) { if ($email === null) { return null; } if (count($options) > 0) { if (isset($options['imgSize'])) { $this->setImgSize($options['imgSize']); } if (isset($options['defaultImg'])) { $this->setDefaultImg($options['defaultImg']); } if (isset($options['rating'])) { $this->setRating($options['rating']); } } /** * @see Zend_Validate_EmailAddress */ require_once 'Zend/Validate/EmailAddress.php'; $validatorEmail = new Zend_Validate_EmailAddress(); $validatorResult = $validatorEmail->isValid($email); if ($validatorResult === false) { return null; } $hashEmail = md5($email); $src = $this->getGravatarUrl($flag) . '/' . $hashEmail . '?s=' . $this->getImgSize() . '&d=' . $this->getDefaultImg() . '&r=' . $this->getRating(); $attribs['src'] = $src; $html = '<img' . $this->_htmlAttribs($attribs) . $this->getClosingBracket(); return $html; }
public function mailAction() { $error = array(); $posts = array('First Name' => $_POST['first_name'], 'Last Name' => $_POST['last_name'], 'Email' => $_POST['email'], 'Message' => $_POST['message']); $validatorChain = new Zend_Validate(); $validatorChain->addValidator(new Zend_Validate_NotEmpty()); $valid_email = new Zend_Validate_EmailAddress(); if ($valid_email->isValid($posts['Email'])) { } else { foreach ($valid_email->getMessages() as $message) { $error[] = "Email {$message}\n"; } } foreach ($posts as $key => $post) { if ($validatorChain->isValid($post)) { } else { foreach ($validatorChain->getMessages() as $message) { $error[] = "{$key} {$message}\n"; } } } if (count($error) != 0) { $this->view->alerts = $error; } else { $to = '*****@*****.**'; $subject = 'Email from Illustrated Portland'; $message = $posts['Message']; $headers = "From: {$posts['First Name']} {$posts['Last Name']} <{$posts['Email']}>"; mail($to, $subject, $message, $headers); //$this->view->alerts = array("Thank You! Your message has been sent."); } }
/** * Create lost login (password retrieval) form. * * @return void */ public function init() { // Invoke the agent user manager $agentUserManager = new Manager_Core_Agent_User(); // Create array of possible security questions $securityQuestions = array('' => '--- please select ---'); $securityQuestions += $agentUserManager->getUserSecurityAllQuestions(); $this->setMethod('post'); // Add agent scheme number element $this->addElement('text', 'agentschemeno', array('label' => 'Agent Scheme Number', 'required' => false, 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your Agent Scheme Number', 'notEmptyInvalid' => 'Please enter your Letting Agent Scheme Number'))), array('regex', true, array('pattern' => '/^\\d{5,}$/', 'messages' => 'Agent Scheme Number must contain at least 5 digits'))))); // Add username element $this->addElement('text', 'username', array('label' => 'Username', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your username', 'notEmptyInvalid' => 'Please enter your username'))), array('regex', true, array('pattern' => '/^[a-z0-9]{6,64}$/i', 'messages' => 'Username must contain between 6 and 64 alphanumeric characters'))))); // Add password element $this->addElement('password', 'password', array('label' => 'Password', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your password', 'notEmptyInvalid' => 'Please enter your password'))), array('regex', true, array('pattern' => '/^.{6,}$/', 'messages' => 'Password must contain at least 6 characters'))))); // Add real name element $this->addElement('text', 'realname', array('label' => 'First name + last name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your first name + last name', 'notEmptyInvalid' => 'Please enter your first name + last name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add security question element $this->addElement('select', 'question', array('label' => 'Security question', 'required' => false, 'multiOptions' => $securityQuestions, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select a security question', 'notEmptyInvalid' => 'Please select a security question')))))); // Add security answer element $this->addElement('text', 'answer', array('label' => 'Security answer', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your security answer', 'notEmptyInvalid' => 'Please enter your security answer'))), array('regex', true, array('pattern' => '/^[\\w\\ \\.\\-\'\\,]{2,}$/i', 'messages' => 'Security answer must contain at least two characters and only basic punctuation (hyphen, apostrophe, comma, full stop and space)'))))); // Add e-mail element $this->addElement('text', 'email', array('label' => 'E-mail address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your e-mail address')))))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid e-mail address')); $this->getElement('email')->addValidator($emailValidator); $this->setElementFilters(array('StripTags')); // Set up the element decorators $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors', array('HtmlTag', array('tag' => 'div')))); // Add login button $this->addElement('submit', 'login', array('label' => 'Login')); }
public function registerAction() { $name = $this->_getParam('name'); $avatar = $this->_getParam('avatar'); $sex = $this->_getParam('sex'); $birthday = $this->_getParam('birthday'); $email = $this->_getParam('email'); $passwd = $this->_getParam('passwd'); $phone = $this->_getParam('phone'); $department = $this->_getParam('department'); $city = $this->_getParam('city'); //$certified = $this->_getParam('certified'); $special = $this->_getParam('special'); $country = $this->_getParam('country'); $introduction = $this->_getParam('introduction'); $hospital = $this->_getParam('hospital'); $area = $this->_getParam('area'); $qualification = $this->_getParam('qualification'); if (!$passwd) { $out['errno'] = '3'; $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']); Yy_Utils::jsonOut($out); return; } $validatorEmail = new Zend_Validate_EmailAddress(); if ($validatorEmail->isValid($email)) { $bool = Application_Model_M_Doctor::fetchByEmail($email); if ($bool) { //已注册 $out['errno'] = '1'; } else { $out['errno'] = '0'; $doctor = new Application_Model_O_Doctor(); $doctor->setName($name)->setSex($sex)->setBirthday($birthday)->setEmail($email)->setPasswd(md5($passwd))->setPhone($phone)->setDepartment($department)->setCity($city)->setSpecial($special)->setCountry($country)->setIntroduction($introduction)->setHospital($hospital)->setArea($area)->setQualification($qualification)->setCtime(date('Y-m-d H:i:s')); $certified = ceil(count($doctor->getModifiedFields()) / 3); $doctor->setCertified($certified); $doctor->save(); //保存医生头像 $adapter = new Zend_File_Transfer_Adapter_Http(); $wrdir = Yy_Utils::getWriteDir(); $adapter->setDestination($wrdir); if (!$adapter->receive()) { $messages = $adapter->getMessages(); //echo implode("\n", $messages); } $filename = $adapter->getFileName(); if (is_string($filename)) { $handle = fopen($filename, 'rb'); $avatar = addslashes(fread($handle, filesize($filename))); fclose($handle); Application_Model_M_Doctor::updateAvatar($doctor->getId(), $avatar); } } } else { $out['errno'] = '2'; } $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']); Yy_Utils::jsonOut($out); }
public function indexAction() { $emailValidator = new Zend_Validate_EmailAddress(); $nameValidator = new Zend_Validate_NotEmpty(array(Zend_Validate_NotEmpty::STRING, Zend_Validate_NotEmpty::SPACE)); $password1_Validator = new Zend_Validate(); $password1_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum()); $password2_Validator = new Zend_Validate(); $password2_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum()); $captcha = new Zend_Captcha_Image(); $captcha->setName('captchaword')->setFont(APPLICATION_PATH . '/data/arial.ttf')->setFontSize(28)->setImgDir(APPLICATION_PATH . '/../public/img')->setImgUrl('/img')->setWordLen(5)->setDotNoiseLevel(20)->setExpiration(300); $request = $this->getRequest(); $post = $request->getPost(); // $passwordIdentical = new Zend_Validate_Identical(array('token' => $post['password1'])); $messages = array(); $error = array(); $noValiError = true; if ($this->getRequest()->isPost()) { if (!$emailValidator->isValid($post['user-email'])) { $error['user-emailVali'] = '請輸入正確的Email帳號'; $noValiError = false; } if (!$nameValidator->isValid($post['name'])) { $error['nameVali'] = '姓名必填'; $noValiError = false; } if (!$password1_Validator->isValid($post['password1'])) { $error['password1_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文'; $noValiError = false; } if (!$password2_Validator->isValid($post['password2'])) { $error['password2_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文'; $noValiError = false; } if (isset($post['password1']) && isset($post['password2']) && !($post['password1'] == $post['password2'])) { $error['passwordIdentical'] = '2.密碼輸入不同'; $noValiError = false; } if (!($post['agree'] == 1)) { $error['agreeVali'] = '需同意服務條款及隱私權政策,才可以註冊'; $noValiError = false; } if (!$captcha->isValid($post['captchaword'])) { $error['captchawordVali'] = '認證碼輸入錯誤'; $noValiError = false; } if ($noValiError) { // register process $this->_signup($post); $this->view->messages = $post; $this->redirect('index/index'); } else { $this->_genCaptcha($captcha); $this->view->error = $error; $this->view->messages = $post; } } else { $this->_genCaptcha($captcha); } }
public function setSandboxPrimaryEmail($email) { $validator = new Zend_Validate_EmailAddress(); if (!$validator->isValid($email)) { throw new Exception($email . ' is not a valid email address!'); } $this->_sandboxPrimaryEmail = $email; }
public function setEmail($email) { $validator = new Zend_Validate_EmailAddress(); if (!$validator->isValid($email)) { throw new Exception('Invalid e-mail address specified'); } $this->_email = $email; }
public function registerAction() { $name = $this->_getParam('name'); $avatar = $this->_getParam('avatar'); $email = $this->_getParam('email'); $phone = $this->_getParam('phone'); $departments = $this->_getParam('departments'); $type = $this->_getParam('type'); $city = $this->_getParam('city'); $label = $this->_getParam('label'); $country = $this->_getParam('country'); $area = $this->_getParam('area'); $passwd = $this->_getParam('passwd'); $introduction = $this->_getParam('introduction'); $longitude = $this->_getParam('longitude'); $latitude = $this->_getParam('latitude'); if (!$passwd) { $out['errno'] = '3'; $out['msg'] = Yy_ErrMsg_Hospital::getMsg('register', $out['errno']); Yy_Utils::jsonOut($out); return; } $validatorEmail = new Zend_Validate_EmailAddress(); if ($validatorEmail->isValid($email)) { $bool = Application_Model_M_Hospital::fetchByEmail($email); if ($bool) { //已注册 $out['errno'] = '1'; } else { $out['errno'] = '0'; $hospital = new Application_Model_O_Hospital(); $hospital->setName($name)->setEmail($email)->setPasswd(md5($passwd))->setPhone($phone)->setDepartments($departments)->setType($type)->setCity($city)->setLabel($label)->setCountry($country)->setArea($area)->setIntroduction($introduction)->setLongitude($longitude)->setLatitude($latitude); $certified = ceil(count($hospital->getModifiedFields()) / 3); $hospital->setCertified($certified); $hospital->save(); //保存医院头像 $adapter = new Zend_File_Transfer_Adapter_Http(); $wrdir = Yy_Utils::getWriteDir(); $adapter->setDestination($wrdir); if (!$adapter->receive()) { $messages = $adapter->getMessages(); //echo implode("\n", $messages); } $filename = $adapter->getFileName(); if (is_string($filename)) { $handle = fopen($filename, 'rb'); $avatar = addslashes(fread($handle, filesize($filename))); fclose($handle); Application_Model_M_Hospital::updateAvatar($hospital->getId(), $avatar); } } } else { $out['errno'] = '2'; } $out['msg'] = Yy_ErrMsg_Hospital::getMsg('register', $out['errno']); Yy_Utils::jsonOut($out); }
public function __construct($email) { $email = trim($email); $validator = new Zend_Validate_EmailAddress(); if (!$validator->isValid($email)) { throw new SimpleCal_Exception('Not a valid email address for creating an invitation'); } $this->_email = $email; }
/** * Validates email address * * @return bool */ protected function _validateEmail() { $validator = new Zend_Validate_EmailAddress(); $msg = Sanmax_MessageStack::getInstance('SxCms_User'); if (!$validator->isValid($this->_user->getEmail())) { $msg->addMessage('email', array($this->_user->getEmail())); } return false == $msg->getMessages('email'); }
/** * Konfiguriert das Formularelement. */ public function init() { parent::init(); $this->setAttrib('placeholder', $this->getTranslator()->translate('email_format')); $this->setAttrib('size', 60); $validator = new Zend_Validate_EmailAddress(); $validator->setMessage('admin_validate_error_email'); $this->addValidator($validator); }
public function init() { //Reference subject title element $this->addElement('select', 'personal_title', array('label' => 'Tenant Title', 'required' => true, 'multiOptions' => array('' => 'Not Known', 'Mr' => 'Mr', 'Ms' => 'Ms', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Dr' => 'Dr', 'Prof' => 'Professor', 'Sir' => 'Sir'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the tenant title', 'notEmptyInvalid' => 'Please select a valid tenant title')))), 'attribs' => array('class' => 'form-control'))); //First name entry $this->addElement('text', 'first_name', array('label' => 'Tenant First Name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s first name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control'))); //Last name entry $this->addElement('text', 'last_name', array('label' => 'Tenant Last Name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s last name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control'))); // Email entry $this->addElement('text', 'email', array('label' => 'Tenant Email Address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s email address')))), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control'))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address")); $this->getElement('email')->addValidator($emailValidator); // Add share of rent element $this->addElement('text', 'share_of_rent', array('label' => 'Share of rent per month (£)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the share of rent per month')), 'Digits', true, array('messages' => array('notDigits' => 'Please enter the share of rent per month', 'digitsStringEmpty' => 'Please enter the Share of rent per month')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'currency', 'class' => 'currency form-control'))); // List the products based on the user choice. $productManager = new Manager_Referencing_Product(); $session = new Zend_Session_Namespace('referencing_global'); $productList = array(); if ($session->displayRentGuaranteeProducts) { $productVariable = Model_Referencing_ProductVariables::RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); foreach ($products as $product) { if (!preg_match("/international/i", $product->name)) { $productList[$product->key] = strtoupper($product->name); } } } else { $productVariable = Model_Referencing_ProductVariables::NON_RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); $productSelection = new Model_Referencing_ProductSelection(); $productSelection->referenceId = 0; $productSelection->duration = 0; foreach ($products as $product) { if (!preg_match("/international/i", $product->name)) { $productSelection->product = $product; $price = $productManager->getPrice($productSelection); $productList[$product->key] = strtoupper($product->name) . " (" . $price . " + VAT)"; } } } $this->addElement('radio', 'product_choice', array('required' => true, 'multiOptions' => $productList, 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your product choice', 'notEmptyInvalid' => 'Please select a valid product choice')))))); //Identify if we need to indicate duration. if ($session->displayRentGuaranteeProducts) { //Determine the allowable durations... Needs to be done in ajax //Display duration box. $this->addElement('select', 'product_duration', array('label' => 'Product Duration (months)', 'required' => true, 'multiOptions' => array(6 => '6', 12 => '12'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the product duration', 'notEmptyInvalid' => 'Please select a valid product duration')))), 'attribs' => array('class' => 'form-control'))); } //Completion method element $this->addElement('select', 'completion_method', array('label' => 'Completion Method', 'required' => true, 'multiOptions' => array(Model_Referencing_ReferenceCompletionMethods::ONE_STEP => 'Complete Information Now', Model_Referencing_ReferenceCompletionMethods::TWO_STEP => 'Email to Tenant'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the completion method', 'notEmptyInvalid' => 'Please select a valid completion method')))), 'attribs' => array('class' => 'form-control'))); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'landlords-referencing/product-selection.phtml')))); // Strip all tags to prevent XSS errors $this->setElementFilters(array('StripTags')); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); }
public function init() { parent::init(); $this->setAction(WEB_ROOT . '/commenting/comment/add'); $this->setAttrib('id', 'comment-form'); $user = current_user(); /************************************************************ *REVISIONS * Ver Date Author Description * -------- ---------- -------------- ---------------------- * 1.0 09/02/2015 mrs175 1. added validators/form limitations for author name, email, and comment ************************************************************/ //Validators //------------------------------------------------------------------ $notEmptyValidator = array('validator' => 'NotEmpty', 'breakChainOnFailure' => true, 'options' => array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => __('Please fill in this box.'), Zend_Validate_NotEmpty::INVALID => __('Please only use letters numbers and punctuation.')))); $alphaNumericValidator = array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '#^[a-zA-Z0-9.*@+!\\-_%\\#\\^&$ ]*$#u', 'messages' => array(Zend_Validate_Regex::INVALID => __('Please only use these special characters for your name: + ! @ # $ % ^ & * . - _'), Zend_Validate_Regex::ERROROUS => __('Please only use these special characters for your name: + ! @ # $ % ^ & * . - _'), Zend_Validate_Regex::NOT_MATCH => __('Please only use these special characters for your name: + ! @ # $ % ^ & * . - _')))); //form element options //---------------------------------------------------------- $nameOptions = array('label' => __('Name (required)'), 'required' => true, 'size' => '25', 'maxlength' => '25', 'validators' => array($notEmptyValidator, $alphaNumericValidator)); $emailOptions = array('label' => __('Email (required)'), 'required' => true, 'size' => '100', 'maxlength' => '70', 'validators' => array($notEmptyValidator)); $commentOptions = array('label' => __('1500 character limit'), 'id' => 'comment-form-body', 'rows' => "8", 'cols' => "50", 'maxlength' => '1500', 'required' => true, 'filters' => array(array('StripTags', array('allowTags' => array('p', 'span', 'em', 'strong', 'a', 'ul', 'ol', 'li'), 'allowAttribs' => array('style', 'href')))), 'validators' => array($notEmptyValidator)); //Adding Elements to the form //------------------------------------------------------------------------------- //auto-filling the email and name boxes for logged in users //then making them read only, so logged in users must use their registered name and email if ($user) { $emailOptions['value'] = $user->email; $emailOptions['readonly'] = true; $emailOptions['onfocus'] = "this.blur()"; $nameOptions['value'] = $user->name; $nameOptions['readonly'] = true; $nameOptions['onfocus'] = "this.blur()"; } $this->addElement('text', 'author_name', $nameOptions); $this->addElement('text', 'author_email', $emailOptions); $this->addElement('textarea', 'body', $commentOptions); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessage('Please enter an email address like stuff@email.com'); $this->getElement('author_email')->addValidator($emailValidator, true, array()); if (get_option('recaptcha_public_key') && get_option('recaptcha_private_key')) { $this->addElement('captcha', 'captcha', array('label' => __("Please verify you're a human"), 'captcha' => array('captcha' => 'ReCaptcha', 'pubkey' => get_option('recaptcha_public_key'), 'privkey' => get_option('recaptcha_private_key'), 'ssl' => true))); $this->getElement('captcha')->removeDecorator('ViewHelper'); } $request = Zend_Controller_Front::getInstance()->getRequest(); $params = $request->getParams(); $record_id = $this->_getRecordId($params); $record_type = $this->_getRecordType($params); $this->addElement('hidden', 'record_id', array('value' => $record_id, 'decorators' => array('ViewHelper'))); $this->addElement('hidden', 'path', array('value' => $request->getPathInfo(), 'decorators' => array('ViewHelper'))); if (isset($params['module'])) { $this->addElement('hidden', 'module', array('value' => $params['module'], 'decorators' => array('ViewHelper'))); } $this->addElement('hidden', 'record_type', array('value' => $record_type, 'decorators' => array('ViewHelper'))); fire_plugin_hook('commenting_form', array('comment_form' => $this)); $this->addElement('submit', 'submit', array('label' => __('Submit'))); }
public function validate(array $attributes) { if (empty($attributes[$this->_attributeName])) { return true; } $attributeValues = $attributes[$this->_attributeName]; switch ($this->_options) { case 'URN': $urnValidator = new EngineBlock_Validator_Urn(); foreach ($attributeValues as $attributeValue) { if (!$urnValidator->validate($attributeValue)) { $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URN, $this->_attributeName, $this->_options, $attributeValue); return false; } } break; case 'HostName': $hostnameValidator = new Zend_Validate_Hostname(); foreach ($attributeValues as $attributeValue) { if (!$hostnameValidator->isValid($attributeValue)) { $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_HOSTNAME, $this->_attributeName, $this->_options, $attributeValue); return false; } } break; case 'URL': foreach ($attributeValues as $attributeValue) { if (!Zend_Uri::check($attributeValue)) { $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URL, $this->_attributeName, $this->_options, $attributeValue); return false; } } break; case 'URI': $uriValidator = new EngineBlock_Validator_Uri(); foreach ($attributeValues as $attributeValue) { if (!$uriValidator->validate($attributeValue)) { $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URI, $this->_attributeName, $this->_options, $attributeValue); return false; } } break; case 'EmailAddress': $emailValidator = new Zend_Validate_EmailAddress(); foreach ($attributeValues as $attributeValue) { if (!$emailValidator->isValid($attributeValue)) { $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_EMAIL, $this->_attributeName, $this->_options, $attributeValue); return false; } } break; default: throw new EngineBlock_Exception("Unknown validate option '{$this->_options}' for attribute validation"); } return true; }
/** * Validiert und setzt die übergebene E-Mail Adresse * @param string $emailaddress * @throws Dragon_Application_Exception_User * @return DragonX_Emailaddress_Record_Emailaddress */ public function validateEmailaddress($emailaddress) { $emailaddress = strtolower($emailaddress); $validatorEmailaddress = new Zend_Validate_EmailAddress(); if (!$validatorEmailaddress->isValid($emailaddress)) { throw new Dragon_Application_Exception_User('invalid emailaddress', array('emailaddress' => $emailaddress)); } $this->emailaddress = $emailaddress; return $this; }
/** * Validates an e-mail address * * @param string $address Address * @throws Opus_Mail_Exception Thrown if the e-mail address is not valid * @return string Address */ public static function validateAddress($address) { $validator = new Zend_Validate_EmailAddress(); if ($validator->isValid($address) === false) { foreach ($validator->getMessages() as $message) { throw new Opus_Mail_Exception($message); } } return $address; }
public function validateEmail($email) { //Check each post variable for blanks or spaces $email_validator = new Zend_Validate_EmailAddress(); if (!$email_validator->isValid($email)) { foreach ($email_validator->getMessages() as $error) { array_push($this->messages, $error); } } return $this->messages; }
public function process(Zend_Controller_Request_Abstract $request) { // validate the username $this->username = trim($request->getPost('username')); if (strlen($this->username) == 0) { $this->addError('username', 'Please enter a username'); } else { if (!DatabaseObject_User::IsValidUsername($this->username)) { $this->addError('username', 'Please enter a valid username'); } else { if ($this->user->usernameExists($this->username)) { $this->addError('username', 'The selected username already exists'); } else { $this->user->username = $this->username; } } } // validate first and last name $this->first_name = $this->sanitize($request->getPost('first_name')); if (strlen($this->first_name) == 0) { $this->addError('first_name', 'Please enter your first name'); } else { $this->user->profile->first_name = $this->first_name; } $this->last_name = $this->sanitize($request->getPost('last_name')); if (strlen($this->last_name) == 0) { $this->addError('last_name', 'Please enter your last name'); } else { $this->user->profile->last_name = $this->last_name; } // validate the e-mail address $this->email = $this->sanitize($request->getPost('email')); $validator = new Zend_Validate_EmailAddress(); if (strlen($this->email) == 0) { $this->addError('email', 'Please enter your e-mail address'); } else { if (!$validator->isValid($this->email)) { $this->addError('email', 'Please enter a valid e-mail address'); } else { $this->user->profile->email = $this->email; } } // validate CAPTCHA phrase $session = new Zend_Session_Namespace('captcha'); $this->captcha = $this->sanitize($request->getPost('captcha')); if ($this->captcha != $session->phrase) { $this->addError('captcha', 'Please enter the correct phrase'); } if (!$this->_validateOnly && !$this->hasError()) { $this->user->save(); unset($session->phrase); } return !$this->hasError(); }
protected function _isValidEmail($supervisorEmails) { $emails = explode(',', $supervisorEmails); $emailValidator = new Zend_Validate_EmailAddress(); foreach ($emails as $email) { if (!$emailValidator->isValid($email)) { return false; } } return true; }
/** * Constructor. * @param $affiliateWindow * @return Oara_Network_Aw_Api */ public function __construct($credentials) { ini_set('default_socket_timeout', '120'); $user = $credentials['user']; $password = $credentials['apiPassword']; $passwordExport = $credentials['password']; $this->_exportOverviewParameters = array(new Oara_Curl_Parameter('post', 'yes'), new Oara_Curl_Parameter('merchant', ''), new Oara_Curl_Parameter('limit', '25'), new Oara_Curl_Parameter('submit.x', '75'), new Oara_Curl_Parameter('submit.y', '11'), new Oara_Curl_Parameter('submit', 'submit')); //Login to the website $validator = new Zend_Validate_EmailAddress(); if ($validator->isValid($user)) { //login through darwin $loginUrl = 'https://darwin.affiliatewindow.com/login?'; $valuesLogin = array(new Oara_Curl_Parameter('email', $user), new Oara_Curl_Parameter('password', $passwordExport), new Oara_Curl_Parameter('formuserloginlogin', '')); $this->_exportClient = new Oara_Curl_Access($loginUrl, $valuesLogin, $credentials); $urls = array(); $urls[] = new Oara_Curl_Request('http://darwin.affiliatewindow.com/user/', array()); $exportReport = $this->_exportClient->get($urls); if (preg_match_all("/id=\"goDarwin(.*)\"/", $exportReport[0], $matches)) { foreach ($matches[1] as $user) { $urls = array(); $urls[] = new Oara_Curl_Request('http://darwin.affiliatewindow.com/affiliate/' . $user, array()); $exportReport = $this->_exportClient->get($urls); if (preg_match("/<li>Payment<ul><li><a class=\"arrow sectionList\" href=\"(.*)\">/", $exportReport[0], $matches)) { $urls = array(); $urls[] = new Oara_Curl_Request('http://darwin.affiliatewindow.com' . $matches[1], array()); $exportReport = $this->_exportClient->get($urls); } else { throw new Exception("It couldn't connect to darwin"); } $urls = array(); $urls[] = new Oara_Curl_Request('https://www.affiliatewindow.com/affiliates/accountdetails.php', array()); $exportReport = $this->_exportClient->get($urls); $dom = new Zend_Dom_Query($exportReport[0]); $apiPassword = $dom->query('#aw_api_password_hash'); $apiPassword = $apiPassword->current(); if ($apiPassword != null && $apiPassword->nodeValue == $password) { break; } } } } else { throw new Exception("It's not an email"); } $nameSpace = 'http://api.affiliatewindow.com/'; $wsdlUrl = 'http://api.affiliatewindow.com/v3/AffiliateService?wsdl'; //Setting the client. $this->_apiClient = new Oara_Import_Soap_Client($wsdlUrl, array('login' => $user, 'encoding' => 'UTF-8', 'password' => $password, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE, 'soap_version' => SOAP_1_1)); //Setting the headers $soapHeader1 = new SoapHeader($nameSpace, 'UserAuthentication', array('iId' => $user, 'sPassword' => $password, 'sType' => 'affiliate'), true, $nameSpace); $soapHeader2 = new SoapHeader($nameSpace, 'getQuota', true, true, $nameSpace); //Adding the headers $this->_apiClient->addSoapInputHeader($soapHeader1, true); $this->_apiClient->addSoapInputHeader($soapHeader2, true); }