implement basic Questgroups and Quests structure
This commit is contained in:
parent
ff85002070
commit
efd4f990fa
19 changed files with 774 additions and 8 deletions
85
models/QuestsModel.inc
Normal file
85
models/QuestsModel.inc
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The Legend of Z
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||
* @license http://www.gnu.org/licenses/gpl.html
|
||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||
*/
|
||||
|
||||
namespace hhu\z\models;
|
||||
|
||||
|
||||
/**
|
||||
* Model to interact with Quests-table.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class QuestsModel extends \hhu\z\Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new QuestsModel.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get all Quests for the given Questgroup.
|
||||
*
|
||||
* @param int $questgroupId ID of a Questgroup
|
||||
* @return array Quests of the given Questgroup
|
||||
*/
|
||||
public function getQuestsForQuestgroup($questgroupId)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT id, questtype_id, title, url, xps, text '.
|
||||
'FROM quests '.
|
||||
'WHERE questgroup_id = ?',
|
||||
'i',
|
||||
$questgroupId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a Quest and its data by its URL.
|
||||
*
|
||||
* @throws IdNotFoundException
|
||||
* @param int $seminaryId ID of the corresponding Seminary
|
||||
* @param int $questgroupId ID of the corresponding Questgroup
|
||||
* @param string $questURL URL-title of a Quest
|
||||
* @return array Quest data
|
||||
*/
|
||||
public function getQuestByUrl($seminaryId, $questgroupId, $questUrl)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT quests.id, quests.questtype_id, quests.title, quests.url, quests.xps, quests.text '.
|
||||
'FROM quests '.
|
||||
'LEFT JOIN questgroups ON questgroups.id = quests.questgroup_id '.
|
||||
'LEFT JOIN questgroupshierarchy ON questgroupshierarchy.id = questgroups.questgroupshierarchy_id '.
|
||||
'WHERE questgroupshierarchy.seminary_id = ? AND questgroups.id = ? AND quests.url = ?',
|
||||
'iis',
|
||||
$seminaryId, $questgroupId, $questUrl
|
||||
);
|
||||
if(empty($data)) {
|
||||
throw new \nre\exceptions\IdNotFoundException($questUrl);
|
||||
}
|
||||
|
||||
|
||||
return $data[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue