diff --git a/controllers/SeminarybarController.inc b/controllers/SeminarybarController.inc index 1a36f136..53039526 100644 --- a/controllers/SeminarybarController.inc +++ b/controllers/SeminarybarController.inc @@ -25,7 +25,7 @@ * * @var array */ - public $models = array('characters', 'quests', 'questgroups', 'achievements'); + public $models = array('characters', 'quests', 'questgroups', 'achievements', 'charactergroups', 'avatars', 'media'); @@ -60,12 +60,35 @@ $achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id']); $lastAchievement = array_shift($achievements); + // Get Character group members + $characterGroups = array(); + foreach($this->Charactergroups->getGroupsForCharacter($character['id']) as $group) + { + $groupsgroup = $this->Charactergroups->getGroupsgroupById($group['charactergroupsgroup_id']); + if($groupsgroup['preferred']) + { + $group['members'] = $this->Characters->getCharactersForGroup($group['id']); + foreach($group['members'] as &$member) + { + if(!is_null($member['avatar_id'])) + { + $avatar = $this->Avatars->getAvatarById($member['avatar_id']); + if(!is_null($avatar['small_avatarpicture_id'])) { + $member['small_avatar'] = $this->Media->getSeminaryMediaById($avatar['small_avatarpicture_id']); + } + } + } + $characterGroups[] = $group; + } + } + // Pass data to view $this->set('seminary', $seminary); $this->set('character', $character); $this->set('lastQuest', $lastQuest); $this->set('lastAchievement', $lastAchievement); + $this->set('characterGroups', $characterGroups); } } diff --git a/models/CharactergroupsModel.inc b/models/CharactergroupsModel.inc index e88b1826..e042fd10 100644 --- a/models/CharactergroupsModel.inc +++ b/models/CharactergroupsModel.inc @@ -44,7 +44,7 @@ public function getGroupsroupsForSeminary($seminaryId) { return $this->db->query( - 'SELECT id, name, url '. + 'SELECT id, name, url, preferred '. 'FROM charactergroupsgroups '. 'WHERE seminary_id = ?', 'i', @@ -64,7 +64,7 @@ public function getGroupsgroupByUrl($seminaryId, $groupsgroupUrl) { $data = $this->db->query( - 'SELECT id, name, url '. + 'SELECT id, name, url, preferred '. 'FROM charactergroupsgroups '. 'WHERE seminary_id = ? AND url = ?', 'is', @@ -79,6 +79,31 @@ } + /** + * Get a Character groups-group by its ID. + * + * @throws IdNotFoundException + * @param string $groupsgroupId ID of the Character groups-group + * @return array Character groups-group data + */ + public function getGroupsgroupById($groupsgroupId) + { + $data = $this->db->query( + 'SELECT id, name, url, preferred '. + 'FROM charactergroupsgroups '. + 'WHERE id = ?', + 'i', + $groupsgroupId + ); + if(empty($data)) { + throw new \nre\exceptions\IdNotFoundException($groupsgroupId); + } + + + return $data[0]; + } + + /** * Get Character groups for a Character groups-group. * diff --git a/models/CharactersModel.inc b/models/CharactersModel.inc index c659afec..81b24018 100644 --- a/models/CharactersModel.inc +++ b/models/CharactersModel.inc @@ -83,7 +83,7 @@ public function getCharactersForGroup($groupId) { return $this->db->query( - 'SELECT characters.id, characters.created, characters.charactertype_id, characters.name, characters.url, characters.user_id, characters.xps, characters.avatar_id, charactertypes.name AS charactertype_name, charactertypes.url AS charactertypes_url '. + 'SELECT characters.id, characters.created, characters.charactertype_id, characters.name, characters.url, characters.user_id, characters.xps, characters.xplevel, characters.avatar_id, charactertypes.name AS charactertype_name, charactertypes.url AS charactertypes_url '. 'FROM v_characters AS characters '. 'LEFT JOIN characters_charactergroups ON characters_charactergroups.character_id = characters.id '. 'LEFT JOIN charactertypes ON charactertypes.id = characters.charactertype_id '. diff --git a/views/html/seminarybar/index.tpl b/views/html/seminarybar/index.tpl index 0879970c..60752cc7 100644 --- a/views/html/seminarybar/index.tpl +++ b/views/html/seminarybar/index.tpl @@ -32,33 +32,19 @@
-

Wille und die Majas

+ +

-

Gildenprofil ansehen

+

+