Commit 853e4828 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch 'develop' into ddev-0.20

* develop:
  Fix execution of opcache reset on deploy
  Remove uppercase CSS from mail templates
  Remove return annotation
  Add validation of username to not allow capital chars
  Remove empty line
  [SECURITY] Update TYPO3 CMS to 8.7.17
  Remove obsolete return statement
  Improve code, use core methods, use Hook instead of Controller
  [TASK] add php_cs.cache to gitignore
  [BUGFIX] fix cgl errors
  [FEATURE] Reactivate user process
  [TASK] Register Hook reactivateOldUser
  [WIP] Add workflow button for listview
  [TASK] Add module icon
  [TASK] Add TCA for old user table
  [TASK] Add PID to table structure
parents 05ccbb84 af193abc
Pipeline #4949 passed with stages
in 9 minutes and 3 seconds
......@@ -16,3 +16,4 @@ html/typo3temp/
html/uploads/
/auth.json
/html/typo3conf/realurl_autoconf.php
.php_cs.cache
......@@ -61,7 +61,7 @@ task('typo3', function () {
});
task('cache', function () {
run('cd {{release_path}} && {{php}} {{typo3_console}} opcache:reset');
run('cd {{release_path}} && {{php}} vendor/bin/cachetool opcache:reset');
});
task('deploy', [
......
......@@ -1572,16 +1572,16 @@
},
{
"name": "symfony/console",
"version": "v3.4.11",
"version": "v3.4.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "36f83f642443c46f3cf751d4d2ee5d047d757a27"
"reference": "1b97071a26d028c9bd4588264e101e14f6e7cd00"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/36f83f642443c46f3cf751d4d2ee5d047d757a27",
"reference": "36f83f642443c46f3cf751d4d2ee5d047d757a27",
"url": "https://api.github.com/repos/symfony/console/zipball/1b97071a26d028c9bd4588264e101e14f6e7cd00",
"reference": "1b97071a26d028c9bd4588264e101e14f6e7cd00",
"shasum": ""
},
"require": {
......@@ -1637,20 +1637,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-05-16T08:49:21+00:00"
"time": "2018-05-23T05:02:55+00:00"
},
{
"name": "symfony/debug",
"version": "v3.4.11",
"version": "v3.4.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "b28fd73fefbac341f673f5efd707d539d6a19f68"
"reference": "47e6788c5b151cf0cfdf3329116bf33800632d75"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/b28fd73fefbac341f673f5efd707d539d6a19f68",
"reference": "b28fd73fefbac341f673f5efd707d539d6a19f68",
"url": "https://api.github.com/repos/symfony/debug/zipball/47e6788c5b151cf0cfdf3329116bf33800632d75",
"reference": "47e6788c5b151cf0cfdf3329116bf33800632d75",
"shasum": ""
},
"require": {
......@@ -1693,7 +1693,7 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2018-05-16T14:03:39+00:00"
"time": "2018-06-25T11:10:40+00:00"
},
{
"name": "symfony/dependency-injection",
......@@ -1768,16 +1768,16 @@
},
{
"name": "symfony/finder",
"version": "v3.4.11",
"version": "v3.4.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "472a92f3df8b247b49ae364275fb32943b9656c6"
"reference": "3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/472a92f3df8b247b49ae364275fb32943b9656c6",
"reference": "472a92f3df8b247b49ae364275fb32943b9656c6",
"url": "https://api.github.com/repos/symfony/finder/zipball/3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394",
"reference": "3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394",
"shasum": ""
},
"require": {
......@@ -1813,7 +1813,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2018-05-16T08:49:21+00:00"
"time": "2018-06-19T20:52:10+00:00"
},
{
"name": "symfony/polyfill-ctype",
......@@ -1980,7 +1980,7 @@
},
{
"name": "symfony/yaml",
"version": "v3.4.11",
"version": "v3.4.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
......@@ -2240,16 +2240,16 @@
},
{
"name": "typo3/cms",
"version": "v8.7.16",
"version": "v8.7.17",
"source": {
"type": "git",
"url": "https://github.com/TYPO3/TYPO3.CMS.git",
"reference": "f02a014e16881b0271dda9a4a1a63ec9748b0210"
"reference": "06256af9f2b1ef49fa454c70412ce79de327be97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TYPO3/TYPO3.CMS/zipball/f02a014e16881b0271dda9a4a1a63ec9748b0210",
"reference": "f02a014e16881b0271dda9a4a1a63ec9748b0210",
"url": "https://api.github.com/repos/TYPO3/TYPO3.CMS/zipball/06256af9f2b1ef49fa454c70412ce79de327be97",
"reference": "06256af9f2b1ef49fa454c70412ce79de327be97",
"shasum": ""
},
"require": {
......@@ -2441,7 +2441,7 @@
"extbase",
"typo3"
],
"time": "2018-06-11T17:18:14+00:00"
"time": "2018-07-12T11:29:19+00:00"
},
{
"name": "typo3/cms-composer-installers",
......
<?php
declare(strict_types = 1);
namespace T3o\T3omy\Domain\Model;
/**
* Class UserProfileRepository
*/
class OldUser extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
*/
public $username = '';
/**
* @var string
*/
public $email = '';
/**
* @return string
*/
public function getUsername(): string
{
return $this->username;
}
/**
* @param string $username
*/
public function setUsername(string $username)
{
$this->username = $username;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail(string $email)
{
$this->email = $email;
}
}
<?php
declare(strict_types = 1);
namespace T3o\T3omy\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* Class UserProfileRepository
*
* @method findByUid(int $uid) \T3o\T3omy\Domain\Model\OldUser
*/
class OldUserRepository extends Repository
{
}
......@@ -69,6 +69,10 @@ class ServersideValidator extends \In2code\Femanager\Domain\Validator\Serverside
$this->checkUniqueInLdapValidation($user, $value, $validationSetting, $fieldName);
break;
case 'lowerChars':
$this->checkLowerCharsValidation($user, $value, $validationSetting, $fieldName);
break;
case 'notInOldUserTable':
$this->notInOldUserTableValidation($user, $value, $validationSetting, $fieldName);
break;
......@@ -122,6 +126,20 @@ class ServersideValidator extends \In2code\Femanager\Domain\Validator\Serverside
}
}
/**
* @param \In2code\Femanager\Domain\Model\User $user
* @param string $value
* @param array $validationSetting
* @param string $fieldName
*/
protected function checkLowerCharsValidation($user, $value, $validationSetting, $fieldName)
{
if (preg_match('/[A-Z]/', $value) !== false) {
$this->addError(ucfirst($fieldName) . ' may not contain upper case characters!', $fieldName);
$this->isValid = false;
}
}
/**
* @param \In2code\Femanager\Domain\Model\User $user
* @param $value
......
<?php
declare(strict_types = 1);
namespace T3o\T3omy\Hooks;
use In2code\Femanager\Domain\Model\User;
use In2code\Femanager\Domain\Repository\UserRepository;
use T3o\T3omy\Domain\Model\OldUser;
use T3o\T3omy\Domain\Repository\OldUserRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
/**
* Class ReactivateUserHook
*/
class ReactivateUserHook
{
/**
* @var \T3o\T3omy\Domain\Repository\OldUserRepository
*/
protected $oldUserRepository;
/**
* @var \In2code\Femanager\Domain\Repository\UserRepository
*/
protected $userRepository;
/**
* @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
*/
protected $persistenceManager;
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
*/
protected $objectManager;
/**
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
*/
public function reactivateOldUser()
{
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->persistenceManager = $this->objectManager->get(PersistenceManager::class);
$this->oldUserRepository = $this->objectManager->get(OldUserRepository::class);
// check if there is a fitting user in old user table
/** @var /T3o/T3omy/Domain/Model/OldUser $oldUser */
$oldUser = $this->oldUserRepository->findOneByUsername(GeneralUtility::_POST('user'));
if ($oldUser) {
if ($this->recoverUser($oldUser)) {
$this->oldUserRepository->remove($oldUser);
$this->persistenceManager->persistAll();
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
$uri = $uriBuilder->reset()
->setTargetPageUid(37)
->setCreateAbsoluteUri(true)
->buildFrontendUri();
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($uri, \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
}
}
}
/**
* @param \T3o\T3omy\Domain\Model\OldUser $oldUser
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @return bool
*/
public function recoverUser(OldUser $oldUser): bool
{
$userRepository = $this->objectManager->get(UserRepository::class);
$random = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\Random::class);
/** @var User $frontendUser */
$frontendUser = $this->objectManager->get(User::class);
$frontendUser->setUsername($oldUser->getUsername());
$frontendUser->setEmail($oldUser->getEmail());
$frontendUser->setName($oldUser->getUsername());
$frontendUser->setPassword($random->generateRandomBytes(20));
$userRepository->add($frontendUser);
$this->persistenceManager->persistAll();
$ldapOperation = $this->objectManager->get(FeManagerHooks::class);
$ldapOperation->createUser($frontendUser);
return true;
}
}
<?php
namespace T3o\T3omy\Hooks;
/***************************************************************
* Copyright notice
*
* (c) 2018 in2code.de and the following authors:
* Stefan Busemann
*
* 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 3 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface;
/**
* Class RecordListWorkflowButton
*/
class RecordListWorkflowOldUsers implements RecordListHookInterface
{
/**
* @var IconFactory
*/
protected $iconFactory;
/**
* RecordListWorkflowButton constructor.
*/
public function __construct()
{
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$this->signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
}
/**
* @param string $table
* @param array $row
* @param array $cells
* @param object $parentObject
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function makeClip($table, $row, $cells, &$parentObject)
{
return $cells;
}
/**
* @param string $table
* @param array $row
* @param array $cells
* @param object $parentObject
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function makeControl($table, $row, $cells, &$parentObject)
{
if ($table=='old_users') {
$buttons = [];
$buttons['workflow'] = $this->getWorkflowButton();
$cells['primary'] = $buttons + $cells['primary'];
}
return $cells;
}
/**
* @return string
*/
protected function getWorkflowButton()
{
$urlParameters = [
'tx_in2publish_web_in2publishm2' => [
'uid' => 1,
'table' => 'old_users',
'referringModule' => GeneralUtility::_GP('M'),
'referringPage' => GeneralUtility::_GP('id'),
'action' => 'record',
],
];
$href = BackendUtility::getModuleUrl('web_list', $urlParameters);
$class = 'btn btn-default';
return '<a class="' . $class . '" href="' . $href . '">'
. 'Reactivate'
. '</a>';
}
/**
* @param string $table
* @param array $currentIdList
* @param array $headerColumns
* @param object $parentObject
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function renderListHeader($table, $currentIdList, $headerColumns, &$parentObject)
{
return $headerColumns;
}
/**
* @param string $table
* @param array $currentIdList
* @param array $cells
* @param object $parentObject
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function renderListHeaderActions($table, $currentIdList, $cells, &$parentObject)
{
return $cells;
}
}
<?php
return [
'ctrl' => [
'title' => 'old fe user table',
'label' => 'username',
'default_sortby' => 'ORDER BY username ASC',
'searchFields' => 'title, uid, email',
'iconfile' => 'EXT:t3omy/Resources/Public/Icons/old_user.png',
'delete' => 'deleted',
'label' => 'username',
'default_sortby' => 'ORDER BY username',
'searchFields' => 'username, email'
],
'interface' => [
'showRecordFieldList' => 'uid, username, email',
],
'types' => [
'1' => [
'showitem' => 'uid, username, email, '
],
],
'palettes' => [
'1' => ['showitem' => ''],
],
'columns' => [
'username' => [
'exclude' => 0,
'label' => 'LLL:EXT:t3omy/Resources/Private/Language/locallang.xlf:' .
'old-users.username',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim'
],
],
'email' => [
'exclude' => 0,
'label' => 'LLL:EXT:t3omy/Resources/Private/Language/locallang.xlf:' .
'old-users.email',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim'
],
],
],
];
......@@ -14,6 +14,7 @@ plugin.tx_femanager {
uniqueInDb = 0
uniqueInLdap = 1
notInOldUserTable = 1
lowerChars = 1
}
password {
min = 12
......
......@@ -9,6 +9,12 @@
<trans-unit id="backend_layout.default.column.collection">
<source>CE Collection (Not shown on FE) </source>
</trans-unit>
<trans-unit id="old-users.username">
<source>Username of old fe_user</source>
</trans-unit>
<trans-unit id="old-users.email">
<source>Email</source>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
</xliff>
......@@ -160,7 +160,7 @@
<!-- ///////////////////////////////////////////////////// -->
<p style="Margin:0;color:#f49800;font-family:'Source Sans Pro', 'Helvetica', 'Arial', sans-serif;font-size:22px;font-weight:400;line-height:30px;margin:0;padding:0;text-align:center;text-transform: uppercase;">
<p style="Margin:0;color:#f49800;font-family:'Source Sans Pro', 'Helvetica', 'Arial', sans-serif;font-size:22px;font-weight:400;line-height:30px;margin:0;padding:0;text-align:center;">
<stong>Hi {user.username},</stong>
</p>
......
......@@ -233,7 +233,7 @@
<!-- ///////////////////////////////////////////////////// -->
<p style="Margin:0;color:#f49800;font-family:'Source Sans Pro', 'Helvetica', 'Arial', sans-serif;font-size:22px;font-weight:400;line-height:30px;margin:0;padding:0;text-align:center;text-transform: uppercase;">
<p style="Margin:0;color:#f49800;font-family:'Source Sans Pro', 'Helvetica', 'Arial', sans-serif;font-size:22px;font-weight:400;line-height:30px;margin:0;padding:0;text-align:center;">
<stong>Dear {user.name},</stong>
</p>
......
......@@ -161,7 +161,7 @@
<!-- ///////////////////////////////////////////////////// -->
<p style="Margin:0;color:#f49800;font-family:'Source Sans Pro', 'Helvetica', 'Arial', sans-serif;font-size:22px;font-weight:400;line-height:30px;margin:0;padding:0;text-align:center;text-transform: uppercase;">
<p style="Margin:0;color:#f49800;font-family:'Source Sans Pro', 'Helvetica', 'Arial', sans-serif;font-size:22px;font-weight:400;line-height:30px;margin:0;padding:0;text-align:center;">
<stong>Dear <a href="https://typo3.org" style="text-decoration: none; color:#f49800">typo3.org</a> user,</stong>
</p>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 64 64" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
<rect x="0" y="0" width="64" height="64" style="fill:rgb(200,60,60);fill-rule:nonzero;"/>
<path d="M46.6,41.2C43.785,40.432 41.626,39.375 39.624,38.522C39.582,39.065 39.381,39.635 38.842,40.186C37.222,41.912 34.742,44 32.034,44C29.314,44 26.746,41.885 25.154,40.183C24.596,39.61 24.411,39.006 24.392,38.445C22.385,39.341 20.222,40.33 17.399,41.1C17.399,41.1 14.299,43 13.999,50L49.999,50C49.799,42.9 46.599,41.2 46.599,41.2L46.6,41.2Z" style="fill:white;fill-rule:nonzero;"/>
<path d="M40,20.5C40,16.9 36.8,14 33,14L31,14C27.4,14 24,16.9 24,20.5L24,25.5C24,27.61 25.628,30.213 27.5,32.053C27.4,37.453 25.8,38 26.6,38.8C29.1,41.5 34.7,41.7 37.4,38.8C38.197,38.003 36.81,37.5 36.504,32.053C38.334,30.215 39.942,27.59 40,25.5L40,20.5Z" style="fill:white;fill-rule:nonzero;"/>
<g id="Reply--small-" serif:id="Reply (small)" transform="matrix(0.902781,3.33829e-32,0,0.902781,-393.884,-154.756)">
<path d="M450,208.5L450,202L438.5,213L450,224L450,217.5C455.5,217.5 460,222 460,227.5C460,230.3 458.9,232.8 457.1,234.6C461.2,232.2 464,227.7 464,222.5C464,214.7 457.7,208.5 450,208.5Z" style="fill-rule:nonzero;"/>
</g>
</svg>
......@@ -53,4 +53,12 @@ $dispatcher->connect(
'selfUpdateOfUser'
);
/**
* Register hooks
*/