check additional permissions of previous parent Questgroups for Questgroups and Quests
This commit is contained in:
parent
9b55b2cbae
commit
b3e7303a1a
2 changed files with 41 additions and 8 deletions
|
|
@ -89,7 +89,25 @@
|
||||||
// Check permission
|
// Check permission
|
||||||
if(count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) == 0)
|
if(count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) == 0)
|
||||||
{
|
{
|
||||||
// Only check permissions if Character has not entered Quest before
|
// Check permission of previous parent Questgroups
|
||||||
|
$parentQuestgroup = $questgroup;
|
||||||
|
print_r($parentQuestgroup);
|
||||||
|
while(!is_null($parentQuestgroup['hierarchy']['parent_questgroup_id']))
|
||||||
|
{
|
||||||
|
$parentQuestgroup = $this->Questgroups->getQuestgroupById($parentQuestgroup['hierarchy']['parent_questgroup_id']);
|
||||||
|
$parentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($parentQuestgroup['id']);
|
||||||
|
try {
|
||||||
|
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($seminary['id'], $parentQuestgroup['id']);
|
||||||
|
if(!$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) {
|
||||||
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check permission of previous Questgroup
|
||||||
|
// (only if Character has not entered Questgroup before)
|
||||||
if(!$this->Questgroups->hasCharacterEnteredQuestgroup($questgroup['id'], $character['id']))
|
if(!$this->Questgroups->hasCharacterEnteredQuestgroup($questgroup['id'], $character['id']))
|
||||||
{
|
{
|
||||||
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($seminary['id'], $questgroup['id']);
|
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($seminary['id'], $questgroup['id']);
|
||||||
|
|
|
||||||
|
|
@ -180,16 +180,31 @@
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if(count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) == 0)
|
if(count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) == 0)
|
||||||
{
|
{
|
||||||
$previousQuests = $this->Quests->getPreviousQuests($quest['id']);
|
// Previous Questgroup
|
||||||
if(count($previousQuests) == 0)
|
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($seminary['id'], $questgroup['id']);
|
||||||
|
if(!is_null($previousQuestgroup) && !$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) {
|
||||||
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
|
}
|
||||||
|
// Previous parents of previous Questgroup
|
||||||
|
$parentQuestgroup = $previousQuestgroup;
|
||||||
|
$parentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($parentQuestgroup['id']);
|
||||||
|
while(!is_null($parentQuestgroup['hierarchy']['parent_questgroup_id']))
|
||||||
{
|
{
|
||||||
// Previous Questgroup
|
$parentQuestgroup = $this->Questgroups->getQuestgroupById($parentQuestgroup['hierarchy']['parent_questgroup_id']);
|
||||||
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($seminary['id'], $questgroup['id']);
|
$parentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($parentQuestgroup['id']);
|
||||||
if(!is_null($previousQuestgroup) && !$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) {
|
try {
|
||||||
throw new \nre\exceptions\AccessDeniedException();
|
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($seminary['id'], $parentQuestgroup['id']);
|
||||||
|
if(!$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) {
|
||||||
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Previous Quests
|
||||||
|
$previousQuests = $this->Quests->getPreviousQuests($quest['id']);
|
||||||
|
if(count($previousQuests) > 0)
|
||||||
{
|
{
|
||||||
// Previous Quests
|
// Previous Quests
|
||||||
// One previous Quest has to be solved and no other
|
// One previous Quest has to be solved and no other
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue