Framework  3.9
PasswordFieldRenderer Class Reference

Field renderer for password data fields. More...

+ Inheritance diagram for PasswordFieldRenderer:
+ Collaboration diagram for PasswordFieldRenderer:

Public Member Functions

 PasswordFieldRenderer (&$parent)
 
 addValidatorsToForm ($field, $required=false)
 This method is called by the AutoForm to add any default input validators that are required by the FieldRenderer. More...
 
 renderScript ($field)
 FieldRenderers can override this method to provide any Javascript that their control requires for an edit form. More...
 
 renderPasswordBlock ($field, $display="block")
 
 renderField ($field)
 FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field. More...
 
 renderReadOnly ($field)
 
 preProcess ($field="")
 FieldRenderers can override this method to provide behavior that occurs prior to the saving of the parent form's target object to the database. More...
 
- Public Member Functions inherited from FieldRenderer
 FieldRenderer ($parent)
 Constructor. More...
 
 _printLabel ($field, $colspan=1, $styles="", $annotation="")
 Internal method to generate the HTML for the field label. More...
 
 _getLabel ($field, $addSuffix=true)
 
 _startField ($field, $styles="")
 Internal method to generate the starting HTML for the field (including the label) More...
 
 _endField ($field)
 Internal method to generate the closing HTML for the field. More...
 
 addSearchValidatorsToForm ($field, $mode, $required=false)
 For SearchForm, the validator field needs to match the name tag in the form which is in the format field:mode. More...
 
 formatName ($item, $name)
 Formats the given DataItem based on the supplied format string. More...
 
 renderSearchScript ($field, $mode)
 FieldRenderers can override this method to provide any Javascript that the control requires when being used in a search form. More...
 
 renderSearchField ($field, $mode)
 FieldRenderers must override this method to provide the HTML implementation of the control displayed for the field in a search form. More...
 
 renderOnSubmitHandler ($field)
 FieldRenderers can override this method to provide any Javascript that must be executed when the form is submitted on the client. More...
 
 postProcess ($field="")
 FieldRenderers can override this method to provide behavior that occurs after the parent form's target object has been saved to the database. More...
 

Public Attributes

 $encryptor
 
 $forceReset = false
 true if user logged in with a temporary token More...
 
 $numeric = false
 
 $allowEmpty = false
 
- Public Attributes inherited from FieldRenderer
 $parent = null
 
 $labelSuffix = ""
 
 $colspan = 1
 
 $annotateBefore = false
 
 $annotateNextLine = true
 
 $hideLabel = false
 
 $onPreProcess = null
 callback hook for processing prior to saving the form's data object - individual renderers may override with custom processing More...
 
 $onPostProcess = null
 callback hook for processing after saving the form's data object - individual renderers may override with custom processing More...
 

Detailed Description

Field renderer for password data fields.

Renders as a compound control with password and confirmation fields. Additionally, if updating an existing record the user must click "Update Password" to gain access to these fields.

Definition at line 46 of file password_field_renderer.inc.

Member Function Documentation

◆ addValidatorsToForm()

PasswordFieldRenderer::addValidatorsToForm (   $field,
  $required = false 
)

This method is called by the AutoForm to add any default input validators that are required by the FieldRenderer.

Fields that need custom validation or a custom required validator should override this function.

Parameters
string$fieldthe field name
boolean$required- whether the field is required

Reimplemented from FieldRenderer.

Definition at line 59 of file password_field_renderer.inc.

60  {
61  $label = str_replace("*", "", $this->parent->prettifyFieldName($field));
62  $this->parent->match($field, $label, "{$field}_confirm", "Confirmation");
63  $this->parent->password($field, $label);
64  }

◆ PasswordFieldRenderer()

PasswordFieldRenderer::PasswordFieldRenderer ( $parent)

Definition at line 53 of file password_field_renderer.inc.

54  {
55  $this->FieldRenderer($parent);
56 
57  }
FieldRenderer($parent)
Constructor.

◆ preProcess()

PasswordFieldRenderer::preProcess (   $field = "")

FieldRenderers can override this method to provide behavior that occurs prior to the saving of the parent form's target object to the database.

For example, the FileUploadFieldRenderer overrides this method to process the uploading of the file and then store the location in the associated field in the target object.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 142 of file password_field_renderer.inc.

143  {
144  $pk = $this->parent->data->getPrimaryKey();
145 
146  if (!$this->parent->data->$pk || $_POST["{$this->parent->id}_{$field}_reset_password"])
147  {
148  $password = $_POST[$field];
149  }
150  else
151  {
152  if ($this->parent->data->getFilter() == null)
153  {
154  $this->parent->data->setFilter(new ExclusionFilter());
155  }
156 
157  $filter = $this->parent->data->getFilter();
158 
159  if ($filter->type == "ExclusionFilter")
160  {
161  $filter->add($field);
162  }
163  else
164  {
165  $filter->remove($field);
166  }
167  }
168 
169  if ($this->allowEmpty && !$password)
170  {
171  $this->parent->data->set($field, "");
172  }
173  else
174  {
175  $encryptor = $this->parent->passwordEncryptor;
176 
177  trace("Encryptor: $encryptor", 3);
178 
179  if ($encryptor)
180  {
181  $password = $this->parent->data->$encryptor($password);
182  }
183  else
184  {
185  $password = crypt($password);
186  }
187 
188  $this->parent->data->set($field, $password);
189  }
190  }
Used to place a filter on the contents of a DataItem-derived object.
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010

◆ renderField()

PasswordFieldRenderer::renderField (   $field)

FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 109 of file password_field_renderer.inc.

110  {
111  $pk = $this->parent->data->getPrimaryKey();
112 
113  $this->_startField($field);
114 
115  if (($this->parent->data->get($pk) && !$this->forceReset) || $this->allowEmpty)
116  {
117  $verb = ($this->allowEmpty && !$this->parent->data->get($pk)) ? "set" : "reset";
118 
119  echo "<a id='{$this->parent->id}_{$field}_link' href='#' onclick='{$this->parent->id}_{$field}_showPassword();return false;'>Click to {$verb} password</a>\n";
120  $this->renderPasswordBlock($field, "none");
121  echo "<input type='hidden' id='{$this->parent->id}_{$field}_reset_password' name='{$this->parent->id}_{$field}_reset_password' value=''/>\n";
122  }
123  else
124  {
125  $this->renderPasswordBlock($field);
126  echo "<input type='hidden' id='{$this->parent->id}_{$field}_reset_password' name='{$this->parent->id}_{$field}_reset_password' value='1'/>\n";
127  }
128 
129  $this->_endField($field);
130 
131  }
_startField($field, $styles="")
Internal method to generate the starting HTML for the field (including the label)
_endField($field)
Internal method to generate the closing HTML for the field.
renderPasswordBlock($field, $display="block")

◆ renderPasswordBlock()

PasswordFieldRenderer::renderPasswordBlock (   $field,
  $display = "block" 
)

Definition at line 89 of file password_field_renderer.inc.

90  {
91  $enter = $this->parent->passwordEnterLabel;
92  $confirm = $this->parent->passwordConfirmLabel;
93  $size = $this->numeric ? "6" : "20";
94  $onKeyPress = $this->numeric ? " onkeypress='return maskInput(event, $allowneg);'" : ""
95 ?>
96  <table border="0" cellspacing="0" cellpadding="0" id="<?echo $this->parent->id ?>_<?echo $field?>_block" style="padding: 0px; display: <?echo $display ?>">
97  <tr>
98  <td style="vertical-align: top; text-align: left"><?echo $enter?>&nbsp;</td>
99  <td style="padding-bottom: 2px"><input type="password" autocomplete="new-password" name="<?echo $field?>" id="<?echo $this->parent->id?>_<?echo $field?>" size="<?echo $size?>"<?echo $onKeyPress?> value=""/></td>
100  </tr>
101  <tr>
102  <td style="vertical-align: top; text-align: left"><?echo $confirm?>&nbsp;</td>
103  <td><input type="password" name="<?echo $field?>_confirm" id="<?echo $this->parent->id?>_<?echo $field?>_confirm" size="<?echo $size?>"<?echo $onKeyPress?> value=""/></td>
104  </tr>
105  </table>
106 <?
107  }

◆ renderReadOnly()

PasswordFieldRenderer::renderReadOnly (   $field)

Definition at line 133 of file password_field_renderer.inc.

134  {
135  $this->_startField($field);
136 
137  echo "<i>Password is hidden</i>\n";
138 
139  $this->_endField($field);
140  }

◆ renderScript()

PasswordFieldRenderer::renderScript (   $field)

FieldRenderers can override this method to provide any Javascript that their control requires for an edit form.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 66 of file password_field_renderer.inc.

67  {
68  if (!$this->_includedPasswordScript)
69  {
70 ?>
71 <script type='text/javascript'>
72 <!--
73 function <?echo $this->parent->id?>_<?echo $field?>_showPassword()
74 {
75  var link = document.getElementById("<?echo $this->parent->id?>_<?echo $field?>_link");
76  var block = document.getElementById("<?echo $this->parent->id?>_<?echo $field?>_block");
77  document.id("<?echo $this->parent->id ?>_<?echo $field?>_reset_password").value = 1;
78 
79  link.style.display = "none";
80  block.style.display = "block";
81  ModalDialog.recenterActiveDialog();
82 }
83 //-->
84 </script>
85 <? $this->_includedPasswordScript = true;
86  }
87  }

Member Data Documentation

◆ $allowEmpty

PasswordFieldRenderer::$allowEmpty = false

Definition at line 51 of file password_field_renderer.inc.

◆ $encryptor

PasswordFieldRenderer::$encryptor

Definition at line 48 of file password_field_renderer.inc.

◆ $forceReset

PasswordFieldRenderer::$forceReset = false

true if user logged in with a temporary token

Definition at line 49 of file password_field_renderer.inc.

◆ $numeric

PasswordFieldRenderer::$numeric = false

Definition at line 50 of file password_field_renderer.inc.


The documentation for this class was generated from the following file: