This commit is contained in:
parent
591ce2690b
commit
7873ee0d5b
12 changed files with 760 additions and 245 deletions
|
|
@ -308,7 +308,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get XP-levels
|
// Get XP-levels
|
||||||
$xplevels = $this->Characters->getXPLevelsForSeminary($seminary['id']);
|
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||||
|
|
||||||
// Get Avatars
|
// Get Avatars
|
||||||
if(count($xplevels) > 0)
|
if(count($xplevels) > 0)
|
||||||
|
|
@ -563,7 +563,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get XP-levels
|
// Get XP-levels
|
||||||
$xplevels = $this->Characters->getXPLevelsForSeminary($seminary['id']);
|
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||||
|
|
||||||
|
|
||||||
// Set titile
|
// Set titile
|
||||||
|
|
|
||||||
|
|
@ -31,168 +31,376 @@
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('charactertypes');
|
public $models = array('charactertypes', 'xplevels', 'avatars', 'media');
|
||||||
/**
|
/**
|
||||||
* User permissions
|
* User permissions
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $permissions = array(
|
public $permissions = array(
|
||||||
'manage' => array('admin', 'moderator', 'user')
|
'index' => array('admin', 'moderator', 'user'),
|
||||||
|
'create' => array('admin', 'moderator', 'user'),
|
||||||
|
'edit' => array('admin', 'moderator', 'user'),
|
||||||
|
'delete' => array('admin', 'moderator', 'user')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: manage.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Manage Characters.
|
* List Character types.
|
||||||
*
|
*
|
||||||
* @throws IdNotFoundException
|
* @throws IdNotFoundException
|
||||||
* @param string $seminaryUrl URL-Title of a Seminary
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
*/
|
*/
|
||||||
public function manage($seminaryUrl)
|
public function index($seminaryUrl)
|
||||||
{
|
{
|
||||||
// Get seminary
|
// Get seminary
|
||||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if(
|
if(
|
||||||
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) ||
|
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
|
||||||
(!is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), self::$character['characterroles'])) == 0)
|
$seminary['created_user_id'] != self::$user['id']
|
||||||
) {
|
) {
|
||||||
throw new AccessDeniedException();
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Charactertypes
|
// Get Character types
|
||||||
$charactertypes = $this->Charactertypes->getCharacterTypesForSeminary($seminary['id']);
|
$charactertypes = $this->Charactertypes->getCharacterTypesForSeminary($seminary['id']);
|
||||||
|
|
||||||
// Values
|
// Get Avatars
|
||||||
$charactertypesNames = array();
|
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||||
foreach($charactertypes as &$charactertype) {
|
if(count($xplevels) > 0)
|
||||||
$charactertypesNames[$charactertype['id']] = $charactertype['name'];
|
|
||||||
}
|
|
||||||
$deleteCharactertypes = null;
|
|
||||||
$charactertypeName = '';
|
|
||||||
$validations = array(
|
|
||||||
'edit-charactertypes' => true,
|
|
||||||
'create-charactertype' => true
|
|
||||||
);
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
$action = null;
|
|
||||||
if($this->request->getRequestMethod() == 'POST')
|
|
||||||
{
|
{
|
||||||
// Edit and delete Charactertypes
|
foreach($charactertypes as &$type)
|
||||||
if(!is_null($this->request->getPostParam('edit-charactertypes')))
|
|
||||||
{
|
{
|
||||||
$action = 'edit-charactertypes';
|
try {
|
||||||
|
$type['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $type['url'], $xplevels[0]['level']);
|
||||||
// Get params and validate them
|
|
||||||
$charactertypesNames = $this->request->getPostParam('charactertypes');
|
|
||||||
$deleteCharactertypes = $this->request->getPostParam('delete-charactertypes');
|
|
||||||
foreach($charactertypes as &$charactertype)
|
|
||||||
{
|
|
||||||
if(!is_null($deleteCharactertypes) && array_key_exists($charactertype['id'], $deleteCharactertypes)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||||
$name = $charactertypesNames[$charactertype['id']];
|
// No Avatar available
|
||||||
$charactertypeValidation = $this->Validation->validate($name, \nre\configs\AppConfig::$validation['charactertypename']);
|
|
||||||
if($charactertypeValidation !== true)
|
|
||||||
{
|
|
||||||
if(!is_array($validations['edit-charactertypes'])) {
|
|
||||||
$validations['edit-charactertypes'] = array();
|
|
||||||
}
|
|
||||||
if(!array_key_exists($charactertype['id'], $validations['edit-charactertypes']) || !is_array($validations['edit-charactertypes'][$charactertype['id']])) {
|
|
||||||
$validations['edit-charactertypes'][$charactertype['id']] = array();
|
|
||||||
}
|
|
||||||
$validations['edit-charactertypes'][$charactertype['id']] = $this->Validation->addValidationResults($validations['edit-charactertypes'][$charactertype['id']], 'charactertypename', $charactertypeValidation);
|
|
||||||
}
|
|
||||||
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name, $charactertype['id']))
|
|
||||||
{
|
|
||||||
if(!is_array($validations['edit-charactertypes'])) {
|
|
||||||
$validations['edit-charactertypes'] = array();
|
|
||||||
}
|
|
||||||
if(!array_key_exists($charactertype['id'], $validations['edit-charactertypes']) || !is_array($validations['edit-charactertypes'][$charactertype['id']])) {
|
|
||||||
$validations['edit-charactertypes'][$charactertype['id']] = array();
|
|
||||||
}
|
|
||||||
$validations['edit-charactertypes'][$charactertype['id']] = $this->Validation->addValidationResult($validations['edit-charactertypes'][$charactertype['id']], 'charactertypename', 'exist', true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit and delete
|
|
||||||
if($validations['edit-charactertypes'] === true)
|
|
||||||
{
|
|
||||||
foreach($charactertypes as &$charactertype)
|
|
||||||
{
|
|
||||||
// Delete
|
|
||||||
if(!is_null($deleteCharactertypes) && array_key_exists($charactertype['id'], $deleteCharactertypes)) {
|
|
||||||
$this->Charactertypes->deleteCharactertype($charactertype['id']);
|
|
||||||
}
|
|
||||||
// Edit
|
|
||||||
elseif(!is_null($charactertypesNames) && array_key_exists($charactertype['id'], $charactertypesNames))
|
|
||||||
{
|
|
||||||
$name = $charactertypesNames[$charactertype['id']];
|
|
||||||
$this->Charactertypes->editCharactertype($charactertype['id'], $name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redirect
|
|
||||||
//$this->redirect($this->linker->link(array('seminaries', 'index')));
|
|
||||||
$this->redirect($this->linker->link(null, 3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create Charactertype
|
|
||||||
if(!is_null($this->request->getPostParam('create-charactertype')))
|
|
||||||
{
|
|
||||||
$action = 'create-charactertype';
|
|
||||||
|
|
||||||
// Get params and validate them
|
|
||||||
$validations[$action] = $this->Validation->validateParams($this->request->getPostParams(), array('charactertypename'));
|
|
||||||
$charactertypeName = $this->request->getPostParam('charactertypename');
|
|
||||||
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $charactertypeName)) {
|
|
||||||
$validations[$action] = $this->Validation->addValidationResult($validations[$action], 'charactertypename', 'exist', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create
|
|
||||||
if($validations[$action] === true)
|
|
||||||
{
|
|
||||||
$this->Charactertypes->createCharactertype(
|
|
||||||
$this->Auth->getUserId(),
|
|
||||||
$seminary['id'],
|
|
||||||
$charactertypeName
|
|
||||||
);
|
|
||||||
$charactertypeName = '';
|
|
||||||
|
|
||||||
// Redirect
|
|
||||||
$this->redirect($this->linker->link(null, 3));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get validation settings
|
|
||||||
$validationSettings = array(
|
|
||||||
'charactertypename' => \nre\configs\AppConfig::$validation['charactertypename']
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Set titile
|
// Set titile
|
||||||
$this->addTitleLocalized('Manage Charactertypes');
|
$this->addTitleLocalized('Charactertypes');
|
||||||
$this->addTitle($seminary['title']);
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('seminary', $seminary);
|
$this->set('seminary', $seminary);
|
||||||
$this->set('charactertypesNames', $charactertypesNames);
|
$this->set('xplevels', $xplevels);
|
||||||
$this->set('deleteCharactertypes', $deleteCharactertypes);
|
$this->set('charactertypes', $charactertypes);
|
||||||
$this->set('charactertypeName', $charactertypeName);
|
}
|
||||||
$this->set('action', $action);
|
|
||||||
$this->set('validations', $validations);
|
|
||||||
|
/**
|
||||||
|
* Action: create.
|
||||||
|
*
|
||||||
|
* Create new Character type for a Seminary.
|
||||||
|
*
|
||||||
|
* @throws IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
|
*/
|
||||||
|
public function create($seminaryUrl)
|
||||||
|
{
|
||||||
|
// Get seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Check permissions
|
||||||
|
if(
|
||||||
|
$seminary['created_user_id'] != self::$user['id'] &&
|
||||||
|
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||||
|
) {
|
||||||
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Values
|
||||||
|
$name = '';
|
||||||
|
$fields = array('charactertypename');
|
||||||
|
$validation = array();
|
||||||
|
|
||||||
|
// Create new Charactertype
|
||||||
|
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
||||||
|
{
|
||||||
|
// Get params and validate them
|
||||||
|
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||||
|
$name = $this->request->getPostParam('charactertypename');
|
||||||
|
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name)) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new Charactertype
|
||||||
|
if($validation === true)
|
||||||
|
{
|
||||||
|
$charactertypeId = $this->Charactertypes->createCharactertype(
|
||||||
|
$this->Auth->getUserId(),
|
||||||
|
$seminary['id'],
|
||||||
|
$name
|
||||||
|
);
|
||||||
|
$charactertype = $this->Charactertypes->getCharactertypeById($charactertypeId);
|
||||||
|
|
||||||
|
// Redirect to editing
|
||||||
|
$this->redirect($this->linker->link(array('edit', $seminary['url'], $charactertype['url']), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get validation settings
|
||||||
|
$validationSettings = array();
|
||||||
|
foreach($fields as &$field) {
|
||||||
|
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Create new Charactertype');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('name', $name);
|
||||||
|
$this->set('validation', $validation);
|
||||||
$this->set('validationSettings', $validationSettings);
|
$this->set('validationSettings', $validationSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edit.
|
||||||
|
*
|
||||||
|
* Edit Character type for a Seminary.
|
||||||
|
*
|
||||||
|
* @throws IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-title of a Seminary
|
||||||
|
* @param string $charactertypeUrl URL-title of Character type
|
||||||
|
*/
|
||||||
|
public function edit($seminaryUrl, $charactertypeUrl)
|
||||||
|
{
|
||||||
|
// Get seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Check permissions
|
||||||
|
if(
|
||||||
|
$seminary['created_user_id'] != self::$user['id'] &&
|
||||||
|
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||||
|
) {
|
||||||
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Character type
|
||||||
|
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
|
||||||
|
|
||||||
|
// XP-levels
|
||||||
|
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||||
|
foreach($xplevels as &$xplevel)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$xplevel['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $charactertype['url'], $xplevel['level']);
|
||||||
|
}
|
||||||
|
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||||
|
// No Avatar available
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get allowed mimetypes
|
||||||
|
$mimetypes = \nre\configs\AppConfig::$mimetypes['moodpics'];
|
||||||
|
|
||||||
|
// Values
|
||||||
|
$name = $charactertype['name'];
|
||||||
|
$fields = array('charactertypename');
|
||||||
|
$validation = array();
|
||||||
|
$avatarVariants = array('portrait', 'avatar');
|
||||||
|
$avatarsValidation = true;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
$name = $this->request->getPostParam('charactertypename');
|
||||||
|
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name, $charactertype['id'])) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate and upload avatars
|
||||||
|
if(array_key_exists('avatars', $_FILES))
|
||||||
|
{
|
||||||
|
foreach($xplevels as &$xplevel)
|
||||||
|
{
|
||||||
|
if(array_key_exists($xplevel['id'], $_FILES['avatars']['error']))
|
||||||
|
{
|
||||||
|
foreach($avatarVariants as &$variant)
|
||||||
|
{
|
||||||
|
if(array_key_exists($variant, $_FILES['avatars']['error'][$xplevel['id']]) && $_FILES['avatars']['error'][$xplevel['id']][$variant] !== UPLOAD_ERR_NO_FILE)
|
||||||
|
{
|
||||||
|
$avatar = array(
|
||||||
|
'name' => $_FILES['avatars']['name'][$xplevel['id']][$variant],
|
||||||
|
'type' => $_FILES['avatars']['type'][$xplevel['id']][$variant],
|
||||||
|
'tmp_name' => $_FILES['avatars']['tmp_name'][$xplevel['id']][$variant],
|
||||||
|
'error' => $_FILES['avatars']['error'][$xplevel['id']][$variant],
|
||||||
|
'size' => $_FILES['avatars']['size'][$xplevel['id']][$variant]
|
||||||
|
);
|
||||||
|
$avatarValidation = true;
|
||||||
|
|
||||||
|
// Check error
|
||||||
|
if($avatar['error'] !== UPLOAD_ERR_OK) {
|
||||||
|
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'error', $avatar['error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check mimetype
|
||||||
|
$avatarMimetype = null;
|
||||||
|
$avatar['mimetype'] = \hhu\z\Utils::getMimetype($avatar['tmp_name'], $avatar['type']);
|
||||||
|
foreach($mimetypes as &$mimetype) {
|
||||||
|
if($mimetype['mimetype'] == $avatar['mimetype']) {
|
||||||
|
$avatarMimetype = $mimetype;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(is_null($avatarMimetype)) {
|
||||||
|
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'mimetype', $avatar['mimetype']);
|
||||||
|
}
|
||||||
|
elseif($avatar['size'] > $avatarMimetype['size']) {
|
||||||
|
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'size', $avatarMimetype['size']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add validation result
|
||||||
|
if(!$avatarValidation !== true)
|
||||||
|
{
|
||||||
|
if(!is_array($avatarsValidation)) {
|
||||||
|
$avatarsValidation = array();
|
||||||
|
}
|
||||||
|
if(!array_key_exists($xplevel['id'], $avatarsValidation)) {
|
||||||
|
$avatarsValidation[$xplevel['id']] = array();
|
||||||
|
}
|
||||||
|
$avatarsValidation[$xplevel['id']][$variant] = $avatarValidation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upload avatar
|
||||||
|
if($avatarValidation === true)
|
||||||
|
{
|
||||||
|
$avatar['media_id'] = $this->Media->createAvatarPicture(
|
||||||
|
$this->Auth->getUserId(),
|
||||||
|
$seminary['id'],
|
||||||
|
sprintf('avatar-%d-%d-%s', $charactertype['id'], $xplevel['id'], $variant),
|
||||||
|
'',
|
||||||
|
$avatar['mimetype'],
|
||||||
|
$avatar['tmp_name']
|
||||||
|
);
|
||||||
|
|
||||||
|
// Set avatar
|
||||||
|
if($variant == 'portrait') {
|
||||||
|
$this->Avatars->setAvatarPortraitForTypeAndLevel(
|
||||||
|
$this->Auth->getUserId(),
|
||||||
|
$charactertype['id'],
|
||||||
|
$xplevel['id'],
|
||||||
|
$avatar['media_id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->Avatars->setAvatarForTypeAndLevel(
|
||||||
|
$this->Auth->getUserId(),
|
||||||
|
$charactertype['id'],
|
||||||
|
$xplevel['id'],
|
||||||
|
$avatar['media_id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit Charactertype
|
||||||
|
if($validation === true && $avatarsValidation === true)
|
||||||
|
{
|
||||||
|
$this->Charactertypes->editCharactertype(
|
||||||
|
$charactertype['id'],
|
||||||
|
$name
|
||||||
|
);
|
||||||
|
$charactertype = $this->Charactertypes->getCharactertypeById($charactertype['id']);
|
||||||
|
|
||||||
|
// Redirect to overview
|
||||||
|
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get validation settings
|
||||||
|
$validationSettings = array();
|
||||||
|
foreach($fields as &$field) {
|
||||||
|
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Edit Charactertype');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('charactertype', $charactertype);
|
||||||
|
$this->set('xplevels', $xplevels);
|
||||||
|
$this->set('name', $name);
|
||||||
|
$this->set('mimetypes', $mimetypes);
|
||||||
|
$this->set('validation', $validation);
|
||||||
|
$this->set('avatarsValidation', $avatarsValidation);
|
||||||
|
$this->set('avatarVariants', $avatarVariants);
|
||||||
|
$this->set('validationSettings', $validationSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: delete.
|
||||||
|
*
|
||||||
|
* Delete Character type for a Seminary.
|
||||||
|
*
|
||||||
|
* @throws IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-title of a Seminary
|
||||||
|
* @param string $charactertypeUrl URL-title of Character type
|
||||||
|
*/
|
||||||
|
public function delete($seminaryUrl, $charactertypeUrl)
|
||||||
|
{
|
||||||
|
// Get seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Check permissions
|
||||||
|
if(
|
||||||
|
$seminary['created_user_id'] != self::$user['id'] &&
|
||||||
|
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||||
|
) {
|
||||||
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Character type
|
||||||
|
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
|
||||||
|
|
||||||
|
// Check request method
|
||||||
|
if($this->request->getRequestMethod() == 'POST')
|
||||||
|
{
|
||||||
|
// Check confirmation
|
||||||
|
if(!is_null($this->request->getPostParam('delete')))
|
||||||
|
{
|
||||||
|
// Delete Character type
|
||||||
|
$this->Charactertypes->deleteCharactertype($charactertype['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to overview
|
||||||
|
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Delete Charactertype');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('charactertype', $charactertype);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,60 @@
|
||||||
return $data[0];
|
return $data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the picture for an Avatar.
|
||||||
|
*
|
||||||
|
* @param int $userId ID of creating user
|
||||||
|
* @param int $charactertypeId ID of Charactertype of Avatar
|
||||||
|
* @param int $xplevelId ID of XP-level of Avatar
|
||||||
|
* @param int $avatarpictureId ID of Avatar picture to set
|
||||||
|
*/
|
||||||
|
public function setAvatarForTypeAndLevel($userId, $charactertypeId, $xplevelId, $avatarpictureId)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT INTO avatars '.
|
||||||
|
'(created_user_id, charactertype_id, xplevel_id, avatarpicture_id) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?, ?, ?) '.
|
||||||
|
'ON DUPLICATE KEY UPDATE '.
|
||||||
|
'avatarpicture_id = ?',
|
||||||
|
'iiiii',
|
||||||
|
$userId,
|
||||||
|
$charactertypeId,
|
||||||
|
$xplevelId,
|
||||||
|
$avatarpictureId,
|
||||||
|
$avatarpictureId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the portrait picture for an Avatar.
|
||||||
|
*
|
||||||
|
* @param int $userId ID of creating user
|
||||||
|
* @param int $charactertypeId ID of Charactertype of Avatar
|
||||||
|
* @param int $xplevelId ID of XP-level of Avatar
|
||||||
|
* @param int $avatarpictureId ID of Avatar portrait picture to set
|
||||||
|
*/
|
||||||
|
public function setAvatarPortraitForTypeAndLevel($userId, $charactertypeId, $xplevelId, $avatarpictureId)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT INTO avatars '.
|
||||||
|
'(created_user_id, charactertype_id, xplevel_id, small_avatarpicture_id) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?, ?, ?) '.
|
||||||
|
'ON DUPLICATE KEY UPDATE '.
|
||||||
|
'small_avatarpicture_id = ?',
|
||||||
|
'iiiii',
|
||||||
|
$userId,
|
||||||
|
$charactertypeId,
|
||||||
|
$xplevelId,
|
||||||
|
$avatarpictureId,
|
||||||
|
$avatarpictureId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -578,25 +578,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all XP-levels for a Seminary.
|
|
||||||
*
|
|
||||||
* @param int $seminaryId ID of Seminary
|
|
||||||
* @return array List of XP-levels
|
|
||||||
*/
|
|
||||||
public function getXPLevelsForSeminary($seminaryId)
|
|
||||||
{
|
|
||||||
return $this->db->query(
|
|
||||||
'SELECT id, xps, level, name '.
|
|
||||||
'FROM xplevels '.
|
|
||||||
'WHERE seminary_id = ? '.
|
|
||||||
'ORDER BY level ASC',
|
|
||||||
'i',
|
|
||||||
$seminaryId
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Characters with the given Character role.
|
* Get Characters with the given Character role.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
public function getCharacterTypesForSeminary($seminaryId)
|
public function getCharacterTypesForSeminary($seminaryId)
|
||||||
{
|
{
|
||||||
return $this->db->query(
|
return $this->db->query(
|
||||||
'SELECT id, name, url '.
|
'SELECT id, seminary_id, name, url '.
|
||||||
'FROM charactertypes '.
|
'FROM charactertypes '.
|
||||||
'WHERE seminary_id = ? '.
|
'WHERE seminary_id = ? '.
|
||||||
'ORDER BY name ASC',
|
'ORDER BY name ASC',
|
||||||
|
|
@ -53,6 +53,56 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Character type by its URL.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
|
* @param string $charactretypeUrl URL-title of Character type
|
||||||
|
* @return array Character type data
|
||||||
|
*/
|
||||||
|
public function getCharactertypeByUrl($seminaryId, $charactertypeUrl)
|
||||||
|
{
|
||||||
|
$data = $this->db->query(
|
||||||
|
'SELECT id, seminary_id, name, url '.
|
||||||
|
'FROM charactertypes '.
|
||||||
|
'WHERE seminary_id = ? AND url = ?',
|
||||||
|
'is',
|
||||||
|
$seminaryId,
|
||||||
|
$charactertypeUrl
|
||||||
|
);
|
||||||
|
if(empty($data)) {
|
||||||
|
throw new \nre\exceptions\IdNotFoundException($charactertypeUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Character type by its ID.
|
||||||
|
*
|
||||||
|
* @param string $charactertypeId ID of Character type
|
||||||
|
* @return array Character type data
|
||||||
|
*/
|
||||||
|
public function getCharactertypeById($charactertypeId)
|
||||||
|
{
|
||||||
|
$data = $this->db->query(
|
||||||
|
'SELECT id, seminary_id, name, url '.
|
||||||
|
'FROM charactertypes '.
|
||||||
|
'WHERE id = ?',
|
||||||
|
'i',
|
||||||
|
$charactertypeId
|
||||||
|
);
|
||||||
|
if(empty($data)) {
|
||||||
|
throw new \nre\exceptions\IdNotFoundException($charactertypeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a Charactertype name already exists.
|
* Check if a Charactertype name already exists.
|
||||||
*
|
*
|
||||||
|
|
@ -87,6 +137,10 @@
|
||||||
*/
|
*/
|
||||||
public function createCharactertype($userId, $seminaryId, $name)
|
public function createCharactertype($userId, $seminaryId, $name)
|
||||||
{
|
{
|
||||||
|
$charactertypeId = null;
|
||||||
|
$this->db->setAutocommit(false);
|
||||||
|
try {
|
||||||
|
// Create Charactertype
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
'INSERT INTO charactertypes '.
|
'INSERT INTO charactertypes '.
|
||||||
'(created_user_id, seminary_id, name, url) '.
|
'(created_user_id, seminary_id, name, url) '.
|
||||||
|
|
@ -98,8 +152,32 @@
|
||||||
$name,
|
$name,
|
||||||
\nre\core\Linker::createLinkParam($name)
|
\nre\core\Linker::createLinkParam($name)
|
||||||
);
|
);
|
||||||
|
$charactertypeId = $this->db->getInsertId();
|
||||||
|
|
||||||
return $this->db->getInsertId();
|
// Create avatars
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT INTO avatars '.
|
||||||
|
'(created_user_id, charactertype_id, xplevel_id) '.
|
||||||
|
'SELECT ?, ?, xplevels.id '.
|
||||||
|
'FROM xplevels '.
|
||||||
|
'WHERE seminary_id = ?',
|
||||||
|
'iii',
|
||||||
|
$userId,
|
||||||
|
$charactertypeId,
|
||||||
|
$seminaryId
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
|
||||||
|
|
||||||
|
return $charactertypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,60 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Avatar picture for a Charactertype by creating a new Seminarymedia and
|
||||||
|
* adding it to the list of Avatar pictures.
|
||||||
|
*
|
||||||
|
* @param int $userId ID of user that does the upload
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
|
* @param string $filename Filename of uploading media
|
||||||
|
* @param string $description Description for media
|
||||||
|
* @param string $mimetype Mimetype of media
|
||||||
|
* @param string $tmpFilename Name of temporary uploaded file
|
||||||
|
* @return mixed ID of media record or false if upload failed
|
||||||
|
*/
|
||||||
|
public function createAvatarpicture($userId, $seminaryId, $filename, $description, $mimetype, $tmpFilename)
|
||||||
|
{
|
||||||
|
$mediaId = false;
|
||||||
|
$this->db->setAutocommit(false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Create Seminary media record
|
||||||
|
$mediaId = $this->createSeminaryMedia($userId, $seminaryId, $filename, $description, $mimetype);
|
||||||
|
|
||||||
|
// Add media to Achievements media
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT INTO avatarpictures '.
|
||||||
|
'(seminarymedia_id, created_user_id) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?) '.
|
||||||
|
'ON DUPLICATE KEY UPDATE '.
|
||||||
|
'created_user_id = ?',
|
||||||
|
'iii',
|
||||||
|
$mediaId,
|
||||||
|
$userId,
|
||||||
|
$userId
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create filename
|
||||||
|
$filename = ROOT.DS.\nre\configs\AppConfig::$dirs['seminarymedia'].DS.$mediaId;
|
||||||
|
if(!move_uploaded_file($tmpFilename, $filename))
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
$mediaId = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(\nre\exceptions\DatamodelException $e) {
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
return $mediaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Questgroup picture (Moodpic).
|
* Create a new Questgroup picture (Moodpic).
|
||||||
*
|
*
|
||||||
|
|
@ -339,6 +393,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Achievement media by creating a new Seminarymedia and
|
||||||
|
* adding it to the list of media for Achievements.
|
||||||
|
*
|
||||||
|
* @param int $userId ID of user that does the upload
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
|
* @param string $filename Filename of uploading media
|
||||||
|
* @param string $description Description for media
|
||||||
|
* @param string $mimetype Mimetype of media
|
||||||
|
* @param string $tmpFilename Name of temporary uploaded file
|
||||||
|
* @return mixed ID of media record or false if upload failed
|
||||||
|
*/
|
||||||
public function createAchievementMedia($userId, $seminaryId, $filename, $description, $mimetype, $tmpFilename)
|
public function createAchievementMedia($userId, $seminaryId, $filename, $description, $mimetype, $tmpFilename)
|
||||||
{
|
{
|
||||||
$mediaId = false;
|
$mediaId = false;
|
||||||
|
|
|
||||||
45
views/html/charactertypes/create.tpl
Normal file
45
views/html/charactertypes/create.tpl
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?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>
|
||||||
|
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('index',$seminary['url']),1)?>"><?=_('Charactertypes')?></a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1><?=_('Create new Charactertype')?></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 'charactertypename':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('Name is too short (min. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'maxlength': printf(_('Name is too long (max. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'exist': echo _('Name already exists');
|
||||||
|
break;
|
||||||
|
default: echo _('Name invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
|
<form method="post">
|
||||||
|
<fieldset>
|
||||||
|
<label for="name"><?=_('Name')?>:</legend>
|
||||||
|
<input id="name" type="text" name="charactertypename" placeholder="<?=_('Name')?>" title="<?=_('Name')?>" required="required" maxlength="<?=$validationSettings['charactertypename']['maxlength']?>" value="<?=$name?>" <?=($validation !== true && array_key_exists('name', $validation)) ? 'class="invalid"' : null?> />
|
||||||
|
</fieldset>
|
||||||
|
<input type="submit" name="create" value="<?=_('create')?>" />
|
||||||
|
</form>
|
||||||
16
views/html/charactertypes/delete.tpl
Normal file
16
views/html/charactertypes/delete.tpl
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?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>
|
||||||
|
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('index',$seminary['url']),1)?>"><?=_('Charactertypes')?></a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1><?=_('Delete Charactertype')?></h1>
|
||||||
|
<?=sprintf(_('Should the Characterytpe “%s” really be deleted?'), $charactertype['name'])?>
|
||||||
|
<form method="post">
|
||||||
|
<input type="submit" name="delete" value="<?=_('delete')?>" />
|
||||||
|
<input type="submit" name="not-delete" value="<?=_('cancel')?>" />
|
||||||
|
</form>
|
||||||
125
views/html/charactertypes/edit.tpl
Normal file
125
views/html/charactertypes/edit.tpl
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
<?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>
|
||||||
|
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('index',$seminary['url']),1)?>"><?=_('Charactertypes')?></a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1><?=_('Edit Charactertype')?></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 'charactertypename':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('Name is too short (min. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'maxlength': printf(_('Name is too long (max. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'exist': echo _('Name already exists');
|
||||||
|
break;
|
||||||
|
default: echo _('Name invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<fieldset>
|
||||||
|
<label for="name"><?=_('Name')?>:</label>
|
||||||
|
<input id="name" type="text" name="charactertypename" placeholder="<?=_('Name')?>" title="<?=_('Name')?>" required="required" maxlength="<?=$validationSettings['charactertypename']['maxlength']?>" value="<?=$name?>" <?=($validation !== true && array_key_exists('name', $validation)) ? 'class="invalid"' : null?> />
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend><?=_('Avatars')?></legend>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($xplevels as &$xplevel) : ?>
|
||||||
|
<li>
|
||||||
|
<?php if($avatarsValidation !== true && array_key_exists($xplevel['id'], $avatarsValidation)) : ?>
|
||||||
|
<ul>
|
||||||
|
<?php if(array_key_exists('portrait', $avatarsValidation[$xplevel['id']])) : ?>
|
||||||
|
<?php foreach($avatarsValidation[$xplevel['id']]['portrait'] as $field => &$settings) : ?>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($settings as $setting => $value) : ?>
|
||||||
|
<li>
|
||||||
|
<?php switch($field) {
|
||||||
|
case 'avatar':
|
||||||
|
switch($setting) {
|
||||||
|
case 'error': printf(_('Error during avatar portrait upload: %s'), $value);
|
||||||
|
break;
|
||||||
|
case 'mimetype': printf(_('Avatar portrait has wrong type “%s”'), $value);
|
||||||
|
break;
|
||||||
|
case 'size': echo _('Avatar portrait exceeds size maximum');
|
||||||
|
break;
|
||||||
|
default: echo _('Avatar portrait invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if(array_key_exists('avatar', $avatarsValidation[$xplevel['id']])) : ?>
|
||||||
|
<?php foreach($avatarsValidation[$xplevel['id']]['avatar'] as $field => &$settings) : ?>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($settings as $setting => $value) : ?>
|
||||||
|
<li>
|
||||||
|
<?php switch($field) {
|
||||||
|
case 'avatar':
|
||||||
|
switch($setting) {
|
||||||
|
case 'error': printf(_('Error during avatar upload: %s'), $value);
|
||||||
|
break;
|
||||||
|
case 'mimetype': printf(_('Avatar has wrong type “%s”'), $value);
|
||||||
|
break;
|
||||||
|
case 'size': echo _('Avatar exceeds size maximum');
|
||||||
|
break;
|
||||||
|
default: echo _('Avatar invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<?php endif ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
|
<?=_('Level')?> <?=$xplevel['level']?>:<br />
|
||||||
|
<?php if(array_key_exists('avatar', $xplevel) && !is_null($xplevel['avatar']['small_avatarpicture_id'])) : ?>
|
||||||
|
<img id="avatar" src="<?=$linker->link(array('media','avatar',$seminary['url'],$charactertype['url'],$xplevel['level'],'portrait'))?>" />
|
||||||
|
<?php endif ?>
|
||||||
|
<label for="avatar-<?=$xplevel['id']?>-portrait"><?=_('Protrait')?>:</label>
|
||||||
|
<input id="avatar-<?=$xplevel['id']?>-portrait" type="file" name="avatars[<?=$xplevel['id']?>][portrait]" accept="<?=implode(',', array_map(function($m) { return $m['mimetype']; }, $mimetypes))?>" /><br />
|
||||||
|
<?php if(array_key_exists('avatar', $xplevel) && !is_null($xplevel['avatar']['avatarpicture_id'])) : ?>
|
||||||
|
<img id="avatar" src="<?=$linker->link(array('media','avatar',$seminary['url'],$charactertype['url'],$xplevel['level']))?>" />
|
||||||
|
<?php endif ?>
|
||||||
|
<label for="avatar-<?=$xplevel['id']?>-avatar"><?=_('Avatar')?>:</label>
|
||||||
|
<input id="avatar-<?=$xplevel['id']?>-avatar" type="file" name="avatars[<?=$xplevel['id']?>][avatar]" accept="<?=implode(',', array_map(function($m) { return $m['mimetype']; }, $mimetypes))?>" />
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<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>
|
||||||
|
<input type="submit" name="edit" value="<?=_('save')?>" />
|
||||||
|
</form>
|
||||||
29
views/html/charactertypes/index.tpl
Normal file
29
views/html/charactertypes/index.tpl
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?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><?=_('Charactertypes')?></h1>
|
||||||
|
<?php if($seminary['created_user_id'] == \hhu\z\controllers\IntermediateController::$user['id'] || (!is_null(\hhu\z\controllers\SeminaryController::$character) && in_array('admin', \hhu\z\controllers\SeminaryController::$character['characterroles']))) : ?>
|
||||||
|
<nav class="admin">
|
||||||
|
<li><a href="<?=$linker->link(array('create',$seminary['url']),1)?>"><?=_('Create new Character type')?></a></li>
|
||||||
|
</nav>
|
||||||
|
<?php endif ?>
|
||||||
|
<ul class="avatar">
|
||||||
|
<?php foreach($charactertypes as &$type) : ?>
|
||||||
|
<li>
|
||||||
|
<p><?=$type['name']?></p>
|
||||||
|
<?php if(array_key_exists('avatar', $type) && !is_null($type['avatar']['small_avatarpicture_id'])) : ?>
|
||||||
|
<img id="avatar" src="<?=$linker->link(array('media','avatar',$seminary['url'],$type['url'],$xplevels[0]['level'],'portrait'))?>" />
|
||||||
|
<?php endif ?>
|
||||||
|
<ul class="admin">
|
||||||
|
<li><a href="<?=$linker->link(array('edit',$seminary['url'],$type['url']),1)?>"><?=_('edit')?></a></li>
|
||||||
|
<li><a href="<?=$linker->link(array('delete',$seminary['url'],$type['url']),1)?>"><?=_('delete')?></a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
|
@ -1,92 +0,0 @@
|
||||||
<?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 Charactertypes')?></h1>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2><?=_('Edit Charactertypes')?></h2>
|
|
||||||
<form method="post">
|
|
||||||
<ul>
|
|
||||||
<?php foreach($charactertypesNames as $charactertypeId => &$name) : ?>
|
|
||||||
<li>
|
|
||||||
<?php if($validations['edit-charactertypes'] !== true && array_key_exists($charactertypeId, $validations['edit-charactertypes']) && $validations['edit-charactertypes'][$charactertypeId] !== true) : ?>
|
|
||||||
<ul>
|
|
||||||
<?php foreach($validations['edit-charactertypes'][$charactertypeId] as $field => &$settings) : ?>
|
|
||||||
<li>
|
|
||||||
<ul>
|
|
||||||
<?php foreach($settings as $setting => $value) : ?>
|
|
||||||
<li>
|
|
||||||
<?php switch($field) {
|
|
||||||
case 'charactertypename':
|
|
||||||
switch($setting) {
|
|
||||||
case 'minlength': printf(_('Name is too short (min. %d chars)'), $value);
|
|
||||||
break;
|
|
||||||
case 'maxlength': printf(_('Name is too long (max. %d chars)'), $value);
|
|
||||||
break;
|
|
||||||
case 'exist': echo _('Name already exists');
|
|
||||||
break;
|
|
||||||
default: echo _('Name invalid');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} ?>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
<?php endif ?>
|
|
||||||
<input id="charactertype-<?=$charactertypeId?>" type="text" name="charactertypes[<?=$charactertypeId?>]" placeholder="<?=$name?>" title="<?=$name?>" required="required" maxlength="<?=$validationSettings['charactertype']['maxlength']?>" value="<?=$name?>" <?=($validations['edit-charactertypes'] !== true && array_key_exists($charactertypeId, $validations['edit-charactertypes']) && $validations['edit-charactertypes'][$charactertypeId] !== true && array_key_exists('charactertypename', $validations['edit-charactertypes'][$charactertypeId])) ? 'class="invalid"' : null?>/>
|
|
||||||
<input id="charactertype-<?=$charactertypeId?>-delete" type="checkbox" name="delete-charactertypes[<?=$charactertypeId?>]" <?php if(!is_null($deleteCharactertypes) && array_key_exists($charactertypeId, $deleteCharactertypes)) : ?>checked="checked"<?php endif ?> />
|
|
||||||
<label for="charactertype-<?=$charactertypeId?>-delete"><?=_('delete')?></label><br />
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
<input type="submit" name="edit-charactertypes" value="<?=_('save')?>" />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2><?=_('Create new Charactertype')?></h2>
|
|
||||||
<?php if($validations['create-charactertype'] !== true) : ?>
|
|
||||||
<ul>
|
|
||||||
<?php foreach($validations['create-charactertype'] as $field => &$settings) : ?>
|
|
||||||
<li>
|
|
||||||
<ul>
|
|
||||||
<?php foreach($settings as $setting => $value) : ?>
|
|
||||||
<li>
|
|
||||||
<?php switch($field) {
|
|
||||||
case 'charactertypename':
|
|
||||||
switch($setting) {
|
|
||||||
case 'minlength': printf(_('Name is too short (min. %d chars)'), $value);
|
|
||||||
break;
|
|
||||||
case 'maxlength': printf(_('Name is too long (max. %d chars)'), $value);
|
|
||||||
break;
|
|
||||||
case 'exist': echo _('Name already exists');
|
|
||||||
break;
|
|
||||||
default: echo _('Name invalid');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} ?>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
<?php endif ?>
|
|
||||||
<form method="post">
|
|
||||||
<fieldset>
|
|
||||||
<label for="charactertypename"><?=_('Name')?>:</legend>
|
|
||||||
<input id="charactertypename" type="text" name="charactertypename" placeholder="<?=_('Name')?>" title="<?=_('Name')?>" required="required" maxlength="<?=$validationSettings['charactertypename']['maxlength']?>" value="<?=$charactertypeName?>" <?=($validations['create-charactertype'] !== true && array_key_exists('title', $validations['create-charactertype'])) ? 'class="invalid"' : null?> />
|
|
||||||
</fieldset>
|
|
||||||
<input type="submit" name="create-charactertype" value="<?=_('create')?>" />
|
|
||||||
</form>
|
|
||||||
|
|
@ -31,17 +31,22 @@
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<p><?=\hhu\z\Utils::t($seminary['description'])?></p>
|
<p><?=\hhu\z\Utils::t($seminary['description'])?></p>
|
||||||
<p><small><?=sprintf(_('created by %s on %s'), $seminary['creator']['username'], $dateFormatter->format(new \DateTime($seminary['created'])))?></small></p>
|
<p><small><?=sprintf(_('created by %s on %s'), $seminary['creator']['username'], $dateFormatter->format(new \DateTime($seminary['created'])))?></small></p>
|
||||||
|
|
||||||
|
|
||||||
<?php if(!array_key_exists('usercharacter', $seminary)) : ?>
|
<?php if(!array_key_exists('usercharacter', $seminary)) : ?>
|
||||||
|
<?php if($seminary['created_user_id'] == \hhu\z\controllers\IntermediateController::$user['id']) : ?>
|
||||||
|
<a class="cta orange" href="<?=$linker->link(array('xplevels','manage',$seminary['url']))?>"><?=_('Manage XP-levels')?></a>
|
||||||
|
<?php if(count($seminary['xplevels']) > 0) : ?>
|
||||||
|
<a class="cta orange" href="<?=$linker->link(array('charactertypes','index',$seminary['url']))?>"><?=_('Manage Charactertypes')?></a>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if(count($seminary['charactertypes']) > 0) : ?>
|
<?php if(count($seminary['charactertypes']) > 0) : ?>
|
||||||
<a class="cta orange" href="<?=$linker->link(array('characters','register',$seminary['url']))?>"><?=_('Create a Character')?></a>
|
<a class="cta orange" href="<?=$linker->link(array('characters','register',$seminary['url']))?>"><?=_('Create a Character')?></a>
|
||||||
<?php elseif(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) > 0) : ?>
|
|
||||||
<a class="cta orange" href="<?=$linker->link(array('charactertypes','manage',$seminary['url']))?>"><?=_('Manage Charactertypes')?></a>
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php elseif(count($seminary['usercharacter']['characterroles']) == 0) : ?>
|
<?php elseif(count($seminary['usercharacter']['characterroles']) == 0) : ?>
|
||||||
<p><?=sprintf(_('Your Character “%s” has not been activated yet'), $seminary['usercharacter']['name'])?></p>
|
<p><?=sprintf(_('Your Character “%s” has not been activated yet'), $seminary['usercharacter']['name'])?></p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue