diff --git a/controllers/MailController.inc b/controllers/MailController.inc index f4696091..bcc4307d 100644 --- a/controllers/MailController.inc +++ b/controllers/MailController.inc @@ -106,6 +106,30 @@ $this->set('character', $character); } + + /** + * Action: charactersubmissionapproved. + * + * Generate a mail message to notify a Character that its + * submission has been approved. + * + * @param array $receiver User that the message will be send to + * @param array $seminary Seminary which the Quest belongs to + * @param array $questgroup Questgroup of Quest + * @param array $quest Quest the answer has been submitted for + */ + public function charactersubmissionapproved($receiver, $seminary, $questgroup, $quest) + { + // Set subject + $this->response->setSubject(_('Character submission approved')); + + + // Pass data to view + $this->set('seminary', $seminary); + $this->set('questgroup', $questgroup); + $this->set('quest', $quest); + } + } ?> diff --git a/controllers/QuestsController.inc b/controllers/QuestsController.inc index 4b23d8af..61f5bb8a 100644 --- a/controllers/QuestsController.inc +++ b/controllers/QuestsController.inc @@ -746,6 +746,9 @@ // Save additional data for Character answers $questtypeAgent->controller->saveDataForCharacterAnswers($seminary, $questgroup, $quest, $character, $this->request->getPostParam('characterdata')); + // Send notification + $this->sendSubmissionApprovedMail($character, $seminary, $questgroup, $quest); + // Redirect $this->redirect($this->linker->link(array('submissions', $seminary['url'], $questgroup['url'], $quest['url']), 1)); } @@ -890,6 +893,40 @@ } } + + /** + * Send mail for approval of a Character submission. + * + * @param array $character Character of submission that has been approved + * @param array $seminary Seminary which the Quest belongs to + * @param array $questgroup Questgroup of Quest + * @param array $quest Quest the submission has been approved for + */ + private function sendSubmissionApprovedMail($character, $seminary, $questgroup, $quest) + { + // Get user + $user = $this->Users->getUserById($character['user_id']); + + // Send notification mail + try { + \hhu\z\Utils::sendMail( + $user['email'], + 'charactersubmissionapproved', + true, + array( + $user, + $seminary, + $questgroup, + $quest + ), + $this->linker + ); + } + catch(\hhu\z\exceptions\MailingException $e) { + $this->log($e->getMessage()); + } + } + } ?> diff --git a/locale/de_DE/LC_MESSAGES/The Legend of Z.mo b/locale/de_DE/LC_MESSAGES/The Legend of Z.mo index 0e3f0964..a81cb049 100644 Binary files a/locale/de_DE/LC_MESSAGES/The Legend of Z.mo and b/locale/de_DE/LC_MESSAGES/The Legend of Z.mo differ diff --git a/locale/de_DE/LC_MESSAGES/The Legend of Z.po b/locale/de_DE/LC_MESSAGES/The Legend of Z.po index 279c3c62..bfd8b046 100644 --- a/locale/de_DE/LC_MESSAGES/The Legend of Z.po +++ b/locale/de_DE/LC_MESSAGES/The Legend of Z.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: The Legend of Z\n" -"POT-Creation-Date: 2014-05-27 10:48+0100\n" -"PO-Revision-Date: 2014-05-27 10:52+0100\n" +"POT-Creation-Date: 2014-05-27 11:27+0100\n" +"PO-Revision-Date: 2014-05-27 11:28+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: de_DE\n" @@ -59,6 +59,10 @@ msgstr "Neue Charakterregistrierung" msgid "New Character submission" msgstr "Neuer Lösungsvorschlag" +#: controllers/MailController.inc:124 +msgid "Character submission approved" +msgstr "Lösungsvorschlag bewertet" + #: controllers/QuestsController.inc:735 #: questtypes/submit/html/submission.tpl:30 views/html/quests/quest.tpl:45 #: views/html/quests/submissions.tpl:30 @@ -1344,6 +1348,13 @@ msgstr "" "Der Charakter „%s“ hat einen neuen Lösungsvorschlag für die Quest „%s“ des " "Seminars „%s“ eingereicht" +#: views/htmlmail/mail/charactersubmissionapproved.tpl:1 +#: views/textmail/mail/charactersubmissionapproved.tpl:1 +#, php-format +msgid "" +"Your submission for the Quest “%s” of the Seminary “%s” has been approved" +msgstr "Deine Lösung für die Quest „%s“ des Seminars „%s“ wurde bewertet" + #: views/htmlmail/mail/userregistration.tpl:1 #: views/textmail/mail/userregistration.tpl:1 msgid "A new user has been registered" @@ -1355,10 +1366,6 @@ msgstr "Ein neuer Benutzer wurde registriert" msgid "Hello %s" msgstr "Hallo %s" -#, fuzzy -#~ msgid "Character submission solved" -#~ msgstr "gelöst" - #, fuzzy #~ msgid "Dear %s" #~ msgstr "erstellt von %s am %s um %s Uhr" diff --git a/views/htmlmail/mail/charactersubmissionapproved.tpl b/views/htmlmail/mail/charactersubmissionapproved.tpl new file mode 100644 index 00000000..c62d3ee5 --- /dev/null +++ b/views/htmlmail/mail/charactersubmissionapproved.tpl @@ -0,0 +1,2 @@ +: +//// diff --git a/views/textmail/mail/charactersubmissionapproved.tpl b/views/textmail/mail/charactersubmissionapproved.tpl new file mode 100644 index 00000000..309645af --- /dev/null +++ b/views/textmail/mail/charactersubmissionapproved.tpl @@ -0,0 +1,2 @@ +. +link(array('quests','quest',$seminary['url'],$questgroup['url'],$quest['url']),0,true,null,false,null,true)?>