diff --git a/controllers/QuestgroupsController.inc b/controllers/QuestgroupsController.inc index b5e7e509..1064be74 100644 --- a/controllers/QuestgroupsController.inc +++ b/controllers/QuestgroupsController.inc @@ -71,10 +71,13 @@ $character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']); // Check permission - $previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($questgroup['id']); - if(!is_null($previousQuestgroup)) { - if(!$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) { - throw new \nre\exceptions\AccessDeniedException(); + if(count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) == 0) + { + $previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($questgroup['id']); + if(!is_null($previousQuestgroup)) { + if(!$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) { + throw new \nre\exceptions\AccessDeniedException(); + } } } @@ -92,7 +95,7 @@ foreach($hierarchy['questgroups'] as $i => &$group) { // Check permission of Questgroups - if($i >= 1) + if($i >= 1 && count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) == 0) { if(!$this->Questgroups->hasCharacterSolvedQuestgroup($hierarchy['questgroups'][$i-1]['id'], $character['id'])) { @@ -163,7 +166,7 @@ $quests[] = $currentQuest; } } - while(!is_null($currentQuest) && $currentQuest['solved']); + while(!is_null($currentQuest) && ($currentQuest['solved'] || count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) > 0)); } diff --git a/controllers/QuestsController.inc b/controllers/QuestsController.inc index a8dbdcb7..2ebdb257 100644 --- a/controllers/QuestsController.inc +++ b/controllers/QuestsController.inc @@ -147,46 +147,49 @@ $character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']); // Check permissions - $previousQuests = $this->Quests->getPreviousQuests($quest['id']); - if(count($previousQuests) == 0) + if(count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) == 0) { - // Previous Questgroup - $previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($questgroup['id']); - if(!is_null($previousQuestgroup) && !$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) { - throw new \nre\exceptions\AccessDeniedException(); - } - } - else - { - // Previous Quests - // One previous Quest has to be solved and no other - // following Quests of ones has to be tried - $solved = false; - $tried = false; - foreach($previousQuests as &$previousQuest) + $previousQuests = $this->Quests->getPreviousQuests($quest['id']); + if(count($previousQuests) == 0) { - // // Check previous Quest - if($this->Quests->hasCharacterSolvedQuest($previousQuest['id'], $character['id'])) - { - $solved = true; - - // Check following Quests - $followingQuests = $this->Quests->getNextQuests($previousQuest['id']); - foreach($followingQuests as $followingQuest) - { - // Check following Quest - if($followingQuest['id'] != $quest['id'] && $this->Quests->hasCharacterTriedQuest($followingQuest['id'], $character['id'])) - { - $tried = true; - break; - } - } - - break; + // Previous Questgroup + $previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($questgroup['id']); + if(!is_null($previousQuestgroup) && !$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) { + throw new \nre\exceptions\AccessDeniedException(); } } - if(!$solved || $tried) { - throw new \nre\exceptions\AccessDeniedException(); + else + { + // Previous Quests + // One previous Quest has to be solved and no other + // following Quests of ones has to be tried + $solved = false; + $tried = false; + foreach($previousQuests as &$previousQuest) + { + // // Check previous Quest + if($this->Quests->hasCharacterSolvedQuest($previousQuest['id'], $character['id'])) + { + $solved = true; + + // Check following Quests + $followingQuests = $this->Quests->getNextQuests($previousQuest['id']); + foreach($followingQuests as $followingQuest) + { + // Check following Quest + if($followingQuest['id'] != $quest['id'] && $this->Quests->hasCharacterTriedQuest($followingQuest['id'], $character['id'])) + { + $tried = true; + break; + } + } + + break; + } + } + if(!$solved || $tried) { + throw new \nre\exceptions\AccessDeniedException(); + } } } @@ -270,7 +273,7 @@ $nextQuests = null; $charactedHasChoosenNextQuest = false; $nextQuestgroup = null; - if($questtexttypeUrl == 'Epilog' || $this->Questtexts->getQuesttextCountOfQuest($quest['id'], 'Epilog') == 0) + if($questtexttypeUrl == 'Epilog' || ($solved && $this->Questtexts->getQuesttextCountOfQuest($quest['id'], 'Epilog') == 0) || count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) > 0) { // Next Quest $nextQuests = $this->Quests->getNextQuests($quest['id']); diff --git a/controllers/SeminariesController.inc b/controllers/SeminariesController.inc index 771c9787..06f95652 100644 --- a/controllers/SeminariesController.inc +++ b/controllers/SeminariesController.inc @@ -115,7 +115,7 @@ foreach($hierarchy['questgroups'] as $i => &$questgroup) { // Check permission of Questgroups - if($i >= 1) + if($i >= 1 && count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) == 0) { if(!$this->Questgroups->hasCharacterSolvedQuestgroup($hierarchy['questgroups'][$i-1]['id'], $character['id'])) { diff --git a/views/html/quests/quest.tpl b/views/html/quests/quest.tpl index f914471b..3bad451e 100644 --- a/views/html/quests/quest.tpl +++ b/views/html/quests/quest.tpl @@ -55,21 +55,21 @@

-

+

t($quest['task'])?>

- - -

:

- + +

:

+ + + +

+ +