diff --git a/controllers/CharactergroupsController.inc b/controllers/CharactergroupsController.inc index 5e9ba675..fcd9357c 100644 --- a/controllers/CharactergroupsController.inc +++ b/controllers/CharactergroupsController.inc @@ -115,7 +115,7 @@ $groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl); // Get Character groups - $groups = $this->Charactergroups->getGroupsForGroupsgroup($groupsgroup['id']); + $groups = $this->Charactergroups->getGroupsForGroupsgroup($groupsgroup['id'], 'xps'); // Get Character groups-group Quests $quests = $this->Charactergroupsquests->getQuestsForCharactergroupsgroup($groupsgroup['id']); diff --git a/models/CharactergroupsModel.inc b/models/CharactergroupsModel.inc index 20a3e3a7..fd424d47 100644 --- a/models/CharactergroupsModel.inc +++ b/models/CharactergroupsModel.inc @@ -195,13 +195,26 @@ * @param int $groupsgroupId ID of the Character groups-group * @return array Character groups */ - public function getGroupsForGroupsgroup($groupsgroupId) + public function getGroupsForGroupsgroup($groupsgroupId, $sortorder='name') { + // Set sort order + switch($sortorder) + { + case 'xps': + $sortorder = 'xps DESC'; + break; + case 'name': + default: + $sortorder = 'name ASC'; + break; + } + + // Get and return Character groups return $this->db->query( 'SELECT id, name, url, xps, motto, seminaryupload_id '. 'FROM v_charactergroups '. 'WHERE charactergroupsgroup_id = ? '. - 'ORDER BY name', + "ORDER BY $sortorder", 'i', $groupsgroupId );