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

[FEATURE] Add button to delete all mails and answers #660

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions Classes/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use In2code\Powermail\Utility\BackendUtility;
use In2code\Powermail\Utility\BasicFileUtility;
use In2code\Powermail\Utility\ConfigurationUtility;
use In2code\Powermail\Utility\DatabaseUtility;
use In2code\Powermail\Utility\LocalizationUtility;
use In2code\Powermail\Utility\MailUtility;
use In2code\Powermail\Utility\ReportingUtility;
use In2code\Powermail\Utility\StringUtility;
Expand Down Expand Up @@ -62,6 +64,47 @@ public function listAction(): void
);
}

/**
* Delete all mails and answers if the confirmation checkbox has been checked
*
* @return void
*/
public function deleteAllMailsBeAction(): void
{
$args = $this->request->getArguments();
if ($args['reallyDelete'] === '1' && $this->id > 0) {
$this->deleteAllMails();
}
$this->forward('list');
}

/**
* Delete all mails and answers on the current page
*
* @return void
*/
protected function deleteAllMails(): void
{
$queryBuilder = DatabaseUtility::getQueryBuilderForTable(Answer::TABLE_NAME);
$queryBuilder->delete(Answer::TABLE_NAME)
->where(
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($this->id))
)
->execute();

$queryBuilder = DatabaseUtility::getQueryBuilderForTable(Answer::TABLE_NAME);
$queryBuilder->delete(Mail::TABLE_NAME)
->where(
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($this->id))
)
->execute();

$this->addFlashMessage(
LocalizationUtility::translate('BackendDeleteAllMailsFinished'),
''
);
}

/**
* @return void
* @throws InvalidQueryException
Expand Down
20 changes: 20 additions & 0 deletions Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,26 @@
<source>This TYPO3 instance is running in development context. You can use %s in the AdditionalConfiguration.php to enforce powermail to send testmails to this email-address only.</source>
<target state="translated">Diese TYPO3-Instanz läuft aktuell im Development Context. Mit %s in der AdditionalConfiguration.php kann man powermail anweisen, nur noch an diese Formulare zu senden.</target>
</trans-unit>
<trans-unit id="BackendDeleteAllMailsButton">
<source>Cleanup</source>
<target state="translated">Aufräumen</target>
</trans-unit>
<trans-unit id="BackendDeleteAllMailsTitle">
<source>Delete all mails</source>
<target state="translated">Alle Mails löschen</target>
</trans-unit>
<trans-unit id="BackendDeleteAllMailsFinished">
<source>All mails and answers on this page have been deleted</source>
<target state="translated">Alle Mails und Antworten auf dieser Seite wurden gelöscht.</target>
</trans-unit>
<trans-unit id="BackendDeleteAllMailsReally">
<source>Yes, delete all mails and answers on this page</source>
<target state="translated">Ja, alle Mails und Antworten auf dieser Seite löschen</target>
</trans-unit>
<trans-unit id="BackendDeleteAllMailSubmit">
<source>Delete all</source>
<target state="translated">Alle löschen</target>
</trans-unit>
<trans-unit id="BackendOverviewTitle">
<source>Form Overview</source>
<target state="translated">Formular Übersicht</target>
Expand Down
15 changes: 15 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,21 @@
<trans-unit id="BackendCheckDevelopmentContextAvailable" resname="BackendCheckDevelopmentContextAvailable">
<source>This TYPO3 instance is running in development context. You can use %s in the AdditionalConfiguration.php to enforce powermail to send testmails to this email-address only.</source>
</trans-unit>
<trans-unit id="BackendDeleteAllMailsButton">
<source>Cleanup</source>
</trans-unit>
<trans-unit id="BackendDeleteAllMailsTitle">
<source>Delete all mails</source>
</trans-unit>
<trans-unit id="BackendDeleteAllMailsFinished">
<source>All mails and answers on this page have been deleted</source>
</trans-unit>
<trans-unit id="BackendDeleteAllMailsReally">
<source>Yes, delete all mails and answers on this page</source>
</trans-unit>
<trans-unit id="BackendDeleteAllMailSubmit">
<source>Delete all</source>
</trans-unit>
<trans-unit id="BackendOverviewTitle" resname="BackendOverviewTitle">
<source>Form Overview</source>
</trans-unit>
Expand Down
41 changes: 41 additions & 0 deletions Resources/Private/Partials/Module/DeleteAllMails.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<div class="clearfix">
<div class="pull-right">
<f:form.button
class="btn btn-default"
type="button"
additionalAttributes="{data-toggle:'collapse',data-target:'#deleteAllMails',aria-expanded:'false',aria-controls:'collapseExample'}">
<f:translate key="BackendDeleteAllMailsButton">Cleanup</f:translate>
</f:form.button>
</div>
</div>

<div class="collapse" id="deleteAllMails">
<h2 class="powermail-padding-top" id="deleteAllMails">
<f:translate key="BackendDeleteAllMailsTitle">Delete all mails</f:translate>
</h2>

<div class="message-body powermail-padding-bottom powermail_email">
<f:form
class="form-horizontal"
action="deleteAllMailsBe">
<f:form.hidden name="mode" value="deleteAllMails"/>
<div class="form-group">
<div class="col-sm-6 checkbox">
<label>
<f:form.checkbox
name="reallyDelete"
value="1"
additionalAttributes="{required:''}"
/>
<f:translate key="BackendDeleteAllMailsReally" />
</label>
</div>
<div class="col-sm-6">
<f:form.button type="submit" class="btn btn-primary">
<f:translate key="BackendDeleteAllMailSubmit"/>
</f:form.button>
</div>
</div>
</f:form>
</div>
</div>
4 changes: 4 additions & 0 deletions Resources/Private/Templates/Module/List.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ <h3><f:translate key="BackendListNoMails" /></h3>
</f:if>
</div>

<f:if condition="{writeAccess}">
<f:render partial="Module/DeleteAllMails" arguments="{_all}" />
</f:if>

</f:section>
1 change: 1 addition & 0 deletions ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function () {
[
\In2code\Powermail\Controller\ModuleController::class =>
'dispatch, list, exportXls, exportCsv, reportingBe, toolsBe, overviewBe, ' .
'deleteAllMailsBe, ' .
'checkBe, converterBe, converterUpdateBe, reportingFormBe, reportingMarketingBe, ' .
'fixUploadFolder, fixWrongLocalizedForms, fixFilledMarkersInLocalizedFields, ' .
'fixWrongLocalizedPages, fixFilledMarkersInLocalizedPages'
Expand Down