Contact
extends ContactLib
in package
Contact
This module handles all HTML FORMs with action tags to the contact section. It sends the contact email(s) and uploads data (optional) Ex. <FORM name="form1" action="index.php?section=Contact&cmd=thanks" method="post">
Tags
Table of Contents
Constants
- CHECK_TYPE_ALL = 1
- CHECK_TYPE_ALPHA = 4
- CHECK_TYPE_EMAIL = 2
- CHECK_TYPE_INTEGER = 5
- CHECK_TYPE_URL = 3
Properties
- $_arrSettings : mixed
- $arrCheckTypes : mixed
- Regexpression list
- $arrFormFields : array<string|int, mixed>
- List with the names of the formular fields
- $arrForms : mixed
- $errorMsg : mixed
- Contains the error message if an error occurs
- $objTemplate : unknown_type
- Template object
- $_arrRecipients : mixed
- $_lastRecipientId : mixed
- $depositionTarget : string
- used by @link Contact::_uploadFiles() .
- $hasFileField : bool
- Determines whether this form has a file upload field.
- $legacyMode : bool
- Legacy file upload mode
Methods
- _checkValues() : bool
- Checks the Values sent trough post
- _deleteFormRecipients() : bool
- delete recipients
- _getContactFormData() : mixed
- Get data from contact form submit
- _getEmailAdressOfString() : mixed
- Searches for a valid e-mail address
- _getError() : string
- Get the error message
- _getJsSourceCode() : mixed
- Get Javascript Source
- _insertIntoDatabase() : bool
- Inserts the contact form submit into the database
- _isSpam() : bool
- Checks a string for spam keywords
- _sortFormData() : int
- Sort the form input data
- _uploadFilesLegacy() : array<string|int, mixed>
- Upload submitted files
- addForm() : mixed
- Add a new form
- deleteFormEntry() : mixed
- getContactFormCaptchaStatus() : mixed
- getContactFormDetails() : mixed
- getContactPage() : mixed
- Parse contact form page
- getFormEntries() : mixed
- getFormEntry() : mixed
- getFormFieldNames() : mixed
- getFormFields() : array<string|int, mixed>
- Get the form fields
- getHighestSortValue() : int
- return the highest sort value of a recipient list
- getLastRecipientId() : int
- return the last recipient id
- getRecipients() : array<string|int, mixed>
- Return the recipients of a form
- getSettings() : mixed
- initCheckTypes() : mixed
- initContactForms() : mixed
- Read the contact forms
- initSettings() : mixed
- isUniqueFormName() : bool
- Check if there already exist a form with this name
- updateForm() : mixed
- Update an existing form
- uploadFinished() : mixed
- _uploadFiles() : array<string|int, mixed>
- Handle uploads
- addFormField() : int
- Add a form field to the database
- addRecipient() : mixed
- Add a new recipient
- cleanFormFields() : mixed
- Remove the form fields that are not in the given list
- cleanRecipients() : mixed
- Delete the recipients that aren't wanted anymore
- deleteForm() : mixed
- Delete a form
- dropUploads() : mixed
- Drop any submitted files in case the storage of form submission is not allowed
- getFormEntity() : mixed
- Get the form entity
- getTemporaryUploadPath() : array<string|int, mixed>
- Gets the temporary upload location for files.
- insertFormLangValues() : mixed
- Insert the language values, update them if they already exist
- setFormFieldLang() : mixed
- Add a form lang to a field
- showError() : string
- Show Error
- showFeedback() : mixed
- Show the feedback message
- updateFormField() : mixed
- Update a form field
- updateRecipient() : mixed
- Update the recipient
- _deleteFormFieldsAndDataByFormId() : mixed
- Delete form fields and data
- sendMail() : mixed
- Sends an email with the contact details to the responsible persons
- setRecipientLang() : mixed
- Set the recipient name of a lang
Constants
CHECK_TYPE_ALL
public
mixed
CHECK_TYPE_ALL
= 1
CHECK_TYPE_ALPHA
public
mixed
CHECK_TYPE_ALPHA
= 4
CHECK_TYPE_EMAIL
public
mixed
CHECK_TYPE_EMAIL
= 2
CHECK_TYPE_INTEGER
public
mixed
CHECK_TYPE_INTEGER
= 5
CHECK_TYPE_URL
public
mixed
CHECK_TYPE_URL
= 3
Properties
$_arrSettings
public
mixed
$_arrSettings
$arrCheckTypes
Regexpression list
public
mixed
$arrCheckTypes
$arrFormFields
List with the names of the formular fields
public
array<string|int, mixed>
$arrFormFields
= array()
$arrForms
public
mixed
$arrForms
$errorMsg
Contains the error message if an error occurs
public
mixed
$errorMsg
= ''
This variable will contain a message that describes the error that happend.
$objTemplate
Template object
public
unknown_type
$objTemplate
This object contains an instance of the \Cx\Core\Html\Sigma class which is used as the template system.
$_arrRecipients
protected
mixed
$_arrRecipients
= array()
$_lastRecipientId
protected
mixed
$_lastRecipientId
$depositionTarget
used by @link Contact::_uploadFiles() .
protected
string
$depositionTarget
remembers the directory made in the first call to _uploadFiles.
$hasFileField
Determines whether this form has a file upload field.
protected
bool
$hasFileField
= false
$legacyMode
Legacy file upload mode
protected
bool
$legacyMode
= false
In legacy file upload mode, file uploads are coming directly from inputs, rather than being handled by the cloudrexx Uploader component.
Q: What is the legacyMode for? A: With legacyMode we support the old submission forms that hadn't been migrated to the new Uploader component or if you want to build a submission form without JavaScript.
TRUE if file uploads are handled the legacy way (through HTTP Form POST).
Methods
_checkValues()
Checks the Values sent trough post
public
_checkValues(mixed $arrFields, mixed $useCaptcha) : bool
Checks the Values sent trough post. Normally this is already done by Javascript, but it could be possible that the client doens't run JS, so this is done here again. Sadly, it is not possible to rewrite the posted values again
Parameters
- $arrFields : mixed
- $useCaptcha : mixed
Tags
Return values
bool —Return FALSE if a field's value isn't valid, otherwise TRUE
_deleteFormRecipients()
delete recipients
public
_deleteFormRecipients(int $id) : bool
Parameters
- $id : int
Return values
bool_getContactFormData()
Get data from contact form submit
public
_getContactFormData() : mixed
Reads out the data that has been submited by the visitor.
Tags
Return values
mixed —An array with the contact details or FALSE if an error occurs
_getEmailAdressOfString()
Searches for a valid e-mail address
public
_getEmailAdressOfString(string $string) : mixed
Returns the first e-mail address that occours in the given string $string
Parameters
- $string : string
Tags
Return values
mixed —Returns an e-mail addess as string, or a boolean false if there is no valid e-mail address in the given string
_getError()
Get the error message
public
_getError() : string
Returns a formatted string with error messages if there happened any errors
Tags
Return values
string —Error messages
_getJsSourceCode()
Get Javascript Source
public
_getJsSourceCode(mixed $id, mixed $formFields[, mixed $preview = false ][, mixed $show = false ]) : mixed
Makes the sourcecode for the javascript based field checking
Parameters
- $id : mixed
- $formFields : mixed
- $preview : mixed = false
- $show : mixed = false
Tags
_insertIntoDatabase()
Inserts the contact form submit into the database
public
_insertIntoDatabase(mixed $arrFormData) : bool
This method does store the request in the database
Parameters
- $arrFormData : mixed
Tags
Return values
bool —TRUE on succes, otherwise FALSE
_isSpam()
Checks a string for spam keywords
public
_isSpam(mixed $string, mixed $arrKeywords) : bool
This method looks for forbidden words in a string that have been defined in the option "Spam protection word list"
Parameters
- $string : mixed
- $arrKeywords : mixed
Tags
Return values
bool —Return TRUE if the string contains an forbidden word, otherwise FALSE
_sortFormData()
Sort the form input data
public
_sortFormData(string $a, string $b) : int
Sorts the input data of the form according of the field's order. This method is used as the comparison function of uksort.
Parameters
- $a : string
- $b : string
Return values
int_uploadFilesLegacy()
Upload submitted files
public
_uploadFilesLegacy(mixed $arrFields) : array<string|int, mixed>
Move all files that are allowed to be uploaded in the folder that has been specified in the configuration option "File upload deposition path"
Parameters
- $arrFields : mixed
Tags
Return values
array<string|int, mixed> —A list of files that have been stored successfully in the system
addForm()
Add a new form
public
addForm(string $emails, bool $showForm, bool $useCaptcha, bool $useCustomStyle, bool $sendCopy, mixed $useEmailOfSender, mixed $sendHtmlMail, mixed $sendAttachment, mixed $saveDataInCrm, mixed $crmCustomerGroups, mixed $sendMultipleReply) : mixed
Parameters
- $emails : string
- $showForm : bool
- $useCaptcha : bool
- $useCustomStyle : bool
- $sendCopy : bool
- $useEmailOfSender : mixed
- $sendHtmlMail : mixed
- $sendAttachment : mixed
- $saveDataInCrm : mixed
- $crmCustomerGroups : mixed
- $sendMultipleReply : mixed
Tags
deleteFormEntry()
public
deleteFormEntry(mixed $id) : mixed
Parameters
- $id : mixed
getContactFormCaptchaStatus()
public
getContactFormCaptchaStatus(mixed $id) : mixed
Parameters
- $id : mixed
getContactFormDetails()
public
getContactFormDetails(mixed $id, mixed &$arrEmails, mixed &$subject, mixed &$feedback, mixed &$mailTemplate, mixed &$showForm, mixed &$useCaptcha, mixed &$sendCopy, mixed &$useEmailOfSender, mixed &$htmlMail, mixed &$sendAttachment, mixed &$saveDataInCRM, mixed &$crmCustomerGroups, mixed &$sendMultipleReply) : mixed
Parameters
- $id : mixed
- $arrEmails : mixed
- $subject : mixed
- $feedback : mixed
- $mailTemplate : mixed
- $showForm : mixed
- $useCaptcha : mixed
- $sendCopy : mixed
- $useEmailOfSender : mixed
- $htmlMail : mixed
- $sendAttachment : mixed
- $saveDataInCRM : mixed
- $crmCustomerGroups : mixed
- $sendMultipleReply : mixed
getContactPage()
Parse contact form page
public
getContactPage(Page $page) : mixed
Parameters
- $page : Page
-
Page object
getFormEntries()
public
getFormEntries(mixed $formId, mixed &$arrCols, mixed $pagingPos, mixed &$paging[, mixed $limit = true ]) : mixed
Parameters
- $formId : mixed
- $arrCols : mixed
- $pagingPos : mixed
- $paging : mixed
- $limit : mixed = true
getFormEntry()
public
getFormEntry(mixed $entryId) : mixed
Parameters
- $entryId : mixed
getFormFieldNames()
public
getFormFieldNames(mixed $id) : mixed
Parameters
- $id : mixed
getFormFields()
Get the form fields
public
getFormFields(int $formID) : array<string|int, mixed>
Parameters
- $formID : int
Tags
Return values
array<string|int, mixed>getHighestSortValue()
return the highest sort value of a recipient list
public
getHighestSortValue(mixed $formId) : int
Parameters
- $formId : mixed
Return values
intgetLastRecipientId()
return the last recipient id
public
getLastRecipientId([mixed $refresh = false ]) : int
Parameters
- $refresh : mixed = false
Return values
intgetRecipients()
Return the recipients of a form
public
getRecipients(int $formID[, mixed $allLanguages = true ]) : array<string|int, mixed>
Parameters
- $formID : int
- $allLanguages : mixed = true
Tags
Return values
array<string|int, mixed>getSettings()
public
getSettings([mixed $reinitialize = false ]) : mixed
Parameters
- $reinitialize : mixed = false
initCheckTypes()
public
initCheckTypes() : mixed
initContactForms()
Read the contact forms
public
initContactForms([int $id = 0 ][, string $order = null ]) : mixed
Parameters
- $id : int = 0
-
Form ID
- $order : string = null
-
the order for the sql query (comes from Sorting class)
initSettings()
public
initSettings() : mixed
isUniqueFormName()
Check if there already exist a form with this name
public
isUniqueFormName(string $name, int $lang[, int $id = 0 ]) : bool
Parameters
- $name : string
- $lang : int
- $id : int = 0
Tags
Return values
boolupdateForm()
Update an existing form
public
updateForm(int $formID, string $emails, bool $showForm, bool $useCaptcha, bool $useCustomStyle, bool $sendCopy, mixed $useEmailOfSender, mixed $sendHtmlMail, mixed $sendAttachment, mixed $saveDataInCrm, mixed $crmCustomerGroups, mixed $sendMultipleReply) : mixed
Parameters
- $formID : int
- $emails : string
- $showForm : bool
- $useCaptcha : bool
- $useCustomStyle : bool
- $sendCopy : bool
- $useEmailOfSender : mixed
- $sendHtmlMail : mixed
- $sendAttachment : mixed
- $saveDataInCrm : mixed
- $crmCustomerGroups : mixed
- $sendMultipleReply : mixed
Tags
uploadFinished()
public
static uploadFinished(mixed $tempPath, mixed $tempWebPath, mixed $data, mixed $uploadId, mixed $fileInfos) : mixed
Parameters
- $tempPath : mixed
- $tempWebPath : mixed
- $data : mixed
- $uploadId : mixed
- $fileInfos : mixed
_uploadFiles()
Handle uploads
protected
_uploadFiles(array<string|int, mixed> $arrFields[, mixed $move = false ]) : array<string|int, mixed>
Parameters
- $arrFields : array<string|int, mixed>
- $move : mixed = false
Tags
Return values
array<string|int, mixed> —A list of files that have been stored successfully in the system
addFormField()
Add a form field to the database
protected
addFormField(int $formID, array<string|int, mixed> $field) : int
Parameters
- $formID : int
- $field : array<string|int, mixed>
Tags
Return values
intaddRecipient()
Add a new recipient
protected
addRecipient(int $formID, array<string|int, mixed> $recipient) : mixed
Parameters
- $formID : int
- $recipient : array<string|int, mixed>
Tags
cleanFormFields()
Remove the form fields that are not in the given list
protected
cleanFormFields(int $formID, array<string|int, mixed> $formFields) : mixed
Parameters
- $formID : int
- $formFields : array<string|int, mixed>
Tags
cleanRecipients()
Delete the recipients that aren't wanted anymore
protected
cleanRecipients(int $formID, array<string|int, mixed> $recipients) : mixed
Parameters
- $formID : int
- $recipients : array<string|int, mixed>
Tags
deleteForm()
Delete a form
protected
deleteForm(mixed $id) : mixed
Parameters
- $id : mixed
Tags
dropUploads()
Drop any submitted files in case the storage of form submission is not allowed
protected
dropUploads(array<string|int, mixed> $arrFormData) : mixed
Parameters
- $arrFormData : array<string|int, mixed>
-
Details of the contact request
getFormEntity()
Get the form entity
protected
getFormEntity(int $id, string $emails, bool $showForm, bool $useCaptcha, bool $useCustomStyle, bool $sendCopy, mixed $useEmailOfSender, mixed $sendHtmlMail, mixed $sendAttachment, mixed $saveDataInCrm, mixed $crmCustomerGroups, mixed $sendMultipleReply) : mixed
Parameters
- $id : int
- $emails : string
- $showForm : bool
- $useCaptcha : bool
- $useCustomStyle : bool
- $sendCopy : bool
- $useEmailOfSender : mixed
- $sendHtmlMail : mixed
- $sendAttachment : mixed
- $saveDataInCrm : mixed
- $crmCustomerGroups : mixed
- $sendMultipleReply : mixed
getTemporaryUploadPath()
Gets the temporary upload location for files.
protected
static getTemporaryUploadPath(mixed $fieldId) : array<string|int, mixed>
Parameters
- $fieldId : mixed
Tags
Return values
array<string|int, mixed> —array('path','webpath', 'dirname')
insertFormLangValues()
Insert the language values, update them if they already exist
protected
insertFormLangValues(int $formID, int $langID, mixed $isActive, string $name, string $text, string $feedback, mixed $mailTemplate, string $subject) : mixed
Parameters
- $formID : int
- $langID : int
- $isActive : mixed
- $name : string
- $text : string
- $feedback : string
- $mailTemplate : mixed
- $subject : string
Tags
setFormFieldLang()
Add a form lang to a field
protected
setFormFieldLang(int $fieldID, mixed $langID, array<string|int, mixed> $values) : mixed
In case it already exists, update the value
Parameters
- $fieldID : int
- $langID : mixed
- $values : array<string|int, mixed>
Tags
showError()
Show Error
protected
showError(Sigma $template) : string
Parameters
- $template : Sigma
-
Template object
Return values
string —Form content with Error message
showFeedback()
Show the feedback message
protected
showFeedback(array<string|int, mixed> $arrFormData, Sigma $template) : mixed
Parameters
- $arrFormData : array<string|int, mixed>
-
Details of the requested form
- $template : Sigma
-
Template object
updateFormField()
Update a form field
protected
updateFormField(array<string|int, mixed> $field) : mixed
Parameters
- $field : array<string|int, mixed>
Tags
updateRecipient()
Update the recipient
protected
updateRecipient(array<string|int, mixed> $recipient) : mixed
Parameters
- $recipient : array<string|int, mixed>
Tags
_deleteFormFieldsAndDataByFormId()
Delete form fields and data
private
_deleteFormFieldsAndDataByFormId(int $id) : mixed
Parameters
- $id : int
Tags
sendMail()
Sends an email with the contact details to the responsible persons
private
sendMail(mixed $arrFormData) : mixed
This methode sends an email to all email addresses that are defined in the option "Receiver address(es)" of the requested contact form.
Parameters
- $arrFormData : mixed
Tags
setRecipientLang()
Set the recipient name of a lang
private
setRecipientLang(int $rcID, int $langID, string $name) : mixed
Parameters
- $rcID : int
- $langID : int
- $name : string