forked from Public/pics
AccountSettings: list tags owned by current user
This commit is contained in:
parent
daa8b051c5
commit
a76dde927b
@ -73,6 +73,11 @@ class AccountSettings extends HTMLController
|
|||||||
$formview = new FormView($form, $form_title);
|
$formview = new FormView($form, $form_title);
|
||||||
$this->page->adopt($formview);
|
$this->page->adopt($formview);
|
||||||
|
|
||||||
|
// Fetch user tags
|
||||||
|
$tags = Tag::getAllByOwner($user->getUserId());
|
||||||
|
if (!empty($tags))
|
||||||
|
$this->page->adopt(new MyTagsView($tags));
|
||||||
|
|
||||||
// Left a message?
|
// Left a message?
|
||||||
if (isset($_SESSION['account_msg']))
|
if (isset($_SESSION['account_msg']))
|
||||||
{
|
{
|
||||||
|
@ -96,6 +96,25 @@ class Tag
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getAllByOwner($id_user_owner)
|
||||||
|
{
|
||||||
|
$db = Registry::get('db');
|
||||||
|
$res = $db->query('
|
||||||
|
SELECT *
|
||||||
|
FROM tags
|
||||||
|
WHERE id_user_owner = {int:id_user_owner}
|
||||||
|
ORDER BY tag',
|
||||||
|
[
|
||||||
|
'id_user_owner' => $id_user_owner,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$objects = [];
|
||||||
|
while ($row = $db->fetch_assoc($res))
|
||||||
|
$objects[$row['id_tag']] = new Tag($row);
|
||||||
|
|
||||||
|
return $objects;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getAlbums($id_parent = 0, $offset = 0, $limit = 24, $return_format = 'array')
|
public static function getAlbums($id_parent = 0, $offset = 0, $limit = 24, $return_format = 'array')
|
||||||
{
|
{
|
||||||
$rows = Registry::get('db')->queryAssocs('
|
$rows = Registry::get('db')->queryAssocs('
|
||||||
|
32
templates/MyTagsView.php
Normal file
32
templates/MyTagsView.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
/*****************************************************************************
|
||||||
|
* MyTagsView.php
|
||||||
|
* Contains the user tag list.
|
||||||
|
*
|
||||||
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
class MyTagsView extends SubTemplate
|
||||||
|
{
|
||||||
|
private $tags;
|
||||||
|
|
||||||
|
public function __construct(array $tags)
|
||||||
|
{
|
||||||
|
$this->tags = $tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function html_content()
|
||||||
|
{
|
||||||
|
echo '
|
||||||
|
<h2>Tags you can edit</h2>
|
||||||
|
<p>You can currently edit the tags below. Click a tag to edit it.</p>
|
||||||
|
<ul>';
|
||||||
|
|
||||||
|
foreach ($this->tags as $tag)
|
||||||
|
echo '
|
||||||
|
<li><a href="', BASEURL, '/edittag/?id=', $tag->id_tag, '">', $tag->tag, '</a></li>';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
</ul>';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user