Skip to content

Commit

Permalink
Merge pull request #60 from itx-informationssysteme/develop
Browse files Browse the repository at this point in the history
2.0.0 - [BREAKING] TYPO3 11 support and new features - see changelog for more information

* [BREAKING] added static coding analysis via phpstan
* [FEATURE] upgrade to TYPO3 11. Removed support for older versions
* [BREAKING] removed vhs dependency
	* make sure to compare the templates, if you have overrides
* [FIX] fixed position of traits
* [BREAKING] fixed filter and reworked pagination on postings list
	* make sure to compare the templates and css, if you have overrides
* [FEATURE] added configurable page size via flexform to postings plugin
* [FIX] refactoring of google jobs structured data
* [BREAKING] replaced signal slots in favor of events
	* please change your implementations if you used signal slots previously
* [FEATURE] use new language configuration in tca
* [FIX]: fixed problems of postings filter caching in multilanguage setup
* [BREAKING]: postings can have multiple locations now
	* make sure to use the upgrade wizard to migrate entries in the location field to the new locations field and its corresponding mm table
	* make sure to compare the templates, if you have overrides
* [FEATURE]: redesigned posting tca (more place for slugs, etc)
* [FIX]: fixed error where postings could not be translated when no contact was selected
  • Loading branch information
itx-stefanie-doell authored Apr 29, 2022
2 parents 1be4eda + 7601128 commit d1071bd
Show file tree
Hide file tree
Showing 102 changed files with 2,047 additions and 8,716 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Static analysis

on: [ push, pull_request ]

jobs:
phpstan:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- php-version: 7.4
- php-version: 8.0
- php-version: 8.1
steps:
- uses: actions/checkout@v2

- id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}
restore-keys: |
${{ runner.os }}-composer-
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none

- run: composer install --no-progress

- run: vendor/bin/phpstan analyse Classes -c phpstan.neon
137 changes: 137 additions & 0 deletions Classes/Command/AnonymizeApplicationsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php

namespace ITX\Jobapplications\Command;

/***************************************************************
* Copyright notice
*
* (c) 2020
* 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 ITX\Jobapplications\Domain\Model\Application;
use ITX\Jobapplications\Domain\Repository\ApplicationRepository;
use ITX\Jobapplications\Service\ApplicationFileService;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException;
use TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException;
use TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;

/**
* Task for deleting all applications older than a specific amount of time
*
* @package ITX\Jobapplications
*/
class AnonymizeApplicationsCommand extends Command
{
private LoggerInterface $logger;

public int $days = 90;
public int $status = 0;

protected PersistenceManager $persistenceManager;
protected ApplicationRepository $applicationRepository;
protected ApplicationFileService $applicationFileService;

public function __construct(PersistenceManager $persistenceManager,
ApplicationRepository $applicationRepository,
ApplicationFileService $applicationFileService,
LoggerInterface $logger
)
{
$this->persistenceManager = $persistenceManager;
$this->applicationRepository = $applicationRepository;
$this->applicationFileService = $applicationFileService;
$this->logger = $logger;

parent::__construct();
}

public function configure()
{
$this
->setDescription("Anonymizes applications that are older than the specified days.")
->addArgument("days", InputArgument::OPTIONAL, "How old can an application be before is should be deleted?", 90)
->addOption("withStatus", "s", InputOption::VALUE_NONE, "Should applications only be deleted if they are in an end status?");
}

/**
* This is the main method that is called when a task is executed
* Should return TRUE on successful execution, FALSE on error.
*
* @return int Returns TRUE on successful execution, FALSE on error
* @throws InvalidFileNameException
* @throws InsufficientFolderAccessPermissionsException
* @throws InvalidQueryException
*/
public function execute($input, $output): int
{
$anonymizeChars = "***";
$days = $input->getArgument('days') ?? 90;
$withStatus = $input->getOption('withStatus') ?? false;

$now = new \DateTime();
$timestamp = $now->modify("-".$days." days")->getTimestamp();

$applications = $this->applicationRepository->findOlderThan($timestamp, $withStatus, true);

$resultCount = count($applications);

/* @var Application $application */
foreach ($applications as $application)
{
// Actual anonymization + deleting application files

/* @var ApplicationFileService $applicationFileService */
$fileStorage = $this->applicationFileService->getFileStorage($application);

$this->applicationFileService->deleteApplicationFolder($this->applicationFileService->getApplicantFolder($application), $fileStorage);

$application->setFirstName($anonymizeChars);
$application->setLastName($anonymizeChars);
$application->setAddressStreetAndNumber($anonymizeChars);
$application->setAddressAddition($anonymizeChars);
$application->setAddressPostCode(0);
$application->setEmail("[email protected]");
$application->setPhone($anonymizeChars);
$application->setMessage($anonymizeChars);
$application->setArchived(true);
$application->setSalutation("");
$application->setSalaryExpectation($anonymizeChars);
$application->setEarliestDateOfJoining(new \DateTime("@0"));
$application->setAnonymized(true);

$this->applicationRepository->update($application);
}

if ($resultCount > 0)
{
$this->persistenceManager->persistAll();
}

$this->logger->info('[ITX\\Jobapplications\\Task\\AnonymizeApplications]: '.$resultCount.' applications anonymized.');
$output->writeln("$resultCount applications anonymized.");

return Command::SUCCESS;
}
}
114 changes: 114 additions & 0 deletions Classes/Command/CleanUpApplicationsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

namespace ITX\Jobapplications\Command;

/***************************************************************
* Copyright notice
*
* (c) 2020
* 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 ITX\Jobapplications\Domain\Repository\ApplicationRepository;
use ITX\Jobapplications\Service\ApplicationFileService;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException;
use TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException;
use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException;
use TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;

/**
* Task for deleting all applications older than a specific amount of time
*
* @package ITX\Jobapplications
*/
class CleanUpApplicationsCommand extends Command
{
private LoggerInterface $logger;

protected PersistenceManager $persistenceManager;
protected ApplicationRepository $applicationRepository;
protected ApplicationFileService $applicationFileService;

public function __construct(PersistenceManager $persistenceManager,
ApplicationRepository $applicationRepository,
ApplicationFileService $applicationFileService,
LoggerInterface $logger)
{
$this->persistenceManager = $persistenceManager;
$this->applicationRepository = $applicationRepository;
$this->applicationFileService = $applicationFileService;
$this->logger = $logger;

parent::__construct();
}

public function configure()
{
$this
->setDescription("Deletes applications that are older than the specified days.")
->addArgument("days", InputArgument::OPTIONAL, "How old can an application be before is should be deleted?", 90)
->addOption("withStatus", "s", InputOption::VALUE_NONE, "Should applications only be deleted if they are in an end status?");
}

/**
* This is the main method that is called when a task is executed
* Should return TRUE on successful execution, FALSE on error.
*
* @return int Returns TRUE on successful execution, FALSE on error
* @throws InvalidFileNameException
* @throws InsufficientFolderAccessPermissionsException
* @throws InvalidQueryException
* @throws IllegalObjectTypeException
*/
public function execute($input, $output): int
{
$days = $input->getArgument('days') ?? 90;
$withStatus = $input->getOption('withStatus') ?? false;

$now = new \DateTime();
$timestamp = $now->modify("-".$days." days")->getTimestamp();

$applications = $this->applicationRepository->findOlderThan($timestamp, $withStatus);

$resultCount = count($applications);

foreach ($applications as $application)
{
$fileStorage = $this->applicationFileService->getFileStorage($application);
$this->applicationRepository->remove($application);

$this->applicationFileService->deleteApplicationFolder($this->applicationFileService->getApplicantFolder($application), $fileStorage);
}

if ($resultCount > 0)
{
$this->persistenceManager->persistAll();
}

$this->logger->info('[ITX\\Jobapplications\\Task\\CleanUpApplications]: '.$resultCount.' applications deleted.');
$output->writeln("$resultCount applications deleted.");

return Command::SUCCESS;
}
}
13 changes: 7 additions & 6 deletions Classes/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace ITX\Jobapplications\Controller;

use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use ITX\Jobapplications\Utility\UploadFileUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Core\Environment;
Expand All @@ -50,13 +52,12 @@ public function __construct()

/**
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function uploadAction(
\Psr\Http\Message\ServerRequestInterface $request
): \Psr\Http\Message\ResponseInterface
ServerRequestInterface $request
): ResponseInterface
{

$response = new HtmlResponse('');
Expand All @@ -66,7 +67,7 @@ public function uploadAction(
$responseContent = '';

/** @var ExtensionConfiguration $extconf */
$extconf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ExtensionConfiguration::class);
$extconf = GeneralUtility::makeInstance(ExtensionConfiguration::class);
$extConfLimit = $extconf->get('jobapplications', 'customFileSizeLimit');
$allowedFileTypesString = $extconf->get('jobapplications', 'allowedFileTypes');
$allowedFileTypes = $allowedFileTypesString !== '' ? explode(',', $allowedFileTypesString) : [];
Expand Down Expand Up @@ -143,8 +144,8 @@ public function uploadAction(
}

public function revertAction(
\Psr\Http\Message\ServerRequestInterface $request
): \Psr\Http\Message\ResponseInterface
ServerRequestInterface $request
): ResponseInterface
{
$response = new HtmlResponse('');
$body = $request->getBody();
Expand Down
Loading

0 comments on commit d1071bd

Please sign in to comment.