list Character groups Achievements for Character groups and groups-groups

This commit is contained in:
oliver 2016-03-12 16:02:58 +01:00
parent 73c378d9f3
commit e4f98c29d1
3 changed files with 61 additions and 1 deletions

View file

@ -24,7 +24,7 @@
*
* @var array
*/
public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'characters', 'avatars', 'media');
public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'charactergroupsachievements', 'characters', 'avatars', 'media');
/**
* Required components
*
@ -120,6 +120,14 @@
// Get Character groups-group Quests
$quests = $this->Charactergroupsquests->getQuestsForCharactergroupsgroup($groupsgroup['id']);
// Get Achievements
$achievements = array();
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) {
$achievements = $this->Charactergroupsachievements->getAchievementsForCharactergroupsgroup(
$groupsgroup['id']
);
}
// Set titile
$this->addTitle($groupsgroup['name']);
@ -131,6 +139,7 @@
$this->set('groupsgroup', $groupsgroup);
$this->set('groups', $groups);
$this->set('quests', $quests);
$this->set('achievements', $achievements);
}
@ -350,6 +359,11 @@
// Get Character groups Quests
$quests = $this->Charactergroupsquests->getQuestsForGroup($group['id']);
// Get Achievements
$achievements = $this->Charactergroupsachievements->getAchievedAchievementsForGroup(
$group['id']
);
// Set titile
$this->addTitle($group['name']);
@ -361,6 +375,7 @@
$this->set('groupsgroup', $groupsgroup);
$this->set('group', $group);
$this->set('quests', $quests);
$this->set('achievements', $achievements);
}

View file

@ -59,3 +59,28 @@
<?php endforeach ?>
</ul>
</section>
<?php if(!empty($achievements) || count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) : ?>
<section>
<h1 id="achievements"><i class="fa fa-trophy fa-fw"></i><?=_('Achievements')?></a></h1>
<?php if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) : ?>
<nav class="admin">
<li><a href="<?=$linker->link(array('charactergroupsachievements','manage',$seminary['url'],$groupsgroup['url']))?>"><?=sprintf(_('Manage %s-Achievements'), $groupsgroup['name'])?></a></li>
</nav>
<?php endif ?>
<ul class="achmnts">
<?php foreach($achievements as &$achievement) : ?>
<li class="cf">
<?php if(!is_null($achievement['achievementsmedia_id'])) : ?>
<img src="<?=$linker->link(array('media','charactergroupsachievement',$seminary['url'],$groupsgroup['url'],$achievement['url']))?>" />
<?php endif ?>
<h3 id="<?=$achievement['url']?>">
<?=$achievement['title']?>
<span class="unlcked"><?=sprintf(_('achieved at: %s'), $dateFormatter->format(new \DateTime($achievement['created'])))?></span>
</h3>
<p class="desc"><?=\hhu\z\Utils::t($achievement['description'])?></p>
</li>
<?php endforeach?>
</ul>
</section>
<?php endif ?>

View file

@ -44,3 +44,23 @@
</li>
<?php endforeach ?>
</ul>
<?php if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0 || in_array(\hhu\z\controllers\SeminaryController::$character['id'], array_map(function($c) { return $c['id']; }, $group['characters']))) : ?>
<h2 id="achievements"><i class="fa fa-trophy fa-fw"></i><?=sprintf(_('%s-Achievements'),$groupsgroup['name'])?></a></h2>
<nav class="admin">
<li><a href="<?=$linker->link(array('charactergroupsachievements','create',$seminary['url'],$groupsgroup['url']))?>"><?=sprintf(_('Create new %s-Achievement'), $groupsgroup['name'])?></a></li>
<li><a href="<?=$linker->link(array('charactergroupsachievements','manage',$seminary['url'],$groupsgroup['url']))?>"><?=sprintf(_('Manage %s-Achievements'), $groupsgroup['name'])?></a></li>
</nav>
<ul class="achmnts">
<?php foreach($achievements as &$achievement) : ?>
<li class="cf">
<?php if(!is_null($achievement['achievementsmedia_id'])) : ?>
<img src="<?=$linker->link(array('media','charactergroupsachievement',$seminary['url'],$groupsgroup['url'],$achievement['url']))?>" />
<?php endif ?>
<h3 id="<?=$achievement['url']?>"><?=$achievement['title']?></h3>
<p class="desc"><?=\hhu\z\Utils::t($achievement['description'])?></p>
</li>
<?php endforeach?>
</ul>
<?php endif ?>