diff --git a/controllers/AccountSettings.php b/controllers/AccountSettings.php index 4bbb056..4f4a431 100644 --- a/controllers/AccountSettings.php +++ b/controllers/AccountSettings.php @@ -73,6 +73,11 @@ class AccountSettings extends HTMLController $formview = new FormView($form, $form_title); $this->page->adopt($formview); + // Fetch user tags + $tags = Tag::getAllByOwner($user->getUserId()); + if (!empty($tags)) + $this->page->adopt(new MyTagsView($tags)); + // Left a message? if (isset($_SESSION['account_msg'])) { diff --git a/models/Tag.php b/models/Tag.php index d5bbccc..13af5c7 100644 --- a/models/Tag.php +++ b/models/Tag.php @@ -96,6 +96,25 @@ class Tag 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') { $rows = Registry::get('db')->queryAssocs(' diff --git a/templates/MyTagsView.php b/templates/MyTagsView.php new file mode 100644 index 0000000..2b06fd9 --- /dev/null +++ b/templates/MyTagsView.php @@ -0,0 +1,32 @@ +tags = $tags; + } + + protected function html_content() + { + echo ' +

Tags you can edit

+

You can currently edit the tags below. Click a tag to edit it.

+ '; + } +}