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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Feb 22 21:07:48 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
+ updated whole lib to version 2.2.1 (new FormProcessing since 2.2.0!)

1 jonen 1.1 <?php
2     /**
3     * This file contains the Password FormElement class.
4     *
5     * $Id: FEPassword.inc,v 1.8 2003/02/18 23:02:00 hemna Exp $
6     *
7     * @author Walter A. Boring IV <waboring@buildabetterweb.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@buildabetterweb.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     * This function performs the actual validation
51     * It is called only if the validation is required by
52     * this element
53     *
54     * This function is responsible for performing complete
55     * validation and setting the appropriate error message
56     * in case of a failed validation
57     *
58     */
59     function validate() {
60     $v = new FormValidation;
61     if (!$v->is_password($this->get_value())) {
62     $this->set_error_message( $v->get_error_message() );
63     return FALSE;
64     }
65     return TRUE;
66     }
67     }
68    
69     /**
70     * This is the ConfirmPassword FormElement which builds a
71     * input field of type="password". It requires the caller
72     * to add a FEPassword object to this class to have something
73     * to compare during validation time.
74     * It first validates that the value is_password(), and then
75     * makes sure it matches exactly what the value is in
76     * the FEPassword.
77     *
78     * USE: after u create the FEConfirmPassword, you MUST call
79     * password() method which adds a reference to the FEPassword
80     * object, so it can validate against.
81     *
82     *
83     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
84     * @author Suren Markossian <suren@bcsweb.com>
85     * @package phpHtmlLib
86     * @subpackage FormProcessing
87     *
88     * @copyright LGPL - See LICENCE
89     */
90     class FEConfirmPassword extends FEPassword {
91    
92     /**
93     * This holds the FEPassword we are
94     * trying to confirm
95     */
96     var $_fepassword = NULL;
97    
98     /**
99     * use this function to add the
100     * FEPassword object that we want
101     * to confirm.
102     *
103     * @param FEPassword object
104     */
105     function password( &$fepassword ) {
106     $this->_fepassword = &$fepassword;
107     }
108    
109    
110     /**
111     * This function performs the actual validation
112     * It is called only if the validation is required by
113     * this element
114     *
115     * This function is responsible for performing complete
116     * validation and setting the appropriate error message
117     * in case of a failed validation
118     *
119     */
120     function validate() {
121     $v = new FormValidation;
122     if (!$v->is_password($this->get_value())) {
123     $this->set_error_message( $v->get_error_message() );
124     return FALSE;
125     }
126    
127     if ($this->_fepassword == NULL) {
128     $this->set_error_message( "No Password to confirm. ".
129     "please use FEConfirmPassword::password() ".
130     "to set the FEPassword you wish to ".
131     "confirm");
132     return FALSE;
133     }
134    
135     //looks like we have an FEPassword to confirm against
136     if (!$v->is_confirm_password($this->get_value(),
137     $this->_fepassword->get_value())) {
138     $this->set_error_message( $v->get_error_message() );
139     return FALSE;
140     }
141    
142     return TRUE;
143     }
144     }
145     ?>

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