File indexing completed on 2025-02-23 05:29:07
0001 <?php 0002 0003 /** 0004 * ocs-webserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-webserver. 0009 * 0010 * This program is free software: you can redistribute it and/or modify 0011 * it under the terms of the GNU Affero General Public License as 0012 * published by the Free Software Foundation, either version 3 of the 0013 * License, or (at your option) any later version. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Affero General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Affero General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 **/ 0023 class Default_Form_Rectification extends Zend_Form 0024 { 0025 0026 /** 0027 * @throws Zend_Exception 0028 * @throws Zend_Form_Exception 0029 * @throws Zend_Validate_Exception 0030 */ 0031 public function init() 0032 { 0033 $this->addElementPrefixPath('Local', 'Local/'); 0034 0035 $usernameValidChars = new Zend_Validate_Regex('/^(?=.{4,20}$)(?![-])(?!.*[-]{2})[a-z0-9-]+(?<![-])$/'); 0036 $userExistCheck = new Local_Validate_UsernameExists(); 0037 $userExistCheck->setMessage('This username already exists.', Local_Validate_UsernameExists::EXISTS); 0038 $userEmptyCheck = new Zend_Validate_NotEmpty(); 0039 $userEmptyCheck->setMessage('RegisterFormUsernameErr', Zend_Validate_NotEmpty::IS_EMPTY); 0040 $userNameLength = new Zend_Validate_StringLength(array('min' => 4, 'max' => 40)); 0041 $groupNameExists = new Local_Validate_GroupnameExistsInOpenCode(); 0042 0043 $fname = $this->createElement('text', 'username') 0044 ->setDecorators(array('ViewHelper', 'Errors')) 0045 ->addFilter(new Zend_Filter_StringTrim()) 0046 ->addFilter(new Zend_Filter_StripNewlines()) 0047 ->addValidator($userEmptyCheck, true) 0048 ->addValidator($userNameLength, true) 0049 ->addValidator($usernameValidChars, true) 0050 ->addValidator($userExistCheck, true) 0051 ->addValidator($groupNameExists, true) 0052 ; 0053 0054 $mailValidCheck = new Zend_Validate_EmailAddress(); 0055 $mailValidCheck->setMessage('RegisterFormEmailErrNotValid', Zend_Validate_EmailAddress::INVALID) 0056 ->setMessage('RegisterFormEmailErrNotValid', Zend_Validate_EmailAddress::INVALID_FORMAT) 0057 ->setMessage('RegisterFormEmailErrNotValid', Zend_Validate_EmailAddress::INVALID_LOCAL_PART) 0058 ->setMessage("RegisterFormEmailErrWrongHost", Zend_Validate_EmailAddress::INVALID_HOSTNAME) 0059 ->setMessage("RegisterFormEmailErrWrongHost2", Zend_Validate_Hostname::INVALID_HOSTNAME) 0060 ->setMessage("RegisterFormEmailErrHostLocal", Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED) 0061 ->setOptions(array('domain' => true)) 0062 ; 0063 0064 $mailExistCheck = new Local_Validate_EmailExists(); 0065 $mailExistCheck->setMessage('RegisterFormEmailErrAlreadyRegistered', Local_Validate_EmailExists::EXISTS); 0066 0067 $mailEmpty = new Zend_Validate_NotEmpty(); 0068 $mailEmpty->setMessage('RegisterFormEmailErrEmpty', Zend_Validate_NotEmpty::IS_EMPTY); 0069 0070 $mailValidatorChain = new Zend_Validate(); 0071 $mailValidatorChain->addValidator($mailEmpty, true) 0072 ->addValidator($mailValidCheck, true) 0073 ->addValidator($mailExistCheck, true); 0074 0075 $mail = $this->createElement('text', 'mail') 0076 ->setLabel('RegisterFormEmailLabel') 0077 ->addValidator($mailEmpty, true) 0078 ->addValidator($mailValidCheck, true) 0079 ->addValidator($mailExistCheck, true) 0080 ->setDecorators(array( 0081 'ViewHelper', 0082 'Errors' 0083 )) 0084 ; 0085 0086 $submit = $this->createElement('button', 'save'); 0087 $submit->setLabel('Save'); 0088 $submit->setDecorators(array('ViewHelper')); 0089 0090 $this->addElement($fname) 0091 ->addElement($mail) 0092 ->addElement($submit); 0093 } 0094 0095 }