[FEATURE] Migrate to TYPO3 9 LTS 90/58690/3
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 25 Oct 2018 02:50:46 +0000 (22:50 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 25 Oct 2018 03:20:46 +0000 (05:20 +0200)
Adapt to changes in core API's for TYPO3 9 LTS.

Resolves: #86724
Change-Id: I367fc1ef98a2a268b1cf468ef87417958cbdcf2b
Reviewed-on: https://review.typo3.org/58690
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
41 files changed:
ChangeLog
Classes/Configuration/ConfigurationCheck.php
Classes/Configuration/Reports/StatusProvider.php
Classes/Controller/AbstractActionController.php
Classes/Controller/EditActionController.php
Classes/Controller/InfomailActionController.php
Classes/Controller/RegisterPluginController.php
Classes/Domain/Data.php
Classes/Hooks/FileUploadHooks.php
Classes/Hooks/RegistrationProcessHooks.php
Classes/Hooks/UsergroupHooks.php
Classes/Mail/Message.php
Classes/Request/Parameters.php
Classes/Security/SecuredData.php
Classes/Security/SessionData.php
Classes/Security/StorageSecurity.php
Classes/Security/TransmissionSecurity.php
Classes/Utility/DataUtility.php [new file with mode: 0644]
Classes/Utility/HashUtility.php
Classes/Utility/LocalizationUtility.php
Classes/Utility/UrlUtility.php
Classes/View/AbstractView.php
Classes/View/CreateView.php
Classes/View/DeleteView.php
Classes/View/EditView.php
Classes/View/Email.php
Classes/View/Marker.php
Configuration/FlexForms/flexform_ds_pi1.xml
Configuration/TCA/Overrides/fe_groups.php [new file with mode: 0644]
Configuration/TCA/Overrides/fe_groups_language_overlay.php [deleted file]
Configuration/TCA/Overrides/fe_users.php
Configuration/TCA/Overrides/pages.php [new file with mode: 0644]
Configuration/TCA/Overrides/sys_file_metadata.php [new file with mode: 0644]
Configuration/TCA/Overrides/tt_content.php
Configuration/TCA/fe_groups_language_overlay.php [deleted file]
composer.json
doc/manual.sxw
ext_conf_template.txt
ext_emconf.php
ext_localconf.php
ext_tables.sql

index 10608fd..8a5f157 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2018-10-24 Stanislas Rolland  <typo3(arobas)sjbr.ca>
        * Resolves #86736: Removing all selectable user groups was not possible
        * Update version to 5.1.1
+       * Resolves #86724: Migrate to TYPO3 9 LTS
 
 2018-10-23 Stanislas Rolland  <typo3(arobas)sjbr.ca>
        * Resolves #85925: PHP codeinspection returns errors
index eda0a7e..f85cc96 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Configuration;
 /*\r
  *  Copyright notice\r
  *\r
- *  (c) 2004-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>\r
+ *  (c) 2004-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>\r
  *  All rights reserved\r
  *\r
  *  This script is part of the TYPO3 project. The TYPO3 project is\r
@@ -22,20 +22,21 @@ namespace SJBR\SrFeuserRegister\Configuration;
  *  This copyright notice MUST APPEAR in all copies of the script!\r
  */\r
 \r
+use Psr\Log\LoggerAwareInterface;\r
+use Psr\Log\LoggerAwareTrait;\r
 use SJBR\SrFeuserRegister\Utility\LocalizationUtility;\r
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;\r
 use TYPO3\CMS\Core\Utility\GeneralUtility;\r
-use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;\r
 use TYPO3\CMS\Rsaauth\Backend\BackendFactory;\r
 use TYPO3\CMS\Rsaauth\Storage\StorageFactory;\r
-use TYPO3\CMS\Saltedpasswords\Salt\SaltFactory;\r
-use TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility;\r
 \r
 /**\r
  * Validate the extension configuration\r
  */\r
-class ConfigurationCheck\r
+class ConfigurationCheck implements LoggerAwareInterface\r
 {\r
+       use LoggerAwareTrait;\r
+\r
        /**\r
         * Checks requirements for this plugin\r
         *\r
@@ -52,7 +53,7 @@ class ConfigurationCheck
                        foreach ($requiredExtensions as $requiredExtension) {\r
                                if (!ExtensionManagementUtility::isLoaded($requiredExtension)) {\r
                                        $message = sprintf(LocalizationUtility::translate('internal_required_extension_missing', $extensionName), $requiredExtension);\r
-                                       GeneralUtility::sysLog($message, $extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);\r
+                                       $this->logger->error($extensionName . ': ' . $message);\r
                                        $content .= sprintf(LocalizationUtility::translate('internal_check_requirements_frontend', $extensionName), $message);\r
                                }\r
                        }\r
@@ -75,26 +76,9 @@ class ConfigurationCheck
                        $supportedTransmissionSecurityLevels = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extensionKey]['loginSecurityLevels'];\r
                        if (!in_array($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel'], $supportedTransmissionSecurityLevels)) {\r
                                $message = LocalizationUtility::translate('internal_login_security_level', $extensionName);\r
-                               GeneralUtility::sysLog($message, $extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);\r
+                               $this->logger->error($extensionName . ': ' . $message);\r
                                $content .= sprintf(LocalizationUtility::translate('internal_check_requirements_frontend', $extensionName), $message);\r
                        } else {\r
-                               // Check if salted passwords are enabled in front end\r
-                               if (ExtensionManagementUtility::isLoaded('saltedpasswords')) {\r
-                                       if (!SaltedPasswordsUtility::isUsageEnabled('FE')) {\r
-                                               $message = LocalizationUtility::translate('internal_salted_passwords_disabled', $extensionName);\r
-                                               GeneralUtility::sysLog($message, $extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);\r
-                                               $content .= sprintf(LocalizationUtility::translate('internal_check_requirements_frontend', $extensionName), $message);\r
-                                       } else {\r
-                                               // Check if we can get a salting instance\r
-                                               $objSalt = SaltFactory::getSaltingInstance(NULL);\r
-                                               if (!is_object($objSalt)) {\r
-                                                       // Could not get a salting instance from saltedpasswords\r
-                                                       $message = LocalizationUtility::translate('internal_salted_passwords_no_instance', $extensionName);\r
-                                                       GeneralUtility::sysLog($message, $extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);\r
-                                                       $content .= sprintf(LocalizationUtility::translate('internal_check_requirements_frontend', $extensionName), $message);\r
-                                               }\r
-                                       }\r
-                               }\r
                                // Check if we can get a backend from rsaauth\r
                                if (ExtensionManagementUtility::isLoaded('rsaauth')) {\r
                                        $backend = BackendFactory::getBackend();\r
@@ -102,7 +86,7 @@ class ConfigurationCheck
                                        if (!is_object($backend) || !$backend->isAvailable() || !is_object($storage)) {\r
                                                // Required RSA auth backend not available\r
                                                $message = LocalizationUtility::translate('internal_rsaauth_backend_not_available', $extensionName);\r
-                                               GeneralUtility::sysLog($message, $extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);\r
+                                               $this->logger->error($extensionName . ': ' . $message);\r
                                                $content .= sprintf(LocalizationUtility::translate('internal_check_requirements_frontend', $extensionName), $message);\r
                                        }\r
                                }\r
@@ -110,71 +94,4 @@ class ConfigurationCheck
                }\r
                return $content;\r
        }\r
-\r
-       /**\r
-        * Checks whether the HTML templates contains any deprecated marker\r
-        *\r
-        * @param string $extensionKey: the extension key\r
-        * @param array $configuration: the configuration of the plugin\r
-        * @return string Error message, if error found, empty string otherwise\r
-        */\r
-       static public function checkDeprecatedMarkers($extensionKey, $conf)\r
-       {\r
-               $content = '';\r
-               $messages = array();\r
-               $extensionName = GeneralUtility::underscoredToUpperCamelCase($extensionKey);\r
-               $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);\r
-               $templateCode = $cObj->fileResource($conf['templateFile']);\r
-               // These changes apply only to sr_feuser_register\r
-               if ($extensionKey === 'sr_feuser_register') {\r
-                       // Version 3: no clear-text passwords in templates\r
-                       // Remove any ###FIELD_password###, ###FIELD_password_again### markers\r
-                       // Remove markers ###TEMPLATE_INFOMAIL###, ###TEMPLATE_INFOMAIL_SENT### and ###EMAIL_TEMPLATE_INFOMAIL###\r
-                       $removeMarkers = array(\r
-                               '###FIELD_password###',\r
-                               '###FIELD_password_again###',\r
-                               '###TEMPLATE_INFOMAIL###',\r
-                               '###TEMPLATE_INFOMAIL_SENT###',\r
-                               '###EMAIL_TEMPLATE_INFOMAIL###',\r
-                       );\r
-                       $removeMarkerMessage = LocalizationUtility::translate('LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang.xlf:internal_remove_deprecated_marker', $extensionName);\r
-                       foreach ($removeMarkers as $marker) {\r
-                               if (strpos($templateCode, $marker) !== FALSE) {\r
-                                       $messages[] = sprintf($removeMarkerMessage, $marker, $fileName);\r
-                               }\r
-                       }\r
-                       // Version 3: No clear-text password in email\r
-                       // Replace ###LABEL_V_REGISTRATION_INVITED_MESSAGE1### with ###LABEL_V_REGISTRATION_INVITED_MESSAGE1A###\r
-                       // Replace ###LABEL_V_REGISTRATION_INFOMAIL_MESSAGE1### with ###LABEL_V_REGISTRATION_INFOMAIL_MESSAGE1A###\r
-                       $replaceMarkers = array(\r
-                               array(\r
-                                       'marker' => '###LABEL_V_REGISTRATION_INVITED_MESSAGE1###',\r
-                                       'replacement' => '###LABEL_V_REGISTRATION_INVITED_MESSAGE1A###'\r
-                               ),\r
-                               array(\r
-                                       'marker' => '###LABEL_V_REGISTRATION_INVITED_MESSAGE1_INFORMAL###',\r
-                                       'replacement' => '###LABEL_V_REGISTRATION_INVITED_MESSAGE1A_INFORMAL###',\r
-                               ),\r
-                               array(\r
-                                       'marker' => '###LABEL_V_REGISTRATION_INFOMAIL_MESSAGE1###',\r
-                                       'replacement' => '###LABEL_V_REGISTRATION_INFOMAIL_MESSAGE1A###',\r
-                               ),\r
-                               array(\r
-                                       'marker' => '###LABEL_V_REGISTRATION_INFOMAIL_MESSAGE1_INFORMAL###',\r
-                                       'replacement' => '###LABEL_V_REGISTRATION_INFOMAIL_MESSAGE1A_INFORMAL###',\r
-                               ),\r
-                       );\r
-                       $replaceMarkerMessage = LocalizationUtility::translate('LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang.xlf:internal_replace_deprecated_marker', $extensionName);\r
-                       foreach ($replaceMarkers as $replaceMarker) {\r
-                               if (strpos($templateCode, $replaceMarker['marker']) !== false) {\r
-                                       $messages[] = sprintf($replaceMarkerMessage, $replaceMarker['marker'], $replaceMarker['replacement'], $fileName);\r
-                               }\r
-                       }\r
-               }\r
-               foreach ($messages as $message) {\r
-                       GeneralUtility::sysLog($message, $extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);\r
-                       $content .= sprintf(LocalizationUtility::translate('internal_check_requirements_frontend', $extensionName), $message);\r
-               }\r
-               return $content;\r
-       }\r
 }
\ No newline at end of file
index ad0c028..79ef8b1 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Configuration\Reports;
 /*
  *  Copyright notice
  *
- *  (c) 2012-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2012-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -28,7 +28,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
 use TYPO3\CMS\Reports\Status;
 use TYPO3\CMS\Reports\StatusProviderInterface;
-use TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility;
 
 /**
  * Hook into the backend module "Reports" checking the configuration required for sr_feuser_register
@@ -47,12 +46,11 @@ class StatusProvider implements StatusProviderInterface
         */
        public function getStatus()
        {
-               $reports = array(
+               $reports = [
                        'requiredExtensionsAreInstalled' => $this->checkIfRequiredExtensionsAreInstalled(),
                        'noConflictingExtensionIsInstalled' => $this->checkIfNoConflictingExtensionIsInstalled(),
-                       'frontEndLoginSecurityLevelIsCorrectlySet' => $this->checkIfFrontEndLoginSecurityLevelIsCorrectlySet(),
-                       'saltedPasswordsAreEnabledInFrontEnd' => $this->checkIfSaltedPasswordsAreEnabledInFrontEnd()
-               );
+                       'frontEndLoginSecurityLevelIsCorrectlySet' => $this->checkIfFrontEndLoginSecurityLevelIsCorrectlySet()
+               ];
                return $reports;
        }
 
@@ -133,24 +131,4 @@ class StatusProvider implements StatusProviderInterface
                }
                return GeneralUtility::makeInstance(Status::class, $title, $value, $message, $status);
        }
-
-       /**
-        * Check whether salted passwords are enabled in front end
-        *
-        * @return      Status
-        */
-       protected function checkIfSaltedPasswordsAreEnabledInFrontEnd()
-       {
-               $title = LocalizationUtility::translate('LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_statusreport.xlf:Salted_passwords_in_front_end', $this->extensionName);
-               if (!ExtensionManagementUtility::isLoaded('saltedpasswords') || !SaltedPasswordsUtility::isUsageEnabled('FE')) {
-                       $value = LocalizationUtility::translate('LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_statusreport.xlf:disabled', $this->extensionName);
-                       $message = LocalizationUtility::translate('LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_statusreport.xlf:salted_passwords_must_be_enabled', $this->extensionName);
-                       $status = Status::ERROR;
-               } else {
-                       $value = LocalizationUtility::translate('LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_statusreport.xlf:enabled', $this->extensionName);
-                       $message = '';
-                       $status = Status::OK;
-               }
-               return GeneralUtility::makeInstance(Status::class, $title, $value, $message, $status);
-       }
 }
\ No newline at end of file
index 99225f9..78ae973 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Controller;
 /*
  *  Copyright notice
  *
- *  (c) 2007-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2007-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -22,6 +22,8 @@ namespace SJBR\SrFeuserRegister\Controller;
  *  This copyright notice MUST APPEAR in all copies of the script!
  */
 
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
 use SJBR\SrFeuserRegister\Domain\Data;
 use SJBR\SrFeuserRegister\Request\Parameters;
 use SJBR\SrFeuserRegister\Security\SessionData;
@@ -30,14 +32,20 @@ use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
 use SJBR\SrFeuserRegister\Utility\UrlUtility;
 use SJBR\SrFeuserRegister\View\Email;
 use SJBR\SrFeuserRegister\View\Marker;
+use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 
 /**
  * Action functions
  */
 
-abstract class AbstractActionController
+abstract class AbstractActionController implements LoggerAwareInterface
 {
+       use LoggerAwareTrait;
 
        /**
         * Extension key
@@ -209,49 +217,50 @@ abstract class AbstractActionController
                $success = true;
                $message = '';
                // Log the user in
-               $loginData = array(
+               $loginData = [
                        'uname' => $username,
                        'uident' => $password,
                        'uident_text' => $password,
                        'status' => 'login',
-               );
+               ];
                // Check against configured pid (defaulting to current page)
-               $GLOBALS['TSFE']->fe_user->checkPid = true;
-               $GLOBALS['TSFE']->fe_user->checkPid_value = (int) $this->parameters->getPid();
+               $tsfe = $this->getTypoScriptFrontendController();
+               $tsfe->fe_user->checkPid = true;
+               $tsfe->fe_user->checkPid_value = (int)$this->parameters->getPid();
                // Get authentication info array
-               $authInfo = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
-               // Get user info
-               $user = $GLOBALS['TSFE']->fe_user->fetchUserRecord($authInfo['db_user'], $loginData['uname']);
-               if (is_array($user)) {
-                       // Get the appropriate authentication service
-                       $authServiceObj = GeneralUtility::makeInstanceService('auth', 'authUserFE');
-                       // Check authentication
-                       if (is_object($authServiceObj)) {
-                               $ok = $authServiceObj->compareUident($user, $loginData);
-                               if ($ok) {
-                                       // Login successfull: create user session
-                                       $GLOBALS['TSFE']->fe_user->createUserSession($user);
-                                       $GLOBALS['TSFE']->initUserGroups();
-                                       $GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->fetchUserSession();
-                                       $GLOBALS['TSFE']->loginUser = 1;
+               $authInfo = $tsfe->fe_user->getAuthInfoArray();
+               // Get the appropriate authentication service
+               $authServiceObj = GeneralUtility::makeInstanceService('auth', 'authUserFE');
+               if (is_object($authServiceObj)) {
+                       $authServiceObj->initAuth('processLoginDataFE', $loginData, $authInfo, $tsfe->fe_user);
+                       // Get user info
+                       $user = $authServiceObj->getUser();
+                       if (is_array($user)) {
+                               // Check authentication
+                                       $ok = $authServiceObj->authUser($user);
+                                       if ($ok) {
+                                               // Login successfull: create user session
+                                               $tsfe->fe_user->createUserSession($user);
+                                               $tsfe->initUserGroups();
+                                               $tsfe->fe_user->user = $tsfe->fe_user->fetchUserSession();
+                                       } else {
+                                               // Login failed...
+                                               SessionData::clearSessionData($this->extensionKey, false);
+                                               $message = LocalizationUtility::translate('internal_auto_login_failed', $this->extensionName);
+                                               $success = false;
+                                       }
                                } else {
-                                       // Login failed...
-                                       SessionData::clearSessionData($this->extensionKey, false);
-                                       $message = LocalizationUtility::translate('internal_auto_login_failed', $this->extensionName);
-                                       $success = false;
-                               }
-                       } else {
-                               // Required authentication service not available
-                               $message = LocalizationUtility::translate('internal_required_authentication_service_not_available', $this->extensionName);
-                               GeneralUtility::sysLog($message, $this->extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                               // No enabled user of the given name
+                               $message = sprintf(LocalizationUtility::translate('internal_no_enabled_user', $this->extensionName), $loginData['uname']);
                                SessionData::clearSessionData($this->extensionKey, false);
                                $success = false;
                        }
                } else {
-                       // No enabled user of the given name
-                       $message = sprintf(LocalizationUtility::translate('internal_no_enabled_user', $this->extensionName), $loginData['uname']);
-                       SessionData::clearSessionData($this->extensionKey, false);
-                       $success = false;
+                               // Required authentication service not available
+                               $message = LocalizationUtility::translate('internal_required_authentication_service_not_available', $this->extensionName);
+                               $this->logger->error($this->extensionName . ': ' . $message);
+                               SessionData::clearSessionData($this->extensionKey, false);
+                               $success = false;
                }
                // Delete regHash
                if ($this->parameters->getValidRegHash()) {
@@ -261,7 +270,7 @@ abstract class AbstractActionController
                if (!$success) {
                        SessionData::clearSessionData($this->extensionKey, false);
                   if ($message !== '') {
-                          GeneralUtility::sysLog($message, $this->extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                               $this->logger->error($this->extensionName . ': ' . $message);
                   }
         }
                if ($redirect) {
@@ -272,7 +281,7 @@ abstract class AbstractActionController
                        }
                        if (!$redirectUrl) {
                                if ((int) $this->conf['loginPID']) {
-                                       $redirectUrl = UrlUtility::get($this->prefixId, '', (int) $this->conf['loginPID'], array(), array(), false);
+                                       $redirectUrl = UrlUtility::get($this->prefixId, '', (int) $this->conf['loginPID'], [], [], false);
                                } else {
                                        $redirectUrl = UrlUtility::getSiteUrl();
                                }
@@ -281,4 +290,12 @@ abstract class AbstractActionController
                }
                return $success;
        }
+
+    /**
+     * @return TypoScriptFrontendController
+     */
+    protected static function getTypoScriptFrontendController()
+    {
+        return $GLOBALS['TSFE'];
+    }
 }
\ No newline at end of file
index 80b3adc..9828e48 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Controller;
 /*
  *  Copyright notice
  *
- *  (c) 2007-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2007-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -35,6 +35,7 @@ use SJBR\SrFeuserRegister\View\CreateView;
 use SJBR\SrFeuserRegister\View\EditView;
 use SJBR\SrFeuserRegister\View\Marker;
 use SJBR\SrFeuserRegister\View\PlainView;
+use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -149,10 +150,11 @@ class EditActionController extends AbstractActionController
                                }
                                $origArray = $this->data->parseIncomingData($origArray);
                                $aCAuth = Authentication::aCAuth($this->parameters->getAuthCode(), $origArray, $this->conf, $this->conf['setfixed.']['EDIT.']['_FIELDLIST']);
-                               if (($this->theTable === 'fe_users' && $GLOBALS['TSFE']->loginUser) || $aCAuth || ($theCode && !strcmp($this->parameters->getAuthCode(), $theCode))) {
+                               if (($this->theTable === 'fe_users' && GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('frontend.user', 'isLoggedIn')) || $aCAuth || ($theCode && !strcmp($this->parameters->getAuthCode(), $theCode))) {
                                        // Must be logged in OR be authenticated by the aC code in order to edit
                                        // If the recUid selects a record.... (no check here)
-                                       if (!strcmp($this->parameters->getAuthCode(), $theCode) || $aCAuth || $this->data->DBmayFEUserEdit($this->theTable, $origArray, $GLOBALS['TSFE']->fe_user->user, $this->conf['allowedGroups'], $this->conf['fe_userEditSelf'])) {
+                                       $userAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user');
+                                       if (!strcmp($this->parameters->getAuthCode(), $theCode) || $aCAuth || $this->data->DBmayFEUserEdit($this->theTable, $origArray, ['uid' => $userAspect->get('id'), 'usergroup' => $userAspect->get('groupIds')], $this->conf['allowedGroups'], $this->conf['fe_userEditSelf'])) {
                                                // Display the form, if access granted.
                                                $editView = GeneralUtility::makeInstance(EditView::class, $this->extensionKey, $this->prefixId, $this->theTable, $this->conf, $this->data, $this->parameters, $this->marker);
                                                $content .= $editView->render($dataArray, $origArray, $securedArray, $cmd, $cmdKey, $mode);
index c7e4cce..954b3dd 100644 (file)
@@ -24,6 +24,7 @@ namespace SJBR\SrFeuserRegister\Controller;
 
 use SJBR\SrFeuserRegister\Exception;
 use SJBR\SrFeuserRegister\Controller\AbstractActionController;
+use SJBR\SrFeuserRegister\Utility\DataUtility;
 use SJBR\SrFeuserRegister\Utility\HashUtility;
 use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
 use SJBR\SrFeuserRegister\View\Marker;
@@ -64,7 +65,7 @@ class InfomailActionController extends AbstractActionController
                if (!empty($fetch) && empty($failure)) {
                        $pidLock = 'AND pid IN (\'' . implode('\',\'', GeneralUtility::trimExplode(',', $this->parameters->getPid(), true)) . '\')';
                        $enable = $GLOBALS['TSFE']->sys_page->enableFields($this->theTable);
-                       $DBrows = $GLOBALS['TSFE']->sys_page->getRecordsByField($this->theTable, $this->conf['email.']['field'], $fetch, $pidLock . $enable, '', '', '100');
+                       $DBrows = DataUtility::getRecordsByField($this->theTable, $this->conf['email.']['field'], $fetch, $pidLock . $enable, '', '', '100');
                        if (is_array($DBrows)) {
                                $recipient = $DBrows[0][$this->conf['email.']['field']];
                                $this->data->setDataArray($DBrows[0]);
index ca015bb..cbd0536 100644 (file)
@@ -5,7 +5,7 @@ namespace SJBR\SrFeuserRegister\Controller;
  *  Copyright notice\r
  *\r
  *  (c) 1999-2003 Kasper Skårhøj <kasperYYYY@typo3.com>\r
- *  (c) 2004-2015 Stanislas Rolland <typo3(arobas)sjbr.ca>\r
+ *  (c) 2004-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>\r
  *  All rights reserved\r
  *\r
  *  This script is part of the TYPO3 project. The TYPO3 project is\r
@@ -25,6 +25,11 @@ namespace SJBR\SrFeuserRegister\Controller;
 \r
 use SJBR\SrFeuserRegister\Exception;\r
 use SJBR\SrFeuserRegister\Configuration\ConfigurationCheck;\r
+use SJBR\SrFeuserRegister\Controller\CreateActionController;\r
+use SJBR\SrFeuserRegister\Controller\DeleteActionController;\r
+use SJBR\SrFeuserRegister\Controller\EditActionController;\r
+use SJBR\SrFeuserRegister\Controller\InfomailActionController;\r
+use SJBR\SrFeuserRegister\Controller\SetfixedActionController;\r
 use SJBR\SrFeuserRegister\Domain\Data;\r
 use SJBR\SrFeuserRegister\Request\Parameters;\r
 use SJBR\SrFeuserRegister\Security\Authentication;\r
@@ -32,10 +37,13 @@ use SJBR\SrFeuserRegister\Security\SessionData;
 use SJBR\SrFeuserRegister\Utility\CssUtility;\r
 use SJBR\SrFeuserRegister\Utility\LocalizationUtility;\r
 use SJBR\SrFeuserRegister\View\Marker;\r
+use SJBR\SrFeuserRegister\View\PlainView;\r
+use TYPO3\CMS\Core\Context\Context;\r
 use TYPO3\CMS\Core\Utility\ArrayUtility;\r
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;\r
 use TYPO3\CMS\Core\Utility\GeneralUtility;\r
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;\r
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;\r
 use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;\r
 \r
 /**\r
@@ -131,7 +139,7 @@ class RegisterPluginController extends AbstractPlugin
         * Commands that may be processed when no user is logged in\r
         * @var array\r
         */\r
-       protected $noLoginCommands = array('create', 'invite', 'setfixed', 'infomail');\r
+       protected $noLoginCommands = ['create', 'invite', 'setfixed', 'infomail'];\r
 \r
        /**\r
         * Plugin entry script\r
@@ -149,8 +157,6 @@ class RegisterPluginController extends AbstractPlugin
                $content = ConfigurationCheck::checkRequirements($this->extKey);\r
                // Check installation security settings\r
                $content .= ConfigurationCheck::checkSecuritySettings($this->extKey);\r
-               // Check presence of deprecated markers\r
-               $content .= ConfigurationCheck::checkDeprecatedMarkers($this->extKey, $this->conf);\r
                // The table may be configured\r
                if (isset($this->conf['table.']) && is_array($this->conf['table.']) && $this->conf['table.']['name']) {\r
                        $this->theTable  = $this->conf['table.']['name'];\r
@@ -164,23 +170,23 @@ class RegisterPluginController extends AbstractPlugin
                // If no error content, proceed\r
                if (!$content) {\r
                        // Validate the token and initialize request parameters\r
-                       $this->parameters = GeneralUtility::makeInstance('SJBR\\SrFeuserRegister\\Request\\Parameters', $this->extKey, $this->prefixId, $this->theTable, $this->conf, $this->piVars, $this);\r
+                       $this->parameters = GeneralUtility::makeInstance(Parameters::class, $this->extKey, $this->prefixId, $this->theTable, $this->conf, $this->piVars, $this);\r
                        // Initialize the incoming and original data\r
-                       $this->data = GeneralUtility::makeInstance('SJBR\\SrFeuserRegister\\Domain\\Data', $this->extKey, $this->prefixId, $this->theTable, $this->conf, $this->cObj, $this->parameters, $this->adminFieldList);\r
+                       $this->data = GeneralUtility::makeInstance(Data::class, $this->extKey, $this->prefixId, $this->theTable, $this->conf, $this->cObj, $this->parameters, $this->adminFieldList);\r
                        // Initialize the controller\r
                        $this->initialize();\r
                        // Initialize marker class\r
-                       $this->marker = GeneralUtility::makeInstance('SJBR\\SrFeuserRegister\\View\\Marker', $this->extKey, $this->prefixId, $this->theTable, $this->conf, $this->parameters, $this->buttonLabelsList, $this->otherLabelsList);\r
+                       $this->marker = GeneralUtility::makeInstance(Marker::class, $this->extKey, $this->prefixId, $this->theTable, $this->conf, $this->parameters, $this->buttonLabelsList, $this->otherLabelsList);\r
                        if ($this->parameters->isTokenValid() || ($this->parameters->getCmd() !== 'setfixed' && $this->parameters->getCmd() !== 'infomail')) {\r
                                // Process the request\r
                                $content = $this->doProcessing($this->parameters->getCmd(), $this->parameters->getCmdKey(), $this->data->getOrigArray(), $this->data->getDataArray());\r
                        } else {\r
                                $this->marker->generateURLMarkers();\r
-                               $plainView = GeneralUtility::makeInstance('SJBR\\SrFeuserRegister\\View\\PlainView', $this->extensionKey, $this->prefixId, $this->theTable, $this->conf, $this->data, $this->parameters, $this->marker);\r
+                               $plainView = GeneralUtility::makeInstance(PlainView::class, $this->extensionKey, $this->prefixId, $this->theTable, $this->conf, $this->data, $this->parameters, $this->marker);\r
                                if ($this->parameters->getCmd() === 'setfixed') {\r
-                                       $content = $plainView->render('###TEMPLATE_SETFIXED_FAILED###', array(), array(), array(), '', '');\r
+                                       $content = $plainView->render('###TEMPLATE_SETFIXED_FAILED###', [], [], a[], '', '');\r
                                } else {\r
-                                       $content = $plainView->render('###TEMPLATE_INVALID_TOKEN###', array(), array(), array(), '', '');\r
+                                       $content = $plainView->render('###TEMPLATE_INVALID_TOKEN###', [], [], [], '', '');\r
                                }\r
                        }\r
                }\r
@@ -192,14 +198,14 @@ class RegisterPluginController extends AbstractPlugin
         */\r
        protected function initialize()\r
        {\r
-               $origArray = array();\r
+               $origArray = [];\r
                $cmd = $this->parameters->getCmd();\r
                $dataArray = $this->data->getDataArray();\r
                $feUserdata = $this->parameters->getFeUserData();\r
-               $uid = $dataArray['uid'] ? $dataArray['uid'] : ($feUserdata['rU'] ? $feUserdata['rU'] : (!in_array($cmd, $this->noLoginCommands) ? $GLOBALS['TSFE']->fe_user->user['uid'] : 0));\r
+               $uid = $dataArray['uid'] ? $dataArray['uid'] : ($feUserdata['rU'] ? $feUserdata['rU'] : (!in_array($cmd, $this->noLoginCommands) ? GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('frontend.user', 'id') : 0));\r
                if ($uid) {\r
                        $this->data->setRecUid((int) $uid);\r
-                       $newOrigArray = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, (int) $uid);\r
+                       $newOrigArray = $this->getTypoScriptFrontendController()->sys_page->getRawRecord($this->theTable, (int)$uid);\r
                        if (isset($newOrigArray) && is_array($newOrigArray)) {\r
                                $this->data->modifyRow($newOrigArray, true);\r
                                $origArray = $newOrigArray;\r
@@ -226,7 +232,7 @@ class RegisterPluginController extends AbstractPlugin
                if ($cmd === 'edit' || $cmd === 'invite' || $cmd === 'password' || $cmd === 'infomail') {\r
                        $cmdKey = $cmd;\r
                } else {\r
-                       if (($cmd === '' || $cmd === 'setfixed') && (($this->theTable !== 'fe_users' || $uid == $GLOBALS['TSFE']->fe_user->user['uid']) && $nonEmptyRecord)) {\r
+                       if (($cmd === '' || $cmd === 'setfixed') && (($this->theTable !== 'fe_users' || $uid == GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('frontend.user', 'id')) && $nonEmptyRecord)) {\r
                                $cmdKey = 'edit';\r
                        } else {\r
                                $cmdKey = 'create';\r
@@ -244,11 +250,11 @@ class RegisterPluginController extends AbstractPlugin
        protected function processSettings($cmdKey)\r
        {\r
                if (!ExtensionManagementUtility::isLoaded('direct_mail')) {\r
-                       $this->conf[$cmdKey.'.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), array('module_sys_dmail_category,module_sys_dmail_newsletter')));\r
-                       $this->conf[$cmdKey . '.']['required'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['required'], 1), array('module_sys_dmail_category, module_sys_dmail_newsletter')));\r
+                       $this->conf[$cmdKey.'.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), ['module_sys_dmail_category,module_sys_dmail_newsletter']));\r
+                       $this->conf[$cmdKey . '.']['required'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['required'], 1), ['module_sys_dmail_category, module_sys_dmail_newsletter']));\r
                }\r
                // Make lists ready for GeneralUtility::inList which does not yet allow blanks\r
-               $fieldConfArray = array('fields', 'required');\r
+               $fieldConfArray = ['fields', 'required'];\r
                foreach ($fieldConfArray as $k => $v) {\r
                        $this->conf[$cmdKey . '.'][$v] = implode(',',  array_unique(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.'][$v], true)));\r
                }\r
@@ -262,25 +268,25 @@ class RegisterPluginController extends AbstractPlugin
                        }\r
                        // When in edit mode, remove password from required fields\r
                        if ($cmdKey === 'edit') {\r
-                               $this->conf[$cmdKey . '.']['required'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['required'], 1), array('password')));\r
+                               $this->conf[$cmdKey . '.']['required'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['required'], 1), ['password']));\r
                        }\r
                        if ($this->conf[$cmdKey . '.']['generateUsername'] || $cmdKey == 'password') {\r
-                               $this->conf[$cmdKey . '.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), array('username')));\r
+                               $this->conf[$cmdKey . '.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), ['username']));\r
                        }\r
                        if ($cmdKey === 'invite') {\r
-                               $this->conf[$cmdKey . '.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), array('password')));\r
-                               $this->conf[$cmdKey . '.']['required'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['required'], 1), array('password')));\r
+                               $this->conf[$cmdKey . '.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), ['password']));\r
+                               $this->conf[$cmdKey . '.']['required'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['required'], 1), ['password']));\r
                                // Do not evaluate any password when inviting\r
                                unset($this->conf[$cmdKey . '.']['evalValues.']['password']);\r
                        }\r
                        if ($this->conf[$cmdKey . '.']['useEmailAsUsername']) {\r
-                               $this->conf[$cmdKey . '.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), array('username')));\r
+                               $this->conf[$cmdKey . '.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), ['username']));\r
                                if ($cmdKey === 'create' || $cmdKey === 'invite') {\r
                                        $this->conf[$cmdKey . '.']['fields'] = implode(',', GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'] . ',email', 1));\r
                                        $this->conf[$cmdKey . '.']['required'] = implode(',', GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['required'] . ',email', 1));\r
                                }\r
                                if (($cmdKey === 'edit' || $cmdKey === 'password') && ($this->conf['enableEmailConfirmation'] || $this->conf['enableAdminReview'] || $this->conf['setfixed'])) {\r
-                                       $this->conf[$cmdKey . '.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), array('email')));\r
+                                       $this->conf[$cmdKey . '.']['fields'] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], 1), ['email']));\r
                                }\r
                        }\r
                        // Do not evaluate the username if it is generated or if email is used\r
@@ -288,7 +294,7 @@ class RegisterPluginController extends AbstractPlugin
                                unset($this->conf[$cmdKey . '.']['evalValues.']['username']);\r
                        }\r
                        // Invoke hooks that may modify the configuration\r
-                       $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['configuration']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['configuration'] : array();\r
+                       $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['configuration']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['configuration'] : [];\r
                        foreach ($hookClassArray as $classRef) {\r
                                $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($classRef);\r
                                if (is_object($hookObject) && method_exists($hookObject, 'modifyConf')) {\r
@@ -339,22 +345,22 @@ class RegisterPluginController extends AbstractPlugin
         * @return string text to display\r
         */\r
        public function doProcessing($cmd, $cmdKey, array $origArray, array $dataArray) {\r
-               $finalDataArray = array();\r
-               $securedArray = array();\r
+               $finalDataArray = [];\r
+               $securedArray = [];\r
                $uid = $this->data->getRecUid();\r
-\r
+               $context = GeneralUtility::makeInstance(Context::class);\r
                if (\r
                        (\r
                                // Check if the login user is the right one\r
                                $this->theTable === 'fe_users'\r
-                               && (!$GLOBALS['TSFE']->loginUser || ($uid > 0 && $GLOBALS['TSFE']->fe_user->user['uid'] != $uid))\r
+                               && (!$context->getPropertyFromAspect('frontend.user', 'isLoggedIn') || ($uid > 0 && $context->getPropertyFromAspect('frontend.user', 'id') != $uid))\r
                                // Or no login is_a required for this command\r
                                && !in_array($cmd, $this->noLoginCommands)\r
                                // this is a unsubscribe link from Direct Mail\r
                                && !($cmd === 'delete' && Authentication::aCAuth($this->parameters->getAuthCode(), $origArray, $this->conf, $this->conf['setfixed.']['DELETE.']['_FIELDLIST']))\r
                        )\r
                ) {\r
-                       $origArray = array();\r
+                       $origArray = [];\r
                        $this->data->setOrigArray($origArray);\r
                        $this->data->resetDataArray();\r
                        $finalDataArray = $dataArray;\r
@@ -370,38 +376,46 @@ class RegisterPluginController extends AbstractPlugin
                switch ($cmd) {\r
                        case 'create':\r
                        case 'invite':\r
-                               $controllerClass = 'SJBR\\SrFeuserRegister\\Controller\\CreateActionController';\r
+                               $controllerClass = CreateActionController::class;\r
                                break;\r
                        case 'edit':\r
                        case 'password':\r
                        case 'login':\r
-                               $controllerClass = 'SJBR\\SrFeuserRegister\\Controller\\EditActionController';\r
+                               $controllerClass = EditActionController::class;\r
                                break;\r
                        case 'delete':\r
-                               $controllerClass = 'SJBR\\SrFeuserRegister\\Controller\\DeleteActionController';\r
+                               $controllerClass = DeleteActionController::class;\r
                                break;\r
                        case 'setfixed':\r
-                               $controllerClass = 'SJBR\\SrFeuserRegister\\Controller\\SetfixedActionController';\r
+                               $controllerClass = SetfixedActionController::class;\r
                                break;\r
                        case 'infomail':\r
-                               $controllerClass = 'SJBR\\SrFeuserRegister\\Controller\\InfomailActionController';\r
+                               $controllerClass = InfomailActionController::class;\r
                                break;\r
                        case '':\r
                                switch ($cmdKey) {\r
                                        case 'edit':\r
-                                               $controllerClass = 'SJBR\\SrFeuserRegister\\Controller\\EditActionController';\r
+                                               $controllerClass = EditActionController::class;\r
                                                break;\r
                                        case 'create':\r
                                        default:\r
-                                               $controllerClass = 'SJBR\\SrFeuserRegister\\Controller\\CreateActionController';\r
+                                               $controllerClass = CreateActionController::class;\r
                                                break;\r
                                }\r
                                break;\r
                        default:\r
-                               $controllerClass = 'SJBR\\SrFeuserRegister\\Controller\\CreateActionController';\r
+                               $controllerClass = CreateActionController::class;\r
                }\r
                $actionController = GeneralUtility::makeInstance($controllerClass, $this->extKey, $this->prefixId, $this->theTable, $this->conf, $this->data, $this->parameters, $this->marker);\r
                $content = $actionController->doProcessing($finalDataArray, $cmd, $cmdKey);\r
                return $content;\r
        }\r
+\r
+    /**\r
+     * @return TypoScriptFrontendController\r
+     */\r
+    protected static function getTypoScriptFrontendController()\r
+    {\r
+        return $GLOBALS['TSFE'];\r
+    }\r
 }
\ No newline at end of file
index 9d5e2bf..c7542af 100644 (file)
@@ -30,6 +30,10 @@ use SJBR\SrFeuserRegister\Security\SessionData;
 use SJBR\SrFeuserRegister\Security\StorageSecurity;
 use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
 use SJBR\SrFeuserRegister\View\AbstractView;
+use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -129,22 +133,22 @@ class Data
         *
         * @var array
         */
-        protected $requiredFieldsArray = array();
+        protected $requiredFieldsArray = [];
 
        /**
         * The array of incoming data
         *
         * @var array
         */
-       protected $dataArray = array();
+       protected $dataArray = [];
 
        /**
         * The array of incoming data
         *
         * @var array
         */
-       protected $origArray = array();
-       
+       protected $origArray = [];
+
        /**
         * The list of fields that ar in error
         *
@@ -152,7 +156,7 @@ class Data
         */
        protected $failure = '';
 
-       protected $evalErrors = array();
+       protected $evalErrors = [];
 
        /**
         * True when data was saved
@@ -161,7 +165,7 @@ class Data
         */
        protected $saved = false;
 
-       public $addTableArray = array();
+       public $addTableArray = [];
 
        public $error;
        public $additionalUpdateFields = '';
@@ -173,8 +177,8 @@ class Data
         */
        protected $recUid = 0;
 
-       public $missing = array(); // array of required missing fields
-       public $inError = array(); // array of fields with eval errors other than absence
+       public $missing = []; // array of required missing fields
+       public $inError = []; // array of fields with eval errors other than absence
 
        /**
         * Constructor
@@ -206,13 +210,11 @@ class Data
                $this->parameters = $parameters;
                if (ExtensionManagementUtility::isLoaded('static_info_tables')) {
                        $this->staticInfoObj = GeneralUtility::makeInstance('SJBR\\StaticInfoTables\\PiBaseApi');
-                       if ($this->staticInfoObj->needsInit()) {
-                               $this->staticInfoObj->init();
-                       }
+                       $this->staticInfoObj->init();
                }
                // Usergroup hook object
                if ($this->theTable === 'fe_users') {
-                       $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId][$this->theTable]['usergroup']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId][$this->theTable]['usergroup'] : array();
+                       $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId][$this->theTable]['usergroup']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId][$this->theTable]['usergroup'] : [];
                        foreach ($hookClassArray as $classRef) {
                                $this->userGroupObj = GeneralUtility::makeInstance($classRef);
                                if (is_object($this->userGroupObj)) {
@@ -286,7 +288,7 @@ class Data
         */
        public function resetDataArray()
        {
-               $this->dataArray = array();
+               $this->dataArray = [];
        }
 
        /**
@@ -336,7 +338,7 @@ class Data
        public function getFieldList()
        {
                if (empty($this->fieldList)) {
-                       $excludeFields = array('felogin_forgotHash', 'felogin_redirectPid', 'lastlogin', 'lockToDomain', 'starttime', 'endtime', 'token', 'TSconfig');
+                       $excludeFields = ['felogin_forgotHash', 'felogin_redirectPid', 'lastlogin', 'lockToDomain', 'starttime', 'endtime', 'token', 'TSconfig'];
                        $this->fieldList = implode(',', array_diff(array_keys($GLOBALS['TCA'][$this->theTable]['columns']), $excludeFields));           
                }
                return $this->fieldList;
@@ -350,7 +352,7 @@ class Data
        public function getRequiredFieldsArray($cmdKey)
        {
                if (!isset($this->requiredFieldsArray[$cmdKey])) {
-                       $this->requiredFieldsArray[$cmdKey] = array();
+                       $this->requiredFieldsArray[$cmdKey] = [];
                        if (isset($this->conf[$cmdKey . '.']['required']) && isset($this->conf[$cmdKey . '.']['fields'])) {
                                $this->requiredFieldsArray[$cmdKey] = array_intersect(GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['required'], true), GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], true));
                        }
@@ -503,7 +505,7 @@ class Data
         */
        public function defaultValues($cmdKey)
        {
-               $dataArray = array();
+               $dataArray = [];
                if (is_array($this->conf[$cmdKey . '.']['defaultValues.'])) {
                        foreach ($this->conf[$cmdKey . '.']['defaultValues.'] as $theField => $theValue) {
                                $dataArray[$theField] = $theValue;
@@ -548,12 +550,12 @@ class Data
         */
        public function evalValues(array &$dataArray, array $origArray, $markerObj, $cmdKey, $mode = AbstractView::MODE_NORMAL)
        {
-               $failureArray = array();
-               $failureMsg = array();
-               $markerArray = array();
+               $failureArray = [];
+               $failureMsg = [];
+               $markerArray = [];
                $displayFieldArray = GeneralUtility::trimExplode(',', $this->conf[$cmdKey.'.']['fields'], true);
                if (CaptchaManager::useCaptcha($cmdKey, $this->conf, $this->extensionKey)) {
-                       $displayFieldArray = array_merge($displayFieldArray, array('captcha_response'));
+                       $displayFieldArray = array_merge($displayFieldArray, ['captcha_response']);
                }
                // Check required fields, set failure if missing.
                $requiredArray = $this->getRequiredFieldsArray($cmdKey);
@@ -588,7 +590,7 @@ class Data
                                        // This may be tricked if the input has the pid-field set but the edit-field list does NOT allow the pid to be edited. Then the pid may be false.
                                        $recordTestPid = (int)$pid;
                                } else {
-                                       $tempRecArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $dataArray['uid']);
+                                       $tempRecArr = $this->getTypoScriptFrontendController()->sys_page->getRawRecord($this->theTable, $dataArray['uid']);
                                        $recordTestPid = (int) $tempRecArr['pid'];
                                }
                        } else {
@@ -596,8 +598,8 @@ class Data
                                $recordTestPid = $thePid ? $thePid : $pid;
                        }
                        foreach ($this->conf[$cmdKey.'.']['evalValues.'] as $theField => $theValue) {
-                               $this->evalErrors[$theField] = array();
-                               $failureMsg[$theField] = array();
+                               $this->evalErrors[$theField] = [];
+                               $failureMsg[$theField] = [];
                                $listOfCommands = GeneralUtility::trimExplode(',', $theValue, true);
                                // Unset the incoming value is empty and unsetEmpty is specified
                                if (array_search('unsetEmpty', $listOfCommands) !== false) {
@@ -618,53 +620,38 @@ class Data
                                                        case 'uniqueDeletedGlobal':
                                                        case 'uniqueLocal':
                                                        case 'uniqueDeletedLocal':
-                                                               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                                                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                                                                               ->getQueryBuilderForTable($this->theTable);
+                                                               $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                                                                       ->getQueryBuilderForTable($this->theTable);
+                                                               $queryBuilder
+                                                                               ->getRestrictions()
+                                                                               ->removeAll();
+                                                               if ($theCmd === 'uniqueLocal' || $theCmd === 'uniqueGlobal') {
                                                                        $queryBuilder
-                                                                                       ->getRestrictions()
-                                                                                       ->removeAll();
-                                                                       if ($theCmd === 'uniqueLocal' || $theCmd === 'uniqueGlobal') {
-                                                                               $queryBuilder
-                                                                                       ->getRestrictions()
-                                                                                       ->add(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction::class));
-                                                                       }
+                                                                               ->getRestrictions()
+                                                                               ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+                                                               }
+                                                               $queryBuilder
+                                                                       ->select('uid', $theField)
+                                                                       ->from($this->theTable)
+                                                                       ->where(
+                                                                               $queryBuilder->expr()->eq($theField, $queryBuilder->createNamedParameter($dataArray[$theField]), \PDO::PARAM_STR)
+                                                                       )
+                                                                       ->setMaxResults(1);
+                                                               if ($dataArray['uid']) {
                                                                        $queryBuilder
-                                                                               ->select('uid', $theField)
-                                                                               ->from($this->theTable)
-                                                                               ->where(
-                                                                                       $queryBuilder->expr()->eq($theField, $queryBuilder->createNamedParameter($dataArray[$theField]), \PDO::PARAM_STR)
-                                                                               )
-                                                                               ->setMaxResults(1);
-                                                                       if ($dataArray['uid']) {
-                                                                               $queryBuilder
-                                                                                       ->andWhere(
-                                                                                               $queryBuilder->expr()->neq('uid', $queryBuilder->createNamedParameter((int)$dataArray['uid']), \PDO::PARAM_INT)
-                                                                                       );
-                                                                       }
-                                                                       if ($theCmd === 'uniqueLocal' || $theCmd === 'uniqueDeletedLocal') {
-                                                                               $queryBuilder
-                                                                                       ->andWhere(
-                                                                                               $queryBuilder->expr()->in('pid', GeneralUtility::intExplode(',', $recordTestPid, true))
-                                                                                       );
-                                                                       }
-                                                                       $DBrows = $queryBuilder
-                                                                               ->execute()
-                                                                               ->fetchAll();
-                                                               } else {
-                                                                       // TYPO3 CMS 7 LTS
-                                                                       $where = $theField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($dataArray[$theField], $this->theTable);
-                                                                       if ($dataArray['uid']) {
-                                                                               $where .= ' AND uid != ' . (int)$dataArray['uid'];
-                                                                       }
-                                                                       if ($theCmd === 'uniqueLocal' || $theCmd === 'uniqueGlobal') {
-                                                                               $where .= $GLOBALS['TSFE']->sys_page->deleteClause($this->theTable);
-                                                                       }
-                                                                       if ($theCmd === 'uniqueLocal' || $theCmd === 'uniqueDeletedLocal') {
-                                                                               $where .= ' AND pid IN (' . $recordTestPid.')';
-                                                                       }
-                                                                       $DBrows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,' . $theField, $this->theTable, $where, '', '', '1');
+                                                                               ->andWhere(
+                                                                                       $queryBuilder->expr()->neq('uid', $queryBuilder->createNamedParameter((int)$dataArray['uid']), \PDO::PARAM_INT)
+                                                                               );
                                                                }
+                                                               if ($theCmd === 'uniqueLocal' || $theCmd === 'uniqueDeletedLocal') {
+                                                                       $queryBuilder
+                                                                               ->andWhere(
+                                                                                       $queryBuilder->expr()->in('pid', GeneralUtility::intExplode(',', $recordTestPid, true))
+                                                                               );
+                                                               }
+                                                               $DBrows = $queryBuilder
+                                                                       ->execute()
+                                                                       ->fetchAll();
                                                                if (
                                                                        !is_array($dataArray[$theField]) &&
                                                                        trim($dataArray[$theField]) != '' &&
@@ -778,7 +765,7 @@ class Data
                                                                if (!is_array($dataArray[$theField]) && !empty($dataArray[$theField]) && $dataArray[$theField] !== '0') {
                                                                        $pattern = str_replace('preg[', '', $cmd);
                                                                        $pattern = substr($pattern, 0, strlen($pattern) - 1);
-                                                                       $matches = array();
+                                                                       $matches = [];
                                                                        $test = preg_match($pattern, $dataArray[$theField], $matches);
                                                                        if (count($matches) === 0) {
                                                                                $failureArray[] = $theField;
@@ -790,7 +777,7 @@ class Data
                                                                break;
                                                        case 'hook':
                                                        default:
-                                                               $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model'] : array();
+                                                               $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model'] : [];
                                                                // The captcha cannot be checked twice
                                                                if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['captcha']) && ($mode == AbstractView::MODE_PREVIEW || !$this->conf[$cmdKey . '.']['preview'])) {
                                                                                $hookClassArray = array_merge($hookClassArray, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['captcha']);
@@ -912,7 +899,7 @@ class Data
                                                                $dataValue = substr(md5(uniqid(microtime(), 1)), 0, intval($cmdParts[1]));
                                                                break;
                                                        case 'files':
-                                                               $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model'] : array();
+                                                               $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model'] : [];
                                                                foreach ($hookClassArray as $classRef) {
                                                                        $hookObj = GeneralUtility::makeInstance($classRef);
                                                                        if (is_object($hookObj) && method_exists($hookObj, 'parseValues')) {
@@ -947,7 +934,7 @@ class Data
                                                                break;
                                                        case 'uniqueHashInt':
                                                                $otherFields = GeneralUtility::trimExplode(';', $cmdParts[1], true);
-                                                               $hashArray = array();
+                                                               $hashArray = [];
                                                                foreach($otherFields as $fN) {
                                                                        $vv = $dataArray[$fN];
                                                                        $vv = preg_replace('/\s+/', '', $vv);
@@ -1023,21 +1010,21 @@ class Data
                                $rc = $theUid;
                                $aCAuth = Authentication::aCAuth($this->parameters->getAuthCode(), $origArray, $this->conf, $this->conf['setfixed.']['EDIT.']['_FIELDLIST']);
                                // Fetch the original record to check permissions
-                               if ($this->conf['edit'] && ($GLOBALS['TSFE']->loginUser || $aCAuth)) {
+                               if ($this->conf['edit'] && (GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('frontend.user', 'isLoggedIn') || $aCAuth)) {
                                        // Must be logged in in order to edit  (OR be validated by email)
                                        $newFieldList = implode(',', array_intersect(explode(',', $this->getFieldList()), GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], true)));
                                        $newFieldArray = array_unique( array_merge (explode(',', $newFieldList), explode(',', $this->getAdminFieldList())));
                                        $fieldArray = GeneralUtility::trimExplode(',', $this->conf[$cmdKey . '.']['fields'], true);
                                        // Do not reset the name if we have no new value
                                        if (!in_array('name', $fieldArray) && !in_array('first_name', $fieldArray) && !in_array('last_name', $fieldArray)) {
-                                               $newFieldArray = array_diff($newFieldArray, array('name'));
+                                               $newFieldArray = array_diff($newFieldArray, ['name']);
                                        }
                                        // Do not reset the username if we have no new value
                                        if (!in_array('username', $fieldArray) && $dataArray['username'] == '') {
-                                               $newFieldArray = array_diff($newFieldArray, array('username'));
+                                               $newFieldArray = array_diff($newFieldArray, ['username']);
                                        }
-
-                                       if ($aCAuth || $this->DBmayFEUserEdit($this->theTable, $origArray, $GLOBALS['TSFE']->fe_user->user, $this->conf['allowedGroups'], $this->conf['fe_userEditSelf'])) {
+                                       $userAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user');
+                                       if ($aCAuth || $this->DBmayFEUserEdit($this->theTable, $origArray, ['uid' => $userAspect->get('id'), 'usergroup' => $userAspect->get('groupIds')], $this->conf['allowedGroups'], $this->conf['fe_userEditSelf'])) {
                                                $outGoingData = $this->parseOutgoingData($cmdKey, $pid, $dataArray, $origArray);
                                                // Do not set the outgoing password if the incoming password was unset
                                                if ($this->theTable === 'fe_users' && !empty($dataArray['password'])) {
@@ -1054,7 +1041,7 @@ class Data
                                                $this->updateMMRelations($dataArray);
                                                $this->setSaved(true);
 
-                                               $newRow = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $theUid);
+                                               $newRow = $this->getTypoScriptFrontendController()->sys_page->getRawRecord($this->theTable, $theUid);
                                                $newRow = $this->parseIncomingData($newRow);
                                                $this->modifyRow($newRow, true);
 
@@ -1103,7 +1090,7 @@ class Data
                                        // Enable users to own themselves.
                                        if ($this->theTable === 'fe_users' && $this->conf['fe_userOwnSelf']) {
                                                $extraList = '';
-                                               $tmpDataArray = array();
+                                               $tmpDataArray = [];
                                                if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id']) {
                                                        $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id'];
                                                        $dataArray[$field] = $newId;
@@ -1127,7 +1114,7 @@ class Data
                                        }
                                        $dataArray['uid'] = $newId;
                                        $this->updateMMRelations($dataArray);
-                                       $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model'] : array();
+                                       $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model'] : [];
                                        foreach ($hookClassArray as $classRef) {
                                                $hookObj = GeneralUtility::makeInstance($classRef);
                                                if (is_object($hookObj) && method_exists($hookObj, 'afterSave')) {
@@ -1136,7 +1123,7 @@ class Data
                                        }
                                        $this->setSaved(true);
 
-                                       $newRow = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $newId);
+                                       $newRow = $this->getTypoScriptFrontendController()->sys_page->getRawRecord($this->theTable, $newId);
                                        if (is_array($newRow)) {
                                                $newRow = $this->parseIncomingData($newRow);
                                                $this->modifyRow($newRow, true);
@@ -1161,7 +1148,7 @@ class Data
                                                        }
                                                }
                                        } else {
-                                               $newRow = array();
+                                               $newRow = [];
                                                $this->setError('###TEMPLATE_NO_PERMISSIONS###');
                                                $this->setSaved(false);
                                                $rc = 0;
@@ -1177,7 +1164,7 @@ class Data
      *
      * @param string $table The table name, found in $GLOBALS['TCA']
      * @param array $row The record data array for the record in question
-     * @param array $feUserRow The array of the fe_user which is evaluated, typ. $GLOBALS['TSFE']->fe_user->user
+     * @param array $feUserRow The array of the fe_user which is evaluated: ['uid' => $userAspect->get('id'), 'usergroup' => $userAspect->get('groupIds')]
      * @param string $allowedGroups Commalist of the only fe_groups uids which may edit the record. If not set, then the usergroup field of the fe_user is used.
      * @param bool|int $feEditSelf TRUE, if the fe_user may edit his own fe_user record.
      * @return bool
@@ -1188,12 +1175,12 @@ class Data
                $groupList = implode(
                        ',',
                        array_intersect(
-                               GeneralUtility::trimExplode(',', $feUserRow['usergroup'], true),
+                               $feUserRow['usergroup'],
                                GeneralUtility::trimExplode(',', $allowedGroups, true)
                 )
             );
         } else {
-            $groupList = $feUserRow['usergroup'];
+            $groupList = implode(',', $feUserRow['usergroup']);
         }
         $ok = 0;
         // Points to the field that allows further editing from frontend if not set. If set the record is locked.
@@ -1232,56 +1219,51 @@ class Data
         */
        protected function insertRecord($pid, $dataArr, $fieldList)
        {
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $extraList = 'pid';
-                       if ($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp']) {
-                               $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp'];
-                               $dataArr[$field] = $GLOBALS['EXEC_TIME'];
-                               $extraList .= ',' . $field;
-                       }
-                       if ($GLOBALS['TCA'][$this->theTable]['ctrl']['crdate']) {
-                               $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['crdate'];
-                               $dataArr[$field] = $GLOBALS['EXEC_TIME'];
-                               $extraList .= ',' . $field;
-                       }
-                       if ($GLOBALS['TCA'][$this->theTable]['ctrl']['cruser_id']) {
-                               $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['cruser_id'];
-                               $dataArr[$field] = 0;
-                               $extraList .= ',' . $field;
-                       }
-                       if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id']) {
-                               $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id'];
-                               $dataArr[$field] = (int)$this->getTypoScriptFrontendController()->fe_user->user['uid'];
-                               $extraList .= ',' . $field;
-                       }
-                       if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_crgroup_id']) {
-                               $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['fe_crgroup_id'];
-                               list($dataArr[$field]) = explode(',', $this->getTypoScriptFrontendController()->fe_user->user['usergroup']);
-                               $dataArr[$field] = (int)$dataArr[$field];
-                               $extraList .= ',' . $field;
-                       }
-                       unset($dataArr['uid']);
-                       if ($pid >= 0) {
-                               $dataArr['pid'] = $pid;
-                       }
-                       $fieldList = implode(',', GeneralUtility::trimExplode(',', $fieldList . ',' . $extraList, true));
-                       $insertFields = [];
-                       foreach ($dataArr as $f => $v) {
-                               if (GeneralUtility::inList($fieldList, $f)) {
-                                       $insertFields[$f] = $v;
-                               }
+               $extraList = 'pid';
+               $userAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user');
+               if ($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp']) {
+                       $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp'];
+                       $dataArr[$field] = $GLOBALS['EXEC_TIME'];
+                       $extraList .= ',' . $field;
+               }
+               if ($GLOBALS['TCA'][$this->theTable]['ctrl']['crdate']) {
+                       $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['crdate'];
+                       $dataArr[$field] = $GLOBALS['EXEC_TIME'];
+                       $extraList .= ',' . $field;
+               }
+               if ($GLOBALS['TCA'][$this->theTable]['ctrl']['cruser_id']) {
+                       $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['cruser_id'];
+                       $dataArr[$field] = 0;
+                       $extraList .= ',' . $field;
+               }
+               if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id']) {
+                       $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id'];
+                       $dataArr[$field] = $userAspect->get('id');
+                       $extraList .= ',' . $field;
+               }
+               if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_crgroup_id']) {
+                       $field = $GLOBALS['TCA'][$this->theTable]['ctrl']['fe_crgroup_id'];
+                       list($dataArr[$field]) = $userAspect->get('groupIds');
+                       $dataArr[$field] = (int)$dataArr[$field];
+                       $extraList .= ',' . $field;
+               }
+               unset($dataArr['uid']);
+               if ($pid >= 0) {
+                       $dataArr['pid'] = $pid;
+               }
+               $fieldList = implode(',', GeneralUtility::trimExplode(',', $fieldList . ',' . $extraList, true));
+               $insertFields = [];
+               foreach ($dataArr as $f => $v) {
+                       if (GeneralUtility::inList($fieldList, $f)) {
+                               $insertFields[$f] = $v;
                        }
-                       $connection = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getConnectionForTable($this->theTable);
-                       $queryBuilder = $connection->createQueryBuilder()
-                               ->insert($this->theTable)
-                               ->values($insertFields)
-                               ->execute();
-                       return $connection->lastInsertId($this->theTable);
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $this->cObj->DBgetInsert($this->theTable, (int)$pid, $dataArr, $fieldList, true);
-                       return $GLOBALS['TYPO3_DB']->sql_insert_id();
                }
+               $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($this->theTable);
+               $queryBuilder = $connection->createQueryBuilder()
+                       ->insert($this->theTable)
+                       ->values($insertFields)
+                       ->execute();
+               return $connection->lastInsertId($this->theTable);
        }
 
        /**
@@ -1294,30 +1276,25 @@ class Data
         */
        public function updateRecord($uid, array $dataArr, $fieldList)
        {
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       if ($uid) {
-                               $fields = GeneralUtility::trimExplode(',', $fieldList, true);
-                               $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable($this->theTable);
-                               $queryBuilder
-                                       ->update($this->theTable)
-                                       ->where(
-                                               $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT))
-                                       );
-                               foreach ($dataArr as $field => $value) {
-                                       if (in_array($field, $fields)) {
-                                               $queryBuilder->set($field, $value);
-                                       }
-                               }
-                               if ($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp']) {
-                                       $queryBuilder->set($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp'], (int)$GLOBALS['EXEC_TIME']);
+               if ($uid) {
+                       $fields = GeneralUtility::trimExplode(',', $fieldList, true);
+                       $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->theTable);
+                       $queryBuilder
+                               ->update($this->theTable)
+                               ->where(
+                                       $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT))
+                               );
+                       foreach ($dataArr as $field => $value) {
+                               if (in_array($field, $fields)) {
+                                       $queryBuilder->set($field, $value);
                                }
-                               $queryBuilder->execute();
                        }
-                       return false;
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       return $this->cObj->DBgetUpdate($this->theTable, $uid, $dataArr, $fieldList, true);
+                       if ($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp']) {
+                               $queryBuilder->set($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp'], (int)$GLOBALS['EXEC_TIME']);
+                       }
+                       $queryBuilder->execute();
                }
+               return false;
        }
 
        /**
@@ -1329,36 +1306,31 @@ class Data
         */
        public function deleteRecordByUid($uid)
        {
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $uid = (int)$uid;
-                       if (!$uid) {
-                               return false;
-                       }
-                       $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
-                       if ($GLOBALS['TCA'][$this->theTable]['ctrl']['delete']) {
-                               $queryBuilder = $connectionPool->getQueryBuilderForTable($this->theTable);
-                               $queryBuilder
-                                       ->update($this->theTable)
-                                       ->where(
-                                               $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
-                                       )
-                                       ->set($GLOBALS['TCA'][$this->theTable]['ctrl']['delete'], 1);
-                               if ($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp']) {
-                                       $queryBuilder->set($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp'], (int)$GLOBALS['EXEC_TIME']);
-                               }
-                               $queryBuilder->execute();
-            } else {
-               $connectionPool->getConnectionForTable($this->theTable)
-                                       ->delete(
-                                               $this->theTable,
-                                               ['uid' => $uid]
-                                       );
-                       }
+               $uid = (int)$uid;
+               if (!$uid) {
                        return false;
+               }
+               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
+               if ($GLOBALS['TCA'][$this->theTable]['ctrl']['delete']) {
+                       $queryBuilder = $connectionPool->getQueryBuilderForTable($this->theTable);
+                       $queryBuilder
+                               ->update($this->theTable)
+                               ->where(
+                                       $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
+                               )
+                               ->set($GLOBALS['TCA'][$this->theTable]['ctrl']['delete'], 1);
+                       if ($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp']) {
+                               $queryBuilder->set($GLOBALS['TCA'][$this->theTable]['ctrl']['tstamp'], (int)$GLOBALS['EXEC_TIME']);
+                       }
+                       $queryBuilder->execute();
                } else {
-                       // TYPO3 CMS 7 LTS
-                       return $this->cObj->DBgetDelete($this->theTable, $uid, true);
+                       $connectionPool->getConnectionForTable($this->theTable)
+                               ->delete(
+                                       $this->theTable,
+                                       ['uid' => $uid]
+                               );
                }
+               return false;
        }
 
        /**
@@ -1371,11 +1343,12 @@ class Data
                if ($this->conf['delete']) {
                        // If deleting is enabled
                        $aCAuth = Authentication::aCAuth($this->parameters->getAuthCode(), $origArray, $this->conf, $this->conf['setfixed.']['DELETE.']['_FIELDLIST']);
-                       if ($GLOBALS['TSFE']->loginUser || $aCAuth) {
+                       if (GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('frontend.user', 'isLoggedIn') || $aCAuth) {
                                // Must be logged in OR be authenticated by the aC code in order to delete
                                // If the recUid selects a record.... (no check here)
                                if (is_array($origArray)) {
-                                       if ($aCAuth || $this->DBmayFEUserEdit($this->theTable, $origArray, $GLOBALS['TSFE']->fe_user->user, $this->conf['allowedGroups'], $this->conf['fe_userEditSelf'])) {
+                                       $userAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user');
+                                       if ($aCAuth || $this->DBmayFEUserEdit($this->theTable, $origArray, ['uid' => $userAspect->get('id'), 'usergroup' => $userAspect->get('groupIds')], $this->conf['allowedGroups'], $this->conf['fe_userEditSelf'])) {
                                                // Delete the record and display form, if access granted.
                                                // Call all beforeSaveDelete hooks BEFORE the record is deleted
                                                if (is_array ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['registrationProcess'])) {
@@ -1410,8 +1383,8 @@ class Data
         */
        public function deleteFilesFromRecord($uid)
        {
-               $rec = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $uid);
-               $updateFields = array();
+               $rec = $this->getTypoScriptFrontendController()->sys_page->getRawRecord($this->theTable, $uid);
+               $updateFields = [];
                foreach ($GLOBALS['TCA'][$this->theTable]['columns'] as $field => $fieldConf) {
                        if ($fieldConf['config']['type'] === 'group' && $fieldConf['config']['internal_type'] === 'file') {
                                $updateFields[$field] = '';
@@ -1420,7 +1393,7 @@ class Data
                                $delFileArr = explode(',', $rec[$field]);
                                foreach ($delFileArr as $n) {
                                        if ($n) {
-                                               $fpath = PATH_site . $fieldConf['config']['uploadfolder'] . '/' . $n;
+                                               $fpath = Environment::getPublicPath() . '/' . $fieldConf['config']['uploadfolder'] . '/' . $n;
                                                if (@is_file($fpath)) {
                                                        @unlink($fpath);
                                                }
@@ -1428,7 +1401,7 @@ class Data
                                }
                        }
                }
-               $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model'] : array();
+               $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model']) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId]['model'] : [];
                foreach ($hookClassArray as $classRef) {
                        $hookObj = GeneralUtility::makeInstance($classRef);
                        if (is_object($hookObj) && method_exists($hookObj, 'deleteFileReferences')) {
@@ -1442,7 +1415,7 @@ class Data
         */
        protected function fetchDate($value, $dateFormat = 'Y-m-d')
        {
-               $rcArray = array('m' => '', 'd' => '', 'y' => '');
+               $rcArray = ['m' => '', 'd' => '', 'y' => ''];
                $dateValue = trim($value);
                $split = '/-/';
                $dateFormatArray = preg_split($split, $dateFormat);
@@ -1518,71 +1491,39 @@ class Data
        public function updateMMRelations(array $row)
        {
                $fieldsList = array_keys($row);
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
-               }
+               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
                foreach ($GLOBALS['TCA'][$this->theTable]['columns'] as $colName => $colSettings) {
                        if (in_array($colName, $fieldsList) && $colSettings['config']['type'] === 'select' && $colSettings['config']['MM']) {
                                $valuesArray = $row[$colName];
                                $side = isset($colSettings['config']['MM_opposite_field']) ? 'foreign' : 'local';
                                $oppositeSide = ($side === 'foreign') ?  'local' : 'foreign';
                                if (isset($valuesArray) && is_array($valuesArray)) {
-                                       if (is_object($connectionPool)) {
-                                               $connection = $connectionPool->getConnectionForTable($colSettings['config']['MM']);
-                                               $connection->delete(
-                                                       $colSettings['config']['MM'],
-                                                       ['uid_' . $side => (int)$row['uid']]
-                                               );
-                                               if (isset($colSettings['config']['MM_match_fields'])) {
-                                                       $tablenames = $colSettings['config']['MM_match_fields']['tablenames'];
-                                                       $fieldname = $colSettings['config']['MM_match_fields']['fieldname'];
-                                               }
-                                               $insertFields = [
-                                                       'uid_' . $side => (int)$row['uid'],
-                                                       'sorting' . ($side === 'foreign' ? '_' . $side : '') => 0
-                                               ];
-                                               if (isset($tablenames)) {
-                                                       $insertFields['tablenames'] = $tablenames ?: '';
-                                               }
-                                               if (isset($fieldname)) {
-                                                       $insertFields['fieldname'] = $fieldname ?: '';
-                                               }
-                                               foreach ($valuesArray as $theValue) {
-                                                       $insertFields['uid_' . $oppositeSide] = (int)$theValue;
-                                                       $insertFields['sorting' . ($side === 'foreign' ? '_' . $side : '')]++;
-                                                       $connection->insert(
-                                                               $colSettings['config']['MM'],
-                                                               $insertFields
-                                                       );
-                                               }
-                                       } else {
-                                               // TYPO3 CMS 7 LTS
-                                               $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                                       $connection = $connectionPool->getConnectionForTable($colSettings['config']['MM']);
+                                       $connection->delete(
+                                               $colSettings['config']['MM'],
+                                               ['uid_' . $side => (int)$row['uid']]
+                                       );
+                                       if (isset($colSettings['config']['MM_match_fields'])) {
+                                               $tablenames = $colSettings['config']['MM_match_fields']['tablenames'];
+                                               $fieldname = $colSettings['config']['MM_match_fields']['fieldname'];
+                                       }
+                                       $insertFields = [
+                                               'uid_' . $side => (int)$row['uid'],
+                                               'sorting' . ($side === 'foreign' ? '_' . $side : '') => 0
+                                       ];
+                                       if (isset($tablenames)) {
+                                               $insertFields['tablenames'] = $tablenames ?: '';
+                                       }
+                                       if (isset($fieldname)) {
+                                               $insertFields['fieldname'] = $fieldname ?: '';
+                                       }
+                                       foreach ($valuesArray as $theValue) {
+                                               $insertFields['uid_' . $oppositeSide] = (int)$theValue;
+                                               $insertFields['sorting' . ($side === 'foreign' ? '_' . $side : '')]++;
+                                               $connection->insert(
                                                        $colSettings['config']['MM'],
-                                                       'uid_' . $side . '=' . (int)$row['uid']
+                                                       $insertFields
                                                );
-                                               if (isset($colSettings['config']['MM_match_fields'])) {
-                                                       $tablenames = $colSettings['config']['MM_match_fields']['tablenames'];
-                                                       $fieldname = $colSettings['config']['MM_match_fields']['fieldname'];
-                                               }
-                                               $insertFields = [
-                                                       'uid_' . $side => (int)$row['uid'],
-                                                       'sorting' . ($side === 'foreign' ? '_' . $side : '') => 0
-                                               ];
-                                               if (isset($tablenames)) {
-                                                       $insertFields['tablenames'] = $tablenames ?: '';
-                                               }
-                                               if (isset($fieldname)) {
-                                                       $insertFields['fieldname'] = $fieldname ?: '';
-                                               }
-                                               foreach ($valuesArray as $theValue) {
-                                                       $insertFields['uid_' . $oppositeSide] = (int)$theValue;
-                                                       $insertFields['sorting' . ($side === 'foreign' ? '_' . $side : '')]++;
-                                                       $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery(
-                                                               $colSettings['config']['MM'],
-                                                               $insertFields
-                                                       );
-                                               }
                                        }
                                }
                        }
@@ -1594,29 +1535,19 @@ class Data
         *
         * @return void
         */
-       public function deleteMMRelations($uid, array $row = array())
+       public function deleteMMRelations($uid, array $row = [])
        {
                $fieldsList = array_keys($row);
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
-               }
+               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
                foreach ($GLOBALS['TCA'][$this->theTable]['columns'] as $colName => $colSettings) {
                        if (in_array($colName, $fieldsList) && $colSettings['config']['type'] === 'select' && $colSettings['config']['MM']) {
                                $side = isset($colSettings['config']['MM_opposite_field']) ? 'foreign' : 'local';
-                               if (is_object($connectionPool)) {
-                                       $connectionPool
-                                               ->getConnectionForTable($colSettings['config']['MM'])
-                                               ->delete(
-                                                       $colSettings['config']['MM'],
-                                                       ['uid_' . $side => (int)$uid]
-                                               );
-                               } else {
-                                       // TYPO3 CMS 7 LTS
-                                       $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                               $connectionPool
+                                       ->getConnectionForTable($colSettings['config']['MM'])
+                                       ->delete(
                                                $colSettings['config']['MM'],
-                                               'uid_' . $side . '=' . (int)$uid
+                                               ['uid_' . $side => (int)$uid]
                                        );
-                               }
                        }
                }
        }
@@ -1824,19 +1755,21 @@ class Data
                                                case 'adodb_date':
                                                        if ($dataArray[$theField]) {
                                                                $parsedArray[$theField] = mktime(0, 0, 0, $dateArray['m'], $dateArray['d'], $dateArray['y']);
+                                                       } else {
+                                                               $parsedArray[$theField] = 0;
                                                        }
                                                        break;
                                                case 'deleteUnreferencedFiles':
                                                        $fieldConfig = $GLOBALS['TCA'][$this->theTable]['columns'][$theField]['config'];
                                                        if (is_array($fieldConfig) && $fieldConfig['type'] === 'group' && $fieldConfig['internal_type'] === 'file' && $fieldConfig['uploadfolder']) {
                                                                $uploadPath = $fieldConfig['uploadfolder'];
-                                                               $origFiles = array();
+                                                               $origFiles = [];
                                                                if (is_array($origArray[$theField])) {
                                                                        $origFiles = $origArray[$theField];
                                                                } else if ($origArray[$theField]) {
                                                                        $origFiles = GeneralUtility::trimExplode(',', $origArray[$theField], true);
                                                                }
-                                                               $updatedFiles = array();
+                                                               $updatedFiles = [];
                                                                if (is_array($dataArray[$theField])) {
                                                                        $updatedFiles = $dataArray[$theField];
                                                                } else if ($dataArray[$theField]) {
@@ -1844,8 +1777,8 @@ class Data
                                                                }
                                                                $unReferencedFiles = array_diff($origFiles, $updatedFiles);
                                                                foreach ($unReferencedFiles as $file) {
-                                                                       if(@is_file(PATH_site . $uploadPath . '/' . $file)) {
-                                                                               @unlink(PATH_site . $uploadPath . '/' . $file);
+                                                                       if(@is_file(Environment::getPublicPath() . '/' . $uploadPath . '/' . $file)) {
+                                                                               @unlink(Environment::getPublicPath() . '/' . $uploadPath . '/' . $file);
                                                                        }
                                                                }
                                                        }
@@ -1860,7 +1793,7 @@ class Data
                foreach ($GLOBALS['TCA'][$this->theTable]['columns'] as $colName => $colSettings) {
                        if (isset($parsedArray[$colName]) || isset($origArray[$colName])) {
                                $foreignTable = $GLOBALS['TCA'][$this->theTable]['columns'][$colName]['config']['foreign_table'] ?: '';
-                               $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId][$this->theTable][$colName]) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId][$this->theTable][$colName] : array();
+                               $hookClassArray = is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId][$this->theTable][$colName]) ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey][$this->prefixId][$this->theTable][$colName] : [];
                                foreach ($hookClassArray as $classRef) {
                                        $hookObject = GeneralUtility::makeInstance($classRef);
                                        if (is_object($hookObject) && method_exists($hookObject, 'parseOutgoingData')) {
@@ -1869,7 +1802,7 @@ class Data
                                }
                        }
                }
-               // Update the MM relation count field
+               // Update the MM relation count field and implode arrays
                foreach ($GLOBALS['TCA'][$this->theTable]['columns'] as $colName => $colSettings) {
                        if (isset($parsedArray[$colName])) {
                                if (is_array ($parsedArray[$colName])) {
@@ -1951,9 +1884,7 @@ class Data
        public function modifyTcaMMfields(array $dataArray, &$modArray)
        {
                $rcArray = $dataArray;
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
-               }
+               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
                foreach ($GLOBALS['TCA'][$this->theTable]['columns'] as $colName => $colSettings) {
                        $colConfig = $colSettings['config'];
                        switch ($colConfig['type']) {
@@ -1962,25 +1893,16 @@ class Data
                                                $side = isset($colConfig['MM_opposite_field']) ? 'foreign' : 'local';
                                                $oppositeSide = ($side === 'foreign') ?  'local' : 'foreign';
                                                $valueArray = [];
-                                               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                                       $queryBuilder = $connectionPool->getQueryBuilderForTable($colConfig['MM']);
-                                                       $query = $queryBuilder
-                                                               ->select('uid_' . $oppositeSide)
-                                                               ->from($colConfig['MM'])
-                                                               ->where(
-                                                                       $queryBuilder->expr()->eq('uid_' . $side, $queryBuilder->createNamedParameter((int)$dataArray['uid'], \PDO::PARAM_INT))
-                                                               )
-                                                               ->execute();
-                                                       while ($row = $query->fetch()) {
-                                                               $valueArray[] = $row['uid_' . $oppositeSide];
-                                                       }
-                                               } else {
-                                                       // TYPO3 CMS 7 LTS
-                                                       $where = 'uid_' . $side . ' = ' . (int)$dataArray['uid'];
-                                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_' . $oppositeSide, $colConfig['MM'], $where);
-                                                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                                                               $valueArray[] = $row['uid_' . $oppositeSide];
-                                                       }
+                                               $queryBuilder = $connectionPool->getQueryBuilderForTable($colConfig['MM']);
+                                               $query = $queryBuilder
+                                                       ->select('uid_' . $oppositeSide)
+                                                       ->from($colConfig['MM'])
+                                                       ->where(
+                                                               $queryBuilder->expr()->eq('uid_' . $side, $queryBuilder->createNamedParameter((int)$dataArray['uid'], \PDO::PARAM_INT))
+                                                       )
+                                                       ->execute();
+                                               while ($row = $query->fetch()) {
+                                                       $valueArray[] = $row['uid_' . $oppositeSide];
                                                }
                                                $rcArray[$colName] = implode(',', $valueArray);
                                                $modArray[$colName] = $rcArray[$colName];
@@ -2034,33 +1956,19 @@ class Data
                                                        $side = isset($colConfig['MM_opposite_field']) ? 'foreign' : 'local';
                                                        $oppositeSide = ($side === 'foreign') ?  'local' : 'foreign';
                                                        $valuesArray = [];
-                                                       if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                                               $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                                                                       ->getQueryBuilderForTable($colConfig['MM']);
-                                                               $queryBuilder->getRestrictions()->removeAll();
-                                                               $query = $queryBuilder
-                                                                       ->select('uid_local','uid_foreign', 'sorting' . ($side === 'foreign' ? '_' . $side : ''))
-                                                                       ->from($colConfig['MM'])
-                                                                       ->where(
-                                                                               $queryBuilder->expr()->eq('uid_' . $side, $queryBuilder->createNamedParameter((int)$dataArray['uid'], \PDO::PARAM_INT))
-                                                                       )
-                                                                       ->orderBy('sorting' . ($side === 'foreign' ? '_' . $side : ''))
-                                                                       ->execute();
-                                                               while ($row = $query->fetch()) {
-                                                                       $valuesArray[] = $row['uid_' . $oppositeSide];
-                                                               }
-                                                       } else {
-                                                               // TYPO3 CMS 7 LTS
-                                                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                                                       'uid_local,uid_foreign,sorting' . ($side === 'foreign' ? '_' . $side : ''),
-                                                                       $colConfig['MM'],
-                                                                       'uid_' . $side . '=' . (int)$dataArray['uid'],
-                                                                       '',
-                                                                       'sorting' . ($side === 'foreign' ? '_' . $side : '')
-                                                               );
-                                                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                                                                       $valuesArray[] = $row['uid_' . $oppositeSide];
-                                                               }
+                                                       $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                                                               ->getQueryBuilderForTable($colConfig['MM']);
+                                                       $queryBuilder->getRestrictions()->removeAll();
+                                                       $query = $queryBuilder
+                                                               ->select('uid_local','uid_foreign', 'sorting' . ($side === 'foreign' ? '_' . $side : ''))
+                                                               ->from($colConfig['MM'])
+                                                               ->where(
+                                                                       $queryBuilder->expr()->eq('uid_' . $side, $queryBuilder->createNamedParameter((int)$dataArray['uid'], \PDO::PARAM_INT))
+                                                               )
+                                                               ->orderBy('sorting' . ($side === 'foreign' ? '_' . $side : ''))
+                                                               ->execute();
+                                                       while ($row = $query->fetch()) {
+                                                               $valuesArray[] = $row['uid_' . $oppositeSide];
                                                        }
                                                        $dataArray[$colName] = $valuesArray;
                                                } else {
index f1ddbfd..c2c40a9 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Hooks;
 /*
  *  Copyright notice
  *
- *  (c) 2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2017-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -24,13 +24,14 @@ namespace SJBR\SrFeuserRegister\Hooks;
 
 use SJBR\SrFeuserRegister\Utility\CssUtility;
 use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
+use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Resource\DuplicationBehavior;
 use TYPO3\CMS\Core\Resource\FileReference;
 use TYPO3\CMS\Core\Resource\FileRepository;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
-use TYPO3\CMS\Core\Utility\File\BasicFileUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\VersionNumberUtility;
+use TYPO3\CMS\Frontend\Resource\FilePathSanitizer;
 
 /**
  * Hooks for file upload fields
@@ -114,8 +115,6 @@ class FileUploadHooks
                                        $fieldConfig = $GLOBALS['TCA'][$theTable]['columns'][$theField]['config'];
                                        if ($fieldConfig['type'] === 'inline' && $fieldConfig['foreign_table'] === 'sys_file_reference') {
                                                $dataArray[$theField] = $dataArray['uid'] ? count($fileNameArray) : $fileArray;
-                                       } else {
-                                               $dataArray[$theField] = $fileNameArray;
                                        }
                                }
                        }
@@ -179,7 +178,7 @@ class FileUploadHooks
                                                }
                                        } else {
                                                if ($fieldConfig['type'] === 'group' && $fieldConfig['internal_type'] === 'file') {
-                                                       $fileArray[] = ['name' => $file, 'size' => filesize(PATH_site . $uploadPath . '/' . $file)];
+                                                       $fileArray[] = ['name' => $file, 'size' => filesize(Environment::getPublicPath() . '/' . $uploadPath . '/' . $file)];
                                                }
                                        }
                                }
@@ -233,7 +232,7 @@ class FileUploadHooks
                                  DuplicationBehavior::RENAME
                        );
                        if ($uid) {
-                               $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
+                               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
                                // Get the record from the table in use
                                $connectionTheTable = $connectionPool->getConnectionForTable($theTable);
                                $row = $connectionTheTable
@@ -271,15 +270,6 @@ class FileUploadHooks
                        } else {
                                return ['name' => $fileObject->getName(), 'uid' => $fileObject->getUid(), 'size' => $fileObject->getSize(), 'table' => 'sys_file'];
                        }
-               } else {
-                       $fileUtility = GeneralUtility::makeInstance(BasicFileUtility::class);
-                       $fI = pathinfo($fileName);
-                       $tempFileName = basename($fileName, '.' . $fI['extension']) . '_' . GeneralUtility::shortmd5(uniqid($fileName)) . '.' . $fI['extension'];
-                       $cleanFileName = $fileUtility->cleanFileName($tempFileName);
-                       $theDestFile = $fileUtility->getUniqueName($cleanFileName, PATH_site . $uploadPath . '/');
-                       $fI = pathinfo($theDestFile);
-                       GeneralUtility::upload_copy_move($uploadedFileName, $theDestFile);
-                       return ['name' => $fI['basename'], 'size' => filesize(PATH_site . $uploadPath . '/' . $fI['basename'])];
                }
        }
 
@@ -302,10 +292,6 @@ class FileUploadHooks
                                $fileReference = $fileRepository->findByUid((int)$file['uid']);
                        }
                        return is_object($fileReference);
-               } else {
-                       $uploadPath = $fieldConfig['uploadfolder'];
-                       $uploadPath = $uploadPath ?: $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_feuser_register']['uploadfolder'];
-                       return @is_file(PATH_site . $uploadPath . '/' . $file['name']);
                }
        }
 
@@ -325,7 +311,7 @@ class FileUploadHooks
                        if ($uid && $file['submit_delete'] && $file['uid']) {
                                // If in create mode, there is no file reference to delete
                                // Delete the file reference
-                               $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
+                               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
                                $connectionPool->getConnectionForTable('sys_file_reference')
                                        ->delete(
                                                'sys_file_reference',
@@ -349,27 +335,6 @@ class FileUploadHooks
                                                );
                                }
                        }
-               } else {
-                       if ($fieldConf['config']['type'] === 'group' && $fieldConf['config']['internal_type'] === 'file') {
-                               // TYPO3 7 LTS
-                               $uploadPath = $fieldConf['uploadfolder'];
-                               $uploadPath = $uploadPath ?: $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_feuser_register']['uploadfolder'];
-                               $record = $GLOBALS['TSFE']->sys_page->getRawRecord($theTable, (int)$uid);
-                               if (is_array($rec)) {
-                                       $fileArray = explode(',', $record[$theField]);
-                                       foreach ($fileArray as $index => $fileItem) {
-                                               if ($fileItem == $file['name']) {
-                                                       unset($fileArray[$index]]);
-                                               }
-                                       }
-                                       $updateFields = [];
-                                       $updateFields[$theField] = implode(',', $fileArray);
-                                       $res = $GLOBALS['TSFE']->cObj->DBgetUpdate($theTable, (int)$uid, $updateFields, $theField, true);
-                               }
-                               if (@is_file(PATH_site . $uploadPath . '/' . $file['name'])) {
-                                       @unlink(PATH_site . $uploadPath . '/' . $file['name']);
-                               }
-                       }
                }
        }
 
@@ -428,7 +393,7 @@ class FileUploadHooks
                                $fieldConfig = $config['config'];
                                if ($fieldConfig['type'] === 'inline' && $fieldConfig['foreign_table'] === 'sys_file_reference') {
                                        if (is_array($dataArray[$theField])) {
-                                               $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
+                                               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
                                                $connectionFileReference = $connectionPool->getConnectionForTable('sys_file_reference');
                                                foreach ($dataArray[$theField] as $file) {
                                                        if ($file['table'] === 'sys_file') {
@@ -543,46 +508,6 @@ class FileUploadHooks
                                $markerArray['###HIDDENFIELDS###'] .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . $max_size . '" />' . LF;
                                $markerArray['###HIDDENFIELDS###'] .= '<input type="hidden" name="' . $prefixId . '[fileDelete]" value="0" />' . LF;
                        }
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $markerArray = $this->addCompatibleMarkers($theTable, $theField, $cmd, $cmdKey, $dataArray, $viewOnly, $activity, $bHtml, $extensionName, $prefixId, $conf);
-               }
-               return $markerArray;
-       }
-
-       /**
-        * TYPO3 CMS 7 LTS
-        *
-        * Adds uploading markers to a marker array
-        *
-        * @param string $theTable: the name of the table in use
-        * @param string $theField: the field name
-        * @param string $cmd: the command CODE
-        * @param string $cmdKey: the command key
-        * @param array $dataArray: the record array
-        * @param bool $viewOnly: whether the fields are presented for view only or for input/update
-        * @param string $activity: 'preview', 'input' or 'email': parameter of stdWrap configuration
-        * @param bool $bHtml: wheter HTML or plain text should be generated
-        * @param string $extensionName: name of the extension
-        * @param string $prefixId: the prefixId
-        * @param array $conf: the plugin configuration
-        * @return void
-        */
-       public function addCompatibleMarkers($theTable, $theField, $cmd, $cmdKey, $dataArray = array(), $viewOnly = false, $activity = '', $bHtml = true, $extensionName, $prefixId, array $conf)
-       {
-               $markerArray = [];
-               $fieldConfig = $GLOBALS['TCA'][$theTable]['columns'][$theField]['config'];
-               if ($fieldConfig['type'] === 'group' && $fieldConfig['internal_type'] === 'file' && !empty($fieldConfig['uploadfolder'])) {
-                       $fileNameArray = is_array($dataArray[$theField]) ? $dataArray[$theField] : [];
-                       $fileUploader = $this->buildCompatibleFileUploader($theTable, $theField, $cmd, $cmdKey, $fileNameArray, $viewOnly, $activity, $bHtml, $extensionName, $prefixId, $conf);
-                       if ($viewOnly) {
-                               $markerArray['###UPLOAD_PREVIEW_' . $theField . '###'] = $fileUploader;
-                       } else {
-                               $markerArray['###UPLOAD_' . $theField . '###'] = $fileUploader;
-                               $max_size = $fieldConfig['max_size'] * 1024;
-                               $markerArray['###HIDDENFIELDS###'] .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . $max_size . '" />' . LF;
-                               $markerArray['###HIDDENFIELDS###'] .= '<input type="hidden" name="' . $prefixId . '[fileDelete]" value="0" />' . LF;
-                       }
                }
                return $markerArray;
        }
@@ -630,6 +555,7 @@ class FileUploadHooks
                        }
                } else {
                        $formName = $conf['formName'] ?: CssUtility::getClassName($prefixId, $theTable . '_form');
+                       $filePathSanitizer = GeneralUtility::makeInstance(FilePathSanitizer::class);
                        foreach ($fileArray as $i => $file) {
                                $HTMLContent .=
                                        $file['name']
@@ -637,7 +563,7 @@ class FileUploadHooks
                                        . '<input type="hidden" name="' . 'FE[' . $theTable . ']' . '[' . $theField . '][' . $i . '][submit_delete]" value="0">'
                                        . '<input type="hidden" name="' . 'FE[' . $theTable . ']' . '[' . $theField . '][' . $i . '][uid]" value="' . $file['uid'] . '">'
                                        . '<input type="hidden" name="' . 'FE[' . $theTable . ']' . '[' . $theField . '][' . $i . '][type]" value="' . $file['type'] . '">'
-                                       . '<input type="image" src="' . $GLOBALS['TSFE']->tmpl->getFileName($conf['icon_delete']) . '"  title="' . LocalizationUtility::translate('icon_delete', $extensionName) . '" alt="' . LocalizationUtility::translate('icon_delete', $extensionName) . '"' .
+                                       . '<input type="image" src="' . $filePathSanitizer->sanitize($conf['icon_delete']) . '"  title="' . LocalizationUtility::translate('icon_delete', $extensionName) . '" alt="' . LocalizationUtility::translate('icon_delete', $extensionName) . '"' .
                                        CssUtility::classParam($prefixId, 'delete-view') .
                                        ' onclick=\'if(confirm("' . LocalizationUtility::translate('confirm_file_delete', $extensionName) . '")) { var form = window.document.getElementById("' . $formName . '"); form["' . $prefixId . '[fileDelete]"].value = 1; form["FE[' . $theTable . ']' . '[' . $theField . '][' . $i . '][submit_delete]"].value = 1; return true;} else { return false;} \' />'
                                        . '<a href="' . $file['url'] . '" ' .
@@ -655,75 +581,4 @@ class FileUploadHooks
                }
                return $HTMLContent;
        }
-
-       /**
-        * TYPO3 CMS 7 LTS
-        *
-        * Builds a file uploader
-        *
-        * @param string $theTable: the name of the table in use
-        * @param string $theField: the field name
-        * @param string $cmd: the command CODE
-        * @param string $cmdKey: the command key
-        * @param array $fileNameArray: array of uploaded file names
-        * @param boolean $viewOnly: whether the fields are presented for view only or for input/update
-        * @param string $activity: 'preview', 'input' or 'email': parameter of stdWrap configuration
-        * @param bool $bHtml: wheter HTML or plain text should be generated
-        * @param string $extensionName: name of the extension
-        * @param string $prefixId: the prefixId
-        * @param array $conf: the plugin configuration
-        * @return string generated HTML uploading tags
-        */
-       protected function buildCompatibleFileUploader($theTable, $theField, $cmd, $cmdKey, array $fileNameArray, $viewOnly = false, $activity = '', $bHtml = true, $extensionName, $prefixId, array $conf)
-       {
-               $HTMLContent = '';
-               $fieldConfig = $GLOBALS['TCA'][$theTable]['columns'][$theField]['config'];
-               $size = $fieldConfig['maxitems'];
-               $cmdParts = preg_split('/\[|\]/', $conf[$cmdKey . '.']['evalValues.'][$theField]);
-               if (!empty($cmdParts[1])) {
-                       $size = min($size, (int) $cmdParts[1]);
-               }
-               $size = $size ?: 1;
-               $number = $size - count($fileNameArray);
-               $dir = $fieldConfig['uploadfolder'];
-               if ($viewOnly) {
-                       foreach ($fileNameArray as $fileName) {
-                               $HTMLContent .= $fileName;
-                               if ($activity === 'email') {
-                                       if ($bHtml)     {
-                                               $HTMLContent .= '<br />';
-                                       } else {
-                                               $HTMLContent .= CR . LF;
-                                       }
-                               } else if ($bHtml) {
-                                       $HTMLContent .= '<a href="' . ($GLOBALS['TSFE']->config['config']['absRefPrefix'] ?: '') . $dir . '/' . $fileName . '"'
-                                       . CssUtility::classParam($prefixId, 'file-view')
-                                       . ' target="_blank" title="' . LocalizationUtility::translate('file_view', $extensionName) . '">' . LocalizationUtility::translate('file_view', $extensionName) . '</a><br />';
-                               }
-                       }
-               } else {
-                       $formName = $conf['formName'] ?: CssUtility::getClassName($prefixId, $theTable . '_form');
-                       foreach ($fileNameArray as $i => $fileName) {
-                               $HTMLContent .=
-                                       $fileName
-                                       . '<input type="hidden" name="' . 'FE[' . $theTable . ']' . '[' . $theField . '][' . $i . '][name]" value="' . htmlspecialchars($fileName) . '">'
-                                       . '<input type="hidden" name="' . 'FE[' . $theTable . ']' . '[' . $theField . '][' . $i . '][submit_delete]" value="0">'
-                                       . '<input type="image" src="' . $GLOBALS['TSFE']->tmpl->getFileName($conf['icon_delete']) . '"  title="' . LocalizationUtility::translate('icon_delete', $extensionName) . '" alt="' . LocalizationUtility::translate('icon_delete', $extensionName) . '"' .
-                                       CssUtility::classParam($prefixId, 'delete-view') .
-                                       ' onclick=\'if(confirm("' . LocalizationUtility::translate('confirm_file_delete', $extensionName) . '")) { var form = window.document.getElementById("' . $formName . '"); form["' . $prefixId . '[fileDelete]"].value = 1; form["FE[' . $theTable . ']' . '[' . $theField . '][' . $i . '][submit_delete]"].value = 1; return true;} else { return false;} \' />'
-                                       . '<a href="' . $dir . '/' . $fileName . '" ' .
-                                       CssUtility::classParam($prefixId, 'file-view') .
-                                       ' target="_blank" title="' . LocalizationUtility::translate('file_view', $extensionName) . '">' .
-                                       LocalizationUtility::translate('file_view', $extensionName) . '</a><br />';
-                       }
-                       for ($i = count($fileNameArray); $i < $number + count($fileNameArray); $i++) {
-                               $HTMLContent .= '<input id="' .
-                               CssUtility::getClassName($prefixId, $theField) .
-                               '-' . ($i - count($fileNameArray)) . '" name="' . 'FE[' . $theTable . ']' . '[' . $theField . '][' . $i . ']" title="' . LocalizationUtility::translate('tooltip_' . (($cmd == 'invite') ? 'invitation_' : '')  . 'image', $extensionName) . '" size="40" type="file" ' .
-                               CssUtility::classParam($prefixId, 'uploader-view') .
-                               ' /><br />';
-                       }
-               }
-               return $HTMLContent;
-       }
 }
\ No newline at end of file
index 7ff1c24..37091ac 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Hooks;
 /*\r
  *  Copyright notice\r
  *\r
- *  (c) 2005-2015 Stanislas Rolland <typo3(arobas)sjbr.ca>\r
+ *  (c) 2005-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>\r
  *  All rights reserved\r
  *\r
  *  This script is part of the TYPO3 project. The TYPO3 project is\r
@@ -24,7 +24,9 @@ namespace SJBR\SrFeuserRegister\Hooks;
 \r
 use SJBR\SrFeuserRegister\Domain\Data;\r
 use SJBR\SrFeuserRegister\Request\Parameters;\r
+use SJBR\SrFeuserRegister\Utility\DataUtility;\r
 use SJBR\SrFeuserRegister\View\Marker;\r
+use TYPO3\CMS\Core\Utility\GeneralUtility;\r
 \r
 /**\r
  * Example of hooks for extension Front End User Registration (sr_feuser_register)\r
@@ -49,16 +51,16 @@ class RegistrationProcessHooks
                        $lastName = trim($recordArray['last_name']);\r
                        $name = trim($recordArray['name']);\r
                        if ((!$firstName || !$lastName) && $name) {\r
-                               $nameArray = t3lib_div::trimExplode(' ', $name);\r
+                               $nameArray = GeneralUtility::trimExplode(' ', $name);\r
                                $firstName = ($firstName ? $firstName : $nameArray[0]);\r
                                $lastName = ($lastName ? $lastName : $nameArray[1]);\r
                        }\r
                        $recordArray['username'] = substr(strtolower($firstName), 0, 5) . substr(strtolower($lastName), 0, 5);\r
-                       $DBrows = $GLOBALS['TSFE']->sys_page->getRecordsByField($theTable, 'username', $recordArray['username'], 'LIMIT 1');\r
+                       $DBrows = DataUtility::getRecordsByField($theTable, 'username', $recordArray['username'], '', '', '', '1');\r
                        $counter = 0;\r
-                       while($DBrows) {\r
+                       while ($DBrows) {\r
                                $counter = $counter + 1;\r
-                               $DBrows = $GLOBALS['TSFE']->sys_page->getRecordsByField($theTable, 'username', $recordArray['username'] . $counter, 'LIMIT 1');\r
+                               $DBrows = DataUtility::getRecordsByField($theTable, 'username', $recordArray['username'] . $counter, '', '', '', '1');\r
                        }\r
                        if ($counter) {\r
                                $recordArray['username'] = $recordArray['username'] . $counter;\r
index 58c7c6f..c659be8 100644 (file)
@@ -5,7 +5,7 @@ namespace SJBR\SrFeuserRegister\Hooks;
  *  Copyright notice
  *
  *  (c) 2008-2011 Franz Holzinger <franz@ttproducts.de>
- *  (c) 2012-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2012-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -23,6 +23,7 @@ namespace SJBR\SrFeuserRegister\Hooks;
  *  This copyright notice MUST APPEAR in all copies of the script!
  */
 
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 
@@ -113,28 +114,22 @@ class UsergroupHooks
         */
        public function parseOutgoingData($theTable, $fieldname, $foreignTable, $cmdKey, $pid, array $conf, array $dataArray, array $origArray, array &$parsedArray)
        {
-               $valuesArray = array();
+               $valuesArray = [];
                if (isset($origArray[$fieldname]) && is_array($origArray[$fieldname])) {
                        $valuesArray = $origArray[$fieldname];
                        $keepValues = [];
                        if ($conf[$cmdKey . '.']['keepUnselectableUserGroups']) {
                                // Get usergroups that are not selectable
-                               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                                               ->getQueryBuilderForTable($foreignTable)
-                                               ->select('uid')
-                                               ->from($foreignTable);
-                                       $this->getAllowedWhereClause($foreignTable, $pid, $conf, $cmdKey, false, $queryBuilder);
-                                       $query = $queryBuilder
-                                               ->execute();
-                                       $rowArray = [];
-                                       while ($row = $query->fetch()) {
-                                               $rowArray['uid'] = $row;
-                                       }
-                               } else {
-                                       // TYPO3 CMS 7 LTS
-                                       $whereClause = $this->getAllowedWhereClause($foreignTable, $pid, $conf, $cmdKey, false);
-                                       $rowArray = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $foreignTable, $whereClause, '', '', '', 'uid');
+                               $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                                       ->getQueryBuilderForTable($foreignTable)
+                                       ->select('uid')
+                                       ->from($foreignTable);
+                               $this->getAllowedWhereClause($foreignTable, $pid, $conf, $cmdKey, false, $queryBuilder);
+                               $query = $queryBuilder
+                                       ->execute();
+                               $rowArray = [];
+                               while ($row = $query->fetch()) {
+                                       $rowArray['uid'] = $row;
                                }
                                if (!empty($rowArray) && is_array($rowArray)) {
                                        $keepValues = array_keys($rowArray);
@@ -156,14 +151,13 @@ class UsergroupHooks
         */
        public function getAllowedWhereClause($theTable, $pid, array $conf, $cmdKey, $bAllow = true, $queryBuilder = null)
        {
-               if ($queryBuilder === null) {
-                       // TYPO3 CMS 7 LTS
-                       return $this->getCompatibleAllowedWhereClause($theTable, $pid, $conf, $cmdKey, $bAllow);
-               }
-
                $pidArray = GeneralUtility::trimExplode(',', $conf['userGroupsPidList'], true);
                if (empty($pidArray)) {
-                       $pidArray = GeneralUtility::trimExplode(',', $pid, true);
+                       if (is_array($pid)) {
+                               $pidArray = $pid;
+                       } else {
+                               $pidArray = GeneralUtility::trimExplode(',', $pid, true);
+                       }
                }
                if (!empty($pidArray)) {
                        $pidArray = array_map('intval', $pidArray);
@@ -239,64 +233,6 @@ class UsergroupHooks
        }
 
        /**
-        * TYPO3 CMS 7 LTS
-        *
-        * Contruct a where clause to select the user groups that are allowed to be kept
-        *
-        * @return string the where clause
-        */
-       protected function getCompatibleAllowedWhereClause($theTable, $pid, array $conf, $cmdKey, $bAllow = true)
-       {
-               $whereClause = '';
-               $subgroupWhereClauseArray = array();
-               $pidArray = array();
-               $tmpArray = GeneralUtility::trimExplode(',', $conf['userGroupsPidList'], true);
-               if (count($tmpArray)) {
-                       foreach ($tmpArray as $value) {
-                               $valueIsInt = MathUtility::canBeInterpretedAsInteger($value);
-                               if ($valueIsInt) {
-                                       $pidArray[] = (int) $value;
-                               }
-                       }
-               }
-               if (count($pidArray) > 0) {
-                       $whereClause = ' pid IN (\'' . implode('\',\'', $pidArray) . '\') ';
-               } else {
-                       $whereClause = ' pid IN (\'' . implode('\',\'', GeneralUtility::trimExplode(',', $pid, true)) . '\') ';
-               }
-
-               $whereClausePart2 = '';
-               $whereClausePart2Array = array();
-
-               $allowedUserGroupArray = array();
-               $allowedSubgroupArray = array();
-               $deniedUserGroupArray = array();
-               $this->getAllowedValues($conf, $cmdKey, $allowedUserGroupArray, $allowedSubgroupArray, $deniedUserGroupArray);
-               if ($allowedUserGroupArray['0'] !== 'ALL') {
-                       $uidArray = $GLOBALS['TYPO3_DB']->fullQuoteArray($allowedUserGroupArray, $theTable);
-                       $subgroupWhereClauseArray[] = 'uid ' . ($bAllow ? 'IN' : 'NOT IN') . ' (' . implode(',', $uidArray) . ')';
-               }
-               if (count($allowedSubgroupArray)) {
-                       $subgroupArray = $GLOBALS['TYPO3_DB']->fullQuoteArray($allowedSubgroupArray, $theTable);
-                       $subgroupWhereClauseArray[] = 'subgroup ' . ($bAllow ? 'IN' : 'NOT IN') . ' (' . implode(',', $subgroupArray) . ')';
-               }
-               if (count($subgroupWhereClauseArray)) {
-                       $subgroupWhereClause .= implode(' ' . ($bAllow ? 'OR' : 'AND') . ' ', $subgroupWhereClauseArray);
-                       $whereClausePart2Array[] = '( ' . $subgroupWhereClause . ' )';
-               }
-               $deniedUserGroupArray = array_merge($deniedUserGroupArray, $this->getReservedValues($conf));
-               if (count($deniedUserGroupArray)) {
-                       $uidArray = $GLOBALS['TYPO3_DB']->fullQuoteArray($deniedUserGroupArray, $theTable);
-                       $whereClausePart2Array[] = 'uid ' . ($bAllow ? 'NOT IN' : 'IN') . ' (' . implode(',', $uidArray) . ')';
-               }
-               if (count($whereClausePart2Array)) {
-                       $whereClausePart2 = implode(' ' . ($bAllow ? 'AND' : 'OR') . ' ', $whereClausePart2Array);
-                       $whereClause .= ' AND (' . $whereClausePart2 . ')';
-               }
-               return $whereClause;
-       }
-
-       /**
         * Get the allowed values for user groups
         *
         * @param array $conf: the configuration array
index 6c4edd9..84ee795 100644 (file)
@@ -93,7 +93,7 @@ class Message
                                $subject = trim($parts[0]) ? trim($parts[0]) : $defaultSubject;
                                $PLAINContent = trim($parts[1]);
                        }
-                       $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
+                       $mail = GeneralUtility::makeInstance(MailMessage::class);
                        $mail->setSubject($subject);
                        $mail->setFrom(array($fromEmail => $fromName));
                        $mail->setSender($fromEmail);
index 5abb3e8..f1a7c8e 100644 (file)
@@ -5,7 +5,7 @@ namespace SJBR\SrFeuserRegister\Request;
  *  Copyright notice
  *
  *  (c) 2007-2012 Franz Holzinger <franz@ttproducts.de>
- *  (c) 2012-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2012-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -23,6 +23,8 @@ namespace SJBR\SrFeuserRegister\Request;
  *  This copyright notice MUST APPEAR in all copies of the script!
  */
 
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
 use SJBR\SrFeuserRegister\Security\Authentication;
 use SJBR\SrFeuserRegister\Security\SecuredData;
 use SJBR\SrFeuserRegister\Security\SessionData;
@@ -35,8 +37,10 @@ use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
 /**
  * Request parameters
  */
-class Parameters
+class Parameters implements LoggerAwareInterface
 {
+       use LoggerAwareTrait;
+
        /**
         * Extension key
         *
@@ -84,7 +88,7 @@ class Parameters
         *
         * @var array
         */
-       protected $feUserData = array();
+       protected $feUserData = [];
 
        /**
         * The regHash if available among GET parameters (after validation)
@@ -98,10 +102,10 @@ class Parameters
         *
         * @var array
         */
-       protected $setFixedVars = array();
+       protected $setFixedVars = [];
 
        /**
-        * The input command 
+        * The input command
         *
         * @var string
         */
@@ -119,7 +123,7 @@ class Parameters
         *
         * @var array
         */
-       protected $pid = array();
+       protected $pid = [];
 
        /**
         * Whether the token was found valid
@@ -238,7 +242,7 @@ class Parameters
         */
        protected function setPids()
        {
-               $pidTypeArray = array('login', 'register', 'edit', 'infomail', 'confirm', 'confirmInvitation');
+               $pidTypeArray = ['login', 'register', 'edit', 'infomail', 'confirm', 'confirmInvitation'];
                foreach ($pidTypeArray as $type) {
                        $this->setPid($type, $this->conf[$type . 'PID']);
                }
@@ -268,7 +272,7 @@ class Parameters
                                        $pid = $this->getPid('confirm');
                                        break;
                                default:
-                                       $pidArray = array();
+                                       $pidArray = [];
                                        $tmpArray = GeneralUtility::trimExplode(',', $this->conf['pid'], true);
                                        if (count($tmpArray)) {
                                                foreach ($tmpArray as $value) {
@@ -301,20 +305,20 @@ class Parameters
                }
                if (!$pid) {
                        $pids = [];
-                       if ($this->cObj->data['pages']) {
-                               $pids = explode(',', $this->cObj->data['pages']);
+                       if ($this->pibaseObj->cObj->data['pages']) {
+                               $pids = explode(',', $this->pibaseObj->cObj->data['pages']);
                        }
                        if (count($pids)) {
-                               $pid = $type ? $pids['0'] : $pids;
+                               $pid = $type ? $pids['0'] : implode(',', $pids);
                        }
                        if (empty($pid)) {
-                               $pidArray = array();
+                               $pidArray = [];
                                $tmpArray = GeneralUtility::trimExplode(',', $this->conf['pid'], true);
                                if (count($tmpArray)) {
                                        foreach ($tmpArray as $value) {
                                                $valueIsInt = MathUtility::canBeInterpretedAsInteger($value);
                                                if ($valueIsInt) {
-                                                       $pidArray[] = (int) $value;
+                                                       $pidArray[] = (int)$value;
                                                }
                                        }
                                }
@@ -333,10 +337,8 @@ class Parameters
         */
        protected function setPidTitle()
        {
-               $pidRecord = GeneralUtility::makeInstance(PageRepository::class);
-               $pidRecord->init(0);
-               $pidRecord->sys_language_uid = (int) $GLOBALS['TSFE']->config['config']['sys_language_uid'];
-               $row = $pidRecord->getPage((int) $this->getPid());
+               $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
+               $row = $pageRepository->getPage_noCheck((int)$this->getPid());
                $this->pidTitle = $this->conf['pidTitleOverride'] ?: $row['title'];
        }
 
@@ -368,8 +370,8 @@ class Parameters
                        $getHashVars = HashUtility::getParametersFromHash($this->feUserData['regHash']);
                        if (!empty($getHashVars) && is_array($getHashVars)) {
                                $this->setRegHash($this->feUserData['regHash']);
-                               $keepFieldArray = array('sFK', 'cmd', 'submit', 'fetch', 'regHash', 'preview');
-                               $keepFeuserData = array();
+                               $keepFieldArray = ['sFK', 'cmd', 'submit', 'fetch', 'regHash', 'preview'];
+                               $keepFeuserData = [];
                                // Copy the original values which must not be overridden by the regHash stored values
                                foreach ($keepFieldArray as $keepField) {
                                        if (isset($feUserData[$keepField])) {
@@ -378,7 +380,7 @@ class Parameters
                                }
                                // Restore former GET values from the url
                                foreach ($getHashVars as $k => $v) {
-                                       GeneralUtility::_GETset($v, $k);
+                                       $this->GETset($v, $k);
                                }
                                // Overlay the $this->feUserData with the hashed values if rU is the same in both
                                $hashedFeUserData = $getHashVars[$this->prefixId];
@@ -398,7 +400,7 @@ class Parameters
                        }
                }
                // Establishing compatibility with Direct Mail
-               $piVarArray = array('rU', 'aC', 'sFK');
+               $piVarArray = ['rU', 'aC', 'sFK'];
                foreach ($piVarArray as $pivar) {
                        $value = htmlspecialchars(GeneralUtility::_GP($pivar));
                        if (!empty($value)) {
@@ -416,7 +418,7 @@ class Parameters
         */
        protected function resetFeUserData()
        {
-               $this->feUserData = array();
+               $this->feUserData = [];
        }
 
        /**
@@ -569,7 +571,7 @@ class Parameters
                                        $codeLength = strlen($this->getAuthCode());
                                        $sFK = $this->getFeUserData('sFK');
                                        // Let's try with a code length of 8 in case this link is coming from direct mail
-                                       if ($codeLength === 8 && in_array($sFK, array('DELETE', 'EDIT', 'UNSUBSCRIBE'))) {
+                                       if ($codeLength === 8 && in_array($sFK, ['DELETE', 'EDIT', 'UNSUBSCRIBE'])) {
                                                $authCode = Authentication::setfixedHash($setFixedArray, $this->conf, $fieldList, $codeLength);
                                        } else {
                                                $authCode = Authentication::setfixedHash($setFixedArray, $this->conf, $fieldList);
@@ -583,7 +585,7 @@ class Parameters
                                        // aC parameter from URL does not match the hash calculated from the given user record data
                                        if ($token === '' && (!isset($this->setFixedVars) || !is_array($this->setFixedVars))) {
                                                $message = 'The submitted authcode does not match the one from the given user record, perhaps due to missing fD[_FIELDLIST] parameter.';
-                                               GeneralUtility::sysLog($message, $this->extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                                               $this->logger->error(GeneralUtility::underscoredToUpperCamelCase($this->extensionKey) . ': ' . $message);
                                        }
                                }
                        }
@@ -672,4 +674,40 @@ class Parameters
                        || ($this->conf['infomail'] && ($this->getCmd() === 'setfixed' || $this->getCmd() === 'infomail'))
                );
        }
+
+    /**
+     * Writes input value to $_GET.
+     *
+     * @param mixed $inputGet
+     * @param string $key
+     * @see TYPO3 v9 LTS TYPO3\CMS\Core\Utility\GeneralUtility.
+     */
+    protected function GETset($inputGet, $key = '')
+    {
+        if ($key != '') {
+            if (strpos($key, '|') !== false) {
+                $pieces = explode('|', $key);
+                $newGet = [];
+                $pointer = &$newGet;
+                foreach ($pieces as $piece) {
+                    $pointer = &$pointer[$piece];
+                }
+                $pointer = $inputGet;
+                $mergedGet = $_GET;
+                ArrayUtility::mergeRecursiveWithOverrule($mergedGet, $newGet);
+                $_GET = $mergedGet;
+                $GLOBALS['HTTP_GET_VARS'] = $mergedGet;
+            } else {
+                $_GET[$key] = $inputGet;
+                $GLOBALS['HTTP_GET_VARS'][$key] = $inputGet;
+            }
+        }
+        /*elseif (is_array($inputGet)) {
+            $_GET = $inputGet;
+            $GLOBALS['HTTP_GET_VARS'] = $inputGet;
+            if (isset($GLOBALS['TYPO3_REQUEST']) && $GLOBALS['TYPO3_REQUEST'] instanceof ServerRequestInterface) {
+                $GLOBALS['TYPO3_REQUEST'] = $GLOBALS['TYPO3_REQUEST']->withQueryParams($inputGet);
+            }
+        }*/
+    }
 }
\ No newline at end of file
index 5f5993e..ebf604e 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Security;
 /*
  *  Copyright notice
  *
- *  (c) 2015 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2015-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -35,7 +35,7 @@ class SecuredData
         *
         * @var array
         */
-       protected static $securedFields = array('password', 'password_again', 'tx_srfeuserregister_password');
+       protected static $securedFields = ['password', 'password_again', 'tx_srfeuserregister_password'];
 
        /**
         * Gets the array of names of secured fields
index 5f3a88a..78973b0 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Security;
 /*
  *  Copyright notice
  *
- *  (c) 2015-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2015-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -27,6 +27,7 @@ use SJBR\SrFeuserRegister\Security\StorageSecurity;
 use SJBR\SrFeuserRegister\Security\TransmissionSecurity;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 
 /**
  * Frontend user session data handling
@@ -42,8 +43,8 @@ class SessionData
         */
        protected static function readSessionData($extensionKey, $readAll = false)
        {
-               $sessionData = array();
-               $allSessionData = $GLOBALS['TSFE']->fe_user->getKey('ses', 'feuser');
+               $sessionData = [];
+               $allSessionData = static::getTypoScriptFrontendController()->fe_user->getKey('ses', 'feuser');
                if (isset($allSessionData) && is_array($allSessionData)) {
                        if ($readAll) {
                                $sessionData = $allSessionData;
@@ -88,12 +89,12 @@ class SessionData
                                }
                        }
                } else {
-                       $allSessionData[$extensionKey] = array();
+                       $allSessionData[$extensionKey] = [];
                }
                ArrayUtility::mergeRecursiveWithOverrule($allSessionData[$extensionKey], $data);
-               $GLOBALS['TSFE']->fe_user->setKey('ses', 'feuser', $allSessionData);
+               static::getTypoScriptFrontendController()->fe_user->setKey('ses', 'feuser', $allSessionData);
                // The feuser session data shall not get lost when coming back from external scripts
-               $GLOBALS['TSFE']->fe_user->storeSessionData($extensionKey);
+               static::getTypoScriptFrontendController()->fe_user->storeSessionData($extensionKey);
        }
 
        /**
@@ -105,7 +106,7 @@ class SessionData
         */
        public static function clearSessionData($keepRedirectUrl = true)
        {
-               $data = array();
+               $data = [];
                $keepToken  = true;
                self::writeSessionData($extensionKey, $data, $keepToken, $keepRedirectUrl);
        }
@@ -170,7 +171,7 @@ class SessionData
        {
                $redirectUrl = GeneralUtility::_GET('redirect_url');
                if ($redirectUrl != '') {
-                       $data = array();
+                       $data = [];
                        $data['redirect_url'] = $redirectUrl;
                        self::writeSessionData($extensionKey, $data);
                }
@@ -184,7 +185,7 @@ class SessionData
         */
        public static function readSecuredArray($extensionKey)
        {
-               $securedArray = array();
+               $securedArray = [];
                $sessionData = self::readSessionData($extensionKey);
                $fields = SecuredData::getSecuredFields();
                foreach ($fields as $securedField) {
@@ -271,4 +272,12 @@ class SessionData
                $dataArray['password_again'] = $generatedPassword;
                self::writePassword($extensionKey, $generatedPassword, $generatedPassword);
        }
+
+    /**
+     * @return TypoScriptFrontendController
+     */
+    protected static function getTypoScriptFrontendController()
+    {
+        return $GLOBALS['TSFE'];
+    }
 }
\ No newline at end of file
index a2feb61..5f91cae 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Security;
 /*
  *  Copyright notice
  *
- *  (c) 2012-2015 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2012-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -22,11 +22,12 @@ namespace SJBR\SrFeuserRegister\Security;
  *  This copyright notice MUST APPEAR in all copies of the script!
  */
 
+use Psr\Log\LoggerInterface;
 use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
+use TYPO3\CMS\Core\Log\LogManager;
+use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Rsaauth\Backend\BackendFactory;
-use TYPO3\CMS\Saltedpasswords\Salt\SaltFactory;
-use TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility;
 
 /**
  * Storage security functions
@@ -39,21 +40,6 @@ class StorageSecurity
        static protected $extensionName = 'SrFeuserRegister';
 
        /**
-        * @var string Extension key
-        */
-       static protected $extensionKey = 'sr_feuser_register';
-
-       /**
-        * Gets the storage security level
-        *
-        * @return string the storage security level
-        */
-       static protected function getStorageSecurityLevel()
-       {
-               return SaltedPasswordsUtility::isUsageEnabled('FE') ? 'salted' : 'normal';
-       }
-
-       /**
         * Encrypts the password for secure storage
         *
         * @param string $password: password to encrypt
@@ -63,21 +49,13 @@ class StorageSecurity
        {
                $encryptedPassword = $password;
                if ($password != '') {
-                       switch (self::getStorageSecurityLevel()) {
-                               case 'salted':
-                                       $objSalt = SaltFactory::getSaltingInstance(null);
-                                       if (is_object($objSalt)) {
-                                               $encryptedPassword = $objSalt->getHashedPassword($password);
-                                       } else {
-                                               $encryptedPassword = false;
-                                               // Could not get a salting instance from saltedpasswords
-                                               // Should not happen
-                                       }
-                                       break;
-                               case 'normal':
-                               default:
-                                       // No encryption!
-                                       break;
+                       $objSalt = PasswordHashFactory::getDefaultHashInstance('FE');
+                       if (is_object($objSalt)) {
+                               $encryptedPassword = $objSalt->getHashedPassword($password);
+                       } else {
+                               $encryptedPassword = false;
+                               // Could not get a salting instance
+                               // Should not happen
                        }
                }
                return $encryptedPassword;
@@ -160,7 +138,7 @@ class StorageSecurity
                                                } else {
                                                        // Failed to decrypt auto login password
                                                        $message = LocalizationUtility::translate('internal_decrypt_auto_login_failed', self::$extensionName);
-                                                       GeneralUtility::sysLog($message, self::$extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                                                       static::getLogger()->error(self::$extensionName . ': ' . $message);
                                                }
                                        } else {
                                                // Required RSA auth backend not available
@@ -170,4 +148,12 @@ class StorageSecurity
                        }
                }
        }
+
+    /**
+     * @return LoggerInterface
+     */
+    protected static function getLogger()
+    {
+        return GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
+    }
 }
\ No newline at end of file
index f4ba723..4e859d1 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Security;
 /*
  *  Copyright notice
  *
- *  (c) 2012-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2012-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -22,7 +22,9 @@ namespace SJBR\SrFeuserRegister\Security;
  *  This copyright notice MUST APPEAR in all copies of the script!
  */
 
+use Psr\Log\LoggerInterface;
 use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
+use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Rsaauth\Backend\BackendFactory;
@@ -42,13 +44,6 @@ class TransmissionSecurity
        static protected $extensionName = 'SrFeuserRegister';
 
        /**
-        * Extension key
-        *
-        * @var string
-        */
-       static protected $extensionKey = 'sr_feuser_register';
-
-       /**
         * Gets the transmission security level
         *
         * @return string the transmission security level
@@ -91,7 +86,7 @@ class TransmissionSecurity
                                                                                        // May happen if the key is wrong
                                                                                        $success = false;
                                                                                        $message = LocalizationUtility::translate('internal_rsaauth_process_incoming_password_failed', self::$extensionName);
-                                                                                       GeneralUtility::sysLog($message, self::$extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                                                                                       static::getLogger()->error(self::$extensionName . ': ' . $message);
                                                                                }
                                                                        }
                                                                }
@@ -103,14 +98,14 @@ class TransmissionSecurity
                                                        // May happen if the key was already removed
                                                        $success = false;
                                                        $message = LocalizationUtility::translate('internal_rsaauth_retrieve_private_key_failed', self::$extensionName);
-                                                       GeneralUtility::sysLog($message, self::$extensionKey, GeneralUtility::SYSLOG_SEVERITY_WARNING);
+                                                       static::getLogger()->warning(self::$extensionName . ': ' . $message);
                                                }
                                        } else {
                                                // Required RSA auth backend not available
                                                // Should not happen
                                                $success = false;
                                                $message = LocalizationUtility::translate('internal_rsaauth_backend_not_available', self::$extensionName);
-                                               GeneralUtility::sysLog($message, self::$extensionKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                                               static::getLogger()->error(self::$extensionName . ': ' . $message);
                                        }
                                        break;
                                case 'normal':
@@ -169,4 +164,12 @@ class TransmissionSecurity
                }
                return $result;
        }
+
+    /**
+     * @return LoggerInterface
+     */
+    protected static function getLogger()
+    {
+        return GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
+    }
 }
\ No newline at end of file
diff --git a/Classes/Utility/DataUtility.php b/Classes/Utility/DataUtility.php
new file mode 100644 (file)
index 0000000..3e4d713
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+namespace SJBR\SrFeuserRegister\Utility;
+
+/*
+ *  Copyright notice
+ *
+ *  (c) 2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ */
+
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Data access utility
+ */
+class DataUtility
+{
+    /**
+     * Selects records based on matching a field (ei. other than UID) with a value
+     *
+     * @param string $theTable The table name to search, eg. "pages" or "tt_content
+     * @param string $theField The fieldname to match, eg. "uid" or "alias
+     * @param string $theValue The value that fieldname must match, eg. "123" or "frontpage
+     * @param string $whereClause Optional additional WHERE clauses put in the end of the query. DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
+     * @param string $groupBy Optional GROUP BY field(s). If none, supply blank string.
+     * @param string $orderBy Optional ORDER BY field(s). If none, supply blank string.
+     * @param string $limit Optional LIMIT value ([begin,]max). If none, supply blank string.
+     * @return mixed Returns array (the record) if found, otherwise nothing (void)
+     * @see since TYPO3 9 TYPO3\CMS\Frontend\Page\PageRepository
+     */
+    public static function getRecordsByField($theTable, $theField, $theValue, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '')
+    {
+        if (is_array($GLOBALS['TCA'][$theTable])) {
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($theTable);
+            $queryBuilder->getRestrictions()
+                ->removeAll()
+                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+
+            $queryBuilder->select('*')
+                ->from($theTable)
+                ->where($queryBuilder->expr()->eq($theField, $queryBuilder->createNamedParameter($theValue)));
+
+            if ($whereClause !== '') {
+                $queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($whereClause));
+            }
+
+            if ($groupBy !== '') {
+                $queryBuilder->groupBy(QueryHelper::parseGroupBy($groupBy));
+            }
+
+            if ($orderBy !== '') {
+                foreach (QueryHelper::parseOrderBy($orderBy) as $orderPair) {
+                    list($fieldName, $order) = $orderPair;
+                    $queryBuilder->addOrderBy($fieldName, $order);
+                }
+            }
+
+            if ($limit !== '') {
+                if (strpos($limit, ',')) {
+                    $limitOffsetAndMax = GeneralUtility::intExplode(',', $limit);
+                    $queryBuilder->setFirstResult((int)$limitOffsetAndMax[0]);
+                    $queryBuilder->setMaxResults((int)$limitOffsetAndMax[1]);
+                } else {
+                    $queryBuilder->setMaxResults((int)$limit);
+                }
+            }
+
+            $rows = $queryBuilder->execute()->fetchAll();
+
+            if (!empty($rows)) {
+                return $rows;
+            }
+        }
+        return null;
+    }
+}
\ No newline at end of file
index 98f9083..a01f3ed 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Utility;
 /*
  *  Copyright notice
  *
- *  (c) 2015-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2015-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -22,6 +22,7 @@ namespace SJBR\SrFeuserRegister\Utility;
  *  This copyright notice MUST APPEAR in all copies of the script!
  */
 
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Page\CacheHashCalculator;
 
@@ -43,39 +44,29 @@ class HashUtility
                $hash = $cacheHash->calculateCacheHash($parameterArray);
                $hash = substr($hash, 0, 20);
                // and store it with a serialized version of the array in the DB
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
-                       $queryBuilder = $connectionPool->getQueryBuilderForTable('cache_md5params');
-                       $queryBuilder->getRestrictions()->removeAll();
-                       $count = $queryBuilder
-                               ->count('md5hash')
-                               ->from('cache_md5params')
-                               ->where(
-                                       $queryBuilder->expr()->eq('md5hash', $queryBuilder->createNamedParameter($hash,\PDO::PARAM_STR))
-                               )
-                               ->execute()
-                               ->fetchColumn(0);
-                       if (!$count) {
-                               $connectionPool
-                                       ->getConnectionForTable('cache_md5params')
-                                       ->insert(
-                                               'cache_md5params',
-                                               [
-                                                       'md5hash' => $hash,
-                                                       'tstamp' => time(),
-                                                       'type' => 99,
-                                                       'params' => serialize($parameterArray)
-                                               ]
-                                       );
-                       }
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('md5hash', 'cache_md5params', 'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_md5params'));
-                       if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
-                               $insertFields = array('md5hash' => $hash, 'tstamp' => time(), 'type' => 99, 'params' => serialize($parameterArray));
-                               $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields);
-                       }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
+               $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
+               $queryBuilder = $connectionPool->getQueryBuilderForTable('cache_md5params');
+               $queryBuilder->getRestrictions()->removeAll();
+               $count = $queryBuilder
+                       ->count('md5hash')
+                       ->from('cache_md5params')
+                       ->where(
+                               $queryBuilder->expr()->eq('md5hash', $queryBuilder->createNamedParameter($hash,\PDO::PARAM_STR))
+                       )
+                       ->execute()
+                       ->fetchColumn(0);
+               if (!$count) {
+                       $connectionPool
+                               ->getConnectionForTable('cache_md5params')
+                               ->insert(
+                                       'cache_md5params',
+                                       [
+                                               'md5hash' => $hash,
+                                               'tstamp' => time(),
+                                               'type' => 99,
+                                               'params' => serialize($parameterArray)
+                                       ]
+                               );
                }
                return $hash;
        }
@@ -90,35 +81,26 @@ class HashUtility
        {
                // Get the serialised array from the DB based on the passed hash value
                $variables = [];
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                               ->getQueryBuilderForTable('cache_md5params');
-                       $queryBuilder->getRestrictions()->removeAll();
-                       $query = $queryBuilder
-                               ->select('params')
-                               ->from('cache_md5params')
-                               ->where(
-                                       $queryBuilder->expr()->eq('md5hash', $queryBuilder->createNamedParameter($hash, \PDO::PARAM_STR)),
-                                       $queryBuilder->expr()->eq('type', $queryBuilder->createNamedParameter(99, \PDO::PARAM_INT))
-                               )
-                               ->execute();
-                       while ($row = $query->fetch()) {
-                               $variables = unserialize($row['params']);
-                       }                       
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_md5params'));
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               $variables = unserialize($row['params']);
-                       }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
+               $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                       ->getQueryBuilderForTable('cache_md5params');
+               $queryBuilder->getRestrictions()->removeAll();
+               $query = $queryBuilder
+                       ->select('params')
+                       ->from('cache_md5params')
+                       ->where(
+                               $queryBuilder->expr()->eq('md5hash', $queryBuilder->createNamedParameter($hash, \PDO::PARAM_STR)),
+                               $queryBuilder->expr()->eq('type', $queryBuilder->createNamedParameter(99, \PDO::PARAM_INT))
+                       )
+                       ->execute();
+               while ($row = $query->fetch()) {
+                       $variables = unserialize($row['params']);
                }
                // Convert the array to one that will be properly incorporated into the GET global array
-               $parameterArray = array();
+               $parameterArray = [];
                foreach ($variables as $key => $value) {
                        $value = str_replace('%2C', ',', $value);
-                       $search = array('[%5D]', '[%5B]');
-                       $replace = array('\']', '\'][\'');
+                       $search = ['[%5D]', '[%5B]'];
+                       $replace = ['\']', '\'][\''];
                        $newkey = "['" . preg_replace($search, $replace, $key);
                        if (!preg_match('/' . preg_quote(']') . '$/', $newkey)){
                                $newkey .= "']";
@@ -137,20 +119,15 @@ class HashUtility
        public static function deleteHash($hash)
        {
                if (!empty($hash)) {
-                       if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                               GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                                       ->getConnectionForTable('cache_md5params')
-                                       ->delete(
-                                               'cache_md5params',
-                                               [
-                                                       'md5hash' => $hash,
-                                                       'type' => 99
-                                               ]
-                                       );
-                       } else {
-                               // TYPO3 CMS 7 LTS
-                               $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_md5params', 'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_md5params'));
-                       }
+                       GeneralUtility::makeInstance(ConnectionPool::class)
+                               ->getConnectionForTable('cache_md5params')
+                               ->delete(
+                                       'cache_md5params',
+                                       [
+                                               'md5hash' => $hash,
+                                               'type' => 99
+                                       ]
+                               );
                }
        }
 
@@ -164,19 +141,14 @@ class HashUtility
        {
                $shortUrlLife = (int)$conf['shortUrlLife'] ? (int)$conf['shortUrlLife'] : 30;
                $max_life = time() - (86400 * $shortUrlLife);
-               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                               ->getQueryBuilderForTable('cache_md5params');
-                       $queryBuilder
-                               ->delete('cache_md5params')
-                               ->where(
-                                       $queryBuilder->expr()->eq('type', $queryBuilder->createNamedParameter(99, \PDO::PARAM_INT)),
-                                       $queryBuilder->expr()->lt('tstamp', $queryBuilder->createNamedParameter($max_life, \PDO::PARAM_INT))
-                               )
-                               ->execute();
-               } else {
-                       // TYPO3 CMS 7 LTS
-                       $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_md5params', 'tstamp<' . $max_life . ' AND type=99');
-               }
+               $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                       ->getQueryBuilderForTable('cache_md5params');
+               $queryBuilder
+                       ->delete('cache_md5params')
+                       ->where(
+                               $queryBuilder->expr()->eq('type', $queryBuilder->createNamedParameter(99, \PDO::PARAM_INT)),
+                               $queryBuilder->expr()->lt('tstamp', $queryBuilder->createNamedParameter($max_life, \PDO::PARAM_INT))
+                       )
+                       ->execute();
        }
 }
\ No newline at end of file
index 9ad8df1..847e74f 100644 (file)
@@ -34,7 +34,7 @@ class LocalizationUtility
        /**
         * @var array List of allowed suffixes
         */
-       static protected $allowedSuffixes = array('formal', 'informal');
+       static protected $allowedSuffixes = ['formal', 'informal'];
 
        /**
         * @var string Configured suffix
@@ -42,7 +42,7 @@ class LocalizationUtility
        static protected $suffix = null;
 
        /**
-        * @var ConfigurationManager
+        * @var ConfigurationManagerInterface
         */
        static protected $configurationManager = null;
 
@@ -94,7 +94,8 @@ class LocalizationUtility
         *
         * @return ConfigurationManager
         */
-       static protected function getConfigurationManager() {
+       static protected function getConfigurationManager()
+       {
                if (!is_null(static::$configurationManager)) {
                        return static::$configurationManager;
                }
index b014ed1..823c7bf 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\Utility;
 /*
  *  Copyright notice
  *
- *  (c) 2007-2015 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2007-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -129,7 +129,7 @@ class UrlUtility
        static protected function initializeUrlUtility()
        {
                if (self::$cObj === null) {
-                       self::$cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
+                       self::$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
                }
        }
 
@@ -140,7 +140,7 @@ class UrlUtility
         */
        static public function getSiteUrl()
        {
-               $siteUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
+               $siteUrl = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
                if ($GLOBALS['TSFE']->absRefPrefix) {
                        if(strpos($GLOBALS['TSFE']->absRefPrefix, 'http://') === 0 || strpos($GLOBALS['TSFE']->absRefPrefix, 'https://') === 0) {
                                $siteUrl = $GLOBALS['TSFE']->absRefPrefix;
index b309466..f180e72 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\View;
 /*
  *  Copyright notice
  *
- *  (c) 2007-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2007-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -27,6 +27,7 @@ use SJBR\SrFeuserRegister\Request\Parameters;
 use SJBR\SrFeuserRegister\View\Marker;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
 
 /**
  * Display functions
@@ -157,7 +158,7 @@ abstract class AbstractView
        /*]]>*/
 </script>
 ';
-               $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename(ExtensionManagementUtility::siteRelPath('sr_feuser_register')  . 'Resources/Public/JavaScript/jsfunc.updateform.js') . '"></script>';
+               $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename(PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath('sr_feuser_register'))  . 'Resources/Public/JavaScript/jsfunc.updateform.js') . '"></script>';
                return $JSPart;
        }
 
index c1dfbd3..d2b47c9 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\View;
 /*
  *  Copyright notice
  *
- *  (c) 2007-2015 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2007-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -28,6 +28,7 @@ use SJBR\SrFeuserRegister\Utility\CssUtility;
 use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
 use SJBR\SrFeuserRegister\View\AbstractView;
 use SJBR\SrFeuserRegister\View\Marker;
+use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -42,6 +43,7 @@ class CreateView extends AbstractView
         */
        public function render(array $dataArray, array $origArray, array $securedArray, $cmd, $cmdKey, $mode) {
                $content = '';
+
                $currentArray = $origArray;
                if (isset($dataArray) && is_array($dataArray)) {
                        foreach ($dataArray as $key => $value) {
@@ -78,7 +80,7 @@ class CreateView extends AbstractView
                                $this->marker->addPasswordTransmissionMarkers($this->getUsePassword(), $this->getUsePasswordAgain());
                        } else {
                                $bNeedUpdateJS = false;
-                               if ($GLOBALS['TSFE']->loginUser) {
+                               if (GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('frontend.user', 'isLoggedIn')) {
                                        $subpartMarker = '###TEMPLATE_CREATE_LOGIN###';
                                } else {
                                        $subpartMarker = '###TEMPLATE_AUTH###';
index e66208f..a1571d0 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\View;
 /*
  *  Copyright notice
  *
- *  (c) 2007-2015 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2007-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -25,6 +25,8 @@ namespace SJBR\SrFeuserRegister\View;
 use SJBR\SrFeuserRegister\Security\Authentication;
 use SJBR\SrFeuserRegister\Utility\UrlUtility;
 use SJBR\SrFeuserRegister\View\PlainView;
+use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Delete view rendering
@@ -40,9 +42,10 @@ class DeleteView extends PlainView
        public function render($subpartMarker, array $dataArray, array $origArray, array $securedArray, $cmd, $cmdKey)
        {
                $aCAuth = Authentication::aCAuth($this->parameters->getAuthCode(), $origArray, $this->conf, $this->conf['setfixed.']['DELETE.']['_FIELDLIST']);
-               if (($this->theTable === 'fe_users' && $GLOBALS['TSFE']->loginUser) || $aCAuth) {
+               $userAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user');
+               if (($this->theTable === 'fe_users' && $userAspect->get('isLoggedIn')) || $aCAuth) {
                        // Must be logged in OR be authenticated by the aC code in order to delete
-                       $bMayEdit = $this->data->DBmayFEUserEdit($this->theTable, $origArray, $GLOBALS['TSFE']->fe_user->user, $this->conf['allowedGroups'], $this->conf['fe_userEditSelf']);
+                       $bMayEdit = $this->data->DBmayFEUserEdit($this->theTable, $origArray, ['uid' => $userAspect->get('id'), 'usergroup' => $userAspect->get('groupIds')], $this->conf['allowedGroups'], $this->conf['fe_userEditSelf']);
                        if ($aCAuth || $bMayEdit) {
                                // Display the form, if access granted.
                                $backUrl = $this->parameters->getBackURL() ?: UrlUtility::getTypoLink_URL($this->parameters->getPid('login') . ',' . $GLOBALS['TSFE']->type);
index 8602136..3b77768 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\View;
 /*
  *  Copyright notice
  *
- *  (c) 2007-2015 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2007-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
index 3ddb07d..2f0cf75 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\SrFeuserRegister\View;
 /*
  *  Copyright notice
  *
- *  (c) 2007-2017 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  (c) 2007-2018 Stanislas Rolland <typo3(arobas)sjbr.ca>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -33,6 +33,7 @@ use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
 use SJBR\SrFeuserRegister\View\Marker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Frontend\Resource\FilePathSanitizer;
 
 /**
  * Email functions
@@ -160,7 +161,7 @@ class Email
                $cmd,
                $cmdKey
        ) {
-               $missingSubpartArray = array();
+               $missingSubpartArray = [];
                $userSubpartsFound = 0;
                $adminSubpartsFound = 0;
                $bHTMLMailEnabled = $this->isHTMLMailEnabled();
@@ -179,14 +180,14 @@ class Email
 
                $viewOnly = true;
                $requiredFields = $this->data->getRequiredFieldsArray($cmdKey);
-               $content = array('user' => array(), 'userhtml' => array(), 'admin' => array(), 'adminhtml' => array(), 'mail' => array());
+               $content = ['user' => [], 'userhtml' => [], 'admin' => [], 'adminhtml' => [], 'mail' => []];
                $content['mail'] = '';
                $content['user']['all'] = '';
                $content['userhtml']['all'] = '';
                $content['admin']['all'] = '';
                $content['adminhtml']['all'] = '';
-               $setfixedArray = array('SETFIXED_CREATE', 'SETFIXED_CREATE_REVIEW', 'SETFIXED_INVITE', 'SETFIXED_REVIEW');
-               $infomailArray = array('INFOMAIL', 'INFOMAIL_NORECORD');
+               $setfixedArray = ['SETFIXED_CREATE', 'SETFIXED_CREATE_REVIEW', 'SETFIXED_INVITE', 'SETFIXED_REVIEW'];
+               $infomailArray = ['INFOMAIL', 'INFOMAIL_NORECORD'];
                if (
                        (isset($this->conf['email.'][$key]) && $this->conf['email.'][$key] != '0') ||
                        ($this->conf['enableEmailConfirmation'] && in_array($key, $setfixedArray)) ||
@@ -241,9 +242,9 @@ class Email
                        }
                }
 
-               $contentIndexArray = array();
-               $contentIndexArray['text'] = array();
-               $contentIndexArray['html'] = array();
+               $contentIndexArray = [];
+               $contentIndexArray['text'] = [];
+               $contentIndexArray['html'] = [];
 
                if ($content['user']['all']) {
                        $content['user']['rec'] = $this->marker->getSubpart($content['user']['all'], '###SUB_RECORD###');
@@ -262,7 +263,7 @@ class Email
                        $contentIndexArray['html'][] = 'adminhtml';
                }
                $changesOnly = (($this->conf['email.']['EDIT_SAVED'] == '2' || $this->conf['notify.']['EDIT_SAVED'] == '2') && $cmd == 'edit');
-               $keepFields = $changesOnly ? array('uid', 'pid', 'tstamp', 'name', 'username') : array();
+               $keepFields = $changesOnly ? ['uid', 'pid', 'tstamp', 'name', 'username'] : [];
                $this->marker->fillInMarkerArray($DBrows[0], $securedArray, '', false);
                $this->marker->addLabelMarkers($DBrows[0], $origRows[0], $securedArray, $keepFields, $requiredFields, $this->data->getFieldList(), $this->data->getSpecialFieldList(), $changesOnly);
                $content['user']['all'] = $this->marker->substituteMarkerArray($content['user']['all'], $this->marker->getMarkerArray());
@@ -283,7 +284,7 @@ class Email
                        }
                        $mrow = $currentRow;
                        if ($changesOnly) {
-                               $mrow = array();
+                               $mrow = [];
                                foreach ($currentRow as $theField => $v) {
                                        if (in_array($theField, $keepFields)) {
                                                $mrow[$theField] = $v;
@@ -381,7 +382,8 @@ class Email
                        && $this->conf['addAttachment.']['cmd'] === $cmd
                        && $this->conf['addAttachment.']['sFK'] === $this->parameters->getFeUserData('sFK')
                ) {
-                       $file = ($this->conf['addAttachment.']['file'] ? $GLOBALS['TSFE']->tmpl->getFileName($this->conf['addAttachment.']['file']) : '');
+                       $filePathSanitizer = GeneralUtility::makeInstance(FilePathSanitizer::class);
+                       $file = $this->conf['addAttachment.']['file'] ? $filePathSanitizer->sanitize($this->conf['addAttachment.']['file']) : '';
                }
                // SETFIXED_REVIEW will be sent to user only if the admin part is present
                if (($userSubpartsFound + $adminSubpartsFound >= 1) && ($adminSubpartsFound >= 1 || $key !== 'SETFIXED_REVIEW')) {
index cc85007..bc1d9b9 100644 (file)
@@ -33,11 +33,16 @@ use SJBR\SrFeuserRegister\Utility\LocalizationUtility;
 use SJBR\SrFeuserRegister\Utility\UrlUtility;
 use SJBR\SrFeuserRegister\View\AbstractView;
 use SJBR\StaticInfoTables\PiBaseApi;
+use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
+use TYPO3\CMS\Frontend\Resource\FilePathSanitizer;
 
 /**
  * Marker functions
@@ -148,19 +153,19 @@ class Marker
         *
         * @var array
         */
-       protected $markerArray = array();
+       protected $markerArray = [];
 
        /**
         * Url marker array
         *
         * @var array
         */
-       protected $urlMarkerArray = array();
+       protected $urlMarkerArray = [];
 
        /**
         * Marker-based template service
         *
-        * @var \TYPO3\CMS\Core\Service\MarkerBasedTemplateService
+        * @var MarkerBasedTemplateService
         */
        protected $markerBasedTemplateService = null;
 
@@ -203,9 +208,7 @@ class Marker
                // Static Info object
                if (ExtensionManagementUtility::isLoaded('static_info_tables')) {
                        $this->staticInfoObj = GeneralUtility::makeInstance(PiBaseApi::class);
-                       if ($this->staticInfoObj->needsInit()) {
-                               $this->staticInfoObj->init();
-                       }
+                       $this->staticInfoObj->init();
                }
                // Marker-based service
                $this->markerBasedTemplateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
@@ -316,7 +319,12 @@ class Marker
        public function getTemplateCode()
        {
                if (empty($this->templateCode)) {
-                       $this->templateCode = $this->cObj->fileResource($this->conf['templateFile']);
+                       $filePathSanitizer = GeneralUtility::makeInstance(FilePathSanitizer::class);
+                       $templateFile = $filePathSanitizer->sanitize($this->conf['templateFile']);
+                       $this->templateCode = '';
+                       if ($templateFile && file_exists($templateFile)) {
+                               $this->templateCode = file_get_contents($templateFile);
+                       }
                }
                return $this->templateCode;
        }
@@ -449,7 +457,7 @@ class Marker
 
                // Data field labels
                $infoFieldArray = GeneralUtility::trimExplode(',', $infoFields, true);
-               $charset = $GLOBALS['TSFE']->renderCharset ?: 'utf-8';
+               $charset = $GLOBALS['TSFE']->metaCharset;
                $specialFieldArray = GeneralUtility::trimExplode(',', $specialFieldList, true);
                $infoFieldArray = array_merge($infoFieldArray, $specialFieldArray);
                $requiredArray = array_merge($requiredArray, $specialFieldArray);
@@ -556,7 +564,7 @@ class Marker
                        $name = $row['first_name'];
                } else {
                        // Honour Address List (tt_address) configuration settings
-                       if ($this->theTable === 'tt_address' && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('tt_address')) {
+                       if ($this->theTable === 'tt_address' && ExtensionManagementUtility::isLoaded('tt_address')) {
                                $settings = \TYPO3\TtAddress\Utility\SettingsUtility::getSettings();
                                $nameFormat = '';
                                if ($settings->isStoreBackwardsCompatName() && !empty($row['name'])) {
@@ -687,7 +695,8 @@ class Marker
                if ($this->conf['terms.']['url']) {
                        $termsUrlParam = $this->conf['terms.']['url'];
                } else {
-                       $termsUrlParam = ($this->conf['terms.']['file'] ? $GLOBALS['TSFE']->tmpl->getFileName($this->conf['terms.']['file']) : '');
+                       $filePathSanitizer = GeneralUtility::makeInstance(FilePathSanitizer::class);
+                       $termsUrlParam = ($this->conf['terms.']['file'] ? $filePathSanitizer->sanitize($this->conf['terms.']['file']) : '');
                }
                $markerArray['###TERMS_URL###'] = UrlUtility::get($this->prefixId, '', $termsUrlParam, array(), array(), false);
 
@@ -1251,8 +1260,13 @@ class Marker
                $markerArray = $this->getMarkerArray();
                $markerArray['###CSS_STYLES###'] = '    /*<![CDATA[*/
 ';
-               $fileResource = $this->cObj->fileResource($this->conf['email.']['HTMLMailCSS']);
-               $markerArray['###CSS_STYLES###'] .= $fileResource;
+               $filePathSanitizer = GeneralUtility::makeInstance(FilePathSanitizer::class);
+               $file = $filePathSanitizer->sanitize($this->conf['email.']['HTMLMailCSS']);
+               $fileContent = '';
+               if ($file && file_exists($file)) {
+                       $fileContent = file_get_contents($file);
+               }
+               $markerArray['###CSS_STYLES###'] .= $fileContent;
                $markerArray['###CSS_STYLES###'] .= '
 /*]]>*/';
                $this->setMarkerArray($markerArray);
@@ -1284,9 +1298,8 @@ class Marker
                $HSC = true
        ) {
                $markerArray = $this->getMarkerArray();
-               $charset = $GLOBALS['TSFE']->renderCharset ? $GLOBALS['TSFE']->renderCharset : 'utf-8';
-               $languageUid = (int) $GLOBALS['TSFE']->config['config']['sys_language_uid'];
-
+               $charset = $GLOBALS['TSFE']->metaCharset;
+               $languageUid = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id');
                if ($bChangesOnly && is_array($origRow)) {
                        $mrow = array();
                        foreach ($origRow as $k => $v) {
@@ -1411,7 +1424,7 @@ class Marker
                                                                if ($mrow[$colName] !== '') {
                                                                        $valuesArray = is_array($mrow[$colName]) ? $mrow[$colName] : explode(',', $mrow[$colName]);
                                                                        if ($colConfig['itemsProcFunc']) {
-                                                                               $itemArray = GeneralUtility::callUserFunction($colConfig['itemsProcFunc'], $colConfig, $this, '');
+                                                                               $itemArray = GeneralUtility::callUserFunction($colConfig['itemsProcFunc'], $colConfig, $this);
                                                                        }
                                                                        $itemArray = $colConfig['items'];
                                                                        if (is_array($itemArray)) {
@@ -1436,7 +1449,7 @@ class Marker
                                                                if ($mrow[$colName] != '') {
                                                                        $valuesArray = is_array($mrow[$colName]) ? $mrow[$colName] : explode(',', $mrow[$colName]);
                                                                        if ($colConfig['itemsProcFunc']) {
-                                                                               $itemArray = GeneralUtility::callUserFunction($colConfig['itemsProcFunc'], $colConfig, $this, '');
+                                                                               $itemArray = GeneralUtility::callUserFunction($colConfig['itemsProcFunc'], $colConfig, $this);
                                                                        }
                                                                        $itemArray = $colConfig['items'];
                                                                        if (!$bStdWrap) {
@@ -1462,30 +1475,22 @@ class Marker
                                                                                $firstValue = current($valuesArray);
                                                                                if (!empty($firstValue) || count($valuesArray) > 1) {
                                                                                        $titleField = $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['label'];
-                                                                                       if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                                                                               $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                                                                                                       ->getQueryBuilderForTable($colConfig['foreign_table']);
-                                                                                               $queryBuilder
-                                                                                                       ->getRestrictions()
-                                                                                                       ->removeAll();
-                                                                                               $foreignRows = $queryBuilder
-                                                                                                       ->select('*')
-                                                                                                       ->from($colConfig['foreign_table'])
-                                                                                                       ->where(
-                                                                                                               $queryBuilder->expr()->in('uid', array_map('intval', $valuesArray))
-                                                                                                       )
-                                                                                                       ->execute()
-                                                                                                       ->fetchAll();
-                                                                                       } else {
-                                                                                               // TYPO3 CMS 7 LTS
-                                                                                               $where = 'uid IN (' . implode(',', $valuesArray) . ')';
-                                                                                               $foreignRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $colConfig['foreign_table'], $where);
-                                                                                       }
+                                                                                       $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                                                                                               ->getQueryBuilderForTable($colConfig['foreign_table']);
+                                                                                       $queryBuilder
+                                                                                               ->getRestrictions()
+                                                                                               ->removeAll();
+                                                                                       $foreignRows = $queryBuilder
+                                                                                               ->select('*')
+                                                                                               ->from($colConfig['foreign_table'])
+                                                                                               ->where(
+                                                                                                       $queryBuilder->expr()->in('uid', array_map('intval', $valuesArray))
+                                                                                               )
+                                                                                               ->execute()
+                                                                                               ->fetchAll();
                                                                                        if (is_array($foreignRows) && count($foreignRows) > 0) {
                                                                                                for ($i = 0; $i < count($foreignRows); $i++) {
-                                                                                                       if ($this->theTable === 'fe_users' && $colName === 'usergroup') {
-                                                                                                               $foreignRows[$i] = $this->getUsergroupOverlay($foreignRows[$i]);
-                                                                                                       } else if ($localizedRow = $GLOBALS['TSFE']->sys_page->getRecordOverlay($colConfig['foreign_table'], $foreignRows[$i], $languageUid)) {
+                                                                                                       if ($localizedRow = $GLOBALS['TSFE']->sys_page->getRecordOverlay($colConfig['foreign_table'], $foreignRows[$i], $languageUid)) {
                                                                                                                $foreignRows[$i] = $localizedRow;
                                                                                                        }
                                                                                                        $text = $foreignRows[$i][$titleField];
@@ -1517,7 +1522,7 @@ class Marker
                                                                        $valuesArray[] = $colConfig['default'];
                                                                }
                                                                if (in_array($type, array('radio', 'select')) && $colConfig['itemsProcFunc']) {
-                                                                       $itemArray = GeneralUtility::callUserFunction($colConfig['itemsProcFunc'], $colConfig, $this, '');
+                                                                       $itemArray = GeneralUtility::callUserFunction($colConfig['itemsProcFunc'], $colConfig, $this);
                                                                }
                                                                $itemArray = $colConfig['items'];
                                                }
@@ -1664,92 +1669,58 @@ class Marker
 
                                                                if ($colConfig['foreign_table'] && isset($GLOBALS['TCA'][$colConfig['foreign_table']])) {
                                                                        $titleField = $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['label'];
-                                                                       $reservedValues = array();
-                                                                       if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                                                               $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                                                                                       ->getQueryBuilderForTable($colConfig['foreign_table'])
-                                                                                       ->select('*')
-                                                                                       ->from($colConfig['foreign_table']);
-                                                                               $queryBuilder->setRestrictions(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer::class));
-                                                                               if ($colName === 'usergroup' && is_object($this->userGroupObj)) {
-                                                                                       $reservedValues = $this->userGroupObj->getReservedValues($this->conf);
-                                                                                       $this->userGroupObj->getAllowedWhereClause($colConfig['foreign_table'], $this->parameters->getPid(), $this->conf, $cmdKey, true, $queryBuilder);
-                                                                               }
-                                                                               if (
-                                                                                       $this->conf['useLocalization']
-                                                                                       && $GLOBALS['TCA'][$colConfig['foreign_table']]
-                                                                                       && $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['languageField']
-                                                                                       && $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['transOrigPointerField']
-                                                                               ) {
-                                                                                       if (empty($queryBuilder->getQueryPart('where'))) {
-                                                                                               $queryBuilder->where($queryBuilder->expr()->eq($GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)));
-                                                                                       } else {
-                                                                                               $queryBuilder->andWhere($queryBuilder->expr()->eq($GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)));
-                                                                                       }
-                                                                               }
-                                                                               if (
-                                                                                       $colName === 'module_sys_dmail_category'
-                                                                                       && $colConfig['foreign_table'] === 'sys_dmail_category'
-                                                                                       && $this->conf['module_sys_dmail_category_PIDLIST']
-                                                                               ) {
-                                                                                       $pidArray = array_map('intval', GeneralUtility::trimExplode(',', $this->conf['module_sys_dmail_category_PIDLIST']));
-                                                                                       if (empty($queryBuilder->getQueryPart('where'))) {
-                                                                                               $queryBuilder->where($queryBuilder->expr()->in('sys_dmail_category.pid', $pidArray));
-                                                                                       } else {
-                                                                                               $queryBuilder->andWhere($queryBuilder->expr()->in('sys_dmail_category.pid', $pidArray));
-                                                                                       }
-                                                                                       if ($this->conf['useLocalization']) {
-                                                                                               $queryBuilder->andWhere($queryBuilder->expr()->eq('sys_dmail_category.sys_language_uid', $queryBuilder->createNamedParameter((int)$languageUid, \PDO::PARAM_INT)));
-                                                                                       }
-                                                                               }
-                                                                               if ($GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['sortby']) {
-                                                                                       $queryBuilder->orderBy($GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['sortby']);
-                                                                               }
-                                                                               $foreignWhereClause = trim($this->replaceForeignWhereMarker('',  $colName, $colConfig));
-                                                                               if ($foreignWhereClause) {
-                                                                                       $foreignWhereClause = \TYPO3\CMS\Core\Database\Query\QueryHelper::stripLogicalOperatorPrefix($foreignWhereClause);
-                                                                                       if (empty($queryBuilder->getQueryPart('where'))) {
-                                                                                               $queryBuilder->where($foreignWhereClause);
-                                                                                       } else {
-                                                                                               $queryBuilder->andWhere($foreignWhereClause);
-                                                                                       }
+                                                                       $reservedValues = [];
+                                                                       $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                                                                               ->getQueryBuilderForTable($colConfig['foreign_table'])
+                                                                               ->select('*')
+                                                                               ->from($colConfig['foreign_table']);
+                                                                       $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+                                                                       if ($colName === 'usergroup' && is_object($this->userGroupObj)) {
+                                                                               $reservedValues = $this->userGroupObj->getReservedValues($this->conf);
+                                                                               $this->userGroupObj->getAllowedWhereClause($colConfig['foreign_table'], $this->parameters->getPid(), $this->conf, $cmdKey, true, $queryBuilder);
+                                                                       }
+                                                                       if (
+                                                                               $this->conf['useLocalization']
+                                                                               && $GLOBALS['TCA'][$colConfig['foreign_table']]
+                                                                               && $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['languageField']
+                                                                               && $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['transOrigPointerField']
+                                                                       ) {
+                                                                               if (empty($queryBuilder->getQueryPart('where'))) {
+                                                                                       $queryBuilder->where($queryBuilder->expr()->eq($GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)));
+                                                                               } else {
+                                                                                       $queryBuilder->andWhere($queryBuilder->expr()->eq($GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)));
                                                                                }
-                                                                               $rows = $queryBuilder
-                                                                                       ->execute()
-                                                                                       ->fetchAll();
-                                                                       } else {
-                                                                               // TYPO3 CMS 7 LTS
-                                                                               $whereClause = '1=1';
-                                                                               if ($colName === 'usergroup' && is_object($this->userGroupObj)) {
-                                                                                       $reservedValues = $this->userGroupObj->getReservedValues($this->conf);
-                                                                                       $whereClause = $this->userGroupObj->getAllowedWhereClause($colConfig['foreign_table'], $this->parameters->getPid(), $this->conf, $cmdKey);
+                                                                       }
+                                                                       if (
+                                                                               $colName === 'module_sys_dmail_category'
+                                                                               && $colConfig['foreign_table'] === 'sys_dmail_category'
+                                                                               && $this->conf['module_sys_dmail_category_PIDLIST']
+                                                                       ) {
+                                                                               $pidArray = array_map('intval', GeneralUtility::trimExplode(',', $this->conf['module_sys_dmail_category_PIDLIST']));
+                                                                               if (empty($queryBuilder->getQueryPart('where'))) {
+                                                                                       $queryBuilder->where($queryBuilder->expr()->in('sys_dmail_category.pid', $pidArray));
+                                                                               } else {
+                                                                                       $queryBuilder->andWhere($queryBuilder->expr()->in('sys_dmail_category.pid', $pidArray));
                                                                                }
-                                                                               if (
-                                                                                       $this->conf['useLocalization']
-                                                                                       && $GLOBALS['TCA'][$colConfig['foreign_table']]
-                                                                                       && $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['languageField']
-                                                                                       && $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['transOrigPointerField']
-                                                                               ) {
-                                                                                       $whereClause .= ' AND ' . $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['transOrigPointerField'] . '=0';
+                                                                               if ($this->conf['useLocalization']) {
+                                                                                       $queryBuilder->andWhere($queryBuilder->expr()->eq('sys_dmail_category.sys_language_uid', $queryBuilder->createNamedParameter((int)$languageUid, \PDO::PARAM_INT)));
                                                                                }
-                                                                               if (
-                                                                                       $colName === 'module_sys_dmail_category'
-                                                                                       && $colConfig['foreign_table'] === 'sys_dmail_category'
-                                                                                       && $this->conf['module_sys_dmail_category_PIDLIST']
-                                                                               ) {
-                                                                                       $tmpArray = GeneralUtility::trimExplode(',', $this->conf['module_sys_dmail_category_PIDLIST']);
-                                                                                       $pidArray = array();
-                                                                                       foreach ($tmpArray as $v) {
-                                                                                               if (is_numeric($v))     {
-                                                                                                       $pidArray[] = $v;
-                                                                                               }
-                                                                                       }
-                                                                                       $whereClause .= ' AND sys_dmail_category.pid IN (' . implode(',',$pidArray) . ')' . ($this->conf['useLocalization'] ? ' AND sys_language_uid=' . (int) $languageUid : '');
+                                                                       }
+                                                                       if ($GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['sortby']) {
+                                                                               $queryBuilder->orderBy($GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['sortby']);
+                                                                       }
+                                                                       $foreignWhereClause = trim($this->replaceForeignWhereMarker('',  $colName, $colConfig));
+                                                                       if ($foreignWhereClause) {
+                                                                               $foreignWhereClause = QueryHelper::stripLogicalOperatorPrefix($foreignWhereClause);
+                                                                               if (empty($queryBuilder->getQueryPart('where'))) {
+                                                                                       $queryBuilder->where($foreignWhereClause);
+                                                                               } else {
+                                                                                       $queryBuilder->andWhere($foreignWhereClause);
                                                                                }
-                                                                               $whereClause .= $this->cObj->enableFields($colConfig['foreign_table']);
-                                                                               $whereClause = $this->replaceForeignWhereMarker($whereClause,  $colName, $colConfig);
-                                                                               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $colConfig['foreign_table'], $whereClause, '', $GLOBALS['TCA'][$colConfig['foreign_table']]['ctrl']['sortby']);
                                                                        }
+                                                                       $rows = $queryBuilder
+                                                                               ->execute()
+                                                                               ->fetchAll();
 
                                                                        if (!in_array($colName, $requiredFields)) {
                                                                                if ($colConfig['renderMode'] === 'checkbox' || $colContent) {
@@ -1768,9 +1739,11 @@ class Marker
                                                                        $selectedValue = false;
                                                                        foreach ($rows as $row2) {
                                                                                // Handle usergroup case
-                                                                               if ($colName === 'usergroup' && is_object($this->userGroupObj)) {
+                                                                               if ($colName === 'usergroup') {
                                                                                        if (!in_array($row2['uid'], $reservedValues)) {
-                                                                                               $row2 = $this->getUsergroupOverlay($row2);
+                                                                                               if ($localizedRow = $GLOBALS['TSFE']->sys_page->getRecordOverlay($colConfig['foreign_table'], $row2, $languageUid)) {
+                                                                                                       $row2 = $localizedRow;
+                                                                                               }
                                                                                                $titleText = htmlspecialchars($row2[$titleField], ENT_QUOTES, $charset);
                                                                                                $selected = (in_array($row2['uid'], $valuesArray) ? ' selected="selected"' : '');
                                                                                                if (!$this->conf['allowMultipleUserGroupSelection'] && $selectedValue) {
@@ -1850,79 +1823,6 @@ class Marker
        }
 
        /**
-        * Return the relevant usergroup overlay record fields
-        * Adapted from t3lib_page.php
-        *
-        * @param mixed If $usergroup is an integer, it's the uid of the usergroup overlay record and thus the usergroup overlay record is returned. If $usergroup is an array, it's a usergroup record and based on this usergroup record the language overlay record is found and overlaid before the usergroup record is returned.
-        * @param integer Language UID. Should be >=0
-        * @return array usergroup row which is overlayed with language_overlay record (or the overlay record alone)
-        */
-       public function getUsergroupOverlay($usergroup, $languageUid = 0)
-       {
-               // Initialize:
-               if (!$languageUid) {
-                       $languageUid = (int) $GLOBALS['TSFE']->config['config']['sys_language_uid'];
-               }
-
-               // If language UID is different from zero, do overlay:
-               if ($languageUid > 0) {
-                       $fieldArr = array('title');
-                       if (is_array($usergroup)) {
-                               $fe_groups_uid = $usergroup['uid'];
-                               // Was the whole record
-                               $fieldArr = array_intersect($fieldArr, array_keys($usergroup));
-                               // Make sure that only fields which exist in the incoming record are overlaid!
-                       } else {
-                               $fe_groups_uid = $usergroup;
-                               // Was the uid
-                       }
-
-                       if (count($fieldArr)) {
-                               if (class_exists('TYPO3\\CMS\\Core\\Database\\ConnectionPool')) {
-                                       $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
-                                               ->getQueryBuilderForTable('fe_groups_language_overlay');
-                                       $queryBuilder->setRestrictions(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer::class));
-                                       $queryBuilder
-                                               ->select(array_shift($fieldArr));
-                                       foreach ($fieldArr as $field) {
-                                               $queryBuilder
-                                                       ->addSelect($field);    
-                                       }
-                                       $rows = $queryBuilder
-                                               ->from('fe_groups_language_overlay')
-                                               ->where(
-                                                       $queryBuilder->expr()->eq('fe_group', $queryBuilder->createNamedParameter((int)$fe_groups_uid, \PDO::PARAM_INT)),
-                                                       $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter((int)$languageUid, \PDO::PARAM_INT))
-                                               )
-                                               ->execute()
-                                               ->fetchAll();
-                                       if (is_array($rows)) {
-                                               $row = $rows[0];
-                                       }
-                               } else {
-                                       // TYPO3 CMS 7 LTS
-                                       $whereClause = 'fe_group=' . (int) $fe_groups_uid . ' ' .
-                                               'AND sys_language_uid=' . (int) $languageUid . ' ' .
-                                               $this->cObj->enableFields('fe_groups_language_overlay');
-                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',', $fieldArr), 'fe_groups_language_overlay', $whereClause);
-                                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
-                                               $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-                                       }
-                               }
-                       }
-               }
-
-               // Create output:
-               if (is_array($usergroup)) {
-                       // If the input was an array, simply overlay the newfound array and return...
-                       return is_array($row) ? array_merge($usergroup, $row) : $usergroup;
-               } else {
-                       // always an array in return
-                       return is_array($row) ? $row : array();
-               }
-       }
-
-       /**
         * Replaces the markers in the foreign table where clause
         *
         * @param string $whereClause: foreign table where clause
index 80dfd59..07a6305 100644 (file)
@@ -15,6 +15,7 @@
                                                        <label>LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_db.xlf:tt_content.pi1_flexform.display_mode</label>\r
                                                        <config>\r
                                                                <type>select</type>\r
+                                                               <renderType>selectSingle</renderType>\r
                                                                <items>\r
                                                                        <numindex index="1">\r
                                                                                <numindex index="0">LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_db.xlf:tt_content.pi1_flexform.display_mode.1</numindex>\r
diff --git a/Configuration/TCA/Overrides/fe_groups.php b/Configuration/TCA/Overrides/fe_groups.php
new file mode 100644 (file)
index 0000000..388734f
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+defined('TYPO3_MODE') or die();
+
+/**
+ * Enabling localization of frontend groups
+ */
+$GLOBALS['TCA']['fe_groups']['ctrl']['origUid'] = 't3_origuid';
+$GLOBALS['TCA']['fe_groups']['ctrl']['languageField'] = 'sys_language_uid';
+$GLOBALS['TCA']['fe_groups']['ctrl']['transOrigPointerField'] = 'l10n_parent';
+$GLOBALS['TCA']['fe_groups']['ctrl']['transOrigDiffSourceField'] = 'l10n_diffsource';
+
+$GLOBALS['TCA']['fe_groups']['columns']['subgroup']['l10n_mode'] = 'exclude';
+$GLOBALS['TCA']['fe_groups']['columns']['TSconfig']['l10n_mode'] = 'exclude';
+$GLOBALS['TCA']['fe_groups']['columns']['lockToDomain']['l10n_mode'] = 'exclude';
+
+$GLOBALS['TCA']['fe_groups']['columns']['subgroup']['config']['foreign_table_where'] = ' AND fe_groups.sys_language_uid IN (-1,0) AND NOT(fe_groups.uid = ###THIS_UID###) AND fe_groups.hidden=0 ORDER BY fe_groups.title';
+
+$addColumnArray = [
+       'sys_language_uid' => [
+               'exclude' => true,
+               'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
+               'config' => [
+                       'type' => 'select',
+                       'renderType' => 'selectSingle',
+                       'foreign_table' => 'sys_language',
+                       'foreign_table_where' => 'ORDER BY sys_language.title',
+                       'items' => [
+                               ['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1],
+                               ['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.default_value', 0]
+                       ],
+                       'default' => 0,
+                       'fieldWizard' => [
+                               'selectIcons' => [
+                                       'disabled' => false,
+                               ],
+                       ],
+               ]
+       ],
+       'l10n_parent' => [
+               'displayCond' => 'FIELD:sys_language_uid:>:0',
+               'exclude' => true,
+               'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent',
+               'config' => [
+                       'type' => 'select',
+                       'renderType' => 'selectSingle',
+                       'items' => [
+                               ['', 0]
+                       ],
+                       'foreign_table' => 'sys_category',
+                       'foreign_table_where' => 'AND sys_category.uid=###REC_FIELD_l10n_parent### AND sys_category.sys_language_uid IN (-1,0)',
+                       'default' => 0
+               ]
+       ],
+       'l10n_diffsource' => [
+               'config' => [
+                       'type' => 'passthrough',
+                       'default' => ''
+               ]
+       ]
+];
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('fe_groups', $addColumnArray);
+unset($addColumnArray);
\ No newline at end of file
diff --git a/Configuration/TCA/Overrides/fe_groups_language_overlay.php b/Configuration/TCA/Overrides/fe_groups_language_overlay.php
deleted file mode 100644 (file)
index 958e6a8..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-defined('TYPO3_MODE') or die();
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToInsertRecords('fe_groups_language_overlay');
\ No newline at end of file
index be3a2e4..ee2769d 100644 (file)
@@ -18,10 +18,8 @@ $GLOBALS['TCA']['fe_users']['columns']['fax']['config']['max'] = '25';
 
 $GLOBALS['TCA']['fe_users']['columns']['image']['config']['max_size'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_feuser_register']['imageMaxSize'];
 $GLOBALS['TCA']['fe_users']['columns']['image']['config']['filter'][0]['parameters']['allowedFileExtensions'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_feuser_register']['imageTypes'];
-if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getNumericTypo3Version()) < 8000000) {
-       $GLOBALS['TCA']['fe_users']['columns']['image']['config']['allowed'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_feuser_register']['imageTypes'];
-       $GLOBALS['TCA']['fe_users']['columns']['image']['config']['uploadfolder'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_feuser_register']['uploadfolder'];
-}
+
+$GLOBALS['TCA']['fe_users']['columns']['usergroup']['config']['foreign_table_where'] = ' AND fe_groups.sys_language_uid IN (-1,0) ORDER BY fe_groups.title';
 
 $addColumnArray = array(
        'cnum' => array(
@@ -73,11 +71,10 @@ $addColumnArray = array(
                'label' => 'LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_db.xlf:fe_users.date_of_birth',
                'config' => array(
                        'type' => 'input',
+                       'renderType' => 'inputDateTime',
                        'size' => '10',
-                       'max' => '20',
                        'eval' => 'date',
-                       'checkbox' => '0',
-                       'default' => ''
+                       'default' => 0
                )
        ),
        'gender' => array(
diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php
new file mode 100644 (file)
index 0000000..de9fb2b
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+defined('TYPO3_MODE') or die();
+
+$GLOBALS['TCA']['pages']['columns']['fe_group']['config']['foreign_table_where'] = ' AND fe_groups.sys_language_uid IN (-1,0) ORDER BY fe_groups.title';
\ No newline at end of file
diff --git a/Configuration/TCA/Overrides/sys_file_metadata.php b/Configuration/TCA/Overrides/sys_file_metadata.php
new file mode 100644 (file)
index 0000000..31afea9
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+defined('TYPO3_MODE') or die();
+
+$GLOBALS['TCA']['sys_file_metadata']['columns']['fe_groups']['config']['foreign_table_where'] = ' AND fe_groups.sys_language_uid IN (-1,0) ORDER BY fe_groups.title';
\ No newline at end of file
index 72dea73..3e70f79 100644 (file)
@@ -4,4 +4,6 @@ defined('TYPO3_MODE') or die();
 $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['sr_feuser_register_pi1'] = 'layout,select_key';\r
 $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['sr_feuser_register_pi1'] = 'pi_flexform';\r
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('sr_feuser_register_pi1', 'FILE:EXT:sr_feuser_register/Configuration/FlexForms/flexform_ds_pi1.xml');\r
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(array('LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_db.xlf:tt_content.list_type', 'sr_feuser_register_pi1'), 'list_type', 'sr_feuser_register');
\ No newline at end of file
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(array('LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_db.xlf:tt_content.list_type', 'sr_feuser_register_pi1'), 'list_type', 'sr_feuser_register');\r
+\r
+$GLOBALS['TCA']['tt_content']['columns']['fe_group']['config']['foreign_table_where'] = ' AND fe_groups.sys_language_uid IN (-1,0) ORDER BY fe_groups.title';
\ No newline at end of file
diff --git a/Configuration/TCA/fe_groups_language_overlay.php b/Configuration/TCA/fe_groups_language_overlay.php
deleted file mode 100644 (file)
index da1614c..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-return array(
-       'ctrl' => array(
-               'title' => 'LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_db.xlf:fe_groups_language_overlay',
-               'label' => 'title',
-               'default_sortby' => 'ORDER BY fe_groups_uid',
-               'sortby' => 'sorting',
-               'delete' => 'deleted',
-               'enablecolumns' => array(
-                       'disabled' => 'hidden'
-               ),
-               'typeicon_classes' => array(
-                       'default'=> 'status-user-group-frontend'
-               )
-       ),
-       'interface' => array(
-               'showRecordFieldList' => 'hidden,fe_group,sys_language_uid,title'
-       ),
-       'columns' => array(
-               'hidden' => array(      
-                       'exclude' => 0, 
-                       'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden',
-                       'config' => array(
-                               'type' => 'check',
-                               'default' => '0'
-                       )
-               ),
-               'fe_group' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:fe_groups',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'foreign_table' => 'fe_groups'
-                       )
-               ),
-               'sys_language_uid' => [
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
-                       'config' => [
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'foreign_table' => 'sys_language',
-                               'foreign_table_where' => 'ORDER BY sys_language.title'
-                       ]
-               ],
-               'title' => array(               
-                       'exclude' => 0,         
-                       'label' => 'LLL:EXT:sr_feuser_register/Resources/Private/Language/locallang_db.xlf:fe_groups_language_overlay.title',
-                       'config' => array(
-                               'type' => 'input',      
-                               'size' => '30',
-                               'max' => '70',
-                               'eval' => 'trim,required',
-                       )
-               ),
-       ),
-       'types' => array(
-               '0' => array('showitem' => 'hidden;;;;1-1-1, fe_group, sys_language_uid, title')
-       )
-);
\ No newline at end of file
index 98db566..3ca1321 100644 (file)
@@ -2,33 +2,39 @@
   "name": "sjbr/sr-feuser-register",
   "description":