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
|
* @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.
|
* Action: cgqs.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
*
|
*
|
||||||
* @var array
|
* @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
|
* Action: charactergroupsqueststation
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@
|
||||||
public function getTitleByHash($titleHash)
|
public function getTitleByHash($titleHash)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT id, hash, title_male, title_female '.
|
'SELECT id, seminary_id, hash, title_male, title_female '.
|
||||||
'FROM charactertitles '.
|
'FROM charactertitles '.
|
||||||
'WHERE hash = ?',
|
'WHERE hash = ?',
|
||||||
's',
|
's',
|
||||||
|
|
@ -123,6 +123,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Character title to the list of titles for a Character.
|
||||||
|
*
|
||||||
|
* @param int $titleId ID of title to assign
|
||||||
|
* @param int $characterId ID of Character to assign title to
|
||||||
|
*/
|
||||||
|
public function assignTitleToCharacter($titleId, $characterId)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT IGNORE INTO characters_charactertitles '.
|
||||||
|
'(character_id, charactertitle_id) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?)',
|
||||||
|
'ii',
|
||||||
|
$characterId,
|
||||||
|
$titleId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a title for a Characters already exists.
|
* Check if a title for a Characters already exists.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
1
views/binary/qrcodes/charactertitle.tpl
Normal file
1
views/binary/qrcodes/charactertitle.tpl
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<?=$file?>
|
||||||
|
|
@ -16,6 +16,11 @@
|
||||||
<ul class="admin">
|
<ul class="admin">
|
||||||
<li><a href="<?=$linker->link(array('edit',$seminary['url'],$title['hash']),1)?>"><?=_('edit')?></a></li>
|
<li><a href="<?=$linker->link(array('edit',$seminary['url'],$title['hash']),1)?>"><?=_('edit')?></a></li>
|
||||||
<li><a href="<?=$linker->link(array('delete',$seminary['url'],$title['hash']),1)?>"><?=_('delete')?></a></li>
|
<li><a href="<?=$linker->link(array('delete',$seminary['url'],$title['hash']),1)?>"><?=_('delete')?></a></li>
|
||||||
|
<li>
|
||||||
|
<a href="<?=$linker->link(array('qrcodes','charactertitle',$seminary['url'],$title['hash'],'50'))?>">
|
||||||
|
<i class="fa fa-qrcode"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
|
||||||
0
views/html/qr/ct.tpl
Normal file
0
views/html/qr/ct.tpl
Normal file
Loading…
Add table
Add a link
Reference in a new issue