add Achievement condition ?qrcode? to trigger Achievements by scanning a QR-code (implements #126)

This commit is contained in:
oliver 2016-03-12 19:19:20 +01:00
commit 4d6e95f81e
12 changed files with 319 additions and 35 deletions

View file

@ -24,7 +24,7 @@
*
* @var array
*/
public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'charactergroupsachievements');
public $models = array('seminaries', 'achievements', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'charactergroupsachievements');
@ -46,6 +46,48 @@
}
/**
* Action: achievement
*
* Display a QR-code for an 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 achievement($seminaryUrl, $achievementUrl, $size=1)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Achievement
$achievement = $this->Achievements->getAchievementByUrl(
$seminary['id'],
$achievementUrl
);
// Get condition
$conditions = $this->Achievements->getAchievementConditionsQrcode(
$achievement['id']
);
if(empty($conditions)) {
throw new IdNotFoundException($achievementUrl);
}
// Generate QR-code
$url = $this->linker->link(array('qr', 'a', $conditions[0]['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);
}
/**
* Action: charactergroupsqueststation
*