diff --git a/app/controllers/SeminaryController.inc b/app/controllers/SeminaryController.inc index b20f4d3c..abd18350 100644 --- a/app/controllers/SeminaryController.inc +++ b/app/controllers/SeminaryController.inc @@ -25,7 +25,7 @@ * * @var array */ - public $components = array('achievement', 'auth'); + public $components = array('achievement', 'auth', 'notification'); /** * Required models * @@ -166,7 +166,7 @@ foreach($achievements as &$achievement) { // Check deadline - if($achievement['deadline'] < date('Y-m-d H:i:s')) { + if(!is_null($achievement['deadline']) && $achievement['deadline'] < date('Y-m-d H:i:s')) { continue; } @@ -278,9 +278,19 @@ } - // Set status - if($achieved) { + // Achievement achieved + if($achieved) + { + // Set status $this->Achievements->setAchievementAchieved($achievement['id'], self::$character['id']); + + // Add notification + $this->Notification->addNotification( + \hhu\z\controllers\components\NotificationComponent::TYPE_ACHIEVEMENT, + $achievement['title'], + $this->linker->link(array('achievements', 'index', self::$seminary['url']), 0, true, null, true, $achievement['url']), + (!is_null($achievement['achieved_achievementsmedia_id']) ? $this->linker->link(array('media','achievement',self::$seminary['url'],$achievement['url'])) : null) + ); } } } diff --git a/controllers/HtmlController.inc b/controllers/HtmlController.inc index 2d7eef25..4c85e074 100644 --- a/controllers/HtmlController.inc +++ b/controllers/HtmlController.inc @@ -19,6 +19,12 @@ */ class HtmlController extends \hhu\z\Controller { + /** + * Required components + * + * @var array + */ + public $components = array('notification'); @@ -52,6 +58,9 @@ $this->set('loggedUser', IntermediateController::$user); $this->set('loggedSeminary', SeminaryController::$seminary); $this->set('loggedCharacter', SeminaryController::$character); + + // Set notifications + $this->set('notifications', $this->Notification->getNotifications()); } } diff --git a/controllers/QuestsController.inc b/controllers/QuestsController.inc index 8a60b3bc..9c91a9b3 100644 --- a/controllers/QuestsController.inc +++ b/controllers/QuestsController.inc @@ -600,6 +600,16 @@ { // Mark Quest as solved $this->Quests->setQuestSolved($quest['id'], $character['id']); + + // Notify of XP-level change + $newXPLevel = $this->Characters->getXPLevelOfCharacters($character['id']); + if($newXPLevel['level'] > $character['xplevel']) { + $this->Notification->addNotification( + \hhu\z\controllers\components\NotificationComponent::TYPE_LEVELUP, + $newXPLevel['level'], + $this->linker->link(array('characters', 'character', $seminary['url'], $character['url'])) + ); + } // Redirect $this->redirect($this->linker->link(array(), 5, true, array('status'=>'solved'), false, 'task')); diff --git a/views/html/html.tpl b/views/html/html.tpl index d66846bb..32acd4c2 100644 --- a/views/html/html.tpl +++ b/views/html/html.tpl @@ -51,6 +51,34 @@
+ 0) : ?> + +