File indexing completed on 2024-12-22 05:33:35

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 class Default_Form_ChangePassword extends Zend_Form
0023 {
0024 
0025     public function init()
0026     {
0027         $this->setMethod('POST');
0028         $this->setAction('/change_password/');
0029         $this->addElementPrefixPath('Local', 'Local/');
0030         $this->setAttrib('id', 'changePasswordForm');
0031         //$this->setAttrib('class', 'standard-form row-fluid');
0032 
0033         $this->addElement($this->getHiddenRedirect());
0034 
0035         $pass1 = $this->createElement('password', 'password1')
0036                       ->setLabel('RegisterFormPasswordLabel')
0037                       ->setRequired(true)//->addErrorMessage('RegisterFormPasswordErr')
0038                       ->setDecorators(array('ViewHelper', 'Errors'))
0039                       ->setAttrib('placeholder', 'Password')
0040                       ->addValidator('stringLength', true, array(6, 200))
0041                       ->setAttrib('class', 'form-control')
0042         ;
0043 
0044         $pass2 = $this->createElement('password', 'password2')
0045                       ->setLabel('RegisterFormPassword2Label')
0046                       ->setRequired(true)
0047                       ->addErrorMessage('RegisterFormPassword2Err')
0048                       ->setDecorators(array('ViewHelper', 'Errors'))
0049                       ->setAttrib('placeholder', 'Confirm Password')
0050                       ->setAttrib('class', 'form-control')
0051         ;
0052 
0053         $passValid = new Local_Validate_PasswordConfirm($pass2->getValue());
0054         $pass1->addValidator($passValid, true);
0055 
0056         $submit = $this->createElement('button', 'change');
0057         $submit->setLabel('Change');
0058         $submit->setDecorators(array('ViewHelper'));
0059         //$submit->setAttrib('class', 'btn btn-min-width btn-native');
0060         //$submit->setAttrib('type', 'submit');
0061 
0062 //        $hash = $this->createElement('hash', 'csrfLogin', array('salt' => 'PlattenSpalter'));
0063 //        $hash->setDecorators(array('ViewHelper', 'Errors'));
0064 //        $hash->getValidator('Identical')->setMessage('Your session is outdated. Please reload the page an try again.');
0065 //        $this->addElement($hash);
0066 
0067 
0068         $this->addElement($pass1);
0069         $this->addElement($pass2);
0070         $this->addElement($submit);
0071     }
0072 
0073     private function getHiddenRedirect()
0074     {
0075         return $this->createElement('hidden', 'redirect')
0076             ->setFilters(array('StringTrim'))
0077             ->setDecorators(
0078                 array(
0079                     array(
0080                         'ViewScript',
0081                         array(
0082                             'viewScript' => 'authorization/viewscripts/input_hidden.phtml',
0083                             'placement' => false
0084                         )
0085                     )
0086                 ));
0087     }
0088 
0089 }