From 1ca7d98b2bab3217d36019e3d19f0fcb47e360cd Mon Sep 17 00:00:00 2001 From: KIMB-technologies Date: Thu, 30 Jan 2020 20:50:41 +0100 Subject: [PATCH] fix #38 --- core/Mail.php | 3 ++- core/api/DelUserSubmission.php | 30 ++++++++++++++++++++++++++--- core/templates/mailAdminDel.json | 7 +++++++ core/templates/mailAdminDel_de.html | 21 ++++++++++++++++++++ core/templates/mailAdminDel_en.html | 21 ++++++++++++++++++++ data/translation_de.json | 1 + data/translation_en.json | 1 + docker-compose.dev.yml | 2 +- 8 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 core/templates/mailAdminDel.json create mode 100644 core/templates/mailAdminDel_de.html create mode 100644 core/templates/mailAdminDel_en.html diff --git a/core/Mail.php b/core/Mail.php index b5a1156..0595537 100644 --- a/core/Mail.php +++ b/core/Mail.php @@ -27,7 +27,8 @@ class Mail { private static $templates = array( 'mailAdminNotif', 'mailNewPollNotif', - 'mailPollSubm' + 'mailPollSubm', + 'mailAdminDel' ); private $type, $template, $mailHeader, $maillog; diff --git a/core/api/DelUserSubmission.php b/core/api/DelUserSubmission.php index 6197392..c32d389 100644 --- a/core/api/DelUserSubmission.php +++ b/core/api/DelUserSubmission.php @@ -23,10 +23,9 @@ class DelUserSubmission { const MAXL_ID = 10; /** - * Poll submission storage + * Poll submission storages and pollid */ - private $pollsub; - private $pollid; + private $pollid, $pollsub, $polldata; /** * Deletes a submisson from a poll @@ -57,6 +56,7 @@ private function openPollSubmissions() { $this->pollid = $_GET['poll']; if( Utilities::checkFileName($this->pollid) && in_array( $this->pollid, $polls->getArray() ) ){ $this->pollsub = new JSONReader( 'pollsub_' . $this->pollid, true ); //exclusive + $this->polldata = new JSONReader( 'poll_' . $this->pollid ); } } else{ @@ -89,11 +89,35 @@ private function deleteSubmission(int $id, string $code){ __DIR__ . '/../../data/pollsubmissions.log', json_encode( array( $this->pollid, 'delted entry' , $name, $mail, [$id], time() ) ) . "\r\n", FILE_APPEND | LOCK_EX ); + + $this->informAdmin($name, $mail, $id); die('ok'); } } } + + /** + * Send Mail to Poll Admin + */ + private function informAdmin(string $name, string $mail, int $termin) { + if( $this->polldata->isValue(['notifymails']) ){ + $tos = $this->polldata->getValue(['notifymails']); + if( !empty($tos) ){ + $m = new Mail( 'AdminDel' ); + + $m->setContent('POLLNAME', Utilities::optimizeOutputString($this->polldata->getValue( ['pollname'] ))); + $m->setContent('TERMINE', Utilities::optimizeOutputString( $this->polldata->getValue( ['termine', $termin, 'bez'] ) ) ); + $m->setContent('NAME', Utilities::optimizeOutputString( $name )); + $m->setContent('EMAIL', Utilities::optimizeOutputString( $mail )); + $m->setContent('ADMINLINK', URL::generateLink('admin', '', $this->polldata->getValue(['code', 'admin']))); + + foreach( $tos as $to ){ + $m->sendMail( $to ); + } + } + } + } } ?> \ No newline at end of file diff --git a/core/templates/mailAdminDel.json b/core/templates/mailAdminDel.json new file mode 100644 index 0000000..2183796 --- /dev/null +++ b/core/templates/mailAdminDel.json @@ -0,0 +1,7 @@ +{ + "%%POLLNAME%%": "", + "%%TERMINE%%": "", + "%%NAME%%": "", + "%%EMAIL%%": "", + "%%ADMINLINK%%": "" +} \ No newline at end of file diff --git a/core/templates/mailAdminDel_de.html b/core/templates/mailAdminDel_de.html new file mode 100644 index 0000000..29e8362 --- /dev/null +++ b/core/templates/mailAdminDel_de.html @@ -0,0 +1,21 @@ + + +

Gelöschter Eintrag

+

%%POLLNAME%%

+ + + Zum Adminbereich + + + \ No newline at end of file diff --git a/core/templates/mailAdminDel_en.html b/core/templates/mailAdminDel_en.html new file mode 100644 index 0000000..4ee7293 --- /dev/null +++ b/core/templates/mailAdminDel_en.html @@ -0,0 +1,21 @@ + + +

Deleted entry

+

%%POLLNAME%%

+ + + Open admin section + + + \ No newline at end of file diff --git a/data/translation_de.json b/data/translation_de.json index ffba10a..22142a8 100644 --- a/data/translation_de.json +++ b/data/translation_de.json @@ -26,5 +26,6 @@ "FillAdditionals": "Bitte alle Felder füllen, nicht als optional gekennzeichnete Felder sind Pflichtfelder.", "InvalMail": "Die eingegebene E-Mail-Adresse erfüllt nicht die Anforderungen!", "mailPollSubm": "Liste meiner Eintraege", + "mailAdminDel": "Gelöschter Eintrag", "MailTimeout": "Mailversand an die Adresse fehlgeschlagen, da zu viele Mails an diese Adresse geschickt wurden. Versuchen Sie es später erneut." } \ No newline at end of file diff --git a/data/translation_en.json b/data/translation_en.json index 3947ed7..0c88180 100644 --- a/data/translation_en.json +++ b/data/translation_en.json @@ -26,5 +26,6 @@ "FillAdditionals": "Please fill in all values, fields not marked as optional are required.", "InvalMail": "The given E-Mail-Address does not fullfil the requirements!", "mailPollSubm": "List of my entries", + "mailAdminDel": "Deleted entry", "MailTimeout": "Error while sending mail, because too many mails have been send to this address. Please try again later." } \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index ad20418..b071b4e 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -21,7 +21,7 @@ services: - CONF_captcha_new=false - CONF_texts_enablePoll=true - CONF_texts_enableNew=true - - CONF_texts_textPoll=Ich bin mit den Datenschutzrichlinien ... einverstanden! + - CONF_texts_textPoll=Ich bin mit den Datenschutzrichtlinien ... einverstanden! - CONF_texts_textNew=Ich bin mit den AGB des Anbieters einverstanden! - CONF_cookiebanner=false - CONF_newpollmailto=info@kimb-technologies.eu