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
|
// User profile
|
||||||
$username = trim($_POST['username'] ?? '');
|
$username = trim($_POST['username'] ?? '');
|
||||||
$displayName = trim($_POST['display_name'] ?? '');
|
$displayName = trim($_POST['display_name'] ?? '');
|
||||||
$about = trim($_POST['about'] ?? '');
|
|
||||||
$website = trim($_POST['website'] ?? '');
|
$website = trim($_POST['website'] ?? '');
|
||||||
|
|
||||||
// Site settings
|
// Site settings
|
||||||
@ -115,7 +114,6 @@ class AdminController extends Controller {
|
|||||||
$config->basePath = $basePath;
|
$config->basePath = $basePath;
|
||||||
$config->itemsPerPage = $itemsPerPage;
|
$config->itemsPerPage = $itemsPerPage;
|
||||||
$config->strictAccessibility = $strictAccessibility;
|
$config->strictAccessibility = $strictAccessibility;
|
||||||
$config->showTickMood = $showTickMood;
|
|
||||||
|
|
||||||
// Save site settings and reload config from database
|
// Save site settings and reload config from database
|
||||||
// TODO - raise and handle exception on failure
|
// TODO - raise and handle exception on failure
|
||||||
@ -124,7 +122,6 @@ class AdminController extends Controller {
|
|||||||
// Update user profile
|
// Update user profile
|
||||||
$user->username = $username;
|
$user->username = $username;
|
||||||
$user->displayName = $displayName;
|
$user->displayName = $displayName;
|
||||||
$user->about = $about;
|
|
||||||
$user->website = $website;
|
$user->website = $website;
|
||||||
|
|
||||||
// Save user profile and reload user from database
|
// Save user profile and reload user from database
|
||||||
|
@ -9,7 +9,6 @@ class ConfigModel {
|
|||||||
public string $timezone = 'relative';
|
public string $timezone = 'relative';
|
||||||
public ?int $cssId = null;
|
public ?int $cssId = null;
|
||||||
public bool $strictAccessibility = true;
|
public bool $strictAccessibility = true;
|
||||||
public bool $showTickMood = true;
|
|
||||||
|
|
||||||
// load config from sqlite database
|
// load config from sqlite database
|
||||||
public static function load(): self {
|
public static function load(): self {
|
||||||
@ -25,8 +24,7 @@ class ConfigModel {
|
|||||||
base_path,
|
base_path,
|
||||||
items_per_page,
|
items_per_page,
|
||||||
css_id,
|
css_id,
|
||||||
strict_accessibility,
|
strict_accessibility
|
||||||
show_tick_mood
|
|
||||||
FROM settings WHERE id=1");
|
FROM settings WHERE id=1");
|
||||||
|
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@ -39,7 +37,6 @@ class ConfigModel {
|
|||||||
$c->itemsPerPage = (int) $row['items_per_page'];
|
$c->itemsPerPage = (int) $row['items_per_page'];
|
||||||
$c->cssId = (int) $row['css_id'];
|
$c->cssId = (int) $row['css_id'];
|
||||||
$c->strictAccessibility = (bool) $row['strict_accessibility'];
|
$c->strictAccessibility = (bool) $row['strict_accessibility'];
|
||||||
$c->showTickMood = (bool) $row['show_tick_mood'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $c;
|
return $c;
|
||||||
@ -71,9 +68,8 @@ class ConfigModel {
|
|||||||
items_per_page,
|
items_per_page,
|
||||||
css_id,
|
css_id,
|
||||||
strict_accessibility,
|
strict_accessibility,
|
||||||
show_tick_mood
|
|
||||||
)
|
)
|
||||||
VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?)");
|
VALUES (1, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
} else {
|
} else {
|
||||||
$stmt = $db->prepare("UPDATE settings SET
|
$stmt = $db->prepare("UPDATE settings SET
|
||||||
site_title=?,
|
site_title=?,
|
||||||
@ -82,8 +78,7 @@ class ConfigModel {
|
|||||||
base_path=?,
|
base_path=?,
|
||||||
items_per_page=?,
|
items_per_page=?,
|
||||||
css_id=?,
|
css_id=?,
|
||||||
strict_accessibility=?,
|
strict_accessibility=?
|
||||||
show_tick_mood=?
|
|
||||||
WHERE id=1");
|
WHERE id=1");
|
||||||
}
|
}
|
||||||
$stmt->execute([$this->siteTitle,
|
$stmt->execute([$this->siteTitle,
|
||||||
@ -93,7 +88,6 @@ class ConfigModel {
|
|||||||
$this->itemsPerPage,
|
$this->itemsPerPage,
|
||||||
$this->cssId,
|
$this->cssId,
|
||||||
$this->strictAccessibility,
|
$this->strictAccessibility,
|
||||||
$this->showTickMood
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return self::load();
|
return self::load();
|
||||||
|
@ -3,7 +3,6 @@ class UserModel {
|
|||||||
// properties
|
// properties
|
||||||
public string $username = '';
|
public string $username = '';
|
||||||
public string $displayName = '';
|
public string $displayName = '';
|
||||||
public string $about = '';
|
|
||||||
public string $website = '';
|
public string $website = '';
|
||||||
public string $mood = '';
|
public string $mood = '';
|
||||||
|
|
||||||
@ -12,14 +11,13 @@ class UserModel {
|
|||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
// There's only ever one user. I'm just leaning into that.
|
// 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);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$u = new self();
|
$u = new self();
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$u->username = $row['username'];
|
$u->username = $row['username'];
|
||||||
$u->displayName = $row['display_name'];
|
$u->displayName = $row['display_name'];
|
||||||
$u->about = $row['about'] ?? '';
|
|
||||||
$u->website = $row['website'] ?? '';
|
$u->website = $row['website'] ?? '';
|
||||||
$u->mood = $row['mood'] ?? '';
|
$u->mood = $row['mood'] ?? '';
|
||||||
}
|
}
|
||||||
@ -32,12 +30,12 @@ class UserModel {
|
|||||||
$userCount = (int) $db->query("SELECT COUNT(*) FROM user")->fetchColumn();
|
$userCount = (int) $db->query("SELECT COUNT(*) FROM user")->fetchColumn();
|
||||||
|
|
||||||
if ($userCount === 0){
|
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 {
|
} 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();
|
return self::load();
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,6 @@
|
|||||||
name="display_name"
|
name="display_name"
|
||||||
value="<?= Util::escape_html($user->displayName) ?>"
|
value="<?= Util::escape_html($user->displayName) ?>"
|
||||||
required>
|
required>
|
||||||
<label for="about">About </label>
|
|
||||||
<input type="text"
|
|
||||||
id="about"
|
|
||||||
name="about"
|
|
||||||
value="<?= Util::escape_html($user->about) ?>">
|
|
||||||
<label for="website">Website </label>
|
<label for="website">Website </label>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
id="website"
|
id="website"
|
||||||
@ -72,12 +67,6 @@
|
|||||||
name="strict_accessibility"
|
name="strict_accessibility"
|
||||||
value="1"
|
value="1"
|
||||||
<?php if ($config->strictAccessibility): ?> checked <?php endif; ?>>
|
<?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>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user