Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_helpers_form_validators_Password | |
0.00% |
0 / 15 |
|
0.00% |
0 / 2 |
90 | |
0.00% |
0 / 1 |
| evaluate | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
72 | |||
| getDefaultMessage | |
0.00% |
0 / 1 |
|
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 | /** |
| 26 | * Short description of class tao_helpers_form_validators_Password |
| 27 | * |
| 28 | * @access public |
| 29 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 30 | * @package tao |
| 31 | |
| 32 | */ |
| 33 | class tao_helpers_form_validators_Password extends tao_helpers_form_Validator |
| 34 | { |
| 35 | // --- ASSOCIATIONS --- |
| 36 | |
| 37 | |
| 38 | // --- ATTRIBUTES --- |
| 39 | |
| 40 | // --- OPERATIONS --- |
| 41 | |
| 42 | /** |
| 43 | * Short description of method evaluate |
| 44 | * |
| 45 | * @access public |
| 46 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 47 | * @param values |
| 48 | * @return boolean |
| 49 | */ |
| 50 | public function evaluate($values) |
| 51 | { |
| 52 | $returnValue = (bool) false; |
| 53 | |
| 54 | |
| 55 | if (is_array($values) && count($values) == 2) { |
| 56 | list($first, $second) = $values; |
| 57 | $returnValue = $first == $second; |
| 58 | } elseif ($this->hasOption('password2_ref')) { |
| 59 | $secondElement = $this->getOption('password2_ref'); |
| 60 | if (is_null($secondElement) || ! $secondElement instanceof tao_helpers_form_FormElement) { |
| 61 | throw new common_Exception("Please set the reference of the second password element"); |
| 62 | } |
| 63 | if ($values == $secondElement->getRawValue() && trim($values) != '') { |
| 64 | $returnValue = true; |
| 65 | } |
| 66 | } else { |
| 67 | throw new common_Exception( |
| 68 | "Please set the reference of the second password element or provide array of 2 elements" |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | |
| 74 | return (bool) $returnValue; |
| 75 | } |
| 76 | |
| 77 | protected function getDefaultMessage() |
| 78 | { |
| 79 | return __('Passwords are not matching'); |
| 80 | } |
| 81 | } |