add e?mail notifcation for approved Quests (resolves issue #298)

This commit is contained in:
coderkun 2014-05-27 11:43:53 +02:00
commit 26ccbc61e0
6 changed files with 78 additions and 6 deletions

View file

@ -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);
}
}
?>

View file

@ -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());
}
}
}
?>