diff --git a/controllers/CharactergroupsquestsController.inc b/controllers/CharactergroupsquestsController.inc index 4b128c4b..5bd3c2ef 100644 --- a/controllers/CharactergroupsquestsController.inc +++ b/controllers/CharactergroupsquestsController.inc @@ -78,13 +78,31 @@ $questgroup = $this->Questgroups->getQuestgroupById($quest['questgroups_id']); $questgroup['entered'] = $this->Questgroups->hasCharacterEnteredQuestgroup($questgroup['id'], self::$character['id']); - // Get Character group - $charactergroup = null; - $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]; + // Get Character group(s) + $stationgroups = null; + $stationgroup = 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']); + $stationgroups = $this->Charactergroups->getGroupsForCharacter($character['id']); + if(!empty($stationgroups)) { + $stationgroup = $stationgroups[0]; + } + } + // 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; + } + } } // Get Stations @@ -99,21 +117,21 @@ } // Entered state - if(!is_null($charactergroup)) { + if(!is_null($stationgroup)) { $station['entered'] = $this->Charactergroupsqueststations->hasCharactergroupEnteredStation( $station['id'], - $charactergroup['id'] + $stationgroup['id'] ); if($station['entered']) { $stationsDiscovered = true; $station['tried'] = $this->Charactergroupsqueststations->hasCharactergroupTriedStation( $station['id'], - $charactergroup['id'] + $stationgroup['id'] ); if($station['tried']) { $station['solved'] = $this->Charactergroupsqueststations->hasCharactergroupSolvedStation( $station['id'], - $charactergroup['id'] + $stationgroup['id'] ); } } @@ -150,6 +168,8 @@ $this->set('questgroup', $questgroup); $this->set('stations', $stations); $this->set('stationsDiscovered', $stationsDiscovered); + $this->set('stationgroups', $stationgroups); + $this->set('stationgroup', $stationgroup); $this->set('groups', $groups); $this->set('uploads', $uploads); } diff --git a/controllers/CharactergroupsqueststationsController.inc b/controllers/CharactergroupsqueststationsController.inc index 7a5491eb..b5e64bec 100644 --- a/controllers/CharactergroupsqueststationsController.inc +++ b/controllers/CharactergroupsqueststationsController.inc @@ -84,20 +84,39 @@ $quest = $this->Charactergroupsquests->getQuestByUrl($groupsgroup['id'], $questUrl); // Get Character group + $charactergroups = null; $charactergroup = null; - $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]; + if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) { + $charactergroups = $this->Charactergroups->getGroupsForGroupsgroup($groupsgroup['id']); + } + else { + $character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']); + $charactergroups = $this->Charactergroups->getGroupsForCharacter($character['id']); + if(!empty($charactergroups)) { + $charactergroup = $stationgroups[0]; + } + } + // Select group by parameter + $selectedStationGroupId = $this->request->getGetParam('stationgroup'); + if(!is_null($selectedStationGroupId)) + { + $selectedStationGroupId = intval($selectedStationGroupId); + foreach($charactergroups as &$group) { + if($group['id'] == $selectedStationGroupId) { + $charactergroup = $group; + break; + } + } } // Get Stations - $stations = null; - if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) { - $stations = $this->Charactergroupsqueststations->getStationsForQuest($quest['id']); + $stations = array(); + if(is_null($charactergroup)) { + if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) { + $stations = $this->Charactergroupsqueststations->getStationsForQuest($quest['id']); + } } - elseif(!is_null($charactergroup)) { + else { $stations = $this->Charactergroupsqueststations->getEnteredStationsForQuestAndGroup($quest['id'], $charactergroup['id']); } diff --git a/models/CharactergroupsqueststationsModel.inc b/models/CharactergroupsqueststationsModel.inc index 19bd0b60..8c216516 100644 --- a/models/CharactergroupsqueststationsModel.inc +++ b/models/CharactergroupsqueststationsModel.inc @@ -589,7 +589,7 @@ 'INNER JOIN charactergroupsqueststations ON charactergroupsqueststations.id = charactergroupsqueststations_charactergroups.charactergroupsqueststation_id '. 'WHERE '. 'charactergroupsqueststations_charactergroups.charactergroup_id = ? AND '. - 'charactergroupsqueststations_charactergroups.status >= ? AND '. + 'charactergroupsqueststations_charactergroups.status = ? AND '. 'charactergroupsquest_id = ? '. 'ORDER BY charactergroupsqueststations_charactergroups.created ASC', 'iii', diff --git a/views/html/charactergroupsquests/quest.tpl b/views/html/charactergroupsquests/quest.tpl index a12ae35b..ec17b625 100644 --- a/views/html/charactergroupsquests/quest.tpl +++ b/views/html/charactergroupsquests/quest.tpl @@ -80,6 +80,19 @@ + 1) : ?> +
+