Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tab
insert_final_newline = true
max_line_length = 160
# tab_width = 2
ij_continuation_indent_size = 2
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false
ij_smart_tabs = false
ij_visual_guides = 120,160
ij_wrap_on_typing = false
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# EXT: datamints_feuser

Online documentation: https://docs.typo3.org/typo3cms/extensions/datamints_feuser/

# Extended functionality
Captcha is now compatible with Powermail captcha

To use you can adjust the typoscript config:

```
captcha.use = powermail
captcha.class = your classes
captcha.reload_class = your reload classes
captcha.reload_icon_path = your path to an image
form.class = your form class
```

If ```captcha.reload_class``` is set there will be a span rendered where you can attach your captcha reload magick to

If ```captcha.reload_icon_path``` is set there, the image will be rendered

To add a class to the form, you can set ```form.class```
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"issues": "http://forge.typo3.org/projects/extension-datamints_feuser"
},
"require": {
"php": ">=5.3.7,<=7.99.99",
"typo3/cms-core": ">=6.2.0,<=10.99.990"
"php": ">=5.3.7,<=8.1.99",
"typo3/cms-core": ">=6.2.0,<=11.99.990"
},
"suggest": {
"typo3db_legacy": ">=1.0.0,<=1.0.99"
Expand Down
1 change: 1 addition & 0 deletions flexform/sheet_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<label>LLL:EXT:datamints_feuser/locallang_db.xml:tt_content.pi_flexform.mailtype</label>
<config>
<type>select</type>
<renderType>selectMultipleSideBySide</renderType>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0"></numIndex>
Expand Down
3 changes: 3 additions & 0 deletions flexform/sheet_registration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<label>LLL:EXT:datamints_feuser/locallang_db.xml:tt_content.pi_flexform.register.usergroup</label>
<config>
<type>select</type>
<renderType>selectMultipleSideBySide</renderType>
<size>3</size>
<autoSizeMax>5</autoSizeMax>
<minitems>0</minitems>
Expand Down Expand Up @@ -78,6 +79,7 @@
<label>LLL:EXT:datamints_feuser/locallang_db.xml:tt_content.pi_flexform.register.approvalcheck</label>
<config>
<type>select</type>
<renderType>selectMultipleSideBySide</renderType>
<size>3</size>
<autoSizeMax>5</autoSizeMax>
<minitems>0</minitems>
Expand Down Expand Up @@ -122,6 +124,7 @@
<label>LLL:EXT:datamints_feuser/locallang_db.xml:tt_content.pi_flexform.mailtype</label>
<config>
<type>select</type>
<renderType>selectMultipleSideBySide</renderType>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0"></numIndex>
Expand Down
5 changes: 3 additions & 2 deletions lib/class.tx_datamintsfeuser_utils.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static function generatePassword($password, $arrGenerate = array()) {
$arrPassword['normal'] = '';

for ($i = 0; $i < (($arrGenerate['length']) ? $arrGenerate['length'] : 8); $i++) {
$arrPassword['normal'] .= $chars{mt_rand(0, strlen($chars))};
$arrPassword['normal'] .= $chars[mt_rand(0, strlen($chars))];
}
}

Expand Down Expand Up @@ -394,7 +394,8 @@ public static function convertHtmlEmailToPlain($content) {
*/
public static function getTemplateSubpart($templateFile, $templatePart, $markerArray = array()) {
// Template laden.
$fileFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($templateFile);
$resourceFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceFactory::class);
$fileFolder = $resourceFactory->retrieveFileOrFolderObject($templateFile);

if (!$fileFolder && class_exists('TYPO3\\CMS\\Core\\LinkHandling\\LinkService')) {
$result = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\LinkHandling\\LinkService')->resolve($templateFile);
Expand Down
94 changes: 84 additions & 10 deletions pi1/class.tx_datamintsfeuser_pi1.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use In2code\Powermail\Domain\Model\Field;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -113,7 +114,11 @@ public function main($content, $conf) {
$this->frontendController = $this->frontendController ?: $GLOBALS['TSFE'];
$this->templateService = $this->templateService ?: $this->cObj;

$this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
if (defined('TYPO3_branch') && (int)TYPO3_branch % 11 === 0) {
$this->pageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Domain\Repository\PageRepository::class);
} else {
$this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
}

// Debug.
// $this->frontendController->set_no_cache();
Expand Down Expand Up @@ -665,6 +670,17 @@ public function checkCaptcha($value) {

switch ($this->conf['captcha.']['use']) {

case 'powermail':
$calculatingCaptchaService = GeneralUtility::makeInstance(\In2code\Powermail\Domain\Service\CalculatingCaptchaService::class);

$field = new Field();
$field->_setProperty('uid', $this->contentId);
if (!$calculatingCaptchaService->validCode($value, $field)) {
return self::validationerrorKeyValid;
}

break;

case 'captcha':
session_start();

Expand Down Expand Up @@ -1675,11 +1691,11 @@ public function sendMail($userId, $templatePart, $adminMail, $config, $extraMark
$mail->setFrom(array($fromEmail => $fromName));
$mail->setReplyTo(array($replytoEmail => $replytoName));
$mail->setTo(array($toEmail => $toName));
$mail->setBody($bodyPlain);
$mail->setCharset($this->frontendController->metaCharset);
$mail->html($bodyPlain);

if ($config['mailtype'] == 'html') {
$mail->addPart($bodyHtml, 'text/html', $this->frontendController->metaCharset);
$mail->html($bodyHtml);
$mail->text($bodyPlain);
}

$mail->send();
Expand Down Expand Up @@ -1990,7 +2006,8 @@ public function showForm($valueCheck = array()) {
$iInfoItem = 1;

// Formular start.
$content = '<form name="' . $this->prefixId . '[' . $this->contentId . ']" action="' . $requestLink . '" method="post" enctype="multipart/form-data" id="' . $this->getFieldId('form') . '">';
$formClassName = $this->conf['form.']['class'] ?: '';
$content = '<form name="' . $this->prefixId . '[' . $this->contentId . ']" action="' . $requestLink . '" method="post" enctype="multipart/form-data" id="' . $this->getFieldId('form') . '" class="' . $formClassName . '">';
$content .= '<fieldset class="group-' . $iFieldset . '">';

// Wenn eine Lgende fuer das erste Fieldset definiert wurde, diese ausgeben.
Expand All @@ -2013,8 +2030,11 @@ public function showForm($valueCheck = array()) {
// Form Item Anfang.
$content .= '<div id="' . $this->getFieldId($fieldName, 'wrapper') . '" class="' . $this->getFieldClasses($iItem, $fieldName, $fieldConfig['type'], $valueCheck) . '">';

// Label schreiben.
$content .= '<label for="' . $this->getFieldId($fieldName) . '">' . $this->getLabel($fieldName) . '</label>';

if ($fieldConfig['type'] !== 'check') {
// Label schreiben.
$content .= '<label for="' . $this->getFieldId($fieldName) . '">' . $this->getLabel($fieldName) . '</label>';
}

switch ($fieldConfig['type']) {

Expand Down Expand Up @@ -2361,8 +2381,13 @@ public function showCheck($fieldName, $fieldConfig, $arrCurrentData, $disabledFi
} else {
$checked = ($arrCurrentData[$fieldName]) ? ' checked="checked"' : '';

$content .= '<label class="label label--checkbox" for="' . $this->getFieldId($fieldName) . '">';
$content .= '<input type="hidden" name="' . $this->getFieldName($fieldName) . '" value="0" />';
$content .= '<input type="checkbox" name="' . $this->getFieldName($fieldName) . '" value="1"' . $checked . $disabledField . ' id="' . $this->getFieldId($fieldName) . '" />';
$content .= '<input class="input input--checkbox" type="checkbox" name="' . $this->getFieldName($fieldName) . '" value="1"' . $checked . $disabledField . ' id="' . $this->getFieldId($fieldName) . '" />';
$content .= '<span class="label__checkmark"></span>';
$content .= $this->getLabel($fieldName) . '</label>';


}

return $content;
Expand Down Expand Up @@ -2647,6 +2672,32 @@ public function showCaptcha($fieldName, $valueCheck, $iItem) {

switch ($this->conf['captcha.']['use']) {

case 'powermail':
$viewHelperInvoker = GeneralUtility::makeInstance(\TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker::class);
$renderingContext = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext::class);

$field = new Field();
$field->_setProperty('uid', $this->contentId);

$result = $viewHelperInvoker->invoke(
\In2code\Powermail\ViewHelpers\Validation\CaptchaViewHelper::class,
[
'field' => $field,
'class' => $this->conf['captcha.']['class'] ?: '',
],
$renderingContext,
);
$captcha = $result;
if ($this->conf['captcha.']['reload_class']) {
$captcha .= '<span class="' . $this->conf['captcha.']['reload_class'] . '">';
if ($this->conf['captcha.']['reload_icon_path']) {
$captcha .= '<img src="' . $this->conf['captcha.']['reload_icon_path'] . '"/>';
}
$captcha .= '</span>';
}

break;

case 'captcha':
$captcha = '<img src="' . tx_datamintsfeuser_utils::getTypoLinkUrl(PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->conf['captcha.']['use'])) . 'captcha/captcha.php') . '" alt="Captcha" />';

Expand Down Expand Up @@ -2690,8 +2741,11 @@ public function showCaptcha($fieldName, $valueCheck, $iItem) {

$content .= '<div id="' . $this->getFieldId($fieldName, 'wrapper') . '" class="' . $this->getFieldClasses($iItem, $fieldName, '', $valueCheck) . '">';
$content .= '<label for="' . $this->getFieldId($fieldName) . '">' . $this->getLabel($fieldName) . '</label>';
if ($this->getLabel('captcha_info')) {
$content .= '<div class="captchaInfo"> ' . $this->getLabel('captcha_info') . '</div>';
}
$content .= '<div class="captcha">' . $captcha . '</div>';
$content .= '<input type="text" name="' . $this->getFieldName($fieldName) . '" value="" id="' . $this->getFieldId($fieldName) . '" />';
$content .= '<input type="text" required="required" name="' . $this->getFieldName($fieldName) . '" value="" id="' . $this->getFieldId($fieldName) . '" />';
// $content .= ($showInput) ? '<input type="text" name="' . $this->getFieldName($fieldName) . '" value="" id="' . $this->getFieldId($fieldName) . '" />' : '';
$content .= $this->getErrorLabel($fieldName, $valueCheck);
$content .= '</div>';
Expand Down Expand Up @@ -2783,8 +2837,15 @@ public function getLabel($fieldName, $checkRequired = TRUE) {
return $label . (($checkRequired) ? $this->isRequiredField($fieldName) : '');
}

//Label aus der Flexform holen
$label = $this->getFlexformLabelByFieldName($fieldName);
if ($label) {
return $label;
}

// LanguageString ermitteln.
$languageString = $this->feUsersTca['columns'][$fieldName]['label'];

} else {
$languageString = $fieldName;
}
Expand All @@ -2809,6 +2870,19 @@ public function getLabel($fieldName, $checkRequired = TRUE) {
return $fieldName . (($checkRequired) ? $this->isRequiredField($fieldName) : '');
}

/**
* @param string $fieldName
* @return mixed|string
*/
public function getFlexformLabelByFieldName(string $fieldName) {
foreach($this->conf['databasefields'] as $databaseField) {
if ($databaseField['field'] === $fieldName) {
return $databaseField['label'];
}
}
return '';
}

/**
* Ermittelt den Fehlertyp aus dem Feldnamen.
*
Expand Down Expand Up @@ -3011,7 +3085,7 @@ public function determineConfiguration() {
$flexConf = array();

// Extension Konfiguration ermitteln.
$this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
$this->extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][$this->extKey];

// Alle Tabs der Flexformkonfiguration durchgehn.
if (is_array($this->cObj->data['pi_flexform']['data'])) {
Expand Down
2 changes: 1 addition & 1 deletion pi1/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>
2 changes: 1 addition & 1 deletion pi1/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>