implement CRUD for XP-levels
This commit is contained in:
parent
765f5a4b19
commit
591ce2690b
8 changed files with 480 additions and 11 deletions
35
agents/intermediate/XplevelsAgent.inc
Normal file
35
agents/intermediate/XplevelsAgent.inc
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?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\agents\intermediate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Agent to handle XP-levels of a Seminary.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class XplevelsAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -238,6 +238,7 @@
|
||||||
array('^users/(?!(index|login|register|logout|manage|create|edit|delete))/?', 'users/user/$1', true),
|
array('^users/(?!(index|login|register|logout|manage|create|edit|delete))/?', 'users/user/$1', true),
|
||||||
array('^seminaries/([^/]+)/(edit|delete)/?$', 'seminaries/$2/$1', true),
|
array('^seminaries/([^/]+)/(edit|delete)/?$', 'seminaries/$2/$1', true),
|
||||||
array('^seminaries/(?!(index|create|edit|delete|calculatexps))/?', 'seminaries/seminary/$1', true),
|
array('^seminaries/(?!(index|create|edit|delete|calculatexps))/?', 'seminaries/seminary/$1', true),
|
||||||
|
array('^xplevels/([^/]+)/(manage)/?$', 'xplevels/$2/$1', true),
|
||||||
array('^questgroupshierarchy/([^/]+)/create/?$', 'questgroupshierarchy/create/$1', true),
|
array('^questgroupshierarchy/([^/]+)/create/?$', 'questgroupshierarchy/create/$1', true),
|
||||||
array('^questgroupshierarchy/([^/]+)/([^/]+)/(edit|delete|moveup|movedown)/?$', 'questgroupshierarchy/$3/$1/$2', true),
|
array('^questgroupshierarchy/([^/]+)/([^/]+)/(edit|delete|moveup|movedown)/?$', 'questgroupshierarchy/$3/$1/$2', true),
|
||||||
array('^questgroups/([^/]+)/create/?$', 'questgroups/create/$1', true),
|
array('^questgroups/([^/]+)/create/?$', 'questgroups/create/$1', true),
|
||||||
|
|
@ -254,6 +255,9 @@
|
||||||
array('^characters/([^/]+)/all/?$', 'characters/index/$1/all', true),
|
array('^characters/([^/]+)/all/?$', 'characters/index/$1/all', true),
|
||||||
array('^characters/([^/]+)/([^/]+)/(edit|delete)/?$', 'characters/$3/$1/$2', true),
|
array('^characters/([^/]+)/([^/]+)/(edit|delete)/?$', 'characters/$3/$1/$2', true),
|
||||||
array('^characters/([^/]+)/(?!(index|register|manage))/?', 'characters/character/$1/$2', true),
|
array('^characters/([^/]+)/(?!(index|register|manage))/?', 'characters/character/$1/$2', true),
|
||||||
|
array('^charactertypes/([^/]+)/?$', 'charactertypes/index/$1', true),
|
||||||
|
array('^charactertypes/([^/]+)/create/?$', 'charactertypes/create/$1', true),
|
||||||
|
array('^charactertypes/([^/]+)/([^/]+)/(edit|delete)/?$', 'charactertypes/$3/$1/$2', true),
|
||||||
array('^charactergroups/([^/]+)/?$', 'charactergroups/index/$1', true),
|
array('^charactergroups/([^/]+)/?$', 'charactergroups/index/$1', true),
|
||||||
array('^charactergroups/([^/]+)/(create)/?$', 'charactergroups/creategroupsgroup/$1/$2', true),
|
array('^charactergroups/([^/]+)/(create)/?$', 'charactergroups/creategroupsgroup/$1/$2', true),
|
||||||
array('^charactergroups/([^/]+)/([^/]+)/?$', 'charactergroups/groupsgroup/$1/$2', true),
|
array('^charactergroups/([^/]+)/([^/]+)/?$', 'charactergroups/groupsgroup/$1/$2', true),
|
||||||
|
|
@ -287,6 +291,7 @@
|
||||||
array('^users/user/(.*)$', 'users/$1', true),
|
array('^users/user/(.*)$', 'users/$1', true),
|
||||||
array('^users/([^/]+)/(.*)$', 'users/$2/$1', true),
|
array('^users/([^/]+)/(.*)$', 'users/$2/$1', true),
|
||||||
array('^seminaries/seminary/(.*)$', 'seminaries/$1', false),
|
array('^seminaries/seminary/(.*)$', 'seminaries/$1', false),
|
||||||
|
array('^xplevels/(manage)/(.*)$', 'xplevels/$2/$1', false),
|
||||||
array('^questgroupshierarchy/create/(.*)$', 'questgroupshierarchy/$1/create', true),
|
array('^questgroupshierarchy/create/(.*)$', 'questgroupshierarchy/$1/create', true),
|
||||||
array('^questgroupshierarchy/([^/]+)/(.*)$', 'questgroupshierarchy/$2/$1', true),
|
array('^questgroupshierarchy/([^/]+)/(.*)$', 'questgroupshierarchy/$2/$1', true),
|
||||||
array('^questgroups/create/(.*)$', 'questgroups/$1/create', true),
|
array('^questgroups/create/(.*)$', 'questgroups/$1/create', true),
|
||||||
|
|
@ -300,6 +305,9 @@
|
||||||
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),
|
||||||
|
array('^charactertypes/index/([^/]+)$', 'charactertypes/$1', true),
|
||||||
|
array('^charactertypes/create/([^/]+)$', 'charactertypes/$1/create', true),
|
||||||
|
array('^charactertypes/(edit|delete)/([^/]+)/([^/]+)$', 'charactertypes/$2/$3/$1', true),
|
||||||
array('^charactergroups/index/([^/]+)$', 'charactergroups/$1', true),
|
array('^charactergroups/index/([^/]+)$', 'charactergroups/$1', true),
|
||||||
array('^charactergroups/creategroupsgroup/([^/]+)$', 'charactergroups/$1/create', true),
|
array('^charactergroups/creategroupsgroup/([^/]+)$', 'charactergroups/$1/create', true),
|
||||||
array('^charactergroups/groupsgroup/([^/]+)/([^/]+)$', 'charactergroups/$1/$2', true),
|
array('^charactergroups/groupsgroup/([^/]+)/([^/]+)$', 'charactergroups/$1/$2', true),
|
||||||
|
|
|
||||||
188
controllers/XplevelsController.inc
Normal file
188
controllers/XplevelsController.inc
Normal file
|
|
@ -0,0 +1,188 @@
|
||||||
|
<?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\controllers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller of the XplevelsAgent to handle XP-levels of a
|
||||||
|
* Seminary.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class XplevelsController extends \hhu\z\controllers\SeminaryController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Required components
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $components = array('validation');
|
||||||
|
/**
|
||||||
|
* Required models
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $models = array('xplevels');
|
||||||
|
/**
|
||||||
|
* User permissions
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $permissions = array(
|
||||||
|
'manage' => array('admin', 'moderator', 'user')
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: manage.
|
||||||
|
*
|
||||||
|
* Manage XP-levels.
|
||||||
|
*
|
||||||
|
* @throws IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
|
*/
|
||||||
|
public function manage($seminaryUrl)
|
||||||
|
{
|
||||||
|
// Get seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Check permissions
|
||||||
|
if(
|
||||||
|
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
|
||||||
|
$seminary['created_user_id'] != self::$user['id']
|
||||||
|
) {
|
||||||
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get XP-levels
|
||||||
|
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||||
|
|
||||||
|
// Values
|
||||||
|
$xplevelsValues = array();
|
||||||
|
foreach($xplevels as &$xplevel) {
|
||||||
|
$xplevelsValues[$xplevel['id']] = $xplevel;
|
||||||
|
}
|
||||||
|
$deletes = array();
|
||||||
|
$validations = array(
|
||||||
|
'edit' => true,
|
||||||
|
'create' => true
|
||||||
|
);
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
$action = null;
|
||||||
|
if($this->request->getRequestMethod() == 'POST')
|
||||||
|
{
|
||||||
|
// Get params
|
||||||
|
$xplevelsValues = $this->request->getPostParam('xplevels');
|
||||||
|
$deletes = $this->request->getPostParam('deletes');
|
||||||
|
|
||||||
|
// Edit and delete XP-levels
|
||||||
|
if(!is_null($this->request->getPostParam('edit')))
|
||||||
|
{
|
||||||
|
$action = 'edit';
|
||||||
|
|
||||||
|
// Validate params
|
||||||
|
if(!is_array($deletes)) {
|
||||||
|
$deletes = array();
|
||||||
|
}
|
||||||
|
foreach($xplevels as &$xplevel)
|
||||||
|
{
|
||||||
|
if(array_key_exists($xplevel['id'], $deletes)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$xplevelValidation = $this->Validation->validateParams($xplevelsValues[$xplevel['id']], array('xps'));
|
||||||
|
if($xplevelValidation !== true)
|
||||||
|
{
|
||||||
|
if(!is_array($validations['edit'])) {
|
||||||
|
$validations['edit'] = array();
|
||||||
|
}
|
||||||
|
if(!array_key_exists($xplevel['id'], $validations['edit']) || !is_array($validations['edit'][$xplevel['id']])) {
|
||||||
|
$validations['edit'][$xplevel['id']] = array();
|
||||||
|
}
|
||||||
|
$validations['edit'][$xplevel['id']] = $this->Validation->addValidationResults($validations['edit'][$xplevel['id']], 'xps', $xplevelValidation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit and delete
|
||||||
|
if($validations['edit'] === true)
|
||||||
|
{
|
||||||
|
foreach($xplevels as &$xplevel)
|
||||||
|
{
|
||||||
|
// Delete
|
||||||
|
if(array_key_exists($xplevel['id'], $deletes)) {
|
||||||
|
$this->Xplevels->deleteXPLevel($xplevel);
|
||||||
|
}
|
||||||
|
// Edit
|
||||||
|
elseif(array_key_exists($xplevel['id'], $xplevelsValues))
|
||||||
|
{
|
||||||
|
$this->Xplevels->editXPLevel(
|
||||||
|
$xplevel['id'],
|
||||||
|
$xplevelsValues[$xplevel['id']]['xps']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect
|
||||||
|
$this->redirect($this->linker->link(null, 3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create XP-level
|
||||||
|
if(!is_null($this->request->getPostParam('create')))
|
||||||
|
{
|
||||||
|
$action = 'create';
|
||||||
|
|
||||||
|
// Get params and validate them
|
||||||
|
$xplevel = $xplevelsValues['new'];
|
||||||
|
$validations[$action] = $this->Validation->validateParams($xplevel, array('xps'));
|
||||||
|
|
||||||
|
// Create
|
||||||
|
if($validations[$action] === true)
|
||||||
|
{
|
||||||
|
$this->Xplevels->createXPLevel(
|
||||||
|
$this->Auth->getUserId(),
|
||||||
|
$seminary['id'],
|
||||||
|
$xplevel['xps']
|
||||||
|
);
|
||||||
|
|
||||||
|
// Redirect
|
||||||
|
$this->redirect($this->linker->link(null, 3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get validation settings
|
||||||
|
$validationSettings = array(
|
||||||
|
'xps' => \nre\configs\AppConfig::$validation['xps']
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Manage XP-levels');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('xplevels', $xplevels);
|
||||||
|
$this->set('xplevelsValues', $xplevelsValues);
|
||||||
|
$this->set('deletes', $deletes);
|
||||||
|
$this->set('action', $action);
|
||||||
|
$this->set('validations', $validations);
|
||||||
|
$this->set('validationSettings', $validationSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
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-07-09 11:21+0100\n"
|
"POT-Creation-Date: 2014-07-09 13:01+0100\n"
|
||||||
"PO-Revision-Date: 2014-07-09 11:29+0100\n"
|
"PO-Revision-Date: 2014-07-09 13:02+0100\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: de_DE\n"
|
"Language: de_DE\n"
|
||||||
|
|
@ -387,6 +387,7 @@ msgstr "Achievement"
|
||||||
#: views/html/questgroupshierarchy/delete.tpl:14
|
#: views/html/questgroupshierarchy/delete.tpl:14
|
||||||
#: views/html/quests/delete.tpl:11 views/html/quests/edittexts.tpl:53
|
#: views/html/quests/delete.tpl:11 views/html/quests/edittexts.tpl:53
|
||||||
#: views/html/seminaries/delete.tpl:13 views/html/users/delete.tpl:11
|
#: views/html/seminaries/delete.tpl:13 views/html/users/delete.tpl:11
|
||||||
|
#: views/html/xplevels/manage.tpl:45
|
||||||
msgid "delete"
|
msgid "delete"
|
||||||
msgstr "löschen"
|
msgstr "löschen"
|
||||||
|
|
||||||
|
|
@ -400,6 +401,7 @@ msgstr "Neue Bedingung"
|
||||||
#: views/html/charactergroupsquests/manage.tpl:66
|
#: views/html/charactergroupsquests/manage.tpl:66
|
||||||
#: views/html/charactertypes/manage.tpl:52 views/html/library/edit.tpl:46
|
#: views/html/charactertypes/manage.tpl:52 views/html/library/edit.tpl:46
|
||||||
#: views/html/library/edit.tpl:86 views/html/users/edit.tpl:105
|
#: views/html/library/edit.tpl:86 views/html/users/edit.tpl:105
|
||||||
|
#: views/html/xplevels/manage.tpl:49
|
||||||
msgid "save"
|
msgid "save"
|
||||||
msgstr "speichern"
|
msgstr "speichern"
|
||||||
|
|
||||||
|
|
@ -839,7 +841,7 @@ msgstr "Motto"
|
||||||
#: 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:108 views/html/seminaries/create.tpl:75
|
#: views/html/quests/create.tpl:108 views/html/seminaries/create.tpl:75
|
||||||
#: views/html/users/create.tpl:96
|
#: views/html/users/create.tpl:96 views/html/xplevels/manage.tpl:83
|
||||||
msgid "create"
|
msgid "create"
|
||||||
msgstr "erstellen"
|
msgstr "erstellen"
|
||||||
|
|
||||||
|
|
@ -925,7 +927,8 @@ msgstr "%squests"
|
||||||
#: views/html/characters/manage.tpl:17
|
#: views/html/characters/manage.tpl:17
|
||||||
#: views/html/questgroups/questgroup.tpl:62 views/html/quests/create.tpl:72
|
#: views/html/questgroups/questgroup.tpl:62 views/html/quests/create.tpl:72
|
||||||
#: views/html/quests/create.tpl:73 views/html/quests/edit.tpl:75
|
#: views/html/quests/create.tpl:73 views/html/quests/edit.tpl:75
|
||||||
#: views/html/quests/edit.tpl:76
|
#: views/html/quests/edit.tpl:76 views/html/xplevels/manage.tpl:43
|
||||||
|
#: views/html/xplevels/manage.tpl:81
|
||||||
msgid "XPs"
|
msgid "XPs"
|
||||||
msgstr "XP"
|
msgstr "XP"
|
||||||
|
|
||||||
|
|
@ -968,6 +971,7 @@ msgstr "Neue %s-Quest"
|
||||||
#: 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
|
#: views/html/quests/create.tpl:43 views/html/quests/edit.tpl:43
|
||||||
|
#: views/html/xplevels/manage.tpl:26 views/html/xplevels/manage.tpl:63
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "XPs not set"
|
msgid "XPs not set"
|
||||||
msgstr "XP nicht angegeben"
|
msgstr "XP nicht angegeben"
|
||||||
|
|
@ -975,12 +979,14 @@ 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
|
#: views/html/quests/create.tpl:45 views/html/quests/edit.tpl:45
|
||||||
|
#: views/html/xplevels/manage.tpl:28 views/html/xplevels/manage.tpl:65
|
||||||
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
|
#: views/html/quests/create.tpl:47 views/html/quests/edit.tpl:47
|
||||||
|
#: views/html/xplevels/manage.tpl:30 views/html/xplevels/manage.tpl:67
|
||||||
msgid "XPs invalid"
|
msgid "XPs invalid"
|
||||||
msgstr "Die XP-Angabe ist ungültig"
|
msgstr "Die XP-Angabe ist ungültig"
|
||||||
|
|
||||||
|
|
@ -1075,7 +1081,7 @@ msgstr "Fortschritt"
|
||||||
#: views/html/characters/character.tpl:77
|
#: views/html/characters/character.tpl:77
|
||||||
#: views/html/characters/character.tpl:83
|
#: views/html/characters/character.tpl:83
|
||||||
#: views/html/characters/character.tpl:89 views/html/seminarybar/index.tpl:43
|
#: views/html/characters/character.tpl:89 views/html/seminarybar/index.tpl:43
|
||||||
#: views/html/users/user.tpl:41
|
#: views/html/users/user.tpl:41 views/html/xplevels/manage.tpl:41
|
||||||
msgid "Level"
|
msgid "Level"
|
||||||
msgstr "Level"
|
msgstr "Level"
|
||||||
|
|
||||||
|
|
@ -1207,7 +1213,7 @@ msgid "Please choose an avatar"
|
||||||
msgstr "Bitte wähle einen Avatar aus"
|
msgstr "Bitte wähle einen Avatar aus"
|
||||||
|
|
||||||
#: views/html/charactertypes/manage.tpl:9 views/html/seminaries/index.tpl:38
|
#: views/html/charactertypes/manage.tpl:9 views/html/seminaries/index.tpl:38
|
||||||
#: views/html/seminaries/seminary.tpl:14
|
#: views/html/seminaries/seminary.tpl:15
|
||||||
msgid "Manage Charactertypes"
|
msgid "Manage Charactertypes"
|
||||||
msgstr "Charakterrassen verwalten"
|
msgstr "Charakterrassen verwalten"
|
||||||
|
|
||||||
|
|
@ -1663,9 +1669,9 @@ msgstr "Erstelle einen Charakter"
|
||||||
msgid "Your Character “%s” has not been activated yet"
|
msgid "Your Character “%s” has not been activated yet"
|
||||||
msgstr "Dein Charakter „%s“ wurde noch nicht aktiviert"
|
msgstr "Dein Charakter „%s“ wurde noch nicht aktiviert"
|
||||||
|
|
||||||
#: views/html/seminaries/seminary.tpl:15
|
#: views/html/seminaries/seminary.tpl:14 views/html/xplevels/manage.tpl:9
|
||||||
msgid "Manage Questgroups"
|
msgid "Manage XP-levels"
|
||||||
msgstr "Questgruppen verwalten"
|
msgstr "XP-Level verwalten"
|
||||||
|
|
||||||
#: views/html/seminaries/seminary.tpl:19
|
#: views/html/seminaries/seminary.tpl:19
|
||||||
msgid "Show Quests"
|
msgid "Show Quests"
|
||||||
|
|
@ -1849,6 +1855,14 @@ msgstr "Registrieren"
|
||||||
msgid "Roles"
|
msgid "Roles"
|
||||||
msgstr "Rollen"
|
msgstr "Rollen"
|
||||||
|
|
||||||
|
#: views/html/xplevels/manage.tpl:11
|
||||||
|
msgid "Edit XP-levels"
|
||||||
|
msgstr "XP-Level bearbeiten"
|
||||||
|
|
||||||
|
#: views/html/xplevels/manage.tpl:52
|
||||||
|
msgid "Create new XP-level"
|
||||||
|
msgstr "Neues XP-Level erstellen"
|
||||||
|
|
||||||
#: views/htmlmail/mail/characterregistration.tpl:1
|
#: views/htmlmail/mail/characterregistration.tpl:1
|
||||||
#: views/textmail/mail/characterregistration.tpl:1
|
#: views/textmail/mail/characterregistration.tpl:1
|
||||||
#, php-format
|
#, php-format
|
||||||
|
|
@ -1884,6 +1898,9 @@ msgstr "Ein neuer Benutzer wurde registriert"
|
||||||
msgid "Hello %s"
|
msgid "Hello %s"
|
||||||
msgstr "Hallo %s"
|
msgstr "Hallo %s"
|
||||||
|
|
||||||
|
#~ msgid "Manage Questgroups"
|
||||||
|
#~ msgstr "Questgruppen verwalten"
|
||||||
|
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
#~ msgid "Edit Questgrouphierarchy"
|
#~ msgid "Edit Questgrouphierarchy"
|
||||||
#~ msgstr "bearbeiten"
|
#~ msgstr "bearbeiten"
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,143 @@
|
||||||
return $data[0];
|
return $data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all XP-levels for a Seminary.
|
||||||
|
*
|
||||||
|
* @throws IdNotFoundException
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
|
* @return array List of XP-level
|
||||||
|
*/
|
||||||
|
public function getXPLevelsForSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
return $this->db->query(
|
||||||
|
'SELECT id, seminary_id, xps, level, name '.
|
||||||
|
'FROM xplevels '.
|
||||||
|
'WHERE seminary_id = ? '.
|
||||||
|
'ORDER BY level ASC',
|
||||||
|
'i',
|
||||||
|
$seminaryId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new XP-level for a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $userId ID of creating user
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
|
* @param int $xps XPs of new XP-level
|
||||||
|
* @param string $name Name of new XP-level (optional)
|
||||||
|
*/
|
||||||
|
public function createXPLevel($userId, $seminaryId, $xps, $name=null)
|
||||||
|
{
|
||||||
|
// Get level
|
||||||
|
$level = $this->db->query(
|
||||||
|
'SELECT COALESCE(MAX(level),0)+1 AS level '.
|
||||||
|
'FROM xplevels '.
|
||||||
|
'WHERE seminary_id = ?',
|
||||||
|
'i',
|
||||||
|
$seminaryId
|
||||||
|
);
|
||||||
|
$level = $level[0]['level'];
|
||||||
|
|
||||||
|
$this->db->setAutocommit(false);
|
||||||
|
try {
|
||||||
|
// Create XP-level
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT INTO xplevels '.
|
||||||
|
'(created_user_id, seminary_id, xps, level, name) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?, ?, ?, ?)',
|
||||||
|
'iiiis',
|
||||||
|
$userId,
|
||||||
|
$seminaryId,
|
||||||
|
$xps,
|
||||||
|
$level,
|
||||||
|
$name
|
||||||
|
);
|
||||||
|
$xplevelId = $this->db->getInsertId();
|
||||||
|
|
||||||
|
// Create avatars
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT INTO avatars '.
|
||||||
|
'(created_user_id, charactertype_id, xplevel_id) '.
|
||||||
|
'SELECT ?, charactertypes.id, ? '.
|
||||||
|
'FROM charactertypes '.
|
||||||
|
'WHERE seminary_id = ?',
|
||||||
|
'iii',
|
||||||
|
$userId,
|
||||||
|
$xplevelId,
|
||||||
|
$seminaryId
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit a XP-level.
|
||||||
|
*
|
||||||
|
* @param int $xplevelId ID of XP-level to edit
|
||||||
|
* @param int $xps New XPs of XP-level
|
||||||
|
* @param string $name New name of XP-level (optional)
|
||||||
|
*/
|
||||||
|
public function editXPLevel($xplevelId, $xps, $name=null)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
'UPDATE xplevels '.
|
||||||
|
'SET xps = ?, name = ? '.
|
||||||
|
'WHERE id = ?',
|
||||||
|
'isi',
|
||||||
|
$xps,
|
||||||
|
$name,
|
||||||
|
$xplevelId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a XP-level.
|
||||||
|
*
|
||||||
|
* @param int $xplevel XP-level to delete
|
||||||
|
*/
|
||||||
|
public function deleteXPLevel($xplevel)
|
||||||
|
{
|
||||||
|
$this->db->setAutocommit(false);
|
||||||
|
try {
|
||||||
|
// Delete XP-level
|
||||||
|
$this->db->query('DELETE FROM xplevels WHERE id = ?', 'i', $xplevel['id']);
|
||||||
|
|
||||||
|
// Adjust levels
|
||||||
|
$this->db->query(
|
||||||
|
'UPDATE xplevels '.
|
||||||
|
'SET level = level - 1 '.
|
||||||
|
'WHERE seminary_id = ? AND level > ?',
|
||||||
|
'ii',
|
||||||
|
$xplevel['seminary_id'],
|
||||||
|
$xplevel['level']
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
<li><a href="<?=$linker->link('delete', 3)?>"><?=_('Delete seminary')?></a></li>
|
<li><a href="<?=$linker->link('delete', 3)?>"><?=_('Delete seminary')?></a></li>
|
||||||
</nav>
|
</nav>
|
||||||
<nav class="admin">
|
<nav class="admin">
|
||||||
<li><a href="<?=$linker->link(array('charactertypes','manage',$seminary['url']))?>"><?=_('Manage Charactertypes')?></a></li>
|
<li><a href="<?=$linker->link(array('xplevels','manage',$seminary['url']))?>"><?=_('Manage XP-levels')?></a></li>
|
||||||
<li><a href="<?=$linker->link(array('questgroups','manage',$seminary['url']))?>"><?=_('Manage Questgroups')?></a></li>
|
<li><a href="<?=$linker->link(array('charactertypes','index',$seminary['url']))?>"><?=_('Manage Charactertypes')?></a></li>
|
||||||
</nav>
|
</nav>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<nav class="admin">
|
<nav class="admin">
|
||||||
|
|
|
||||||
84
views/html/xplevels/manage.tpl
Normal file
84
views/html/xplevels/manage.tpl
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?php if(!is_null($seminary['seminarymedia_id'])) : ?>
|
||||||
|
<div class="moodpic">
|
||||||
|
<img src="<?=$linker->link(array('media','seminarymoodpic',$seminary['url']))?>">
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<ul class="breadcrumbs">
|
||||||
|
<li><a href="<?=$linker->link(array('seminaries',$seminary['url']))?>"><?=$seminary['title']?></a></li>
|
||||||
|
</ul>
|
||||||
|
<h1><?=_('Manage XP-levels')?></h1>
|
||||||
|
|
||||||
|
<h2><?=_('Edit XP-levels')?></h2>
|
||||||
|
<form method="post">
|
||||||
|
<ul>
|
||||||
|
<?php foreach($xplevels as &$xplevel) : ?>
|
||||||
|
<li>
|
||||||
|
<?php if($validations['edit'] !== true && array_key_exists($xplevel['id'], $validations['edit']) && $validations['edit'][$xplevel['id']] !== true) : ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($validations['edit'][$xplevel['id']] as $field => &$settings) : ?>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($settings as $setting => $value) : ?>
|
||||||
|
<li>
|
||||||
|
<?php switch($field) {
|
||||||
|
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 ?>
|
||||||
|
<?=_('Level')?> <?=$xplevel['level']?>:
|
||||||
|
<input id="xplevel-<?=$xplevel['id']?>-xps" type="number" name="xplevels[<?=$xplevel['id']?>][xps]" value="<?=$xplevelsValues[$xplevel['id']]['xps']?>" <?=($validations['edit'] !== true && array_key_exists($xplevel['id'], $validations['edit']) && $validations['edit'][$xplevel['id']] !== true && array_key_exists('xps', $validations['edit'][$xplevel['id']])) ? 'class="invalid"' : null?> />
|
||||||
|
<label for="xplevel-<?=$xplevel['id']?>-xps"><?=_('XPs')?></label>
|
||||||
|
<input id="xplevel-<?=$xplevel['id']?>-delete" type="checkbox" name="deletes[<?=$xplevel['id']?>]" <?php if(array_key_exists($xplevel['id'], $deletes)) : ?>checked="checked"<?php endif ?> />
|
||||||
|
<label for="xplevel-<?=$xplevel['id']?>-delete"><?=_('delete')?></label><br />
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<input type="submit" name="edit" value="<?=_('save')?>" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2><?=_('Create new XP-level')?></h2>
|
||||||
|
<?php if($validations['create'] !== true) : ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($validations['create'] as $field => &$settings) : ?>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($settings as $setting => $value) : ?>
|
||||||
|
<li>
|
||||||
|
<?php switch($field) {
|
||||||
|
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">
|
||||||
|
<fieldset>
|
||||||
|
<input id="xplevel-new-xps" type="number" name="xplevels[new][xps]" value="<?=(count($xplevels) > 0) ? $xplevels[count($xplevels)-1]['xps']+1 : 0 ?>" min="<?=(count($xplevels) > 0) ? $xplevels[count($xplevels)-1]['xps']+1 : 0 ?>" <?=($validations['create'] !== true && array_key_exists('xps', $validations['create'])) ? 'class="invalid"' : null?> />
|
||||||
|
<label for="xplevel-new-xps"><?=_('XPs')?></label>
|
||||||
|
</fieldset>
|
||||||
|
<input type="submit" name="create" value="<?=_('create')?>" />
|
||||||
|
</form>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue