diff --git a/api/tags/index.php b/api/tags/index.php index 1f65376..cb08e14 100644 --- a/api/tags/index.php +++ b/api/tags/index.php @@ -37,7 +37,11 @@ function Tags_GetListOfApproved (): array { return $result; while ($row = $d->fetch_array()) { - $result[] = $row["value"]; + $result[] = array( + "value" => $row["value"], + "author_id" => $row["author_id"], + "added_at" => $row["added_at"] + ); } return $result; diff --git a/docs/DB.md b/docs/DB.md index 6dba1d5..9dec960 100644 --- a/docs/DB.md +++ b/docs/DB.md @@ -33,8 +33,8 @@ USE e949; CREATE TABLE users ( id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique identifier of user', created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When account was created', - login VARCHAR(255) NOT NULL COMMENT 'User login', - email VARCHAR(255) NULL COMMENT 'User e-mail address', + login VARCHAR(255) NOT NULL UNIQUE COMMENT 'User login', + email VARCHAR(255) NULL UNIQUE COMMENT 'User e-mail address', password_hash BINARY(32) NOT NULL COMMENT 'User password hash', salt VARCHAR(8) NOT NULL COMMENT 'User salt, used for password hash', avatar_path VARCHAR(255) NULL COMMENT 'Path or URL to avatar picture', @@ -78,7 +78,9 @@ CREATE TABLE invites ( uses_last SMALLINT UNSIGNED NOT NULL COMMENT 'Remaining uses of invite' ); CREATE TABLE approved_tags ( - value VARCHAR(255) NOT NULL COMMENT 'The tag itself' + value VARCHAR(255) NOT NULL UNIQUE COMMENT 'The tag itself', + author_id INT UNSIGNED NULL COMMENT 'ID of user who added this tag to list of approved', + added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When this tag was added' ); ``` diff --git a/front/pages/main_nav.php b/front/pages/main_nav.php index 7903c51..06f23ce 100644 --- a/front/pages/main_nav.php +++ b/front/pages/main_nav.php @@ -6,11 +6,14 @@ $MARKUP_CURRENT_PAGE = "class=\"current\""; $MARKUP_CURRENT_PAGE_LOGIN = ""; $MARKUP_CURRENT_PAGE_REGISTER = ""; +$MARKUP_CURRENT_PAGE_VIEWTAGS = ""; if ($WHAT_PAGE_IS_CURRENT["login"]) $MARKUP_CURRENT_PAGE_LOGIN = $MARKUP_CURRENT_PAGE; -if ($WHAT_PAGE_IS_CURRENT["register"]) +elseif ($WHAT_PAGE_IS_CURRENT["register"]) $MARKUP_CURRENT_PAGE_REGISTER = $MARKUP_CURRENT_PAGE; +elseif ($WHAT_PAGE_IS_CURRENT["view_tags"]) + $MARKUP_CURRENT_PAGE_VIEWTAGS = $MARKUP_CURRENT_PAGE; @@ -33,7 +36,7 @@ if ($WHAT_PAGE_IS_CURRENT["register"])
| -" . $tagInfo["value"] . "
\n"; + echo "Added by: "; + $aid = $tagInfo["author_id"]; + if (!isset($cachedAuthorsInfo[$aid])) { + $uinfo = User_GetInfoByID($aid); + if ($uinfo->IsError()) { // Seems like no such user id + $cachedAuthorsInfo[$aid] = strval($aid) . " (user deleted)"; + } else { + $cachedAuthorsInfo[$aid] = "" . $uinfo->GetData()["login"] . ""; + } + } + echo $cachedAuthorsInfo[$aid]; + echo "
\n