diff --git a/controllers/AccountSettings.php b/controllers/AccountSettings.php index 4bbb0568..4f4a431d 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 d5bbccc7..13af5c78 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 00000000..2b06fd9e --- /dev/null +++ b/templates/MyTagsView.php @@ -0,0 +1,32 @@ +tags = $tags; + } + + protected function html_content() + { + echo ' +
You can currently edit the tags below. Click a tag to edit it.
+