aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-01-26 17:17:10 +0200
committerSyndamia <kamen@syndamia.com>2025-01-26 17:17:10 +0200
commit5b61a18f1bab2cf17f849b64129efa9726848262 (patch)
tree6e2f596d1078f070b683577e006080b888d62c17
parent229266ebc87133e3f81d19d5e1750fa8419b5b0f (diff)
downloadnowayforward_human-5b61a18f1bab2cf17f849b64129efa9726848262.tar
nowayforward_human-5b61a18f1bab2cf17f849b64129efa9726848262.tar.gz
nowayforward_human-5b61a18f1bab2cf17f849b64129efa9726848262.zip
feat(profile): Show archives made by user in their profile page
-rw-r--r--models/webpage.php8
-rw-r--r--views/profile/index.php25
2 files changed, 33 insertions, 0 deletions
diff --git a/models/webpage.php b/models/webpage.php
index 742b977..3445f62 100644
--- a/models/webpage.php
+++ b/models/webpage.php
@@ -48,6 +48,14 @@ class Webpage extends Table {
);
}
+ static function allArchivesByUser(int $UID) : array {
+ return Table::_get_all(
+ 'Webpages',
+ 'Database\Webpage',
+ "WHERE RequesterUID = \"$UID\" ORDER BY Date DESC"
+ );
+ }
+
static function getArchivePathsByPattern(string $URLPattern) : array {
return Table::_get_all(
'Webpages',
diff --git a/views/profile/index.php b/views/profile/index.php
index 471b257..e4015e9 100644
--- a/views/profile/index.php
+++ b/views/profile/index.php
@@ -12,6 +12,31 @@
<svg class="user-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" ><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2a5 5 0 1 1 -5 5l.005 -.217a5 5 0 0 1 4.995 -4.783z" /><path d="M14 14a5 5 0 0 1 5 5v1a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-1a5 5 0 0 1 5 -5h4z" /></svg>
<h1 class="username"><?= $user->Username ?></h1>
</section>
+
+ <div class="card-blank-afterspace"></div>
+
+ <h2>Archives</h2>
+ <?php foreach (Database\Webpage::allArchivesByUser($user->UID) as $page): ?>
+ <section class="item">
+ <section>
+ <div>
+ <img src="<?= '/archives/' . $page->FaviconPath ?>" class="favicon">
+ <a href="<?= '/archives/' . $page->WID ?>"><?= $page->URL ?></a>
+ <span class="float-right"><?= $page->Date ?></span>
+ </div>
+ <div class="details">
+ <span>Visits: <?= $page->Visits ?></span>
+ <span class="float-right"><?= Database\User::fromDBuid($page->RequesterUID)->Username ?></span>
+ </div>
+ </section>
+ <?php if (false): # If user logged-in ?>
+ <section>
+ <span><!-- Add to list button --></span>
+ <span><!-- Delete (when admin) button --></span>
+ <section>
+ <?php endif; ?>
+ </section>
+ <?php endforeach; ?>
<?php else: ?>
<h2>User "<?= $username ?>" doesn't exist!</h2>
<?php endif; ?>