<?php
namespace Moto\Application\Users; use Moto\InputFilter\AbstractInputFilter; use Moto; class NewUserFilter extends AbstractInputFilter { protected $_name = 'users.new'; public function init() { $this->add(array( 'name' => 'name', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 1, 'max' => 100, ), ), ), )); $this->_addElementEmail(); $this->add(array( 'name' => 'password', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 6, 'max' => 100, ), ), ), )); $this->add(array( 'name' => 'password_confirm', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 6, 'max' => 100, ), ), array( 'name' => 'Identical', 'options' => array( 'token' => 'password' ) ), ), )); $this->add(array( 'name' => 'role_id', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'Digits', ), ), )); $this->add(array( 'name' => 'language_id', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'Digits', ), ), )); $this->add(array( 'name' => 'send_email', 'required' => false, 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array(false, true) ) ), ), )); } protected function _addElementEmail() { $this->add(array( 'name' => 'email', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'EmailAddress', 'options' => array( 'useMxCheck' => false, 'useDeepMxCheck' => false, 'useDomainCheck' => false, ), ), array( 'name' => 'Db\NoRecordExists', 'options' => array( 'table' => Moto\Config::get('database.prefix') . 'users', 'field' => 'email', 'adapter' => Moto\Config::get('databaseAdapter') ) ) ), )); } } 