/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/form/form_elements/FEPassword.inc
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/form/form_elements/FEPassword.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Thu Aug 11 14:09:59 2005 UTC (18 years, 11 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +5 -5 lines
+ updated to version 2.5.3

1 <?php
2 /**
3 * This file contains the Password FormElement class.
4 *
5 * $Id: FEPassword.inc,v 1.10.2.2 2005/05/12 01:24:03 hemna Exp $
6 *
7 * @author Walter A. Boring IV <waboring@newsblob.com>
8 * @author Suren Markosyan <suren@bcsweb.com>
9 * @package phpHtmlLib
10 * @subpackage FormProcessing
11 *
12 * @copyright LGPL - See LICENCE
13 *
14 */
15
16 /**
17 * This is the Password FormElement which builds a
18 * input field of type="password". It validates
19 * the data as is_password().
20 *
21 * NOTE: this is used in conjunction with the
22 * FEConfirmPassword object to ensure the
23 * user's input is what they wanted.
24 *
25 *
26 * @author Walter A. Boring IV <waboring@newsblob.com>
27 * @author Suren Markossian <suren@bcsweb.com>
28 * @package phpHtmlLib
29 * @subpackage FormProcessing
30 *
31 * @copyright LGPL - See LICENCE
32 */
33 class FEPassword extends FEText {
34
35 /**
36 * This function builds and returns the
37 * form element object
38 *
39 * @return object
40 */
41 function get_element() {
42 $attributes = $this->_build_element_attributes();
43 $attributes["type"] = "password";
44 $attributes["value"] = '';
45 return new INPUTtag($attributes);
46 }
47
48
49 /**
50 * return a string to the user for the
51 * confirmation page
52 *
53 * @return string
54 */
55 function get_value_text() {
56 return str_repeat('*', strlen($this->get_value()));
57 }
58
59
60 /**
61 * This function performs the actual validation
62 * It is called only if the validation is required by
63 * this element
64 *
65 * This function is responsible for performing complete
66 * validation and setting the appropriate error message
67 * in case of a failed validation
68 *
69 * @param FormValidation object
70 */
71 function validate(&$_FormValidation) {
72 if (!$_FormValidation->is_password($this->get_value())) {
73 $this->set_error_message( $_FormValidation->get_error_message() );
74 return FALSE;
75 }
76 return TRUE;
77 }
78 }
79
80 /**
81 * This is the ConfirmPassword FormElement which builds a
82 * input field of type="password". It requires the caller
83 * to add a FEPassword object to this class to have something
84 * to compare during validation time.
85 * It first validates that the value is_password(), and then
86 * makes sure it matches exactly what the value is in
87 * the FEPassword.
88 *
89 * USE: after u create the FEConfirmPassword, you MUST call
90 * password() method which adds a reference to the FEPassword
91 * object, so it can validate against.
92 *
93 *
94 * @author Walter A. Boring IV <waboring@newsblob.com>
95 * @author Suren Markossian <suren@bcsweb.com>
96 * @package phpHtmlLib
97 * @subpackage FormProcessing
98 *
99 * @copyright LGPL - See LICENCE
100 */
101 class FEConfirmPassword extends FEPassword {
102
103 /**
104 * This holds the FEPassword we are
105 * trying to confirm
106 */
107 var $_fepassword = NULL;
108
109 /**
110 * use this function to add the
111 * FEPassword object that we want
112 * to confirm.
113 *
114 * @param FEPassword object
115 */
116 function password( &$fepassword ) {
117 $this->_fepassword = &$fepassword;
118 }
119
120
121 /**
122 * This function performs the actual validation
123 * It is called only if the validation is required by
124 * this element
125 *
126 * This function is responsible for performing complete
127 * validation and setting the appropriate error message
128 * in case of a failed validation
129 *
130 * @param FormValidation object
131 */
132 function validate(&$_FormValidation) {
133 if (!$_FormValidation->is_password($this->get_value())) {
134 $this->set_error_message( $_FormValidation->get_error_message() );
135 return FALSE;
136 }
137
138 if ($this->_fepassword == NULL) {
139 $this->set_error_message( "No Password to confirm. ".
140 "please use FEConfirmPassword::password() ".
141 "to set the FEPassword you wish to ".
142 "confirm");
143 return FALSE;
144 }
145
146 //looks like we have an FEPassword to confirm against
147 if (!$_FormValidation->is_confirm_password($this->get_value(),
148 $this->_fepassword->get_value())) {
149 $this->set_error_message( $_FormValidation->get_error_message() );
150 return FALSE;
151 }
152
153 return TRUE;
154 }
155 }
156 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed