do not check Questgroup and Quest permissions for Seminary-admins and -moderators
This commit is contained in:
parent
8dcbe6e7de
commit
5a0e1193ec
4 changed files with 56 additions and 50 deletions
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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']))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,21 +55,21 @@
|
|||
<section>
|
||||
<?php if(!is_null($task)) : ?>
|
||||
<h1 id="task"><?=_('Task')?></h1>
|
||||
<p><?=\hhu\z\Utils::t($quest['task'])?></p>
|
||||
<p><?=$t->t($quest['task'])?></p>
|
||||
<?=$task?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if($solved && !is_null($task)) : ?>
|
||||
<p><?=_('Task already successfully solved')?>:</p>
|
||||
<?php endif ?>
|
||||
<?php if($solved) : ?>
|
||||
<p><?=_('Task already successfully solved')?>:
|
||||
<ul>
|
||||
<?php if(!is_null($task)) : ?>
|
||||
<li><a href="<?=$linker->link(null,0,false,array('show-answer'=>'true'),true,'task')?>"><?=_('Show answer')?></a></li>
|
||||
<li><a href="<?=$linker->link('Epilog',5)?>"><?=_('Skip Quest')?></a></l>
|
||||
<?php elseif(count($nextquests) == 0) : ?>
|
||||
<li><a href="<?=$linker->link('Epilog',5)?>"><?=_('continue')?></a></l>
|
||||
<?php endif ?>
|
||||
<li><a href="<?=$linker->link(null,0,false,array('show-answer'=>'true'),true,'task')?>"><?=_('Show answer')?></a></li>
|
||||
<li><a href="<?=$linker->link('Epilog',5)?>"><?=_('Skip Quest')?></a></l>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
<?php else : ?>
|
||||
<?php if(count($nextquests) == 0) : ?>
|
||||
<p><a href="<?=$linker->link('Epilog',5)?>"><?=_('continue')?></a></p>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue