Framework  3.9
SignatureFieldRenderer Class Reference

Provides a very simple digital signature implementation. More...

+ Inheritance diagram for SignatureFieldRenderer:
+ Collaboration diagram for SignatureFieldRenderer:

Public Member Functions

 SignatureFieldRenderer (&$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...
 
 setSignatureField ($signatureField, $errorMessage)
 Overrides the default field used to match when signing. More...
 
 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 StringFieldRenderer
 StringFieldRenderer (&$parent)
 
 renderScript ($field)
 FieldRenderers can override this method to provide any Javascript that their control requires for an edit form. More...
 
 renderField ($field, $readonly=false)
 
 renderSearchField ($field, $mode="equal")
 FieldRenderers must override this method to provide the HTML implementation of the control displayed for the field in a search form. More...
 
 format ($field)
 
- 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...
 
 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

 $errorMessage = "Your signature does not match your password. Please try again."
 
 $password = true
 Whether to mask the input in the signature field. More...
 
 $autocomplete = false
 Whether to allow autocomplete. More...
 
 $signatureField = "password"
 The field to check for a match when signing. More...
 
- Public Attributes inherited from StringFieldRenderer
 $size = 50
 
 $limit = 0
 optional - restricts users from entering character count over limit More...
 
 $autocomplete = true
 default is true. Set to false to disable autocompletion More...
 
 $onChange = ""
 optional (javascript) callback on data input change More...
 
 $disable = false
 alternative to readonly; field can be reenabled thru javascript More...
 
 $password = false
 Render the field as a password field (masked characters) More...
 
 $template = ""
 StringTypeRenderer template for readonly format (e.g., "prettify") More...
 
 $confirm = false
 Render a second field for the user to confirm their entry (for email addresses, etc) More...
 
 $width = ""
 Optionally specify a CSS width for the field. More...
 
 $CSSclass = ""
 Optionally specify a CSS class for the field. More...
 
 $numeric = false
 Restrict to numeric input. More...
 
 $onKeyPress = null
 Optional key press javascript callback. Note that if $limit is set, it will override this. More...
 
 $placeholder = null
 Placeholder text to display when field is empty. More...
 
- 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

Provides a very simple digital signature implementation.

All it can say is that the correct password was entered by the given user at a given point in time.

Author
andy

Definition at line 14 of file signature_field_renderer.inc.

Member Function Documentation

◆ addValidatorsToForm()

SignatureFieldRenderer::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 StringFieldRenderer.

Definition at line 29 of file signature_field_renderer.inc.

30  {
31  $label = isset($this->label) ? $this->label : $this->parent->prettifyFieldName($field);
32 
33  $this->parent->validator->add(new SignatureValidator($field, $label, $this->errorMessage, $this->signatureField));
34  if ($required)
35  {
36  $this->parent->validator->add(new RequiredValidator($field, $label));
37  }
38  }
RequiredField Validator.
Definition: validation.inc:76
Validates that the user's supplied password is correct.

◆ preProcess()

SignatureFieldRenderer::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 100 of file signature_field_renderer.inc.

101  {
102  global $user;
103 
104  if (!$_POST[$field]) return;
105 
106  $obj = $this->parent->data;
107  if ($this->signatureField == "password")
108  {
109  $obj->set($field, $user->hashPassword($_POST[$field]).":".today().":".$user->get($user->getPrimaryKey()));
110  }
111  else
112  {
113  $obj->set($field, $_POST[$field]).":".today().":".$user->get($user->getPrimaryKey());
114  }
115  }
today()
Returns today as a string.
Definition: functions.inc:424

◆ renderField()

SignatureFieldRenderer::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 51 of file signature_field_renderer.inc.

52  {
53  if ($this->parent->msg)
54  {
55  //Clear out field if the form is in error, to force user to re-enter
56  $this->parent->data->set($field, '');
57  }
58 
59  if ($this->parent->data->get($field))
60  {
61  $this->renderReadOnly($field);
62  }
63  else
64  {
65  parent::renderField($field);
66  }
67  }

◆ renderReadOnly()

SignatureFieldRenderer::renderReadOnly (   $field = "")

Reimplemented from StringFieldRenderer.

Definition at line 69 of file signature_field_renderer.inc.

70  {
71  if (!$field) $field = $this->field;
72  $value = $this->parent->data->get($field);
73  list($signature,$date,$user_id) = explode(":", $value);
74 
75  if ($user_id)
76  {
77  try
78  {
79  $mgr = new UserManager();
80  $u = $mgr->getUser($user_id);
81  $msg = "Signed by ".$mgr->getUserFullName($u)." on $date";
82  }
83  catch(Exception $e)
84  {
85  $msg = "Invalid Signature";
86  }
87  }
88  else
89  {
90  $msg = "Not signed";
91  }
92 
93  $this->_startField($field);
94 
95  echo $msg;
96 
97  $this->_endField($field);
98  }
_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.

◆ setSignatureField()

SignatureFieldRenderer::setSignatureField (   $signatureField,
  $errorMessage 
)

Overrides the default field used to match when signing.

Parameters
string$signatureFieldthe field that is to be match (i.e. email, username)
string$errorMessagethe error message to display when the match fails

Definition at line 45 of file signature_field_renderer.inc.

46  {
47  $this->signatureField = $signatureField;
48  $this->errorMessage = $errorMessage;
49  }
$signatureField
The field to check for a match when signing.

◆ SignatureFieldRenderer()

SignatureFieldRenderer::SignatureFieldRenderer ( $parent)

Definition at line 22 of file signature_field_renderer.inc.

23  {
25  $this->password = true;
26  $this->autocomplete = false;
27  }

Member Data Documentation

◆ $autocomplete

SignatureFieldRenderer::$autocomplete = false

Whether to allow autocomplete.

Definition at line 19 of file signature_field_renderer.inc.

◆ $errorMessage

SignatureFieldRenderer::$errorMessage = "Your signature does not match your password. Please try again."

Definition at line 16 of file signature_field_renderer.inc.

◆ $password

SignatureFieldRenderer::$password = true

Whether to mask the input in the signature field.

Definition at line 18 of file signature_field_renderer.inc.

◆ $signatureField

SignatureFieldRenderer::$signatureField = "password"

The field to check for a match when signing.

Definition at line 20 of file signature_field_renderer.inc.


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