add e?mail notification for Character submissions that need to be reviewed by moderators

This commit is contained in:
coderkun 2014-05-27 11:13:23 +02:00
commit 66ce3caee3
6 changed files with 128 additions and 38 deletions

View file

@ -80,6 +80,32 @@
$this->set('character', $newCharacter);
}
/**
* Action: charactersubmission.
*
* Generate a mail message to notify of a new Character
* submission for a Quest that needs to be valuated.
*
* @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
* @param array $character Character that send the submission
*/
public function charactersubmission($receiver, $seminary, $questgroup, $quest, $character)
{
// Set subject
$this->response->setSubject(_('New Character submission'));
// Pass data to view
$this->set('seminary', $seminary);
$this->set('questgroup', $questgroup);
$this->set('quest', $quest);
$this->set('character', $character);
}
}
?>

View file

@ -660,6 +660,9 @@
else {
// Mark Quest as submitted
$this->Quests->setQuestSubmitted($quest['id'], $character['id']);
// Send notification mail
$this->sendSubmissionMail($seminary, $questgroup, $quest, $character);
// Redirect
$this->redirect($this->linker->link(array(), 5, true, null, false, 'task'));
@ -849,6 +852,44 @@
return $questtypeAgent->render();
}
/**
* Send mail for new Character submission.
*
* @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
* @param array $character Character that send the submission
*/
private function sendSubmissionMail($seminary, $questgroup, $quest, $character)
{
// Get system moderators
$moderators = $this->Users->getUsersWithRole('moderator');
// Send notification mail
try {
foreach($moderators as &$moderator)
{
\hhu\z\Utils::sendMail(
$moderator['email'],
'charactersubmission',
true,
array(
$moderator,
$seminary,
$questgroup,
$quest,
$character
),
$this->linker
);
}
}
catch(\hhu\z\exceptions\MailingException $e) {
$this->log($e->getMessage());
}
}
}
?>