Remove no-longer-used settings (#23)
Some checks are pending
Run unit tests / run-unit-tests (push) Waiting to run
Some checks are pending
Run unit tests / run-unit-tests (push) Waiting to run
Simplifying the app. The "about" profile field is somewhat redundant. There's already a site title and description. I'm removing mood emoji from the ticks and just using the user-level mood. That toggle is no longer necessary. Co-authored-by: Greg Sarjeant <1686767+gsarjeant@users.noreply.github.com> Reviewed-on: https://gitea.subcultureofone.org/greg/tkr/pulls/23
This commit is contained in:
parent
c7acca6bb3
commit
b40a4dce18
@ -55,7 +55,6 @@ class AdminController extends Controller {
|
||||
// User profile
|
||||
$username = trim($_POST['username'] ?? '');
|
||||
$displayName = trim($_POST['display_name'] ?? '');
|
||||
$about = trim($_POST['about'] ?? '');
|
||||
$website = trim($_POST['website'] ?? '');
|
||||
|
||||
// Site settings
|
||||
@ -115,7 +114,6 @@ class AdminController extends Controller {
|
||||
$config->basePath = $basePath;
|
||||
$config->itemsPerPage = $itemsPerPage;
|
||||
$config->strictAccessibility = $strictAccessibility;
|
||||
$config->showTickMood = $showTickMood;
|
||||
|
||||
// Save site settings and reload config from database
|
||||
// TODO - raise and handle exception on failure
|
||||
@ -124,7 +122,6 @@ class AdminController extends Controller {
|
||||
// Update user profile
|
||||
$user->username = $username;
|
||||
$user->displayName = $displayName;
|
||||
$user->about = $about;
|
||||
$user->website = $website;
|
||||
|
||||
// Save user profile and reload user from database
|
||||
|
@ -9,7 +9,6 @@ class ConfigModel {
|
||||
public string $timezone = 'relative';
|
||||
public ?int $cssId = null;
|
||||
public bool $strictAccessibility = true;
|
||||
public bool $showTickMood = true;
|
||||
|
||||
// load config from sqlite database
|
||||
public static function load(): self {
|
||||
@ -25,8 +24,7 @@ class ConfigModel {
|
||||
base_path,
|
||||
items_per_page,
|
||||
css_id,
|
||||
strict_accessibility,
|
||||
show_tick_mood
|
||||
strict_accessibility
|
||||
FROM settings WHERE id=1");
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@ -39,7 +37,6 @@ class ConfigModel {
|
||||
$c->itemsPerPage = (int) $row['items_per_page'];
|
||||
$c->cssId = (int) $row['css_id'];
|
||||
$c->strictAccessibility = (bool) $row['strict_accessibility'];
|
||||
$c->showTickMood = (bool) $row['show_tick_mood'];
|
||||
}
|
||||
|
||||
return $c;
|
||||
@ -71,9 +68,8 @@ class ConfigModel {
|
||||
items_per_page,
|
||||
css_id,
|
||||
strict_accessibility,
|
||||
show_tick_mood
|
||||
)
|
||||
VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
VALUES (1, ?, ?, ?, ?, ?, ?, ?)");
|
||||
} else {
|
||||
$stmt = $db->prepare("UPDATE settings SET
|
||||
site_title=?,
|
||||
@ -82,8 +78,7 @@ class ConfigModel {
|
||||
base_path=?,
|
||||
items_per_page=?,
|
||||
css_id=?,
|
||||
strict_accessibility=?,
|
||||
show_tick_mood=?
|
||||
strict_accessibility=?
|
||||
WHERE id=1");
|
||||
}
|
||||
$stmt->execute([$this->siteTitle,
|
||||
@ -93,7 +88,6 @@ class ConfigModel {
|
||||
$this->itemsPerPage,
|
||||
$this->cssId,
|
||||
$this->strictAccessibility,
|
||||
$this->showTickMood
|
||||
]);
|
||||
|
||||
return self::load();
|
||||
|
@ -3,7 +3,6 @@ class UserModel {
|
||||
// properties
|
||||
public string $username = '';
|
||||
public string $displayName = '';
|
||||
public string $about = '';
|
||||
public string $website = '';
|
||||
public string $mood = '';
|
||||
|
||||
@ -12,14 +11,13 @@ class UserModel {
|
||||
global $db;
|
||||
|
||||
// There's only ever one user. I'm just leaning into that.
|
||||
$stmt = $db->query("SELECT username, display_name, about, website, mood FROM user WHERE id=1");
|
||||
$stmt = $db->query("SELECT username, display_name, website, mood FROM user WHERE id=1");
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$u = new self();
|
||||
|
||||
if ($row) {
|
||||
$u->username = $row['username'];
|
||||
$u->displayName = $row['display_name'];
|
||||
$u->about = $row['about'] ?? '';
|
||||
$u->website = $row['website'] ?? '';
|
||||
$u->mood = $row['mood'] ?? '';
|
||||
}
|
||||
@ -32,12 +30,12 @@ class UserModel {
|
||||
$userCount = (int) $db->query("SELECT COUNT(*) FROM user")->fetchColumn();
|
||||
|
||||
if ($userCount === 0){
|
||||
$stmt = $db->prepare("INSERT INTO user (id, username, display_name, about, website, mood) VALUES (1, ?, ?, ?, ?, ?)");
|
||||
$stmt = $db->prepare("INSERT INTO user (id, username, display_name, website, mood) VALUES (1, ?, ?, ?, ?, ?)");
|
||||
} else {
|
||||
$stmt = $db->prepare("UPDATE user SET username=?, display_name=?, about=?, website=?, mood=? WHERE id=1");
|
||||
$stmt = $db->prepare("UPDATE user SET username=?, display_name=?, website=?, mood=? WHERE id=1");
|
||||
}
|
||||
|
||||
$stmt->execute([$this->username, $this->displayName, $this->about, $this->website, $this->mood]);
|
||||
$stmt->execute([$this->username, $this->displayName, $this->website, $this->mood]);
|
||||
|
||||
return self::load();
|
||||
}
|
||||
|
@ -22,11 +22,6 @@
|
||||
name="display_name"
|
||||
value="<?= Util::escape_html($user->displayName) ?>"
|
||||
required>
|
||||
<label for="about">About </label>
|
||||
<input type="text"
|
||||
id="about"
|
||||
name="about"
|
||||
value="<?= Util::escape_html($user->about) ?>">
|
||||
<label for="website">Website </label>
|
||||
<input type="text"
|
||||
id="website"
|
||||
@ -72,12 +67,6 @@
|
||||
name="strict_accessibility"
|
||||
value="1"
|
||||
<?php if ($config->strictAccessibility): ?> checked <?php endif; ?>>
|
||||
<label for="show_tick_mood">Show tick mood</label>
|
||||
<input type="checkbox"
|
||||
id="show_tick_mood"
|
||||
name="show_tick_mood"
|
||||
value="1"
|
||||
<?php if ($config->showTickMood): ?> checked <?php endif; ?>>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
|
Loading…
x
Reference in New Issue
Block a user