Skip to content

Commit

Permalink
[FEATURE] Don't deleted log entries but set deleted=1. New option for…
Browse files Browse the repository at this point in the history
…ceDelete for BE module
  • Loading branch information
reinhardfuehricht committed Mar 7, 2016
1 parent fa95dcc commit 7f62065
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
13 changes: 11 additions & 2 deletions Classes/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,22 @@ public function exportAction($logDataUids = NULL, array $fields, $filetype = '')
*/
public function deleteLogRowsAction($logDataUids = NULL)
{
$forceDelete = intval($this->settings['forceDelete']);
if ($logDataUids === 'all') {
$text = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('message.deleted-all-logs', 'formhandler');
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('tx_formhandler_log');
if ($forceDelete){
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('tx_formhandler_log');
} else {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_formhandler_log', '1=1', ['deleted' => 1]);
}
} else {
$logDataUids = explode(',', $logDataUids);
$text = sprintf(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('message.deleted-log-rows', 'formhandler'), count($logDataUids));
$GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_formhandler_log', 'uid IN (' . implode(',', $logDataUids) . ')');
if ($forceDelete){
$GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_formhandler_log', 'uid IN (' . implode(',', $logDataUids) . ')');
} else {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_formhandler_log', 'uid IN (' . implode(',', $logDataUids) . ')', ['deleted' => 1]);
}
}

$this->addFlashMessage($text);
Expand Down
3 changes: 2 additions & 1 deletion Classes/Domain/Repository/LogDataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function findByUids($uids)
foreach ($uidArray as $key => $value) {
$constraints[] = $query->equals('uid', $value);
}
$constraints[] = $query->equals('deleted', 0);
return $query->matching(
$query->logicalAnd(
$query->logicalOr(
Expand All @@ -60,7 +61,7 @@ public function findDemanded(\Typoheads\Formhandler\Domain\Model\Demand $demand
{

$query = $this->createQuery();
$constraints = [];
$constraints = [$query->equals('deleted', 0)];

if ($demand !== NULL) {
if ($demand->getPid() > 0) {
Expand Down
1 change: 1 addition & 0 deletions Configuration/TCA/tx_formhandler_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'default_sortby' => 'ORDER BY crdate DESC',
'crdate' => 'crdate',
'tstamp' => 'tstamp',
'delete' => 'deleted',
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('formhandler') . 'ext_icon.gif',
'adminOnly' => 1
],
Expand Down
1 change: 1 addition & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CREATE TABLE tx_formhandler_log (
pid int(11) unsigned DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
deleted int(11) unsigned DEFAULT '0' NOT NULL,
ip tinytext,
params mediumtext,
is_spam int(11) unsigned DEFAULT '0',
Expand Down
1 change: 1 addition & 0 deletions ext_typoscript_setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ config.tx_extbase.persistence.classes {
module.tx_formhandler {
view.widget.TYPO3\CMS\Fluid\ViewHelpers\Be\Widget\PaginateViewHelper.templateRootPath = EXT:formhandler/Resources/Private/Templates/
settings {
forceDelete = 0
pdf {
class = Typoheads\Formhandler\Generator\BackendTcPdf
config {
Expand Down

0 comments on commit 7f62065

Please sign in to comment.