add Character group selector to Station pages and show groups? status

This commit is contained in:
oliver 2016-02-27 16:07:25 +01:00
commit 54ed53ac33
4 changed files with 83 additions and 21 deletions

View file

@ -166,13 +166,33 @@
$station['wrongav'] = $this->Media->getSeminaryMediaById($station['wrongav_id']);
}
// Get Character group
// Get Character group(s)
$stationgroups = null;
$stationgroup = null;
$charactergroup = null;
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) {
$stationgroups = $this->Charactergroups->getGroupsForGroupsgroup($groupsgroup['id']);
}
else
{
$character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']);
$charactergroups = $this->Charactergroups->getGroupsForCharacter($character['id']);
if(!empty($charactergroups)) {
// TODO Multiple Character groups
$charactergroup = $charactergroups[0];
$stationgroups = $this->Charactergroups->getGroupsForCharacter($character['id']);
if(!empty($stationgroups)) {
$stationgroup = $stationgroups[0];
$charactergroup = $stationgroup;
}
}
// Select group by parameter
$selectedStationGroupId = $this->request->getGetParam('stationgroup');
if(!is_null($selectedStationGroupId))
{
$selectedStationGroupId = intval($selectedStationGroupId);
foreach($stationgroups as &$group) {
if($group['id'] == $selectedStationGroupId) {
$stationgroup = $group;
break;
}
}
}
// TODO Check permissions
@ -219,20 +239,27 @@
}
// Status
$solved = false;
$entered = false;
$tried = false;
if(!is_null($charactergroup)) {
$solved = false;
if(!is_null($stationgroup)) {
$entered = $this->Charactergroupsqueststations->hasCharactergroupEnteredStation(
$station['id'],
$stationgroup['id']
);
if($entered) {
$tried = $this->Charactergroupsqueststations->hasCharactergroupTriedStation(
$station['id'],
$charactergroup['id']
$stationgroup['id']
);
if($tried) {
$solved = $this->Charactergroupsqueststations->hasCharactergroupSolvedStation(
$station['id'],
$charactergroup['id']
$stationgroup['id']
);
}
}
}
// Set title
@ -248,9 +275,11 @@
$this->set('station', $station);
$this->set('task', $task);
$this->set('groups', $groups);
$this->set('stationgroup', $charactergroup);
$this->set('solved', $solved);
$this->set('stationgroups', $stationgroups);
$this->set('stationgroup', $stationgroup);
$this->set('entered', $entered);
$this->set('tried', $tried);
$this->set('solved', $solved);
}

View file

@ -98,7 +98,11 @@
<li>
<span class="group">
<?php if(!array_key_exists('entered', $station) || $station['entered']) : ?>
<?php if(!is_null($stationgroup)) : ?>
<a href="<?=$linker->link(array('charactergroupsqueststations','station',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']),0,true,array('stationgroup'=>$stationgroup['id']))?>"><?=$station['title']?></a>
<?php else : ?>
<a href="<?=$linker->link(array('charactergroupsqueststations','station',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']))?>"><?=$station['title']?></a>
<?php endif ?>
<?php else : ?>
<?=_('Station not yet discovered')?>
<?php endif ?>

View file

@ -7,6 +7,7 @@
</ul>
<div class="grpqsicon">
<?php if($entered) : ?>
<?php if($tried) : ?>
<?php if($solved) : ?>
<?php if($station['stationpicture_id']) : ?>
@ -24,6 +25,9 @@
<img title="<?=$station['title']?>" src="<?=$linker->link(array('media','charactergroupsqueststation',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']),0,true)?>" />
<?php endif ?>
<?php endif ?>
<?php else : ?>
<i class="fa fa-question-circle"></i>
<?php endif ?>
</div>
<h1><?=$station['title']?></h1>
@ -41,13 +45,37 @@
<i class="fa fa-qrcode"></i>
</a>
</li>
<?php endif ?>
<?php if($tried) : ?>
<li>
<?php if(count($stationgroups) > 1) : ?>
<form method="get">
<select id="stationgroup" name="stationgroup" onchange="this.form.submit();">
<?php if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) : ?>
<option><?=sprintf(_('Select %s-Group'), $groupsgroup['name'])?></option>
<?php endif ?>
<?php foreach($stationgroups as &$group) : ?>
<option value="<?=$group['id']?>" <?php if($group['id'] == $stationgroup['id']) : ?>selected="selected"<?php endif ?>><?=$group['name']?></option>
<?php endforeach ?>
</select>
</form>
<?php endif ?>
</li>
<?php endif ?>
<?php if($entered) : ?>
<li>
<?php if($tried) : ?>
<?php if($solved) : ?>
<i class="fa fa-check-circle fa-fw"></i>
<?=$dateFormatter->format(new \DateTime($solved))?>
<?=$timeFormatter->format(new \DateTime($solved))?>
<?php else : ?>
<i class="fa fa-times-circle fa-fw"></i>
<?=$dateFormatter->format(new \DateTime($tried))?>
<?=$timeFormatter->format(new \DateTime($tried))?>
<?php endif ?>
<?php else : ?>
<i class="fa fa-globe fa-fw"></i>
<?=$dateFormatter->format(new \DateTime($entered))?>
<?=$timeFormatter->format(new \DateTime($entered))?>
<?php endif ?>
</li>
<?php endif ?>

View file

@ -302,7 +302,8 @@ input[type="submit"][disabled]{text-shadow:1px 2px #d48c4e;background:#f9ac69;bo
.grpqslist li{float:left;width:100px;height:100px;text-align:center;margin:5px}
.grpqslist li a{color:#5e5c58}
.grpqslist li i{font-size:100px;padding:0}
.grpqsicon{float:right;box-shadow:0 0 5px gray}
.grpqsicon{float:right;box-shadow:0 0 5px gray;text-align:center}
.grpqsicon i{display:block;font-size:100px;width:100px;height:100px;padding:0}
/** Achievements **/