merge
This commit is contained in:
commit
e4d89d2d68
4 changed files with 135 additions and 54 deletions
|
|
@ -69,20 +69,40 @@
|
|||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Set default properties to show
|
||||
$properties = array(
|
||||
'username',
|
||||
'xps'
|
||||
);
|
||||
|
||||
// Select proprties to show
|
||||
if($this->request->getRequestMethod() == 'POST')
|
||||
{
|
||||
$properties = $this->request->getPostParam('properties');
|
||||
if(!is_array($properties)) {
|
||||
$properties = array();
|
||||
}
|
||||
}
|
||||
|
||||
// Get registered Characters
|
||||
$characters = $this->Characters->getCharactersForSeminary($seminary['id']);
|
||||
|
||||
// Additional Character information
|
||||
foreach($characters as &$character)
|
||||
{
|
||||
// Level
|
||||
$character['xplevel'] = $this->Characters->getXPLevelOfCharacters($character['id']);
|
||||
$character['characterroles'] = array_map(function($r) { return $r['name']; }, $this->Characterroles->getCharacterrolesForCharacterById($character['id']));
|
||||
$character['user'] = $this->Users->getUserById($character['user_id']);
|
||||
$character['characterfields'] = $this->Seminarycharacterfields->getFieldsForCharacter($character['id']);
|
||||
}
|
||||
|
||||
// Get Seminarycharacterfields
|
||||
$characterfields = $this->Seminarycharacterfields->getFieldsForSeminary($seminary['id']);
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('characters', $characters);
|
||||
$this->set('characterfields', $characterfields);
|
||||
$this->set('properties', $properties);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -107,9 +127,6 @@
|
|||
$character['xplevel'] = $this->Characters->getXPLevelOfCharacters($character['id']);
|
||||
$character['rank'] = $this->Characters->getXPRank($seminary['id'], $character['xps']);
|
||||
|
||||
// Get Seminarycharacterfields
|
||||
$characterfields = $this->Seminarycharacterfields->getFieldsForCharacter($character['id']);
|
||||
|
||||
// Get User
|
||||
$user = $this->Users->getUserById($character['user_id']);
|
||||
|
||||
|
|
@ -153,7 +170,6 @@
|
|||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('character', $character);
|
||||
$this->set('characterfields', $characterfields);
|
||||
$this->set('user', $user);
|
||||
$this->set('groups', $groups);
|
||||
$this->set('achievements', $achievements);
|
||||
|
|
@ -289,56 +305,72 @@
|
|||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Do action
|
||||
// Set default properties to show
|
||||
$properties = array(
|
||||
'username',
|
||||
'xps',
|
||||
'roles'
|
||||
);
|
||||
|
||||
$selectedCharacters = array();
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('actions')) && count($this->request->getPostParam('actions')) > 0 && !is_null($this->request->getPostParam('characters')) && count($this->request->getPostParam('characters')) > 0)
|
||||
if($this->request->getRequestMethod() == 'POST')
|
||||
{
|
||||
$actions = $this->request->getPostParam('actions');
|
||||
$action = array_keys($actions)[0];
|
||||
$selectedCharacters = $this->request->getPostParam('characters');
|
||||
|
||||
switch($action)
|
||||
// Do action
|
||||
if(!is_null($this->request->getPostParam('actions')) && count($this->request->getPostParam('actions')) > 0 && !is_null($this->request->getPostParam('characters')) && count($this->request->getPostParam('characters')) > 0)
|
||||
{
|
||||
// Add/remove role to/from Characters
|
||||
case 'addrole':
|
||||
case 'removerole':
|
||||
// Determine role and check permissions
|
||||
$role = null;
|
||||
switch($actions[$action])
|
||||
{
|
||||
case _('Admin'):
|
||||
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) <= 0 && !in_array('admin', \hhu\z\controllers\SeminaryController::$character['characterroles'])) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
$role = 'admin';
|
||||
break;
|
||||
case _('Moderator'):
|
||||
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) <= 0 && !in_array('admin', \hhu\z\controllers\SeminaryController::$character['characterroles'])) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
$role = 'moderator';
|
||||
break;
|
||||
case _('User'):
|
||||
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) <= 0 && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) <= 0) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
$role = 'user';
|
||||
break;
|
||||
}
|
||||
$actions = $this->request->getPostParam('actions');
|
||||
$action = array_keys($actions)[0];
|
||||
$selectedCharacters = $this->request->getPostParam('characters');
|
||||
|
||||
switch($action)
|
||||
{
|
||||
// Add/remove role to/from Characters
|
||||
case 'addrole':
|
||||
case 'removerole':
|
||||
// Determine role and check permissions
|
||||
$role = null;
|
||||
switch($actions[$action])
|
||||
{
|
||||
case _('Admin'):
|
||||
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) <= 0 && !in_array('admin', \hhu\z\controllers\SeminaryController::$character['characterroles'])) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
$role = 'admin';
|
||||
break;
|
||||
case _('Moderator'):
|
||||
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) <= 0 && !in_array('admin', \hhu\z\controllers\SeminaryController::$character['characterroles'])) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
$role = 'moderator';
|
||||
break;
|
||||
case _('User'):
|
||||
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) <= 0 && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) <= 0) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
$role = 'user';
|
||||
break;
|
||||
}
|
||||
|
||||
// Add role
|
||||
if($action == 'addrole') {
|
||||
foreach($selectedCharacters as &$characterId) {
|
||||
$this->Characterroles->addCharacterroleToCharacter($characterId, $role);
|
||||
// Add role
|
||||
if($action == 'addrole') {
|
||||
foreach($selectedCharacters as &$characterId) {
|
||||
$this->Characterroles->addCharacterroleToCharacter($characterId, $role);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove role
|
||||
else {
|
||||
foreach($selectedCharacters as &$characterId) {
|
||||
$this->Characterroles->removeCharacterroleFromCharacter($characterId, $role);
|
||||
// Remove role
|
||||
else {
|
||||
foreach($selectedCharacters as &$characterId) {
|
||||
$this->Characterroles->removeCharacterroleFromCharacter($characterId, $role);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Properties to show
|
||||
$properties = $this->request->getPostParam('properties');
|
||||
if(!is_array($properties)) {
|
||||
$properties = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -348,12 +380,19 @@
|
|||
{
|
||||
$character['xplevel'] = $this->Characters->getXPLevelOfCharacters($character['id']);
|
||||
$character['characterroles'] = array_map(function($r) { return $r['name']; }, $this->Characterroles->getCharacterrolesForCharacterById($character['id']));
|
||||
$character['user'] = $this->Users->getUserById($character['user_id']);
|
||||
$character['characterfields'] = $this->Seminarycharacterfields->getFieldsForCharacter($character['id']);
|
||||
}
|
||||
|
||||
// Get Seminarycharacterfields
|
||||
$characterfields = $this->Seminarycharacterfields->getFieldsForSeminary($seminary['id']);
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('characters', $characters);
|
||||
$this->set('characterfields', $characterfields);
|
||||
$this->set('properties', $properties);
|
||||
$this->set('selectedCharacters', $selectedCharacters);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
public function getFieldsForCharacter($characterId)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT seminarycharacterfields.title, characters_seminarycharacterfields.value '.
|
||||
'SELECT seminarycharacterfields.id, seminarycharacterfields.title, seminarycharacterfields.url, seminarycharacterfields.regex, seminarycharacterfields.required, seminarycharacterfieldtypes.id AS type_id, seminarycharacterfieldtypes.title AS type_title, seminarycharacterfieldtypes.url AS type_url, characters_seminarycharacterfields.value '.
|
||||
'FROM characters_seminarycharacterfields '.
|
||||
'LEFT JOIN seminarycharacterfields ON seminarycharacterfields.id = characters_seminarycharacterfields.seminarycharacterfield_id '.
|
||||
'LEFT JOIN seminarycharacterfieldtypes ON seminarycharacterfieldtypes.id = seminarycharacterfields.seminarycharacterfieldtype_id '.
|
||||
|
|
|
|||
|
|
@ -14,12 +14,36 @@
|
|||
</nav>
|
||||
<?php endif ?>
|
||||
|
||||
<form method="post">
|
||||
<fieldset>
|
||||
<legend><?=_('Properties')?></legend>
|
||||
<input type="checkbox" id="username" name="properties[]" value="username" <?php if(in_array('username', $properties)) : ?>checked="checked"<?php endif ?> /><label for="username"><?=_('Username')?></label><br />
|
||||
<input type="checkbox" id="xps" name="properties[]" value="xps" <?php if(in_array('xps', $properties)) : ?>checked="checked"<?php endif ?> /><label for="xps"><?=_('XPs')?></label><br />
|
||||
<input type="checkbox" id="roles" name="properties[]" value="roles" <?php if(in_array('roles', $properties)) : ?>checked="checked"<?php endif ?> /><label for="roles"><?=_('Roles')?></label><br />
|
||||
<?php foreach($characterfields as &$characterfield) : ?>
|
||||
<input type="checkbox" id="characterfield-<?=$characterfield['url']?>" name="properties[characterfields][]" value="<?=$characterfield['url']?>" <?php if(array_key_exists('characterfields', $properties) && in_array($characterfield['url'], $properties['characterfields'])) : ?>checked="checked"<?php endif ?> /><label for="characterfield-<?=$characterfield['url']?>"><?=$characterfield['url']?></label><br />
|
||||
<?php endforeach ?>
|
||||
<input type="submit" name="set-properties" value="<?=_('Set properties')?>" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<ul class="gchars cf">
|
||||
<?php foreach($characters as &$character) : ?>
|
||||
<li>
|
||||
<p><img src="<?=$linker->link(array('media','avatar',$seminary['url'],$character['charactertype_url'],$character['xplevel']['level'],'portrait'))?>"></p>
|
||||
<p><a href="<?=$linker->link(array('characters','character',$seminary['url'],$character['url']))?>"><?=$character['name']?></a></p>
|
||||
<p><small><?=$character['xps']?> XP</small></p>
|
||||
<?php if(in_array('username', $properties)) : ?><p><small><a href="<?=$linker->link(array('users','user',$character['user']['url']))?>"><?=$character['user']['username']?></a></small></p><?php endif ?>
|
||||
<?php if(in_array('xps', $properties)) : ?><p><small><?=$character['xps']?> XP</small></p><?php endif ?>
|
||||
<?php if(in_array('roles', $properties)) : ?>
|
||||
<?php if(in_array('admin', $character['characterroles'])) : ?><p><small><?=_('Admin')?></small></p><?php endif ?>
|
||||
<?php if(in_array('moderator', $character['characterroles'])) : ?><p><small><?=_('Moderator')?></small></p><?php endif ?>
|
||||
<?php if(in_array('user', $character['characterroles'])) : ?><p><small><?=_('User')?></small></p><?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php foreach($character['characterfields'] as &$characterfield) : ?>
|
||||
<?php if(array_key_exists('characterfields', $properties) && in_array($characterfield['url'], $properties['characterfields'])) : ?>
|
||||
<p><small><?=$characterfield['value']?></small></p>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,16 @@
|
|||
<h1><?=_('Manage')?></h1>
|
||||
|
||||
<form method="post">
|
||||
<fieldset>
|
||||
<legend><?=_('Properties')?></legend>
|
||||
<input type="checkbox" id="username" name="properties[]" value="username" <?php if(in_array('username', $properties)) : ?>checked="checked"<?php endif ?> /><label for="username"><?=_('Username')?></label><br />
|
||||
<input type="checkbox" id="xps" name="properties[]" value="xps" <?php if(in_array('xps', $properties)) : ?>checked="checked"<?php endif ?> /><label for="xps"><?=_('XPs')?></label><br />
|
||||
<input type="checkbox" id="roles" name="properties[]" value="roles" <?php if(in_array('roles', $properties)) : ?>checked="checked"<?php endif ?> /><label for="roles"><?=_('Roles')?></label><br />
|
||||
<?php foreach($characterfields as &$characterfield) : ?>
|
||||
<input type="checkbox" id="characterfield-<?=$characterfield['url']?>" name="properties[characterfields][]" value="<?=$characterfield['url']?>" <?php if(array_key_exists('characterfields', $properties) && in_array($characterfield['url'], $properties['characterfields'])) : ?>checked="checked"<?php endif ?> /><label for="characterfield-<?=$characterfield['url']?>"><?=$characterfield['url']?></label><br />
|
||||
<?php endforeach ?>
|
||||
<input type="submit" name="set-properties" value="<?=_('Set properties')?>" />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?=_('Selection')?>:</legend>
|
||||
<ul class="gchars cf">
|
||||
|
|
@ -19,10 +29,18 @@
|
|||
<label for="characters-<?=$character['id']?>">
|
||||
<p><img src="<?=$linker->link(array('media','avatar',$seminary['url'],$character['charactertype_url'],$character['xplevel']['level'],'portrait'))?>"></p>
|
||||
<p><a href="<?=$linker->link(array('characters','character',$seminary['url'],$character['url']))?>"><?=$character['name']?></a></p>
|
||||
<p><small><?=$character['xps']?> XP</small></p>
|
||||
<?php if(in_array('username', $properties)) : ?><p><small><a href="<?=$linker->link(array('users','user',$character['user']['url']))?>"><?=$character['user']['username']?></a></small></p><?php endif ?>
|
||||
<?php if(in_array('xps', $properties)) : ?><p><small><?=$character['xps']?> XP</small></p><?php endif ?>
|
||||
<?php if(in_array('roles', $properties)) : ?>
|
||||
<?php if(in_array('admin', $character['characterroles'])) : ?><p><small><?=_('Admin')?></small></p><?php endif ?>
|
||||
<?php if(in_array('moderator', $character['characterroles'])) : ?><p><small><?=_('Moderator')?></small></p><?php endif ?>
|
||||
<?php if(in_array('user', $character['characterroles'])) : ?><p><small><?=_('User')?></small></p><?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php foreach($character['characterfields'] as &$characterfield) : ?>
|
||||
<?php if(array_key_exists('characterfields', $properties) && in_array($characterfield['url'], $properties['characterfields'])) : ?>
|
||||
<p><small><?=$characterfield['value']?></small></p>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue