Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_actions_form_UserPassword | |
0.00% |
0 / 26 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | use oat\generis\model\user\PasswordConstraintsService; |
| 26 | |
| 27 | /** |
| 28 | * Short description of class tao_actions_form_UserPassword |
| 29 | * |
| 30 | * @access public |
| 31 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 32 | * @package tao |
| 33 | |
| 34 | */ |
| 35 | class tao_actions_form_UserPassword extends tao_helpers_form_FormContainer |
| 36 | { |
| 37 | /** |
| 38 | * Short description of method initForm |
| 39 | * |
| 40 | * @access public |
| 41 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 42 | * @return mixed |
| 43 | */ |
| 44 | public function initForm() |
| 45 | { |
| 46 | |
| 47 | $this->form = tao_helpers_form_FormFactory::getForm('password'); |
| 48 | |
| 49 | $actions = tao_helpers_form_FormFactory::getCommonActions('top'); |
| 50 | $this->form->setActions($actions, 'top'); |
| 51 | $this->form->setActions($actions, 'bottom'); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Short description of method initElements |
| 56 | * |
| 57 | * @access public |
| 58 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 59 | */ |
| 60 | public function initElements() |
| 61 | { |
| 62 | |
| 63 | $pass1Element = tao_helpers_form_FormFactory::getElement('oldpassword', 'Hiddenbox'); |
| 64 | $pass1Element->setDescription(__('Old Password')); |
| 65 | $pass1Element->addValidator( |
| 66 | tao_helpers_form_FormFactory::getValidator('Callback', [ |
| 67 | 'message' => __('Passwords are not matching'), |
| 68 | 'object' => tao_models_classes_UserService::singleton(), |
| 69 | 'method' => 'isPasswordValid', |
| 70 | 'param' => tao_models_classes_UserService::singleton()->getCurrentUser() |
| 71 | ]) |
| 72 | ); |
| 73 | $this->form->addElement($pass1Element); |
| 74 | |
| 75 | $pass2Element = tao_helpers_form_FormFactory::getElement('newpassword', 'Hiddenbox'); |
| 76 | $pass2Element->setDescription(__('New password')); |
| 77 | $pass2Element->addValidators(PasswordConstraintsService::singleton()->getValidators()); |
| 78 | $pass2Element->setBreakOnFirstError(false); |
| 79 | $this->form->addElement($pass2Element); |
| 80 | |
| 81 | $pass3Element = tao_helpers_form_FormFactory::getElement('newpassword2', 'Hiddenbox'); |
| 82 | $pass3Element->setDescription(__('Repeat new password')); |
| 83 | $pass3Element->addValidators([ |
| 84 | tao_helpers_form_FormFactory::getValidator('Password', ['password2_ref' => $pass2Element]), |
| 85 | ]); |
| 86 | $this->form->addElement($pass3Element); |
| 87 | } |
| 88 | } |