feat: add custom avatar functionality (#248)

Co-authored-by: Dante Bradshaw <plansuperior@gmail.com>
This commit is contained in:
Miguel Ribeiro
2024-03-24 16:12:44 +01:00
committed by GitHub
co-authored by Dante Bradshaw
parent 40bcf3485e
commit 1dbebd3918
22 changed files with 387 additions and 41 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* This migration script updates the avatar field of the user table to use the new avatar path.
*/
/** @noinspection PhpUndefinedVariableInspection */
$sql = "SELECT avatar FROM user";
$stmt = $db->prepare($sql);
$result = $stmt->execute();
$row = $result->fetchArray(SQLITE3_ASSOC);
if ($row) {
$avatar = $row['avatar'];
if (strlen($avatar) < 2) {
$avatarFullPath = "images/avatars/" . $avatar . ".svg";
$sql = "UPDATE user SET avatar = :avatarFullPath";
$stmt = $db->prepare($sql);
$stmt->bindValue(':avatarFullPath', $avatarFullPath, SQLITE3_TEXT);
$stmt->execute();
}
}
?>