Skip to content

Commit

Permalink
Allow disable forms via SignalSlots e.g. from slub_news_extend.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Bigga committed Aug 3, 2021
1 parent 7d6f28b commit dbe3097
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 156 deletions.
17 changes: 16 additions & 1 deletion Classes/Controller/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ public function newAction(\Slub\SlubForms\Domain\Model\Email $newEmail = null) {

$singleFormShortname = $this->getParametersSafely('form');

// form is shown by default
$formDisabled = false;
$params = [];
// check if form should be disabled
$this->signalSlotDispatcher->dispatch(
__CLASS__,
'checkFormAvailability',
[&$params]
);

if (isset($params['formDisabled'])) {
$formDisabled = $params['formDisabled'];
}

if (!empty($singleFormShortname)) {

/**
Expand All @@ -100,6 +114,7 @@ public function newAction(\Slub\SlubForms\Domain\Model\Email $newEmail = null) {
} else {
$singleForm = $this->formsRepository->findAllByShortname($singleFormShortname);
}

// if no form is found getFirst() will return false and that's what we want
$this->view->assign('singleForm', $singleForm->getFirst());

Expand All @@ -120,7 +135,7 @@ public function newAction(\Slub\SlubForms\Domain\Model\Email $newEmail = null) {

$this->view->assign('newEmail', $newEmail);
$this->view->assign('forms', $forms);

$this->view->assign('formDisabled', $formDisabled);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions Classes/Domain/Repository/EmailRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ class EmailRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
*/
public function findOlderThan($days) {

$query = $this->createQuery();
$query = $this->createQuery();

$constraints = [];
$constraints = [];

$constraints[] = $query->lessThanOrEqual('crdate', strtotime(' - ' . $days . ' days'));
$constraints[] = $query->lessThanOrEqual('crdate', strtotime(' - ' . $days . ' days'));

if (count($constraints)) {
$query->matching($query->logicalAnd($constraints));
}
if (count($constraints)) {
$query->matching($query->logicalAnd($constraints));
}

return $query->execute();
return $query->execute();

}

Expand All @@ -67,10 +67,10 @@ public function findOlderThan($days) {
*/
public function deleteOlderThan($days) {

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_slubforms_domain_model_email');
$affectedRows = $queryBuilder->delete('tx_slubforms_domain_model_email')->where(
$queryBuilder->expr()->lt('crdate', $queryBuilder->createNamedParameter(strtotime(' - ' . $days . ' days'), \PDO::PARAM_INT))
)->execute();
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_slubforms_domain_model_email');
$affectedRows = $queryBuilder->delete('tx_slubforms_domain_model_email')->where(
$queryBuilder->expr()->lt('crdate', $queryBuilder->createNamedParameter(strtotime(' - ' . $days . ' days'), \PDO::PARAM_INT))
)->execute();

return true;

Expand Down
10 changes: 9 additions & 1 deletion Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2019-11-29T14:40:59Z">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2021-08-03T19:30:51Z">
<header>
<generator>LFEditor</generator>
</header>
Expand Down Expand Up @@ -45,6 +45,10 @@
<source><![CDATA[MB]]></source>
<target><![CDATA[MB]]></target>
</trans-unit>
<trans-unit id="slub-forms.form_not_available" approved="yes">
<source><![CDATA[The form "%s" is currently not available.]]></source>
<target><![CDATA[Das Formular "%s" steht momentan nicht zur Verfügung.]]></target>
</trans-unit>
<trans-unit id="slub-forms.senderEmailName" approved="yes">
<source><![CDATA[SLUB Forms]]></source>
<target><![CDATA[SLUB Formulare]]></target>
Expand Down Expand Up @@ -117,6 +121,10 @@
<source><![CDATA[validation]]></source>
<target><![CDATA[Validierung]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets" approved="yes">
<source><![CDATA[Fieldsets]]></source>
<target><![CDATA[Feldgruppe]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets.fields" approved="yes">
<source><![CDATA[fields]]></source>
<target><![CDATA[Feld]]></target>
Expand Down
190 changes: 101 additions & 89 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
@@ -1,98 +1,110 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2013-08-00T09:41:00Z">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2021-08-03T19:30:13Z">
<header>
<generator>LFEditor</generator>
</header>
<body>
<trans-unit id="tx_slubforms_domain_model_email" approved="yes" xml:space="preserve">
<source>Email</source>
<target>Email</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email.content" approved="yes" xml:space="preserve">
<source>Content</source>
<target>Inhalt</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email.form" approved="yes" xml:space="preserve">
<source>Form</source>
<target>Formular</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email.sender_email" approved="yes" xml:space="preserve">
<source>Sender Email</source>
<target>Email-Adresse des Absenders</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email.sender_name" approved="yes" xml:space="preserve">
<source>Sender Name</source>
<target>Name des Absenders</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields" approved="yes" xml:space="preserve">
<source>Fields</source>
<target>Felder</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.configuration" approved="yes" xml:space="preserve">
<source>Configuration</source>
<target>Konfiguration</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.description" approved="yes" xml:space="preserve">
<source>Description</source>
<target>Beschreibung</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.required" approved="yes" xml:space="preserve">
<source>Required</source>
<target>Pflichtfeld</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.shortname" approved="yes" xml:space="preserve">
<source>Short Name</source>
<target>Kurzname</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.title" approved="yes" xml:space="preserve">
<source>Title</source>
<target>Titel</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.type" approved="yes" xml:space="preserve">
<source>Type</source>
<target>Typ</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.validation" approved="yes" xml:space="preserve">
<source>Validation</source>
<target>Validierung</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets" approved="yes" xml:space="preserve">
<source>Fieldsets</source>
<target>Feld-Gruppe</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets.fields" approved="yes" xml:space="preserve">
<source>Fields</source>
<target>Felder</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets.shortname" approved="yes" xml:space="preserve">
<source>Short Name</source>
<target>Kurzname</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets.title" approved="yes" xml:space="preserve">
<source>Title</source>
<target>Titel</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms" approved="yes" xml:space="preserve">
<source>Forms</source>
<target>Formulare</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.parent" approved="yes" xml:space="preserve">
<source>Parent Form</source>
<target>Übergeordnetes Formular</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.recipient" approved="yes" xml:space="preserve">
<source>Recipient</source>
<target>Empfänger</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.shortname" approved="yes" xml:space="preserve">
<source>Short Name</source>
<target>Kurzname</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.title" approved="yes" xml:space="preserve">
<source>Title</source>
<target>Titel</target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email" approved="yes">
<source><![CDATA[Email]]></source>
<target><![CDATA[Email]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email.content" approved="yes">
<source><![CDATA[Content]]></source>
<target><![CDATA[Inhalt]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email.form" approved="yes">
<source><![CDATA[Form]]></source>
<target><![CDATA[Formular]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email.sender_email" approved="yes">
<source><![CDATA[Sender Email]]></source>
<target><![CDATA[Email-Adresse des Absenders]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_email.sender_name" approved="yes">
<source><![CDATA[Sender Name]]></source>
<target><![CDATA[Name des Absenders]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields" approved="yes">
<source><![CDATA[Fields]]></source>
<target><![CDATA[Felder]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.configuration" approved="yes">
<source><![CDATA[Configuration]]></source>
<target><![CDATA[Konfiguration]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.description" approved="yes">
<source><![CDATA[Description]]></source>
<target><![CDATA[Beschreibung]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.is_sender_email" approved="yes">
<source><![CDATA[Field is Sender Email]]></source>
<target><![CDATA[Feld enthält Absender Email-Adresse]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.is_sender_name" approved="yes">
<source><![CDATA[Field is Sender Name]]></source>
<target><![CDATA[Feld enthält Absender Name]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.required" approved="yes">
<source><![CDATA[Required]]></source>
<target><![CDATA[Pflichtfeld]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.shortname" approved="yes">
<source><![CDATA[Short Name]]></source>
<target><![CDATA[Kurzname]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.title" approved="yes">
<source><![CDATA[Title]]></source>
<target><![CDATA[Titel]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.type" approved="yes">
<source><![CDATA[Type]]></source>
<target><![CDATA[Typ]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fields.validation" approved="yes">
<source><![CDATA[Validation]]></source>
<target><![CDATA[Validierung]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets" approved="yes">
<source><![CDATA[Fieldsets]]></source>
<target><![CDATA[Feld-Gruppe]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets.fields" approved="yes">
<source><![CDATA[Fields]]></source>
<target><![CDATA[Felder]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets.shortname" approved="yes">
<source><![CDATA[Short Name]]></source>
<target><![CDATA[Kurzname]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_fieldsets.title" approved="yes">
<source><![CDATA[Title]]></source>
<target><![CDATA[Titel]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms" approved="yes">
<source><![CDATA[Forms]]></source>
<target><![CDATA[Formulare]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.fieldsets" approved="yes">
<source><![CDATA[Fieldsets]]></source>
<target><![CDATA[Feldgruppe]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.parent" approved="yes">
<source><![CDATA[Parent Form]]></source>
<target><![CDATA[Übergeordnetes Formular]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.recipient" approved="yes">
<source><![CDATA[Recipient]]></source>
<target><![CDATA[Empfänger]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.shortname" approved="yes">
<source><![CDATA[Short Name]]></source>
<target><![CDATA[Kurzname]]></target>
</trans-unit>
<trans-unit id="tx_slubforms_domain_model_forms.title" approved="yes">
<source><![CDATA[Title]]></source>
<target><![CDATA[Titel]]></target>
</trans-unit>
</body>
</file>
</xliff>
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<trans-unit id="slub-forms.back_to_forms" xml:space="preserve">
<source>back to form overview</source>
</trans-unit>
<trans-unit id="slub-forms.form_not_available" xml:space="preserve">
<source>The form "%s" is currently not available.</source>
</trans-unit>
<trans-unit id="slub-forms.file-accept-info" xml:space="preserve">
<source>We accept files with the following format: </source>
</trans-unit>
Expand Down
Loading

0 comments on commit dbe3097

Please sign in to comment.