From bdfd021673cb92cd9f3291ca434e364eb96e3aae Mon Sep 17 00:00:00 2001 From: oliver Date: Sat, 12 Mar 2016 16:04:51 +0100 Subject: [PATCH] add QR-codes for Character groups Achievements (implements #124) --- controllers/QrController.inc | 35 ++++++++++++++++- controllers/QrcodesController.inc | 39 ++++++++++++++++++- .../qrcodes/charactergroupsachievements.tpl | 1 + views/html/qr/cga.tpl | 0 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 views/binary/qrcodes/charactergroupsachievements.tpl create mode 100644 views/html/qr/cga.tpl diff --git a/controllers/QrController.inc b/controllers/QrController.inc index 28ce088f..15c340d1 100644 --- a/controllers/QrController.inc +++ b/controllers/QrController.inc @@ -25,7 +25,7 @@ * * @var array */ - public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations'); + public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'charactergroupsachievements'); @@ -62,6 +62,39 @@ ))); } + + /** + * Action: cga. + * + * Redirect to a Character groups Achievements + * + * @param string $achievementHash Hash of Character groups Achievement + */ + public function cga($achievementHash) + { + // Get Achievement + $achievement = $this->Charactergroupsachievements->getAchievementByHash($achievementHash); + + // Get Character groups-group + $groupsgroup = $this->Charactergroups->getGroupsgroupById($achievement['charactergroupsgroup_id']); + + // Get seminary + $seminary = $this->Seminaries->getSeminaryById($groupsgroup['seminary_id']); + + // Redirect + $this->redirect( + $this->linker->link( + array( + 'charactergroupsachievements', + 'achievement', + $seminary['url'], + $groupsgroup['url'], + $achievement['hash'] + ) + ) + ); + } + } ?> diff --git a/controllers/QrcodesController.inc b/controllers/QrcodesController.inc index d08dfcd9..256d1650 100644 --- a/controllers/QrcodesController.inc +++ b/controllers/QrcodesController.inc @@ -24,7 +24,7 @@ * * @var array */ - public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations'); + public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'charactergroupsachievements'); @@ -84,6 +84,43 @@ } + /** + * Action: charactergroupsachievements + * + * Display a QR-code for a Character groups Achievement + * + * @throws \nre\exceptions\IdNotFoundException + * @param string $seminaryUrl URL-Title of a Seminary + * @param string $groupsgroupUrl URL-Title of a Character groups-group + * @param string $achievementUrl URL of Achievement + */ + public function charactergroupsachievements($seminaryUrl, $groupsgroupUrl, $achievementUrl, $size=1) + { + // Get seminary + $seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl); + + // Get Character groups-group + $groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl); + + // Get Achievement + $achievement = $this->Charactergroupsachievements->getAchievementByUrl( + $groupsgroup['id'], + $achievementUrl + ); + + // Generate QR-code + $url = $this->linker->link(array('qr', 'cga', $achievement['hash']), 0, true, null, true, null, true); + $file = $this->generateQRcode($url, $size); + if(is_null($file)) { + return; + } + + + // Pass data to view + $this->set('file', $file); + } + + /** diff --git a/views/binary/qrcodes/charactergroupsachievements.tpl b/views/binary/qrcodes/charactergroupsachievements.tpl new file mode 100644 index 00000000..0d6fb0df --- /dev/null +++ b/views/binary/qrcodes/charactergroupsachievements.tpl @@ -0,0 +1 @@ + diff --git a/views/html/qr/cga.tpl b/views/html/qr/cga.tpl new file mode 100644 index 00000000..e69de29b