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 @@ + +
+