get next and previous Questgroups for correct Seminary (fixes #92)
This commit is contained in:
parent
980ed7d014
commit
fa2dc75be6
3 changed files with 27 additions and 24 deletions
|
|
@ -92,7 +92,7 @@
|
||||||
// Only check permissions if Character has not entered Quest before
|
// Only check permissions if Character has not entered Quest before
|
||||||
if(!$this->Questgroups->hasCharacterEnteredQuestgroup($questgroup['id'], $character['id']))
|
if(!$this->Questgroups->hasCharacterEnteredQuestgroup($questgroup['id'], $character['id']))
|
||||||
{
|
{
|
||||||
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($questgroup['id']);
|
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($seminary['id'], $questgroup['id']);
|
||||||
if(!is_null($previousQuestgroup)) {
|
if(!is_null($previousQuestgroup)) {
|
||||||
if(!$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) {
|
if(!$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) {
|
||||||
throw new \nre\exceptions\AccessDeniedException();
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
|
|
@ -316,7 +316,6 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
// Upload moodpic
|
// Upload moodpic
|
||||||
var_dump($moodpic);
|
|
||||||
if(!is_null($moodpic))
|
if(!is_null($moodpic))
|
||||||
{
|
{
|
||||||
$mediaId = $this->Media->createQuestgrouppicture(
|
$mediaId = $this->Media->createQuestgrouppicture(
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@
|
||||||
if(count($previousQuests) == 0)
|
if(count($previousQuests) == 0)
|
||||||
{
|
{
|
||||||
// Previous Questgroup
|
// Previous Questgroup
|
||||||
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($questgroup['id']);
|
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($seminary['id'], $questgroup['id']);
|
||||||
if(!is_null($previousQuestgroup) && !$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) {
|
if(!is_null($previousQuestgroup) && !$this->Questgroups->hasCharacterSolvedQuestgroup($previousQuestgroup['id'], $character['id'])) {
|
||||||
throw new \nre\exceptions\AccessDeniedException();
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
}
|
}
|
||||||
|
|
@ -309,7 +309,7 @@
|
||||||
{
|
{
|
||||||
if(is_null($relatedQuesttext))
|
if(is_null($relatedQuesttext))
|
||||||
{
|
{
|
||||||
$nextQuestgroup = $this->Questgroups->getNextQuestgroup($questgroup['id']);
|
$nextQuestgroup = $this->Questgroups->getNextQuestgroup($seminary['id'], $questgroup['id']);
|
||||||
if(!is_null($nextQuestgroup)) {
|
if(!is_null($nextQuestgroup)) {
|
||||||
$nextQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($nextQuestgroup['id']);
|
$nextQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($nextQuestgroup['id']);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,10 +166,11 @@
|
||||||
* on the same level as the given Quest then the followed-up
|
* on the same level as the given Quest then the followed-up
|
||||||
* Questgroup from a higher hierarchy level is returned.
|
* Questgroup from a higher hierarchy level is returned.
|
||||||
*
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
* @param int $questgroupId ID of Questgroup to get next Questgroup of
|
* @param int $questgroupId ID of Questgroup to get next Questgroup of
|
||||||
* @return array Questgroup data
|
* @return array Questgroup data
|
||||||
*/
|
*/
|
||||||
public function getNextQuestgroup($questgroupId)
|
public function getNextQuestgroup($seminaryId, $questgroupId)
|
||||||
{
|
{
|
||||||
$currentQuestgroup = $this->getQuestgroupById($questgroupId);
|
$currentQuestgroup = $this->getQuestgroupById($questgroupId);
|
||||||
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
||||||
|
|
@ -177,9 +178,9 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nextQuestgroup = $this->_getNextQuestgroup($currentQuestgroup['hierarchy']['parent_questgroup_id'], $currentQuestgroup['hierarchy']['questgroup_pos']);
|
$nextQuestgroup = $this->_getNextQuestgroup($seminaryId, $currentQuestgroup['hierarchy']['parent_questgroup_id'], $currentQuestgroup['hierarchy']['questgroup_pos']);
|
||||||
if(is_null($nextQuestgroup) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id'])) {
|
if(is_null($nextQuestgroup) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id'])) {
|
||||||
$nextQuestgroup = $this->getNextQuestgroup($currentQuestgroup['hierarchy']['parent_questgroup_id']);
|
$nextQuestgroup = $this->getNextQuestgroup($seminaryId, $currentQuestgroup['hierarchy']['parent_questgroup_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -195,10 +196,11 @@
|
||||||
* followed-up Questgroup from a higher hierarchy level is
|
* followed-up Questgroup from a higher hierarchy level is
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
* @param int $questgroupId ID of Questgroup to get previous Questgroup of
|
* @param int $questgroupId ID of Questgroup to get previous Questgroup of
|
||||||
* @return array Questgroup data
|
* @return array Questgroup data
|
||||||
*/
|
*/
|
||||||
public function getPreviousQuestgroup($questgroupId)
|
public function getPreviousQuestgroup($seminaryId, $questgroupId)
|
||||||
{
|
{
|
||||||
$currentQuestgroup = $this->getQuestgroupById($questgroupId);
|
$currentQuestgroup = $this->getQuestgroupById($questgroupId);
|
||||||
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
||||||
|
|
@ -206,9 +208,9 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$previousQuestgroup = $this->_getPreviousQuestgroup($currentQuestgroup['hierarchy']['parent_questgroup_id'], $currentQuestgroup['hierarchy']['questgroup_pos']);
|
$previousQuestgroup = $this->_getPreviousQuestgroup($seminaryId, $currentQuestgroup['hierarchy']['parent_questgroup_id'], $currentQuestgroup['hierarchy']['questgroup_pos']);
|
||||||
if(is_null($previousQuestgroup) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id'])) {
|
if(is_null($previousQuestgroup) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id'])) {
|
||||||
$previousQuestgroup = $this->getPreviousQuestgroup($currentQuestgroup['hierarchy']['parent_questgroup_id']);
|
$previousQuestgroup = $this->getPreviousQuestgroup($seminaryId, $currentQuestgroup['hierarchy']['parent_questgroup_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -752,11 +754,12 @@
|
||||||
/**
|
/**
|
||||||
* Get the next (direct) Questgroup.
|
* Get the next (direct) Questgroup.
|
||||||
*
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
* @param int $parentQuestgroupId ID of parent Questgroup to get next Questgroup of
|
* @param int $parentQuestgroupId ID of parent Questgroup to get next Questgroup of
|
||||||
* @param int $questgroupPos Position of Questgroup to get next Questgroup of
|
* @param int $questgroupPos Position of Questgroup to get next Questgroup of
|
||||||
* @return array Data of next Questgroup or NULL
|
* @return array Data of next Questgroup or NULL
|
||||||
*/
|
*/
|
||||||
private function _getNextQuestgroup($parentQuestgroupId, $questgroupPos)
|
private function _getNextQuestgroup($seminaryId, $parentQuestgroupId, $questgroupPos)
|
||||||
{
|
{
|
||||||
if(!is_null($parentQuestgroupId))
|
if(!is_null($parentQuestgroupId))
|
||||||
{
|
{
|
||||||
|
|
@ -764,9 +767,9 @@
|
||||||
'SELECT * '.
|
'SELECT * '.
|
||||||
'FROM questgroups_questgroupshierarchy '.
|
'FROM questgroups_questgroupshierarchy '.
|
||||||
'INNER JOIN questgroups ON questgroups.id = questgroups_questgroupshierarchy.questgroup_id '.
|
'INNER JOIN questgroups ON questgroups.id = questgroups_questgroupshierarchy.questgroup_id '.
|
||||||
'WHERE parent_questgroup_id = ? AND pos = ? + 1',
|
'WHERE seminary_id = ? AND parent_questgroup_id = ? AND pos = ? + 1',
|
||||||
'ii',
|
'iii',
|
||||||
$parentQuestgroupId, $questgroupPos
|
$seminaryId, $parentQuestgroupId, $questgroupPos
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -775,9 +778,9 @@
|
||||||
'SELECT * '.
|
'SELECT * '.
|
||||||
'FROM questgroups_questgroupshierarchy '.
|
'FROM questgroups_questgroupshierarchy '.
|
||||||
'INNER JOIN questgroups ON questgroups.id = questgroups_questgroupshierarchy.questgroup_id '.
|
'INNER JOIN questgroups ON questgroups.id = questgroups_questgroupshierarchy.questgroup_id '.
|
||||||
'WHERE parent_questgroup_id IS NULL AND pos = ? + 1',
|
'WHERE seminary_id = ? AND parent_questgroup_id IS NULL AND pos = ? + 1',
|
||||||
'i',
|
'ii',
|
||||||
$questgroupPos
|
$seminaryId, $questgroupPos
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(empty($data)) {
|
if(empty($data)) {
|
||||||
|
|
@ -792,11 +795,12 @@
|
||||||
/**
|
/**
|
||||||
* Get the previous (direct) Questgroup.
|
* Get the previous (direct) Questgroup.
|
||||||
*
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
* @param int $parentQuestgroupId ID of parent Questgroup to get previous Questgroup of
|
* @param int $parentQuestgroupId ID of parent Questgroup to get previous Questgroup of
|
||||||
* @param int $questgroupPos Position of Questgroup to get previous Questgroup of
|
* @param int $questgroupPos Position of Questgroup to get previous Questgroup of
|
||||||
* @return array Data of previous Questgroup or NULL
|
* @return array Data of previous Questgroup or NULL
|
||||||
*/
|
*/
|
||||||
private function _getPreviousQuestgroup($parentQuestgroupId, $questgroupPos)
|
private function _getPreviousQuestgroup($seminaryId, $parentQuestgroupId, $questgroupPos)
|
||||||
{
|
{
|
||||||
if(!is_null($parentQuestgroupId))
|
if(!is_null($parentQuestgroupId))
|
||||||
{
|
{
|
||||||
|
|
@ -804,9 +808,9 @@
|
||||||
'SELECT * '.
|
'SELECT * '.
|
||||||
'FROM questgroups_questgroupshierarchy '.
|
'FROM questgroups_questgroupshierarchy '.
|
||||||
'INNER JOIN questgroups ON questgroups.id = questgroups_questgroupshierarchy.questgroup_id '.
|
'INNER JOIN questgroups ON questgroups.id = questgroups_questgroupshierarchy.questgroup_id '.
|
||||||
'WHERE parent_questgroup_id = ? AND pos = ? - 1',
|
'WHERE seminary_id = ? AND parent_questgroup_id = ? AND pos = ? - 1',
|
||||||
'ii',
|
'iii',
|
||||||
$parentQuestgroupId, $questgroupPos
|
$seminaryId, $parentQuestgroupId, $questgroupPos
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -815,9 +819,9 @@
|
||||||
'SELECT * '.
|
'SELECT * '.
|
||||||
'FROM questgroups_questgroupshierarchy '.
|
'FROM questgroups_questgroupshierarchy '.
|
||||||
'INNER JOIN questgroups ON questgroups.id = questgroups_questgroupshierarchy.questgroup_id '.
|
'INNER JOIN questgroups ON questgroups.id = questgroups_questgroupshierarchy.questgroup_id '.
|
||||||
'WHERE parent_questgroup_id IS NULL AND pos = ? - 1',
|
'WHERE seminary_id = ? AND parent_questgroup_id IS NULL AND pos = ? - 1',
|
||||||
'i',
|
'ii',
|
||||||
$questgroupPos
|
$seminaryId, $questgroupPos
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(empty($data)) {
|
if(empty($data)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue