Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed typo in readme #15

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2f3ce3c
Update Readme.md
georgringer Apr 25, 2018
4c589c6
Update Readme.md
georgringer Apr 29, 2018
a08bf2d
Set theme jekyll-theme-leap-day
georgringer May 8, 2018
de6c188
Set theme jekyll-theme-slate
georgringer May 8, 2018
05f35ec
setup docs
georgringer May 8, 2018
01b8e2a
[DOC] Move docs
georgringer May 8, 2018
d507f77
revert
georgringer May 8, 2018
29e000b
remove links
georgringer May 8, 2018
b1294bd
followup
georgringer May 8, 2018
e15d51c
further doc split
georgringer May 8, 2018
e185f7e
further
georgringer May 8, 2018
63fb705
configuration
georgringer May 8, 2018
8201795
more
georgringer May 8, 2018
0996169
remove features page
georgringer May 8, 2018
c08353a
remove docs branch
georgringer May 8, 2018
eec2ae3
correct backlink
georgringer May 8, 2018
3d540e4
Create CNAME
georgringer May 8, 2018
1f3a819
form overview
georgringer May 8, 2018
9f6fc51
report module
georgringer May 8, 2018
43cf3f2
log screenshot
georgringer May 8, 2018
f0cfe76
more screenshots
georgringer May 8, 2018
6125882
move docs
georgringer May 8, 2018
aa76241
rev
georgringer May 8, 2018
0e8c2ba
[TASK] Add demo version
georgringer May 8, 2018
33c8de8
comparison
georgringer May 8, 2018
6f5a33a
Update Readme.md
georgringer May 9, 2018
5274676
[DOC] More configuration examples
georgringer May 11, 2018
83c9ad5
move configuration
georgringer May 11, 2018
a7f3822
followup
georgringer May 11, 2018
3600198
[DOCS] Imrove readme + FAQ
georgringer May 18, 2018
bec858e
[BUGFIX] Add php docs
georgringer May 20, 2018
902993a
[TASK] Update ext_emconf
georgringer May 20, 2018
8f5f0ad
fixed typo in readme
hiasl May 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gdpr.extension.support
272 changes: 272 additions & 0 deletions Classes/Controller/AdministrationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
<?php
declare(strict_types=1);

namespace GeorgRinger\Gdpr\Controller;

use GeorgRinger\Gdpr\Domain\Model\Dto\LogFilter;
use GeorgRinger\Gdpr\Domain\Model\Dto\Search;
use GeorgRinger\Gdpr\Domain\Model\Dto\Table;
use GeorgRinger\Gdpr\Domain\Repository\FormRepository;
use GeorgRinger\Gdpr\Domain\Repository\LogRepository;
use GeorgRinger\Gdpr\Domain\Repository\RecordRepository;
use GeorgRinger\Gdpr\Service\TableInformation;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;

class AdministrationController extends ActionController
{

/** @var BackendTemplateView */
protected $view;

/** @var string */
protected $defaultViewObjectName = BackendTemplateView::class;

/** @var RecordRepository */
protected $recordRepository;

public function initializeAction()
{
$this->recordRepository = GeneralUtility::makeInstance(RecordRepository::class);

if ($this->request->getControllerActionName() !== 'moduleNotEnabled' && (int)$this->getBackendUser()->user['gdpr_module_enable'] === 0) {
$this->redirect('moduleNotEnabled');
}
}

public function initializeView(ViewInterface $view)
{
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DateTimePicker');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/jquery.clearable');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');

$dateFormat = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? ['MM-DD-YYYY', 'HH:mm MM-DD-YYYY'] : ['DD-MM-YYYY', 'HH:mm DD-MM-YYYY']);
$pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat);

$buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();

$uriBuilder = $this->objectManager->get(UriBuilder::class);
$uriBuilder->setRequest($this->request);

$buttonList = [
[
'action' => 'index',
'icon' => 'actions-system-list-open',
'position' => ButtonBar::BUTTON_POSITION_LEFT,
'group' => 1
],
[
'action' => 'search',
'icon' => 'actions-search',
'position' => ButtonBar::BUTTON_POSITION_LEFT,
'group' => 1
],
[
'action' => 'formOverview',
'icon' => 'ext-gdpr-form-overview',
'position' => ButtonBar::BUTTON_POSITION_LEFT,
'group' => 1
],
[
'action' => 'log',
'icon' => 'actions-document-open-read-only',
'position' => ButtonBar::BUTTON_POSITION_LEFT,
'group' => 2
],
[
'action' => 'configuration',
'icon' => 'actions-system-extension-configure',
'position' => ButtonBar::BUTTON_POSITION_RIGHT,
'group' => 1
],
[
'action' => 'help',
'icon' => 'actions-system-help-open',
'position' => ButtonBar::BUTTON_POSITION_RIGHT,
'group' => 2
],
];

$iconFactory = GeneralUtility::makeInstance(IconFactory::class);

foreach ($buttonList as $buttonDefinition) {
$button = $buttonBar->makeLinkButton()
->setIcon($iconFactory->getIcon($buttonDefinition['icon'], Icon::SIZE_SMALL))
->setTitle($buttonDefinition['icon'])
->setHref($uriBuilder
->reset()
->setRequest($this->request)->uriFor($buttonDefinition['action'], [], 'Administration'));
$buttonBar->addButton($button, $buttonDefinition['position'], $buttonDefinition['group']);
}
}

public function indexAction()
{
$tables = TableInformation::getAllEnabledTables();

$collectedRows = [];
foreach ($tables as $table) {
$collectedRows[$table]['statistics'] = $this->recordRepository->getStatisticOfTable($table);
$collectedRows[$table]['rows'] = $this->recordRepository->getRestrictedRows($table);
$collectedRows[$table]['meta'] = Table::getInstance($table);
}

$this->view->assignMultiple([
'tables' => $tables,
'restrictedData' => $collectedRows
]);
}

/**
* @param string $table
* @param int $id
*/
public function deleteAction(string $table, int $id)
{
$this->addFlashMessage('deleted');
$this->addFlashMessage('Only demo mode');
$this->forward('index');
}

/**
* @param string $table
* @param int $id
*/
public function reenableAction(string $table, int $id)
{
$this->addFlashMessage('reenabled');
$this->addFlashMessage('Only demo mode');
$this->forward('index');

}

/**
* @param string $table
* @param int $id
*/
public function disableAction(string $table, int $id)
{
$this->addFlashMessage('disabled');
$this->addFlashMessage('Only demo mode');
$this->forward('index');

}

/**
* @param string $table
* @param int $id
*/
public function randomizeAction(string $table, int $id)
{
$this->addFlashMessage(sprintf('The record with id %d from table "%s" has been randomized', $id, $table));
$this->addFlashMessage('Only demo mode');
$this->forward('index');
}

/**
* @param \GeorgRinger\Gdpr\Domain\Model\Dto\Search $search
*/
public function searchAction(Search $search = null)
{
$this->addFlashMessage('Only demo mode');
$searchPerformed = false;
if ($search === null) {
$search = $this->objectManager->get(Search::class);
} else {
$searchPerformed = true;
}

$this->view->assignMultiple([
'search' => $search,
'searchPerformed' => $searchPerformed,
]);
}

/**
* @param \GeorgRinger\Gdpr\Domain\Model\Dto\LogFilter $filter
*/
public function logAction(LogFilter $filter = null)
{
$this->addFlashMessage('Only demo mode');
if ($filter === null) {
$filter = $this->objectManager->get(LogFilter::class);
}

$allTableNames = [];
foreach (TableInformation::getAllEnabledTables() as $tableName) {
$allTableNames[$tableName] = $tableName;
}

$this->view->assignMultiple([
'allTableNames' => $allTableNames,
'filter' => $filter,
]);
}

public function formOverviewAction()
{
$formRepository = GeneralUtility::makeInstance(FormRepository::class);
$this->view->assignMultiple([
'forms' => $formRepository->getAllForms(),
]);
}

/**
* @param string $type type
* @param int $formId form
* @param int $status status
*/
public function formStatusUpdateAction(string $type, int $formId, int $status)
{
$this->addFlashMessage(sprintf('The form of content element %s has been updated ', $formId));
$this->addFlashMessage('Only demo mode');

$this->forward('formOverview');
}


public function configurationAction()
{
$allTables = TableInformation::getAllEnabledTables();

$information = [];
foreach ($allTables as $tableName) {
$information[$tableName] = Table::getInstance($tableName);
}

$this->view->assignMultiple([
'tables' => $information
]);
}

/**
* View which shows information if current user got no access
*/
public function moduleNotEnabledAction()
{

}

public function helpAction()
{

}

/**
* @return BackendUserAuthentication
*/
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
}
56 changes: 56 additions & 0 deletions Classes/Database/Query/Restriction/GdprOnlyRestriction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);

namespace GeorgRinger\Gdpr\Database\Query\Restriction;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use GeorgRinger\Gdpr\Domain\Model\Dto\Table;
use GeorgRinger\Gdpr\Service\TableInformation;
use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Restriction to filter records that have been marked as hidden
*/
class GdprOnlyRestriction implements QueryRestrictionInterface
{
/**
* Main method to build expressions for given tables
* Evaluates the ctrl/enablecolumns/disabled flag of the table and adds the according restriction if set
*
* @param array $queriedTables Array of tables, where array key is table alias and value is a table name
* @param ExpressionBuilder $expressionBuilder Expression builder instance to add restrictions with
* @return CompositeExpression The result of query builder expression(s)
*/
public function buildExpression(array $queriedTables, ExpressionBuilder $expressionBuilder): CompositeExpression
{
$constraints = [];
foreach ($queriedTables as $tableAlias => $tableName) {
if (TableInformation::isTableEnabled($tableName)) {
$table = Table::getInstance($tableName);
$restrictionFieldName = $table->getGdprRestrictionField() ?? null;
if (!empty($restrictionFieldName)) {
$constraints[] = $expressionBuilder->eq(
$tableAlias . '.' . $restrictionFieldName,
1
);
}
}
}
return $expressionBuilder->andX(...$constraints);
}
}
56 changes: 56 additions & 0 deletions Classes/Database/Query/Restriction/GdprRandomizedRestriction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);

namespace GeorgRinger\Gdpr\Database\Query\Restriction;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use GeorgRinger\Gdpr\Domain\Model\Dto\Table;
use GeorgRinger\Gdpr\Service\TableInformation;
use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Restriction to filter records that have been marked as hidden
*/
class GdprRandomizedRestriction implements QueryRestrictionInterface
{
/**
* Main method to build expressions for given tables
* Evaluates the ctrl/enablecolumns/disabled flag of the table and adds the according restriction if set
*
* @param array $queriedTables Array of tables, where array key is table alias and value is a table name
* @param ExpressionBuilder $expressionBuilder Expression builder instance to add restrictions with
* @return CompositeExpression The result of query builder expression(s)
*/
public function buildExpression(array $queriedTables, ExpressionBuilder $expressionBuilder): CompositeExpression
{
$constraints = [];
foreach ($queriedTables as $tableAlias => $tableName) {
if (TableInformation::isTableEnabled($tableName)) {
$table = Table::getInstance($tableName);
$restrictionFieldName = $table->getGdprRandomizedField() ?? null;
if (!empty($restrictionFieldName)) {
$constraints[] = $expressionBuilder->eq(
$tableAlias . '.' . $restrictionFieldName,
0
);
}
}
}
return $expressionBuilder->andX(...$constraints);
}
}
Loading