assign Character titles via QR-codes (implements #118)
This commit is contained in:
parent
40d2aa5768
commit
eddc4036cf
6 changed files with 101 additions and 3 deletions
|
|
@ -25,7 +25,7 @@
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'achievements', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'charactergroupsachievements');
|
||||
public $models = array('seminaries', 'achievements', 'charactertitles', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'charactergroupsachievements');
|
||||
|
||||
|
||||
|
||||
|
|
@ -103,6 +103,47 @@
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: ct.
|
||||
*
|
||||
* Trigger a Character title by a hash typically provided via a QR-code.
|
||||
*
|
||||
* @param $titleHash Hash value of Character title
|
||||
*/
|
||||
public function ct($titleHash)
|
||||
{
|
||||
// Get Character title
|
||||
$title = $this->Charactertitles->getTitleByHash($titleHash);
|
||||
|
||||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryById($title['seminary_id']);
|
||||
|
||||
// Get Character
|
||||
$character = $this->Characters->getCharacterForUserAndSeminary(
|
||||
self::$user['id'],
|
||||
$seminary['id']
|
||||
);
|
||||
|
||||
// Assign title to Character
|
||||
$this->Charactertitles->assignTitleToCharacter(
|
||||
$title['id'],
|
||||
$character['id']
|
||||
);
|
||||
|
||||
// Redirect
|
||||
$this->redirect(
|
||||
$this->linker->link(
|
||||
array(
|
||||
'characters',
|
||||
'character',
|
||||
$seminary['url'],
|
||||
$character['url']
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: cgqs.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'achievements', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'charactergroupsachievements');
|
||||
public $models = array('seminaries', 'achievements', 'charactertitles', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'charactergroupsachievements');
|
||||
|
||||
|
||||
|
||||
|
|
@ -88,6 +88,37 @@
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: charactertitles
|
||||
*
|
||||
* Display a QR-code for a Character title.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $titleHash Hash of Character title
|
||||
* @param int $size Size of QR-code (default: 1)
|
||||
*/
|
||||
public function charactertitle($seminaryUrl, $titleHash, $size=1)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Character title
|
||||
$title = $this->Charactertitles->getTitleByHash($titleHash);
|
||||
|
||||
// Generate QR-code
|
||||
$url = $this->linker->link(array('qr', 'ct', $title['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
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue