implement basic CRUD for Quests
This commit is contained in:
parent
0a880b26c8
commit
66bd4ee08b
10 changed files with 840 additions and 156 deletions
|
|
@ -48,6 +48,33 @@
|
||||||
{
|
{
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: create.
|
||||||
|
*/
|
||||||
|
public function create(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edit.
|
||||||
|
*/
|
||||||
|
public function edit(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: delete.
|
||||||
|
*/
|
||||||
|
public function delete(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -242,8 +242,8 @@
|
||||||
array('^questgroups/([^/]+)/([^/]+)/?$', 'questgroups/questgroup/$1/$2', true),
|
array('^questgroups/([^/]+)/([^/]+)/?$', 'questgroups/questgroup/$1/$2', true),
|
||||||
array('^quests/([^/]+)/?$', 'quests/index/$1', true),
|
array('^quests/([^/]+)/?$', 'quests/index/$1', true),
|
||||||
array('^quests/([^/]+)/all/?$', 'quests/index/$1/all', true),
|
array('^quests/([^/]+)/all/?$', 'quests/index/$1/all', true),
|
||||||
array('^quests/([^/]+)/(create|createmedia)/?$', 'quests/$2/$1' , true),
|
array('^quests/([^/]+)/([^/]+)/(create|createmedia)/?$', 'quests/$3/$1/$2', true),
|
||||||
array('^quests/([^/]+)/([^/]+)/([^/]+)/(submissions)/?$', 'quests/$4/$1/$2/$3', true),
|
array('^quests/([^/]+)/([^/]+)/([^/]+)/(submissions|edit|delete)/?$', 'quests/$4/$1/$2/$3', true),
|
||||||
array('^quests/([^/]+)/([^/]+)/([^/]+)/(submission)/([^/]+)/?$', 'quests/$4/$1/$2/$3/$5', true),
|
array('^quests/([^/]+)/([^/]+)/([^/]+)/(submission)/([^/]+)/?$', 'quests/$4/$1/$2/$3/$5', true),
|
||||||
array('^quests/(?!(index|create|createmedia))/?', 'quests/quest/$1', true),
|
array('^quests/(?!(index|create|createmedia))/?', 'quests/quest/$1', true),
|
||||||
array('^characters/([^/]+)/(register|manage)/?$', 'characters/$2/$1', true),
|
array('^characters/([^/]+)/(register|manage)/?$', 'characters/$2/$1', true),
|
||||||
|
|
@ -287,11 +287,11 @@
|
||||||
array('^questgroups/create/(.*)$', 'questgroups/$1/create', true),
|
array('^questgroups/create/(.*)$', 'questgroups/$1/create', true),
|
||||||
array('^questgroups/questgroup/(.*)$', 'questgroups/$1', true),
|
array('^questgroups/questgroup/(.*)$', 'questgroups/$1', true),
|
||||||
array('^questgroups/(edit|delete|moveup|movedown)/(.*)$', 'questgroups/$2/$1', true),
|
array('^questgroups/(edit|delete|moveup|movedown)/(.*)$', 'questgroups/$2/$1', true),
|
||||||
array('^quests/index/(.+)$', 'quests/$1', true),
|
array('^quests/index/(.+)$', 'quests/$1', true),
|
||||||
array('^quests/quest/(.*)$', 'quests/$1', true),
|
array('^quests/quest/(.*)$', 'quests/$1', true),
|
||||||
array('^quests/(create|createmedia)/(.*)$', 'quests/$2/$1' , true),
|
array('^quests/(create|createmedia)/(.*)$', 'quests/$2/$1' , true),
|
||||||
array('^quests/(submissions)/(.*)$', 'quests/$2/$1', true),
|
array('^quests/(submissions)/(.*)$', 'quests/$2/$1', true),
|
||||||
array('^quests/(submission)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$', 'quests/$2/$3/$4/$1/$5', true),
|
array('^quests/(submission|edit|delete)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$', 'quests/$2/$3/$4/$1/$5', true),
|
||||||
array('^characters/(index|character)/(.*)$', 'characters/$2', true),
|
array('^characters/(index|character)/(.*)$', 'characters/$2', true),
|
||||||
array('^characters/(register|manage)/([^/]+)$', 'characters/$2/$1', true),
|
array('^characters/(register|manage)/([^/]+)$', 'characters/$2/$1', true),
|
||||||
array('^characters/(edit|delete)/([^/]+)/([^/]+)$', 'characters/$2/$3/$1', true),
|
array('^characters/(edit|delete)/([^/]+)/([^/]+)$', 'characters/$2/$3/$1', true),
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('seminaries', 'questgroups', 'quests', 'questtexts', 'media', 'questtypes', 'questgroupshierarchy', 'xplevels');
|
public $models = array('seminaries', 'questgroups', 'quests', 'questtexts', 'media', 'questtypes', 'questgroupshierarchy', 'xplevels');
|
||||||
|
/**
|
||||||
|
* Required components
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $components = array('validation');
|
||||||
/**
|
/**
|
||||||
* User permissions
|
* User permissions
|
||||||
*
|
*
|
||||||
|
|
@ -35,7 +41,9 @@
|
||||||
'quest' => array('admin', 'moderator', 'user'),
|
'quest' => array('admin', 'moderator', 'user'),
|
||||||
'submissions' => array('admin', 'moderator', 'user'),
|
'submissions' => array('admin', 'moderator', 'user'),
|
||||||
'submission' => array('admin', 'moderator', 'user'),
|
'submission' => array('admin', 'moderator', 'user'),
|
||||||
'create' => array('admin', 'moderator', 'user')
|
'create' => array('admin', 'moderator', 'user'),
|
||||||
|
'edit' => array('admin', 'moderator', 'user'),
|
||||||
|
'delete' => array('admin', 'moderator', 'user')
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* User seminary permissions
|
* User seminary permissions
|
||||||
|
|
@ -47,7 +55,9 @@
|
||||||
'quest' => array('admin', 'moderator', 'user'),
|
'quest' => array('admin', 'moderator', 'user'),
|
||||||
'submissions' => array('admin', 'moderator'),
|
'submissions' => array('admin', 'moderator'),
|
||||||
'submission' => array('admin', 'moderator'),
|
'submission' => array('admin', 'moderator'),
|
||||||
'create' => array('admin', 'moderator')
|
'create' => array('admin', 'moderator'),
|
||||||
|
'edit' => array('admin', 'moderator'),
|
||||||
|
'delete' => array('admin')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -445,42 +455,49 @@
|
||||||
* Create a new Quest.
|
* Create a new Quest.
|
||||||
*
|
*
|
||||||
* @param string $seminaryUrl URL-Title of a Seminary
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
|
* @param string $questgroupUrl URL-Title of Questgroup
|
||||||
*/
|
*/
|
||||||
public function create($seminaryUrl)
|
public function create($seminaryUrl, $questgroupUrl)
|
||||||
{
|
{
|
||||||
// Get seminary
|
// Get seminary
|
||||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Get Questgroup
|
||||||
|
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
|
||||||
|
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
|
||||||
|
$questgroup['picture'] = (!is_null($questgroup['questgroupspicture_id'])) ? $this->Media->getSeminaryMediaById($questgroup['questgroupspicture_id']) : null;
|
||||||
|
|
||||||
// Quest groups
|
// Get Quest types
|
||||||
$questgroups = $this->Questgroups->getQuestgroupsForSeminary($seminary['id']);
|
|
||||||
|
|
||||||
// Quest types
|
|
||||||
$questtypes = $this->Questtypes->getQuesttypes();
|
$questtypes = $this->Questtypes->getQuesttypes();
|
||||||
|
foreach($questtypes as &$questtype) {
|
||||||
|
$questtype['selected'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get allowed mimetypes
|
||||||
|
$mimetypes = \nre\configs\AppConfig::$mimetypes['moodpics'];
|
||||||
|
|
||||||
|
// Values
|
||||||
|
$title = '';
|
||||||
|
$xps = 0;
|
||||||
|
$task = '';
|
||||||
|
$entryText = '';
|
||||||
|
$wrongText = '';
|
||||||
|
$fields = array('title', 'xps');
|
||||||
|
$validation = array();
|
||||||
|
|
||||||
// Create Quest
|
// Check request method
|
||||||
$validation = true;
|
|
||||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
||||||
{
|
{
|
||||||
// TODO Validation
|
// Get params and validate them
|
||||||
$name = $this->request->getPostParam('name');
|
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||||
|
$title = $this->request->getPostParam('title');
|
||||||
|
if($this->Quests->questTitleExists($title, $seminary['id'])) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
|
||||||
|
}
|
||||||
$xps = $this->request->getPostParam('xps');
|
$xps = $this->request->getPostParam('xps');
|
||||||
$prolog = $this->request->getPostParam('prolog');
|
|
||||||
$entrytext = $this->request->getPostParam('entrytext');
|
|
||||||
$wrongtext = $this->request->getPostParam('wrongtext');
|
|
||||||
$task = $this->request->getPostParam('task');
|
$task = $this->request->getPostParam('task');
|
||||||
|
$entryText = $this->request->getPostParam('entrytext');
|
||||||
// Validate Questgroup
|
$wrongText = $this->request->getPostParam('wrongtext');
|
||||||
$questgroupIndex = null;
|
|
||||||
foreach($questgroups as $index => &$questgroup)
|
|
||||||
{
|
|
||||||
$questgroup['selected'] = ($questgroup['url'] == $this->request->getPostParam('questgroup'));
|
|
||||||
if($questgroup['selected']) {
|
|
||||||
$questgroupIndex = $index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(is_null($questgroupIndex)) {
|
|
||||||
throw new \nre\exceptions\ParamsNotValidException($questgroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate Questtype
|
// Validate Questtype
|
||||||
$questtypeIndex = null;
|
$questtypeIndex = null;
|
||||||
|
|
@ -495,15 +512,32 @@
|
||||||
throw new \nre\exceptions\ParamsNotValidException($questtype);
|
throw new \nre\exceptions\ParamsNotValidException($questtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Questmedia
|
// Validate media
|
||||||
$questmedia = null;
|
$media = null;
|
||||||
if(array_key_exists('questmedia', $_FILES) && !empty($_FILES['questmedia']) && $_FILES['questmedia']['error'] == 0) {
|
if(!empty($_FILES) && array_key_exists('media', $_FILES) && $_FILES['media']['error'] != UPLOAD_ERR_NO_FILE)
|
||||||
$questmedia = $_FILES['questmedia'];
|
{
|
||||||
}
|
$media = $_FILES['media'];
|
||||||
|
|
||||||
// Process Prolog
|
// Check error
|
||||||
if(!empty($prolog)) {
|
if($media['error'] !== UPLOAD_ERR_OK) {
|
||||||
$prolog = preg_split('/\s*(_|=){5,}\s*/', $prolog, -1, PREG_SPLIT_NO_EMPTY);
|
$validation = $this->Validation->addValidationResult($validation, 'media', 'error', $media['error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check mimetype
|
||||||
|
$mediaMimetype = null;
|
||||||
|
$media['mimetype'] = \hhu\z\Utils::getMimetype($media['tmp_name'], $media['type']);
|
||||||
|
foreach($mimetypes as &$mimetype) {
|
||||||
|
if($mimetype['mimetype'] == $media['mimetype']) {
|
||||||
|
$mediaMimetype = $mimetype;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(is_null($mediaMimetype)) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'media', 'mimetype', $media['mimetype']);
|
||||||
|
}
|
||||||
|
elseif($media['size'] > $mediaMimetype['size']) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'media', 'size', $mediaMimetype['size']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new Quest
|
// Create new Quest
|
||||||
|
|
@ -511,41 +545,42 @@
|
||||||
{
|
{
|
||||||
$questId = $this->Quests->createQuest(
|
$questId = $this->Quests->createQuest(
|
||||||
$this->Auth->getUserId(),
|
$this->Auth->getUserId(),
|
||||||
$name,
|
$questgroup['id'],
|
||||||
$questgroups[$questgroupIndex]['id'],
|
|
||||||
$questtypes[$questtypeIndex]['id'],
|
$questtypes[$questtypeIndex]['id'],
|
||||||
|
$title,
|
||||||
$xps,
|
$xps,
|
||||||
$entrytext,
|
$task,
|
||||||
$wrongtext,
|
$entryText,
|
||||||
$task
|
$wrongText
|
||||||
);
|
);
|
||||||
|
$quest = $this->Quests->getQuestById($questId);
|
||||||
|
|
||||||
// Create Questmedia
|
// Update picture
|
||||||
if(!is_null($questmedia))
|
if(!is_null($media))
|
||||||
{
|
{
|
||||||
$questsmediaId = $this->Media->createQuestMedia(
|
$questsmediaId = $this->Media->createQuestMedia(
|
||||||
$this->Auth->getUserId(),
|
$this->Auth->getUserId(),
|
||||||
$seminary['id'],
|
$seminary['id'],
|
||||||
$questmedia['name'],
|
$media['name'],
|
||||||
$name,
|
$title,
|
||||||
$questmedia['type'],
|
$media['type'],
|
||||||
$questmedia['tmp_name']
|
$media['tmp_name']
|
||||||
);
|
);
|
||||||
if($questsmediaId > 0) {
|
if($questsmediaId > 0) {
|
||||||
$this->Quests->setQuestmedia($questId, $questsmediaId);
|
$this->Quests->setQuestmedia($quest['id'], $questsmediaId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Prolog-texts
|
|
||||||
if(!empty($prolog)) {
|
|
||||||
$this->Questtexts->addQuesttextsToQuest($this->Auth->getUserId(), $questId, 'Prolog', $prolog);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Redirect
|
// Redirect
|
||||||
$this->redirect($this->linker->link(array('quests', 'index', $seminary['url'])));
|
$this->redirect($this->linker->link(array('quest', $seminary['url'], $questgroup['url'], $quest['url']), 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get validation settings
|
||||||
|
$validationSettings = array();
|
||||||
|
foreach($fields as &$field) {
|
||||||
|
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set titile
|
// Set titile
|
||||||
|
|
@ -554,8 +589,237 @@
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('seminary', $seminary);
|
$this->set('seminary', $seminary);
|
||||||
$this->set('questgroups', $questgroups);
|
$this->set('questgroup', $questgroup);
|
||||||
|
$this->set('mimetypes', $mimetypes);
|
||||||
$this->set('questtypes', $questtypes);
|
$this->set('questtypes', $questtypes);
|
||||||
|
$this->set('title', $title);
|
||||||
|
$this->set('task', $task);
|
||||||
|
$this->set('entryText', $entryText);
|
||||||
|
$this->set('wrongText', $wrongText);
|
||||||
|
$this->set('xps', $xps);
|
||||||
|
$this->set('questtype_id', $questtype);
|
||||||
|
$this->set('validation', $validation);
|
||||||
|
$this->set('validationSettings', $validationSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edit.
|
||||||
|
*
|
||||||
|
* Edit a Quest of a Seminary.
|
||||||
|
*
|
||||||
|
* @throws IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-Title of Seminary
|
||||||
|
* @param string $questgroupUrl URL-Title of Questgroup
|
||||||
|
* @param string $questUrl URL-Title of Quest
|
||||||
|
*/
|
||||||
|
public function edit($seminaryUrl, $questgroupUrl, $questUrl)
|
||||||
|
{
|
||||||
|
// Get Seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Get Questgroup
|
||||||
|
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
|
||||||
|
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
|
||||||
|
$questgroup['picture'] = (!is_null($questgroup['questgroupspicture_id'])) ? $this->Media->getSeminaryMediaById($questgroup['questgroupspicture_id']) : null;
|
||||||
|
|
||||||
|
// Get Quest
|
||||||
|
$quest = $this->Quests->getQuestByUrl($seminary['id'], $questgroup['id'], $questUrl);
|
||||||
|
|
||||||
|
// Get Quest media
|
||||||
|
$questmedia = null;
|
||||||
|
if(!is_null($quest['questsmedia_id'])) {
|
||||||
|
$questmedia = $this->Media->getSeminaryMediaById($quest['questsmedia_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Quest types
|
||||||
|
$questtypes = $this->Questtypes->getQuesttypes();
|
||||||
|
foreach($questtypes as &$questtype) {
|
||||||
|
$questtype['selected'] = ($questtype['id'] == $quest['questtype_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get allowed mimetypes
|
||||||
|
$mimetypes = \nre\configs\AppConfig::$mimetypes['moodpics'];
|
||||||
|
|
||||||
|
// Values
|
||||||
|
$title = $quest['title'];
|
||||||
|
$xps = $quest['xps'];
|
||||||
|
$task = $quest['task'];
|
||||||
|
$entryText = $quest['entry_text'];
|
||||||
|
$wrongText = $quest['wrong_text'];
|
||||||
|
$fields = array('title', 'xps');
|
||||||
|
$validation = array();
|
||||||
|
|
||||||
|
// Check request method
|
||||||
|
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
|
||||||
|
{
|
||||||
|
// Get params and validate them
|
||||||
|
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||||
|
$title = $this->request->getPostParam('title');
|
||||||
|
if($this->Quests->questTitleExists($title, $seminary['id'], $quest['id'])) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
|
||||||
|
}
|
||||||
|
$xps = $this->request->getPostParam('xps');
|
||||||
|
$task = $this->request->getPostParam('task');
|
||||||
|
$entryText = $this->request->getPostParam('entrytext');
|
||||||
|
$wrongText = $this->request->getPostParam('wrongtext');
|
||||||
|
|
||||||
|
// Validate Questtype
|
||||||
|
$questtypeIndex = null;
|
||||||
|
foreach($questtypes as $index => &$questtype)
|
||||||
|
{
|
||||||
|
$questtype['selected'] = ($questtype['url'] == $this->request->getPostParam('questtype'));
|
||||||
|
if($questtype['selected']) {
|
||||||
|
$questtypeIndex = $index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(is_null($questtypeIndex)) {
|
||||||
|
throw new \nre\exceptions\ParamsNotValidException($questtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate media
|
||||||
|
$media = null;
|
||||||
|
if(!empty($_FILES) && array_key_exists('media', $_FILES) && $_FILES['media']['error'] != UPLOAD_ERR_NO_FILE)
|
||||||
|
{
|
||||||
|
$media = $_FILES['media'];
|
||||||
|
|
||||||
|
// Check error
|
||||||
|
if($media['error'] !== UPLOAD_ERR_OK) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'media', 'error', $media['error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check mimetype
|
||||||
|
$mediaMimetype = null;
|
||||||
|
$media['mimetype'] = \hhu\z\Utils::getMimetype($media['tmp_name'], $media['type']);
|
||||||
|
foreach($mimetypes as &$mimetype) {
|
||||||
|
if($mimetype['mimetype'] == $media['mimetype']) {
|
||||||
|
$mediaMimetype = $mimetype;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(is_null($mediaMimetype)) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'media', 'mimetype', $media['mimetype']);
|
||||||
|
}
|
||||||
|
elseif($media['size'] > $mediaMimetype['size']) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'media', 'size', $mediaMimetype['size']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit Quest
|
||||||
|
if($validation === true)
|
||||||
|
{
|
||||||
|
$this->Quests->editQuest(
|
||||||
|
$quest['id'],
|
||||||
|
$questtypes[$questtypeIndex]['id'],
|
||||||
|
$title,
|
||||||
|
$xps,
|
||||||
|
$task,
|
||||||
|
$entryText,
|
||||||
|
$wrongText
|
||||||
|
);
|
||||||
|
$quest = $this->Quests->getQuestById($quest['id']);
|
||||||
|
|
||||||
|
// Update picture
|
||||||
|
if(!is_null($media))
|
||||||
|
{
|
||||||
|
$questsmediaId = $this->Media->createQuestMedia(
|
||||||
|
$this->Auth->getUserId(),
|
||||||
|
$seminary['id'],
|
||||||
|
$media['name'],
|
||||||
|
$title,
|
||||||
|
$media['type'],
|
||||||
|
$media['tmp_name']
|
||||||
|
);
|
||||||
|
if($questsmediaId > 0) {
|
||||||
|
$this->Quests->setQuestmedia($quest['id'], $questsmediaId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to entry
|
||||||
|
$this->redirect($this->linker->link(array('quest', $seminary['url'], $questgroup['url'], $quest['url']), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get validation settings
|
||||||
|
$validationSettings = array();
|
||||||
|
foreach($fields as &$field) {
|
||||||
|
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Edit Quest');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('questgroup', $questgroup);
|
||||||
|
$this->set('quest', $quest);
|
||||||
|
$this->set('media', $questmedia);
|
||||||
|
$this->set('mimetypes', $mimetypes);
|
||||||
|
$this->set('questtypes', $questtypes);
|
||||||
|
$this->set('title', $title);
|
||||||
|
$this->set('task', $task);
|
||||||
|
$this->set('entryText', $entryText);
|
||||||
|
$this->set('wrongText', $wrongText);
|
||||||
|
$this->set('xps', $xps);
|
||||||
|
$this->set('questtype_id', $questtype);
|
||||||
|
$this->set('validation', $validation);
|
||||||
|
$this->set('validationSettings', $validationSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: delete.
|
||||||
|
*
|
||||||
|
* Delete a Quest of a Seminary.
|
||||||
|
*
|
||||||
|
* @throws IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-Title of Seminary
|
||||||
|
* @param string $questgroupUrl URL-Title of Questgroup
|
||||||
|
* @param string $questUrl URL-Title of Quest
|
||||||
|
*/
|
||||||
|
public function delete($seminaryUrl, $questgroupUrl, $questUrl)
|
||||||
|
{
|
||||||
|
// Get Seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Get Questgroup
|
||||||
|
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
|
||||||
|
$questgroup['picture'] = null;
|
||||||
|
if(!is_null($questgroup['questgroupspicture_id'])) {
|
||||||
|
$questgroup['picture'] = $this->Media->getSeminaryMediaById($questgroup['questgroupspicture_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Quest
|
||||||
|
$quest = $this->Quests->getQuestByUrl($seminary['id'], $questgroup['id'], $questUrl);
|
||||||
|
|
||||||
|
// Check request method
|
||||||
|
if($this->request->getRequestMethod() == 'POST')
|
||||||
|
{
|
||||||
|
// Check confirmation
|
||||||
|
if(!is_null($this->request->getPostParam('delete')))
|
||||||
|
{
|
||||||
|
// Delete seminary
|
||||||
|
$this->Quests->deleteQuest($quest['id']);
|
||||||
|
|
||||||
|
// Redirect to Questgroup
|
||||||
|
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to entry
|
||||||
|
$this->redirect($this->linker->link(array('seminary', $seminary['url']), 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Delete Quest');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('questgroup', $questgroup);
|
||||||
|
$this->set('quest', $quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,8 +1,8 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: The Legend of Z\n"
|
"Project-Id-Version: The Legend of Z\n"
|
||||||
"POT-Creation-Date: 2014-06-24 21:56+0100\n"
|
"POT-Creation-Date: 2014-07-01 15:40+0100\n"
|
||||||
"PO-Revision-Date: 2014-06-24 21:56+0100\n"
|
"PO-Revision-Date: 2014-07-01 15:41+0100\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: de_DE\n"
|
"Language: de_DE\n"
|
||||||
|
|
@ -63,8 +63,8 @@ msgstr "Neuer Lösungsvorschlag"
|
||||||
msgid "Character submission approved"
|
msgid "Character submission approved"
|
||||||
msgstr "Lösungsvorschlag bewertet"
|
msgstr "Lösungsvorschlag bewertet"
|
||||||
|
|
||||||
#: controllers/QuestsController.inc:740
|
#: controllers/QuestsController.inc:1004
|
||||||
#: questtypes/submit/html/submission.tpl:30 views/html/quests/quest.tpl:45
|
#: questtypes/submit/html/submission.tpl:30 views/html/quests/quest.tpl:53
|
||||||
#: views/html/quests/submissions.tpl:30
|
#: views/html/quests/submissions.tpl:30
|
||||||
msgid "solved"
|
msgid "solved"
|
||||||
msgstr "Richtig!"
|
msgstr "Richtig!"
|
||||||
|
|
@ -76,7 +76,7 @@ msgstr "Richtig!"
|
||||||
msgid "lost"
|
msgid "lost"
|
||||||
msgstr "verloren"
|
msgstr "verloren"
|
||||||
|
|
||||||
#: questtypes/bossfight/html/quest.tpl:41 views/html/quests/quest.tpl:120
|
#: questtypes/bossfight/html/quest.tpl:41 views/html/quests/quest.tpl:128
|
||||||
msgid "Choose"
|
msgid "Choose"
|
||||||
msgstr "Wählen"
|
msgstr "Wählen"
|
||||||
|
|
||||||
|
|
@ -132,6 +132,7 @@ msgstr "Fehler beim Dateiupload: %s"
|
||||||
#: views/html/charactergroupsquests/edit.tpl:67
|
#: views/html/charactergroupsquests/edit.tpl:67
|
||||||
#: views/html/charactergroupsquests/manage.tpl:63
|
#: views/html/charactergroupsquests/manage.tpl:63
|
||||||
#: views/html/questgroups/create.tpl:65 views/html/questgroups/edit.tpl:53
|
#: views/html/questgroups/create.tpl:65 views/html/questgroups/edit.tpl:53
|
||||||
|
#: views/html/quests/create.tpl:62 views/html/quests/edit.tpl:65
|
||||||
#: views/html/seminaries/create.tpl:60 views/html/seminaries/edit.tpl:62
|
#: views/html/seminaries/create.tpl:60 views/html/seminaries/edit.tpl:62
|
||||||
msgid "Allowed file types"
|
msgid "Allowed file types"
|
||||||
msgstr "Erlaubte Dateiformate"
|
msgstr "Erlaubte Dateiformate"
|
||||||
|
|
@ -143,6 +144,7 @@ msgstr "Erlaubte Dateiformate"
|
||||||
#: views/html/charactergroupsquests/edit.tpl:70
|
#: views/html/charactergroupsquests/edit.tpl:70
|
||||||
#: views/html/charactergroupsquests/manage.tpl:63
|
#: views/html/charactergroupsquests/manage.tpl:63
|
||||||
#: views/html/questgroups/create.tpl:68 views/html/questgroups/edit.tpl:56
|
#: views/html/questgroups/create.tpl:68 views/html/questgroups/edit.tpl:56
|
||||||
|
#: views/html/quests/create.tpl:65 views/html/quests/edit.tpl:68
|
||||||
#: views/html/seminaries/create.tpl:63 views/html/seminaries/edit.tpl:65
|
#: views/html/seminaries/create.tpl:63 views/html/seminaries/edit.tpl:65
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s-files"
|
msgid "%s-files"
|
||||||
|
|
@ -155,6 +157,7 @@ msgstr "%s-Dateien"
|
||||||
#: views/html/charactergroupsquests/edit.tpl:70
|
#: views/html/charactergroupsquests/edit.tpl:70
|
||||||
#: views/html/charactergroupsquests/manage.tpl:63
|
#: views/html/charactergroupsquests/manage.tpl:63
|
||||||
#: views/html/questgroups/create.tpl:68 views/html/questgroups/edit.tpl:56
|
#: views/html/questgroups/create.tpl:68 views/html/questgroups/edit.tpl:56
|
||||||
|
#: views/html/quests/create.tpl:65 views/html/quests/edit.tpl:68
|
||||||
#: views/html/seminaries/create.tpl:63 views/html/seminaries/edit.tpl:65
|
#: views/html/seminaries/create.tpl:63 views/html/seminaries/edit.tpl:65
|
||||||
msgid "max."
|
msgid "max."
|
||||||
msgstr "max."
|
msgstr "max."
|
||||||
|
|
@ -188,47 +191,55 @@ msgstr "Bewertet von %s am %s um %s Uhr"
|
||||||
msgid "Comment"
|
msgid "Comment"
|
||||||
msgstr "Kommentar"
|
msgstr "Kommentar"
|
||||||
|
|
||||||
#: questtypes/submit/html/submission.tpl:31 views/html/quests/quest.tpl:50
|
#: questtypes/submit/html/submission.tpl:31 views/html/quests/quest.tpl:58
|
||||||
#: views/html/quests/submissions.tpl:20
|
#: views/html/quests/submissions.tpl:20
|
||||||
msgid "unsolved"
|
msgid "unsolved"
|
||||||
msgstr "Leider falsch!"
|
msgstr "Leider falsch!"
|
||||||
|
|
||||||
#: views/ajax/quests/index.tpl:9 views/html/quests/index.tpl:27
|
#: views/ajax/quests/index.tpl:9 views/html/quests/create.tpl:79
|
||||||
|
#: views/html/quests/edit.tpl:82 views/html/quests/index.tpl:27
|
||||||
#: views/html/quests/index.tpl:59
|
#: views/html/quests/index.tpl:59
|
||||||
msgid "Questtype Empty"
|
msgid "Questtype Empty"
|
||||||
msgstr "Leere Aufgabe"
|
msgstr "Leere Aufgabe"
|
||||||
|
|
||||||
#: views/ajax/quests/index.tpl:11 views/html/quests/index.tpl:29
|
#: views/ajax/quests/index.tpl:11 views/html/quests/create.tpl:81
|
||||||
|
#: views/html/quests/edit.tpl:84 views/html/quests/index.tpl:29
|
||||||
#: views/html/quests/index.tpl:61
|
#: views/html/quests/index.tpl:61
|
||||||
msgid "Questtype bossfight"
|
msgid "Questtype bossfight"
|
||||||
msgstr "Boss-Fight"
|
msgstr "Boss-Fight"
|
||||||
|
|
||||||
#: views/ajax/quests/index.tpl:13 views/html/quests/index.tpl:31
|
#: views/ajax/quests/index.tpl:13 views/html/quests/create.tpl:83
|
||||||
|
#: views/html/quests/edit.tpl:86 views/html/quests/index.tpl:31
|
||||||
#: views/html/quests/index.tpl:63
|
#: views/html/quests/index.tpl:63
|
||||||
msgid "Questtype choiceinput"
|
msgid "Questtype choiceinput"
|
||||||
msgstr "Auswahleingabe"
|
msgstr "Auswahleingabe"
|
||||||
|
|
||||||
#: views/ajax/quests/index.tpl:15 views/html/quests/index.tpl:33
|
#: views/ajax/quests/index.tpl:15 views/html/quests/create.tpl:85
|
||||||
|
#: views/html/quests/edit.tpl:88 views/html/quests/index.tpl:33
|
||||||
#: views/html/quests/index.tpl:65
|
#: views/html/quests/index.tpl:65
|
||||||
msgid "Questtype crossword"
|
msgid "Questtype crossword"
|
||||||
msgstr "Kreuzworträtsel"
|
msgstr "Kreuzworträtsel"
|
||||||
|
|
||||||
#: views/ajax/quests/index.tpl:17 views/html/quests/index.tpl:35
|
#: views/ajax/quests/index.tpl:17 views/html/quests/create.tpl:87
|
||||||
|
#: views/html/quests/edit.tpl:90 views/html/quests/index.tpl:35
|
||||||
#: views/html/quests/index.tpl:67
|
#: views/html/quests/index.tpl:67
|
||||||
msgid "Questtype dragndrop"
|
msgid "Questtype dragndrop"
|
||||||
msgstr "Drag&Drop"
|
msgstr "Drag&Drop"
|
||||||
|
|
||||||
#: views/ajax/quests/index.tpl:19 views/html/quests/index.tpl:37
|
#: views/ajax/quests/index.tpl:19 views/html/quests/create.tpl:89
|
||||||
|
#: views/html/quests/edit.tpl:92 views/html/quests/index.tpl:37
|
||||||
#: views/html/quests/index.tpl:69
|
#: views/html/quests/index.tpl:69
|
||||||
msgid "Questtype multiplechoice"
|
msgid "Questtype multiplechoice"
|
||||||
msgstr "Multiple Choice"
|
msgstr "Multiple Choice"
|
||||||
|
|
||||||
#: views/ajax/quests/index.tpl:21 views/html/quests/index.tpl:39
|
#: views/ajax/quests/index.tpl:21 views/html/quests/create.tpl:91
|
||||||
|
#: views/html/quests/edit.tpl:94 views/html/quests/index.tpl:39
|
||||||
#: views/html/quests/index.tpl:71
|
#: views/html/quests/index.tpl:71
|
||||||
msgid "Questtype submit"
|
msgid "Questtype submit"
|
||||||
msgstr "Abgabeaufgabe"
|
msgstr "Abgabeaufgabe"
|
||||||
|
|
||||||
#: views/ajax/quests/index.tpl:23 views/html/quests/index.tpl:41
|
#: views/ajax/quests/index.tpl:23 views/html/quests/create.tpl:93
|
||||||
|
#: views/html/quests/edit.tpl:96 views/html/quests/index.tpl:41
|
||||||
#: views/html/quests/index.tpl:73
|
#: views/html/quests/index.tpl:73
|
||||||
msgid "Questtype textinput"
|
msgid "Questtype textinput"
|
||||||
msgstr "Texteingabe"
|
msgstr "Texteingabe"
|
||||||
|
|
@ -453,8 +464,7 @@ msgstr "Icon"
|
||||||
#: views/html/charactergroups/editgroupsgroup.tpl:46
|
#: views/html/charactergroups/editgroupsgroup.tpl:46
|
||||||
#: views/html/charactergroups/editgroupsgroup.tpl:47
|
#: views/html/charactergroups/editgroupsgroup.tpl:47
|
||||||
#: views/html/charactertypes/manage.tpl:88
|
#: views/html/charactertypes/manage.tpl:88
|
||||||
#: views/html/charactertypes/manage.tpl:89 views/html/quests/create.tpl:15
|
#: views/html/charactertypes/manage.tpl:89 views/html/users/user.tpl:23
|
||||||
#: views/html/quests/create.tpl:16 views/html/users/user.tpl:23
|
|
||||||
msgid "Name"
|
msgid "Name"
|
||||||
msgstr "Name"
|
msgstr "Name"
|
||||||
|
|
||||||
|
|
@ -472,7 +482,7 @@ msgstr "Motto"
|
||||||
#: views/html/charactertypes/manage.tpl:91 views/html/library/create.tpl:46
|
#: views/html/charactertypes/manage.tpl:91 views/html/library/create.tpl:46
|
||||||
#: views/html/library/edit.tpl:124 views/html/questgroups/create.tpl:76
|
#: views/html/library/edit.tpl:124 views/html/questgroups/create.tpl:76
|
||||||
#: views/html/questgroupshierarchy/create.tpl:63
|
#: views/html/questgroupshierarchy/create.tpl:63
|
||||||
#: views/html/quests/create.tpl:43 views/html/seminaries/create.tpl:75
|
#: views/html/quests/create.tpl:110 views/html/seminaries/create.tpl:75
|
||||||
#: views/html/users/create.tpl:96
|
#: views/html/users/create.tpl:96
|
||||||
msgid "create"
|
msgid "create"
|
||||||
msgstr "erstellen"
|
msgstr "erstellen"
|
||||||
|
|
@ -504,7 +514,8 @@ msgstr "Soll die %s-Gruppen „%s“ wirklich gelöscht werden?"
|
||||||
#: views/html/library/delete.tpl:14 views/html/library/edit.tpl:83
|
#: views/html/library/delete.tpl:14 views/html/library/edit.tpl:83
|
||||||
#: views/html/questgroups/delete.tpl:17
|
#: views/html/questgroups/delete.tpl:17
|
||||||
#: views/html/questgroupshierarchy/delete.tpl:14
|
#: views/html/questgroupshierarchy/delete.tpl:14
|
||||||
#: views/html/seminaries/delete.tpl:13 views/html/users/delete.tpl:11
|
#: views/html/quests/delete.tpl:11 views/html/seminaries/delete.tpl:13
|
||||||
|
#: views/html/users/delete.tpl:11
|
||||||
msgid "delete"
|
msgid "delete"
|
||||||
msgstr "löschen"
|
msgstr "löschen"
|
||||||
|
|
||||||
|
|
@ -514,7 +525,8 @@ msgstr "löschen"
|
||||||
#: views/html/characters/delete.tpl:18 views/html/library/delete.tpl:15
|
#: views/html/characters/delete.tpl:18 views/html/library/delete.tpl:15
|
||||||
#: views/html/questgroups/delete.tpl:18
|
#: views/html/questgroups/delete.tpl:18
|
||||||
#: views/html/questgroupshierarchy/delete.tpl:15
|
#: views/html/questgroupshierarchy/delete.tpl:15
|
||||||
#: views/html/seminaries/delete.tpl:14 views/html/users/delete.tpl:12
|
#: views/html/quests/delete.tpl:12 views/html/seminaries/delete.tpl:14
|
||||||
|
#: views/html/users/delete.tpl:12
|
||||||
msgid "cancel"
|
msgid "cancel"
|
||||||
msgstr "abbrechen"
|
msgstr "abbrechen"
|
||||||
|
|
||||||
|
|
@ -538,7 +550,7 @@ msgstr "%s-Gruppe bearbeiten"
|
||||||
#: views/html/charactergroups/editgroupsgroup.tpl:50
|
#: views/html/charactergroups/editgroupsgroup.tpl:50
|
||||||
#: views/html/charactergroupsquests/edit.tpl:94
|
#: views/html/charactergroupsquests/edit.tpl:94
|
||||||
#: views/html/characters/edit.tpl:108 views/html/questgroups/edit.tpl:64
|
#: views/html/characters/edit.tpl:108 views/html/questgroups/edit.tpl:64
|
||||||
#: views/html/questgroupshierarchy/edit.tpl:57
|
#: views/html/questgroupshierarchy/edit.tpl:57 views/html/quests/edit.tpl:113
|
||||||
#: views/html/seminaries/edit.tpl:77
|
#: views/html/seminaries/edit.tpl:77
|
||||||
msgid "edit"
|
msgid "edit"
|
||||||
msgstr "bearbeiten"
|
msgstr "bearbeiten"
|
||||||
|
|
@ -587,8 +599,9 @@ msgstr "%squests"
|
||||||
#: views/html/charactergroupsquests/edit.tpl:78
|
#: views/html/charactergroupsquests/edit.tpl:78
|
||||||
#: views/html/characters/index.tpl:23 views/html/characters/index.tpl:84
|
#: views/html/characters/index.tpl:23 views/html/characters/index.tpl:84
|
||||||
#: views/html/characters/manage.tpl:17
|
#: views/html/characters/manage.tpl:17
|
||||||
#: views/html/questgroups/questgroup.tpl:56 views/html/quests/create.tpl:29
|
#: views/html/questgroups/questgroup.tpl:62 views/html/quests/create.tpl:72
|
||||||
#: views/html/quests/create.tpl:30
|
#: views/html/quests/create.tpl:73 views/html/quests/edit.tpl:75
|
||||||
|
#: views/html/quests/edit.tpl:76
|
||||||
msgid "XPs"
|
msgid "XPs"
|
||||||
msgstr "XP"
|
msgstr "XP"
|
||||||
|
|
||||||
|
|
@ -619,8 +632,8 @@ msgid "Add Characters"
|
||||||
msgstr "Füge Charaktere hinzu"
|
msgstr "Füge Charaktere hinzu"
|
||||||
|
|
||||||
#: views/html/charactergroups/managegroup.tpl:59
|
#: views/html/charactergroups/managegroup.tpl:59
|
||||||
#: views/html/questgroups/questgroup.tpl:102 views/html/quests/create.tpl:9
|
#: views/html/questgroups/questgroup.tpl:21
|
||||||
#: views/html/quests/index.tpl:9
|
#: views/html/questgroups/questgroup.tpl:108 views/html/quests/index.tpl:9
|
||||||
msgid "Quests"
|
msgid "Quests"
|
||||||
msgstr "Quests"
|
msgstr "Quests"
|
||||||
|
|
||||||
|
|
@ -634,6 +647,7 @@ msgstr "Neue %s-Quest"
|
||||||
#: views/html/library/create.tpl:22 views/html/library/edit.tpl:22
|
#: views/html/library/create.tpl:22 views/html/library/edit.tpl:22
|
||||||
#: views/html/library/edit.tpl:62 views/html/library/edit.tpl:100
|
#: views/html/library/edit.tpl:62 views/html/library/edit.tpl:100
|
||||||
#: views/html/questgroups/create.tpl:33 views/html/questgroups/edit.tpl:30
|
#: views/html/questgroups/create.tpl:33 views/html/questgroups/edit.tpl:30
|
||||||
|
#: views/html/quests/create.tpl:30 views/html/quests/edit.tpl:30
|
||||||
#: views/html/seminaries/create.tpl:30 views/html/seminaries/edit.tpl:32
|
#: views/html/seminaries/create.tpl:30 views/html/seminaries/edit.tpl:32
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "Title is too short (min. %d chars)"
|
msgid "Title is too short (min. %d chars)"
|
||||||
|
|
@ -644,6 +658,7 @@ msgstr "Der Titel ist zu kurz (min. %d Zeichen)"
|
||||||
#: views/html/library/create.tpl:24 views/html/library/edit.tpl:24
|
#: views/html/library/create.tpl:24 views/html/library/edit.tpl:24
|
||||||
#: views/html/library/edit.tpl:64 views/html/library/edit.tpl:102
|
#: views/html/library/edit.tpl:64 views/html/library/edit.tpl:102
|
||||||
#: views/html/questgroups/create.tpl:35 views/html/questgroups/edit.tpl:32
|
#: views/html/questgroups/create.tpl:35 views/html/questgroups/edit.tpl:32
|
||||||
|
#: views/html/quests/create.tpl:32 views/html/quests/edit.tpl:32
|
||||||
#: views/html/seminaries/create.tpl:32 views/html/seminaries/edit.tpl:34
|
#: views/html/seminaries/create.tpl:32 views/html/seminaries/edit.tpl:34
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "Title is too long (max. %d chars)"
|
msgid "Title is too long (max. %d chars)"
|
||||||
|
|
@ -654,6 +669,7 @@ msgstr "Der Titel ist zu lang (max. %d Zeichen)"
|
||||||
#: views/html/library/create.tpl:26 views/html/library/edit.tpl:26
|
#: views/html/library/create.tpl:26 views/html/library/edit.tpl:26
|
||||||
#: views/html/library/edit.tpl:66 views/html/library/edit.tpl:104
|
#: views/html/library/edit.tpl:66 views/html/library/edit.tpl:104
|
||||||
#: views/html/questgroups/create.tpl:37 views/html/questgroups/edit.tpl:34
|
#: views/html/questgroups/create.tpl:37 views/html/questgroups/edit.tpl:34
|
||||||
|
#: views/html/quests/create.tpl:34 views/html/quests/edit.tpl:34
|
||||||
#: views/html/seminaries/create.tpl:34 views/html/seminaries/edit.tpl:36
|
#: views/html/seminaries/create.tpl:34 views/html/seminaries/edit.tpl:36
|
||||||
msgid "Title contains illegal characters"
|
msgid "Title contains illegal characters"
|
||||||
msgstr "Der Titel enthält ungültige Zeichen"
|
msgstr "Der Titel enthält ungültige Zeichen"
|
||||||
|
|
@ -663,6 +679,7 @@ msgstr "Der Titel enthält ungültige Zeichen"
|
||||||
#: views/html/library/create.tpl:28 views/html/library/edit.tpl:28
|
#: views/html/library/create.tpl:28 views/html/library/edit.tpl:28
|
||||||
#: views/html/library/edit.tpl:68 views/html/library/edit.tpl:106
|
#: views/html/library/edit.tpl:68 views/html/library/edit.tpl:106
|
||||||
#: views/html/questgroups/create.tpl:39 views/html/questgroups/edit.tpl:36
|
#: views/html/questgroups/create.tpl:39 views/html/questgroups/edit.tpl:36
|
||||||
|
#: views/html/quests/create.tpl:36 views/html/quests/edit.tpl:36
|
||||||
#: views/html/seminaries/create.tpl:36 views/html/seminaries/edit.tpl:38
|
#: views/html/seminaries/create.tpl:36 views/html/seminaries/edit.tpl:38
|
||||||
msgid "Title already exists"
|
msgid "Title already exists"
|
||||||
msgstr "Der Titel existiert bereits"
|
msgstr "Der Titel existiert bereits"
|
||||||
|
|
@ -672,23 +689,27 @@ msgstr "Der Titel existiert bereits"
|
||||||
#: views/html/library/create.tpl:30 views/html/library/edit.tpl:30
|
#: views/html/library/create.tpl:30 views/html/library/edit.tpl:30
|
||||||
#: views/html/library/edit.tpl:70 views/html/library/edit.tpl:108
|
#: views/html/library/edit.tpl:70 views/html/library/edit.tpl:108
|
||||||
#: views/html/questgroups/create.tpl:41 views/html/questgroups/edit.tpl:38
|
#: views/html/questgroups/create.tpl:41 views/html/questgroups/edit.tpl:38
|
||||||
|
#: views/html/quests/create.tpl:38 views/html/quests/edit.tpl:38
|
||||||
#: views/html/seminaries/create.tpl:38 views/html/seminaries/edit.tpl:40
|
#: views/html/seminaries/create.tpl:38 views/html/seminaries/edit.tpl:40
|
||||||
msgid "Title invalid"
|
msgid "Title invalid"
|
||||||
msgstr "Der Titel ist ungültig"
|
msgstr "Der Titel ist ungültig"
|
||||||
|
|
||||||
#: views/html/charactergroupsquests/create.tpl:47
|
#: views/html/charactergroupsquests/create.tpl:47
|
||||||
#: views/html/charactergroupsquests/edit.tpl:47
|
#: views/html/charactergroupsquests/edit.tpl:47
|
||||||
|
#: views/html/quests/create.tpl:43 views/html/quests/edit.tpl:43
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "XPs not set"
|
msgid "XPs not set"
|
||||||
msgstr "XP nicht angegeben"
|
msgstr "XP nicht angegeben"
|
||||||
|
|
||||||
#: views/html/charactergroupsquests/create.tpl:49
|
#: views/html/charactergroupsquests/create.tpl:49
|
||||||
#: views/html/charactergroupsquests/edit.tpl:49
|
#: views/html/charactergroupsquests/edit.tpl:49
|
||||||
|
#: views/html/quests/create.tpl:45 views/html/quests/edit.tpl:45
|
||||||
msgid "XPs contain illegal characters"
|
msgid "XPs contain illegal characters"
|
||||||
msgstr "Die XP-Angabe enthält ungültige Zeichen"
|
msgstr "Die XP-Angabe enthält ungültige Zeichen"
|
||||||
|
|
||||||
#: views/html/charactergroupsquests/create.tpl:51
|
#: views/html/charactergroupsquests/create.tpl:51
|
||||||
#: views/html/charactergroupsquests/edit.tpl:51
|
#: views/html/charactergroupsquests/edit.tpl:51
|
||||||
|
#: views/html/quests/create.tpl:47 views/html/quests/edit.tpl:47
|
||||||
msgid "XPs invalid"
|
msgid "XPs invalid"
|
||||||
msgstr "Die XP-Angabe ist ungültig"
|
msgstr "Die XP-Angabe ist ungültig"
|
||||||
|
|
||||||
|
|
@ -701,7 +722,9 @@ msgstr "Die XP-Angabe ist ungültig"
|
||||||
#: views/html/library/edit.tpl:121 views/html/library/edit.tpl:122
|
#: views/html/library/edit.tpl:121 views/html/library/edit.tpl:122
|
||||||
#: views/html/questgroups/create.tpl:73 views/html/questgroups/create.tpl:74
|
#: views/html/questgroups/create.tpl:73 views/html/questgroups/create.tpl:74
|
||||||
#: views/html/questgroups/edit.tpl:61 views/html/questgroups/edit.tpl:62
|
#: views/html/questgroups/edit.tpl:61 views/html/questgroups/edit.tpl:62
|
||||||
#: views/html/questgroups/questgroup.tpl:82 views/html/quests/index.tpl:47
|
#: views/html/questgroups/questgroup.tpl:88 views/html/quests/create.tpl:70
|
||||||
|
#: views/html/quests/create.tpl:71 views/html/quests/edit.tpl:73
|
||||||
|
#: views/html/quests/edit.tpl:74 views/html/quests/index.tpl:47
|
||||||
#: views/html/quests/index.tpl:48 views/html/seminaries/create.tpl:68
|
#: views/html/quests/index.tpl:48 views/html/seminaries/create.tpl:68
|
||||||
#: views/html/seminaries/create.tpl:69 views/html/seminaries/edit.tpl:70
|
#: views/html/seminaries/create.tpl:69 views/html/seminaries/edit.tpl:70
|
||||||
#: views/html/seminaries/edit.tpl:71 views/html/seminaries/seminary.tpl:69
|
#: views/html/seminaries/edit.tpl:71 views/html/seminaries/seminary.tpl:69
|
||||||
|
|
@ -710,8 +733,7 @@ msgstr "Titel"
|
||||||
|
|
||||||
#: views/html/charactergroupsquests/create.tpl:78
|
#: views/html/charactergroupsquests/create.tpl:78
|
||||||
#: views/html/charactergroupsquests/edit.tpl:79
|
#: views/html/charactergroupsquests/edit.tpl:79
|
||||||
#: views/html/questgroups/create.tpl:58 views/html/quests/create.tpl:17
|
#: views/html/questgroups/create.tpl:58 views/html/quests/index.tpl:14
|
||||||
#: views/html/quests/index.tpl:14
|
|
||||||
msgid "Questgroup"
|
msgid "Questgroup"
|
||||||
msgstr "Questgruppe"
|
msgstr "Questgruppe"
|
||||||
|
|
||||||
|
|
@ -1148,33 +1170,37 @@ msgstr "Soll das die Questgruppe „%s“ wirklich gelöscht werden?"
|
||||||
msgid "Edit Questgroup"
|
msgid "Edit Questgroup"
|
||||||
msgstr "Questgruppe bearbeiten"
|
msgstr "Questgruppe bearbeiten"
|
||||||
|
|
||||||
#: views/html/questgroups/questgroup.tpl:34
|
#: views/html/questgroups/questgroup.tpl:17
|
||||||
|
msgid "Create new Quest"
|
||||||
|
msgstr "Neue Quest erstellen"
|
||||||
|
|
||||||
|
#: views/html/questgroups/questgroup.tpl:40
|
||||||
#: views/html/questgroupshierarchy/edit.tpl:11
|
#: views/html/questgroupshierarchy/edit.tpl:11
|
||||||
#: views/html/seminaries/seminary.tpl:28
|
#: views/html/seminaries/seminary.tpl:28
|
||||||
msgid "Edit Questgroupshierarchy"
|
msgid "Edit Questgroupshierarchy"
|
||||||
msgstr "Hierarchie bearbeiten"
|
msgstr "Hierarchie bearbeiten"
|
||||||
|
|
||||||
#: views/html/questgroups/questgroup.tpl:35
|
#: views/html/questgroups/questgroup.tpl:41
|
||||||
#: views/html/questgroupshierarchy/delete.tpl:11
|
#: views/html/questgroupshierarchy/delete.tpl:11
|
||||||
#: views/html/seminaries/seminary.tpl:29
|
#: views/html/seminaries/seminary.tpl:29
|
||||||
msgid "Delete Questgroupshierarchy"
|
msgid "Delete Questgroupshierarchy"
|
||||||
msgstr "Hierarchie löschen"
|
msgstr "Hierarchie löschen"
|
||||||
|
|
||||||
#: views/html/questgroups/questgroup.tpl:60
|
#: views/html/questgroups/questgroup.tpl:66
|
||||||
msgid "Found optional Questline"
|
msgid "Found optional Questline"
|
||||||
msgstr "Optionale Questline gefunden"
|
msgstr "Optionale Questline gefunden"
|
||||||
|
|
||||||
#: views/html/questgroups/questgroup.tpl:83
|
#: views/html/questgroups/questgroup.tpl:89
|
||||||
#: views/html/seminaries/seminary.tpl:70
|
#: views/html/seminaries/seminary.tpl:70
|
||||||
msgid "Add new Questgroup"
|
msgid "Add new Questgroup"
|
||||||
msgstr "Neue Questgruppe hinzufügen"
|
msgstr "Neue Questgruppe hinzufügen"
|
||||||
|
|
||||||
#: views/html/questgroups/questgroup.tpl:92
|
#: views/html/questgroups/questgroup.tpl:98
|
||||||
#: views/html/seminaries/seminary.tpl:80
|
#: views/html/seminaries/seminary.tpl:80
|
||||||
msgid "New Questgroupshierarchy"
|
msgid "New Questgroupshierarchy"
|
||||||
msgstr "Neue Hierarchie"
|
msgstr "Neue Hierarchie"
|
||||||
|
|
||||||
#: views/html/questgroups/questgroup.tpl:93
|
#: views/html/questgroups/questgroup.tpl:99
|
||||||
#: views/html/questgroupshierarchy/create.tpl:52
|
#: views/html/questgroupshierarchy/create.tpl:52
|
||||||
#: views/html/questgroupshierarchy/create.tpl:53
|
#: views/html/questgroupshierarchy/create.tpl:53
|
||||||
#: views/html/questgroupshierarchy/edit.tpl:52
|
#: views/html/questgroupshierarchy/edit.tpl:52
|
||||||
|
|
@ -1183,7 +1209,7 @@ msgstr "Neue Hierarchie"
|
||||||
msgid "Title (singular)"
|
msgid "Title (singular)"
|
||||||
msgstr "Titel (singular)"
|
msgstr "Titel (singular)"
|
||||||
|
|
||||||
#: views/html/questgroups/questgroup.tpl:94
|
#: views/html/questgroups/questgroup.tpl:100
|
||||||
#: views/html/questgroupshierarchy/create.tpl:54
|
#: views/html/questgroupshierarchy/create.tpl:54
|
||||||
#: views/html/questgroupshierarchy/create.tpl:55
|
#: views/html/questgroupshierarchy/create.tpl:55
|
||||||
#: views/html/questgroupshierarchy/edit.tpl:54
|
#: views/html/questgroupshierarchy/edit.tpl:54
|
||||||
|
|
@ -1192,7 +1218,7 @@ msgstr "Titel (singular)"
|
||||||
msgid "Title (plural)"
|
msgid "Title (plural)"
|
||||||
msgstr "Titel (plural)"
|
msgstr "Titel (plural)"
|
||||||
|
|
||||||
#: views/html/questgroups/questgroup.tpl:96
|
#: views/html/questgroups/questgroup.tpl:102
|
||||||
#: views/html/seminaries/seminary.tpl:83
|
#: views/html/seminaries/seminary.tpl:83
|
||||||
msgid "Add new Questgroupshierarchy"
|
msgid "Add new Questgroupshierarchy"
|
||||||
msgstr "Neue Hierarchy hinzufügen"
|
msgstr "Neue Hierarchy hinzufügen"
|
||||||
|
|
@ -1250,21 +1276,57 @@ msgstr "Der Titel (plural) ist ungültig"
|
||||||
msgid "Should the Questgroupshierarchy “%s” really be deleted?"
|
msgid "Should the Questgroupshierarchy “%s” really be deleted?"
|
||||||
msgstr "Soll die Hierarchie „%s“ wirklich gelöscht werden?"
|
msgstr "Soll die Hierarchie „%s“ wirklich gelöscht werden?"
|
||||||
|
|
||||||
#: views/html/quests/create.tpl:11
|
#: views/html/quests/create.tpl:8
|
||||||
msgid "Create Quest"
|
msgid "Create Quest"
|
||||||
msgstr "Quest erstellen"
|
msgstr "Quest erstellen"
|
||||||
|
|
||||||
#: views/html/quests/create.tpl:37
|
#: views/html/quests/create.tpl:19 views/html/quests/edit.tpl:19
|
||||||
|
#, php-format
|
||||||
|
msgid "Error during picture upload: %s"
|
||||||
|
msgstr "Fehler beim Bildupload: %s"
|
||||||
|
|
||||||
|
#: views/html/quests/create.tpl:21 views/html/quests/edit.tpl:21
|
||||||
|
#, php-format
|
||||||
|
msgid "Picture has wrong type “%s”"
|
||||||
|
msgstr "Der Bildtyp „%s“ ist nicht erlaubt"
|
||||||
|
|
||||||
|
#: views/html/quests/create.tpl:23 views/html/quests/edit.tpl:23
|
||||||
|
msgid "Picture exceeds size maximum"
|
||||||
|
msgstr "Das Bild ist zu groß"
|
||||||
|
|
||||||
|
#: views/html/quests/create.tpl:25 views/html/quests/edit.tpl:25
|
||||||
|
msgid "Picture invalid"
|
||||||
|
msgstr "Das Bild ist ungültig"
|
||||||
|
|
||||||
|
#: views/html/quests/create.tpl:60 views/html/quests/edit.tpl:63
|
||||||
|
msgid "Picture"
|
||||||
|
msgstr "Bild"
|
||||||
|
|
||||||
|
#: views/html/quests/create.tpl:103 views/html/quests/edit.tpl:106
|
||||||
msgid "Entry text"
|
msgid "Entry text"
|
||||||
msgstr "Einstiegstext"
|
msgstr "Einstiegstext"
|
||||||
|
|
||||||
#: views/html/quests/create.tpl:39
|
#: views/html/quests/create.tpl:105 views/html/quests/edit.tpl:108
|
||||||
|
#: views/html/quests/quest.tpl:49
|
||||||
|
msgid "Task"
|
||||||
|
msgstr "Aufgabe"
|
||||||
|
|
||||||
|
#: views/html/quests/create.tpl:108 views/html/quests/edit.tpl:111
|
||||||
msgid "Wrong text"
|
msgid "Wrong text"
|
||||||
msgstr "Text für falsche Antwort"
|
msgstr "Text für falsche Antwort"
|
||||||
|
|
||||||
#: views/html/quests/create.tpl:40 views/html/quests/quest.tpl:41
|
#: views/html/quests/delete.tpl:8 views/html/quests/quest.tpl:13
|
||||||
msgid "Task"
|
msgid "Delete Quest"
|
||||||
msgstr "Aufgabe"
|
msgstr "Quest löschen"
|
||||||
|
|
||||||
|
#: views/html/quests/delete.tpl:9
|
||||||
|
#, php-format
|
||||||
|
msgid "Should the Quest “%s” really be deleted?"
|
||||||
|
msgstr "Soll die Quest „%s“ wirklich gelöscht werden?"
|
||||||
|
|
||||||
|
#: views/html/quests/edit.tpl:8 views/html/quests/quest.tpl:11
|
||||||
|
msgid "Edit Quest"
|
||||||
|
msgstr "Quest bearbeiten"
|
||||||
|
|
||||||
#: views/html/quests/index.tpl:16 views/html/quests/index.tpl:23
|
#: views/html/quests/index.tpl:16 views/html/quests/index.tpl:23
|
||||||
msgid "all"
|
msgid "all"
|
||||||
|
|
@ -1278,44 +1340,44 @@ msgstr "Questtyp"
|
||||||
msgid "open submissions"
|
msgid "open submissions"
|
||||||
msgstr "offene Lösungsvorschläge"
|
msgstr "offene Lösungsvorschläge"
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:11
|
#: views/html/quests/quest.tpl:19
|
||||||
msgid "Prolog"
|
msgid "Prolog"
|
||||||
msgstr "Prolog"
|
msgstr "Prolog"
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:46
|
#: views/html/quests/quest.tpl:54
|
||||||
msgid "Quest completed."
|
msgid "Quest completed."
|
||||||
msgstr "Quest abgeschlossen."
|
msgstr "Quest abgeschlossen."
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:46
|
#: views/html/quests/quest.tpl:54
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "You have earned %d XPs."
|
msgid "You have earned %d XPs."
|
||||||
msgstr "Du hast %d XP erhalten."
|
msgstr "Du hast %d XP erhalten."
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:62
|
#: views/html/quests/quest.tpl:70
|
||||||
msgid "Task already successfully solved"
|
msgid "Task already successfully solved"
|
||||||
msgstr "Du hast die Aufgabe bereits erfolgreich gelöst"
|
msgstr "Du hast die Aufgabe bereits erfolgreich gelöst"
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:64
|
#: views/html/quests/quest.tpl:72
|
||||||
msgid "Show answer"
|
msgid "Show answer"
|
||||||
msgstr "Lösung anzeigen"
|
msgstr "Lösung anzeigen"
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:74
|
#: views/html/quests/quest.tpl:82
|
||||||
msgid "Epilog"
|
msgid "Epilog"
|
||||||
msgstr "Epilog"
|
msgstr "Epilog"
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:100
|
#: views/html/quests/quest.tpl:108
|
||||||
msgid "Continuation"
|
msgid "Continuation"
|
||||||
msgstr "Setze deine Reise fort"
|
msgstr "Setze deine Reise fort"
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:107 views/html/quests/quest.tpl:123
|
#: views/html/quests/quest.tpl:115 views/html/quests/quest.tpl:131
|
||||||
msgid "Quest"
|
msgid "Quest"
|
||||||
msgstr "Quest"
|
msgstr "Quest"
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:125
|
#: views/html/quests/quest.tpl:133
|
||||||
msgid "Go on"
|
msgid "Go on"
|
||||||
msgstr "Fortfahren"
|
msgstr "Fortfahren"
|
||||||
|
|
||||||
#: views/html/quests/quest.tpl:134 views/html/seminaries/seminary.tpl:52
|
#: views/html/quests/quest.tpl:142 views/html/seminaries/seminary.tpl:52
|
||||||
msgid "Let’s go"
|
msgid "Let’s go"
|
||||||
msgstr "Auf ins Abenteuer!"
|
msgstr "Auf ins Abenteuer!"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,26 @@
|
||||||
$questId
|
$questId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the previous Quest for a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to set previous Quest for
|
||||||
|
* @param int $previousQuestId Id of previous Quest
|
||||||
|
*/
|
||||||
|
public function setPreviousQuest($questId, $previousQuestId)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
'REPLACE INTO quests_previousquests '.
|
||||||
|
'(quest_id, previous_quest_id) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?)',
|
||||||
|
'ii',
|
||||||
|
$questId,
|
||||||
|
$previousQuestId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -528,34 +548,80 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a Quest title already exists.
|
||||||
|
*
|
||||||
|
* @param string $title Quest title to check
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
|
* @param int $questId Do not check this ID (for editing)
|
||||||
|
* @return boolean Whether Quest title exists or not
|
||||||
|
*/
|
||||||
|
public function questTitleExists($title, $seminaryId, $questId=null)
|
||||||
|
{
|
||||||
|
$data = $this->db->query(
|
||||||
|
'SELECT quests.id '.
|
||||||
|
'FROM quests '.
|
||||||
|
'INNER JOIN questgroups ON questgroups.id = quests.questgroup_id '.
|
||||||
|
'WHERE questgroups.seminary_id = ? AND (quests.title = ? OR quests.url = ?)',
|
||||||
|
'iss',
|
||||||
|
$seminaryId,
|
||||||
|
$title,
|
||||||
|
\nre\core\Linker::createLinkParam($title)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (!empty($data) && (is_null($questId) || $questId != $data[0]['id']));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Quest.
|
* Create a new Quest.
|
||||||
*
|
*
|
||||||
* @param int $userId User-ID that creates the new character
|
* @param int $userId User-ID that creates the new character
|
||||||
* @param string $name Name for new Quest
|
|
||||||
* @param int $questgroupId ID of Questgroup
|
* @param int $questgroupId ID of Questgroup
|
||||||
* @param int $questtypeId ID of Questtype
|
* @param int $questtypeId ID of Questtype
|
||||||
|
* @param string $title Title for new Quest
|
||||||
* @param int $xps XPs for new Quest
|
* @param int $xps XPs for new Quest
|
||||||
|
* @param string $task Task for new Quest
|
||||||
* @param string $entrytext Entrytext for new Quest
|
* @param string $entrytext Entrytext for new Quest
|
||||||
* @param string $wrongtext Wrongtext for new Quest
|
* @param string $wrongtext Wrongtext for new Quest
|
||||||
* @param string $task Task for new Quest
|
|
||||||
* @return int ID of new Quest
|
* @return int ID of new Quest
|
||||||
*/
|
*/
|
||||||
public function createQuest($userId, $name, $questgroupId, $questtypeId, $xps, $entrytext, $wrongtext, $task)
|
public function createQuest($userId, $questgroupId, $questtypeId, $title, $xps, $task, $entrytext, $wrongtext)
|
||||||
{
|
{
|
||||||
$this->db->query(
|
$questId = null;
|
||||||
'INSERT INTO quests '.
|
$this->db->setAutocommit(false);
|
||||||
'(created_user_id, questgroup_id, questtype_id, title, url, xps, entry_text, wrong_text, task) '.
|
try {
|
||||||
'VALUES '.
|
// Get last Quests of Questgroup
|
||||||
'(?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
$lastQuests = $this->getLastQuestsOfQuestgroup($questgroupId);
|
||||||
'iiississs',
|
|
||||||
$userId, $questgroupId, $questtypeId,
|
// Create Quest
|
||||||
$name, \nre\core\Linker::createLinkParam($name),
|
$this->db->query(
|
||||||
$xps, $entrytext, $wrongtext, $task
|
'INSERT INTO quests '.
|
||||||
);
|
'(created_user_id, questgroup_id, questtype_id, title, url, xps, entry_text, wrong_text, task) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||||
return $this->db->getInsertId();
|
'iiississs',
|
||||||
|
$userId, $questgroupId, $questtypeId,
|
||||||
|
$title, \nre\core\Linker::createLinkParam($title),
|
||||||
|
$xps, $entrytext, $wrongtext, $task
|
||||||
|
);
|
||||||
|
$questId = $this->db->getInsertId();
|
||||||
|
|
||||||
|
// Set previous Quest
|
||||||
|
if(count($lastQuests) > 0) {
|
||||||
|
$this->setPreviousQuest($questId, $lastQuests[0]['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
return $questId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -576,6 +642,69 @@
|
||||||
$questId
|
$questId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit a new Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to edit
|
||||||
|
* @param int $questtypeId ID of Questtype
|
||||||
|
* @param string $title New title for Quest
|
||||||
|
* @param int $xps XPs for Quest
|
||||||
|
* @param string $task New task for Quest
|
||||||
|
* @param string $entrytext New entrytext for Quest
|
||||||
|
* @param string $wrongtext New wrongtext for Quest
|
||||||
|
*/
|
||||||
|
public function editQuest($questId, $questtypeId, $title, $xps, $task, $entrytext, $wrongtext)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
'UPDATE quests '.
|
||||||
|
'SET questtype_id = ?, title = ?, url = ?, xps = ?, entry_text = ?, wrong_text = ?, task = ? '.
|
||||||
|
'WHERE id = ?',
|
||||||
|
'ississsi',
|
||||||
|
$questtypeId,
|
||||||
|
$title,
|
||||||
|
\nre\core\Linker::createLinkParam($title),
|
||||||
|
$xps,
|
||||||
|
$entrytext,
|
||||||
|
$wrongtext,
|
||||||
|
$task,
|
||||||
|
$questId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public function deleteQuest($questId)
|
||||||
|
{
|
||||||
|
$this->db->setAutocommit(false);
|
||||||
|
try {
|
||||||
|
// Set previous Quests of following Quests
|
||||||
|
$previousQuests = $this->getPreviousQuests($questId);
|
||||||
|
$nextQuests = $this->getNextQuests($questId);
|
||||||
|
foreach($nextQuests as &$nextQuest) {
|
||||||
|
foreach($previousQuests as &$previousQuest) {
|
||||||
|
$this->setPreviousQuest($nextQuest['id'], $previousQuest['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete Quest
|
||||||
|
$this->db->query('DELETE FROM quests WHERE id = ?', 'i', $questId);
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,111 @@
|
||||||
<?php if(!is_null($seminary['seminarymedia_id'])) : ?>
|
<?php if(!is_null($questgroup['picture'])) : ?>
|
||||||
<div class="moodpic">
|
<div class="moodpic">
|
||||||
<img src="<?=$linker->link(array('media','seminaryheader',$seminary['url']))?>" />
|
<img src="<?=$linker->link(array('media','seminary',$seminary['url'],$questgroup['picture']['url']))?>" />
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
<?=$questgroupshierarchypath?>
|
||||||
|
|
||||||
<ul class="breadcrumbs">
|
|
||||||
<li><a href="<?=$linker->link(array('seminaries',$seminary['url']))?>"><?=$seminary['title']?></a></li>
|
|
||||||
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('index',$seminary['url']),1)?>"><?=_('Quests')?></a></li>
|
|
||||||
</ul>
|
|
||||||
<h1><?=_('Create Quest')?></h1>
|
<h1><?=_('Create Quest')?></h1>
|
||||||
|
<?php if($validation !== true) : ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($validation as $field => &$settings) : ?>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($settings as $setting => $value) : ?>
|
||||||
|
<li>
|
||||||
|
<?php switch($field) {
|
||||||
|
case 'media':
|
||||||
|
switch($setting) {
|
||||||
|
case 'error': printf(_('Error during picture upload: %s'), $value);
|
||||||
|
break;
|
||||||
|
case 'mimetype': printf(_('Picture has wrong type “%s”'), $value);
|
||||||
|
break;
|
||||||
|
case 'size': echo _('Picture exceeds size maximum');
|
||||||
|
break;
|
||||||
|
default: echo _('Picture invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'title':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('Title is too short (min. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'maxlength': printf(_('Title is too long (max. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'regex': echo _('Title contains illegal characters');
|
||||||
|
break;
|
||||||
|
case 'exist': echo _('Title already exists');
|
||||||
|
break;
|
||||||
|
default: echo _('Title invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'xps':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('XPs not set'), $value);
|
||||||
|
break;
|
||||||
|
case 'regex': echo _('XPs contain illegal characters');
|
||||||
|
break;
|
||||||
|
default: echo _('XPs invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="name"><?=_('Name')?>:</label>
|
<legend><?=_('Picture')?></legend>
|
||||||
<input type="text" name="name" value="" placeholder="<?=_('Name')?>" /><br />
|
<input type="file" name="media" accept="<?=implode(',', array_map(function($m) { return $m['mimetype']; }, $mimetypes))?>" />
|
||||||
<label for="questgroup"><?=_('Questgroup')?>:</label>
|
<p><?=_('Allowed file types')?>:</p>
|
||||||
<select name="questgroup">
|
<ul>
|
||||||
<?php foreach($questgroups as &$questgroup) : ?>
|
<?php foreach($mimetypes as &$mimetype) : ?>
|
||||||
<option value="<?=$questgroup['url']?>"><?=$questgroup['title']?></option>
|
<li><?=sprintf(_('%s-files'), strtoupper(explode('/',$mimetype['mimetype'])[1]))?> <?php if($mimetype['size'] > 0) : ?>(<?=_('max.')?> <?=round($mimetype['size']/(1024*1024),2)?> MiB)<?php endif ?></li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</select><br />
|
</ul>
|
||||||
<label for="questtype"><?=('Questtype')?>:</label>
|
|
||||||
<select name="questtype">
|
|
||||||
<?php foreach($questtypes as &$questtype) : ?>
|
|
||||||
<option value="<?=$questtype['url']?>"><?=$questtype['title']?></option>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</select><br />
|
|
||||||
<label for="name"><?=_('XPs')?>:</label>
|
|
||||||
<input type="number" name="xps" value="" placeholder="<?=_('XPs')?>" /><br />
|
|
||||||
<input type="file" name="questmedia" /><br />
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="prolog">Prolog:</label><br />
|
<label for="title"><?=_('Title')?>:</label>
|
||||||
<textarea name="prolog" placeholder="Prolog" style="width:100%; height:10em;"></textarea><br />
|
<input id="title" type="text" name="title" value="<?=$title?>" placeholder="<?=_('Title')?>" maxlength="<?=$validationSettings['title']['maxlength']?>" <?=(array_key_exists('title', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||||
|
<label for="xps"><?=_('XPs')?>:</label>
|
||||||
|
<input id="xps" type="number" name="xps" placeholder="<?=_('XPs')?>" title="<?=_('XPs')?>" pattern="<?=substr($validationSettings['xps']['regex'],1,strrpos($validationSettings['xps']['regex'],$validationSettings['xps']['regex'][0])-1)?>" value="<?=$xps?>" <?=(array_key_exists('xps', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||||
|
<label for="questtype"><?=('Questtype')?>:</label>
|
||||||
|
<select id="questtype" name="questtype">
|
||||||
|
<?php foreach($questtypes as &$questtype) : ?>
|
||||||
|
<option value="<?=$questtype['url']?>" <?php if($questtype['selected']) : ?>selected="selected"<?php endif ?>>
|
||||||
|
<?php switch($questtype['classname']) {
|
||||||
|
case null: echo _('Questtype Empty');
|
||||||
|
break;
|
||||||
|
case 'bossfight': echo _('Questtype bossfight');
|
||||||
|
break;
|
||||||
|
case 'choiceinput': echo _('Questtype choiceinput');
|
||||||
|
break;
|
||||||
|
case 'crossword': echo _('Questtype crossword');
|
||||||
|
break;
|
||||||
|
case 'dragndrop': echo _('Questtype dragndrop');
|
||||||
|
break;
|
||||||
|
case 'multiplechoice': echo _('Questtype multiplechoice');
|
||||||
|
break;
|
||||||
|
case 'submit': echo _('Questtype submit');
|
||||||
|
break;
|
||||||
|
case 'textinput': echo _('Questtype textinput');
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</select>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<?php if(is_null($questgroup['hierarchy'])) : ?>
|
||||||
<label for="entrytext"><?=('Entry text')?>:</label><br />
|
<label for="entrytext"><?=('Entry text')?>:</label><br />
|
||||||
<textarea name="entrytext" placeholder="<?=_('Entry text')?>" style="width:100%; height:10em;"></textarea><br />
|
<textarea name="entrytext" placeholder="<?=_('Entry text')?>" style="width:100%; height:10em;"><?=$entryText?></textarea><br />
|
||||||
<label for="wrongtext"><?=('Wrong text')?>:</label><br />
|
<?php endif ?>
|
||||||
<textarea name="wrongtext" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"></textarea><br />
|
|
||||||
<label for="task"><?=_('Task')?>:</label><br />
|
<label for="task"><?=_('Task')?>:</label><br />
|
||||||
<textarea name="task" placeholder="<?=('Task')?>" style="width:100%; height:10em;"></textarea><br />
|
<textarea name="task" placeholder="<?=('Task')?>" style="width:100%; height:10em;"><?=$task?></textarea><br />
|
||||||
|
<label for="wrongtext"><?=('Wrong text')?>:</label><br />
|
||||||
|
<textarea name="wrongtext" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongText?></textarea><br />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<input type="submit" name="create" value="<?=_('create')?>" />
|
<input type="submit" name="create" value="<?=_('create')?>" />
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
13
views/html/quests/delete.tpl
Normal file
13
views/html/quests/delete.tpl
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php if(!is_null($seminary['seminarymedia_id'])) : ?>
|
||||||
|
<div class="moodpic">
|
||||||
|
<img src="<?=$linker->link(array('media','seminarymoodpic',$seminary['url']))?>">
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?=$questgroupshierarchypath?>
|
||||||
|
|
||||||
|
<h1><?=_('Delete Quest')?></h1>
|
||||||
|
<?=sprintf(_('Should the Quest “%s” really be deleted?'), $quest['title'])?>
|
||||||
|
<form method="post">
|
||||||
|
<input type="submit" name="delete" value="<?=_('delete')?>" />
|
||||||
|
<input type="submit" name="not-delete" value="<?=_('cancel')?>" />
|
||||||
|
</form>
|
||||||
114
views/html/quests/edit.tpl
Normal file
114
views/html/quests/edit.tpl
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
<?php if(!is_null($questgroup['picture'])) : ?>
|
||||||
|
<div class="moodpic">
|
||||||
|
<img src="<?=$linker->link(array('media','seminary',$seminary['url'],$questgroup['picture']['url']))?>" />
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?=$questgroupshierarchypath?>
|
||||||
|
|
||||||
|
<h1><?=_('Edit Quest')?></h1>
|
||||||
|
<?php if($validation !== true) : ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($validation as $field => &$settings) : ?>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($settings as $setting => $value) : ?>
|
||||||
|
<li>
|
||||||
|
<?php switch($field) {
|
||||||
|
case 'media':
|
||||||
|
switch($setting) {
|
||||||
|
case 'error': printf(_('Error during picture upload: %s'), $value);
|
||||||
|
break;
|
||||||
|
case 'mimetype': printf(_('Picture has wrong type “%s”'), $value);
|
||||||
|
break;
|
||||||
|
case 'size': echo _('Picture exceeds size maximum');
|
||||||
|
break;
|
||||||
|
default: echo _('Picture invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'title':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('Title is too short (min. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'maxlength': printf(_('Title is too long (max. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'regex': echo _('Title contains illegal characters');
|
||||||
|
break;
|
||||||
|
case 'exist': echo _('Title already exists');
|
||||||
|
break;
|
||||||
|
default: echo _('Title invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'xps':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('XPs not set'), $value);
|
||||||
|
break;
|
||||||
|
case 'regex': echo _('XPs contain illegal characters');
|
||||||
|
break;
|
||||||
|
default: echo _('XPs invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<fieldset>
|
||||||
|
<?php if(!is_null($media)) : ?>
|
||||||
|
<a href="<?=$linker->link(array('media','seminary',$seminary['url'],$media['url']))?>"><img style="width:10em; display:block;" src="<?=$linker->link(array('media','seminary',$seminary['url'],$media['url']))?>" /></a>
|
||||||
|
<?php endif ?>
|
||||||
|
<legend><?=_('Picture')?></legend>
|
||||||
|
<input type="file" name="media" accept="<?=implode(',', array_map(function($m) { return $m['mimetype']; }, $mimetypes))?>" />
|
||||||
|
<p><?=_('Allowed file types')?>:</p>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($mimetypes as &$mimetype) : ?>
|
||||||
|
<li><?=sprintf(_('%s-files'), strtoupper(explode('/',$mimetype['mimetype'])[1]))?> <?php if($mimetype['size'] > 0) : ?>(<?=_('max.')?> <?=round($mimetype['size']/(1024*1024),2)?> MiB)<?php endif ?></li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<label for="title"><?=_('Title')?>:</label>
|
||||||
|
<input id="title" type="text" name="title" value="<?=$title?>" placeholder="<?=_('Title')?>" maxlength="<?=$validationSettings['title']['maxlength']?>" <?=(array_key_exists('title', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||||
|
<label for="xps"><?=_('XPs')?>:</label>
|
||||||
|
<input id="xps" type="number" name="xps" placeholder="<?=_('XPs')?>" title="<?=_('XPs')?>" pattern="<?=substr($validationSettings['xps']['regex'],1,strrpos($validationSettings['xps']['regex'],$validationSettings['xps']['regex'][0])-1)?>" value="<?=$xps?>" <?=(array_key_exists('xps', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||||
|
<label for="questtype"><?=('Questtype')?>:</label>
|
||||||
|
<select id="questtype" name="questtype">
|
||||||
|
<?php foreach($questtypes as &$questtype) : ?>
|
||||||
|
<option value="<?=$questtype['url']?>" <?php if($questtype['selected']) : ?>selected="selected"<?php endif ?>>
|
||||||
|
<?php switch($questtype['classname']) {
|
||||||
|
case null: echo _('Questtype Empty');
|
||||||
|
break;
|
||||||
|
case 'bossfight': echo _('Questtype bossfight');
|
||||||
|
break;
|
||||||
|
case 'choiceinput': echo _('Questtype choiceinput');
|
||||||
|
break;
|
||||||
|
case 'crossword': echo _('Questtype crossword');
|
||||||
|
break;
|
||||||
|
case 'dragndrop': echo _('Questtype dragndrop');
|
||||||
|
break;
|
||||||
|
case 'multiplechoice': echo _('Questtype multiplechoice');
|
||||||
|
break;
|
||||||
|
case 'submit': echo _('Questtype submit');
|
||||||
|
break;
|
||||||
|
case 'textinput': echo _('Questtype textinput');
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</select>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<?php if(is_null($questgroup['hierarchy'])) : ?>
|
||||||
|
<label for="entrytext"><?=('Entry text')?>:</label><br />
|
||||||
|
<textarea name="entrytext" placeholder="<?=_('Entry text')?>" style="width:100%; height:10em;"><?=$entryText?></textarea><br />
|
||||||
|
<?php endif ?>
|
||||||
|
<label for="task"><?=_('Task')?>:</label><br />
|
||||||
|
<textarea name="task" placeholder="<?=('Task')?>" style="width:100%; height:10em;"><?=$task?></textarea><br />
|
||||||
|
<label for="wrongtext"><?=('Wrong text')?>:</label><br />
|
||||||
|
<textarea name="wrongtext" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongText?></textarea><br />
|
||||||
|
</fieldset>
|
||||||
|
<input type="submit" name="edit" value="<?=_('edit')?>" />
|
||||||
|
</form>
|
||||||
|
|
@ -6,6 +6,14 @@
|
||||||
<?=$questgroupshierarchypath?>
|
<?=$questgroupshierarchypath?>
|
||||||
<h1><?=$quest['title']?></h1>
|
<h1><?=$quest['title']?></h1>
|
||||||
|
|
||||||
|
<?php if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) : ?>
|
||||||
|
<nav class="admin">
|
||||||
|
<li><a href="<?=$linker->link('edit', 5)?>"><?=_('Edit Quest')?></a></li>
|
||||||
|
<?php if(in_array('admin', \hhu\z\controllers\SeminaryController::$character['characterroles'])) : ?>
|
||||||
|
<li><a href="<?=$linker->link('delete', 5)?>"><?=_('Delete Quest')?></a></li>
|
||||||
|
<?php endif ?>
|
||||||
|
</nav>
|
||||||
|
<?php endif ?>
|
||||||
<?php if(array_key_exists('Prolog', $questtexts) && count($questtexts['Prolog']) > 0) : ?>
|
<?php if(array_key_exists('Prolog', $questtexts) && count($questtexts['Prolog']) > 0) : ?>
|
||||||
<section>
|
<section>
|
||||||
<h1 id="questtext"><?=_('Prolog')?></h1>
|
<h1 id="questtext"><?=_('Prolog')?></h1>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue