This commit is contained in:
@@ -11,6 +11,7 @@ final class AccountPages
|
||||
private const ENCRYPTED_PROFILE_FIELDS = [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'street',
|
||||
'contact_phone',
|
||||
'profession',
|
||||
'languages',
|
||||
@@ -185,6 +186,7 @@ final class AccountPages
|
||||
}
|
||||
$firstNameEnc = self::encryptOptionalProfileField($crypto, trim((string)$_POST['first_name']));
|
||||
$lastNameEnc = self::encryptOptionalProfileField($crypto, trim((string)$_POST['last_name']));
|
||||
$streetEnc = self::encryptOptionalProfileField($crypto, trim((string)($_POST['street'] ?? '')));
|
||||
$phoneEnc = self::encryptOptionalProfileField($crypto, trim((string)$_POST['contact_phone']));
|
||||
$professionEnc = self::encryptOptionalProfileField($crypto, trim((string)$_POST['profession']));
|
||||
$languagesEnc = self::encryptOptionalProfileField($crypto, trim((string)$languages));
|
||||
@@ -193,13 +195,17 @@ final class AccountPages
|
||||
if ($profileSettings) {
|
||||
$profileSettings->ensureSchema();
|
||||
}
|
||||
$stmt = $pdo?->prepare('UPDATE user_profiles SET display_name=:name, first_name=:fname, last_name=:lname, zip=:zip, city=:city, profession=:prof, languages=:langs, about=:about, contact_phone=:phone, location_tracking_preference=:locationPref, updated_at=NOW() WHERE user_id=:id');
|
||||
$stmt = $pdo?->prepare('UPDATE user_profiles SET display_name=:name, first_name=:fname, last_name=:lname, street=:street, zip=:zip, city=:city, region=:region, lat=:lat, lng=:lng, profession=:prof, languages=:langs, about=:about, contact_phone=:phone, location_tracking_preference=:locationPref, updated_at=NOW() WHERE user_id=:id');
|
||||
$stmt?->execute([
|
||||
'name' => trim((string)$_POST['display_name']),
|
||||
'fname' => $firstNameEnc,
|
||||
'lname' => $lastNameEnc,
|
||||
'street' => $streetEnc,
|
||||
'zip' => trim((string)$_POST['zip']),
|
||||
'city' => trim((string)$_POST['city']),
|
||||
'region' => trim((string)($_POST['region'] ?? '')),
|
||||
'lat' => isset($_POST['lat']) && $_POST['lat'] !== '' ? (float)$_POST['lat'] : null,
|
||||
'lng' => isset($_POST['lng']) && $_POST['lng'] !== '' ? (float)$_POST['lng'] : null,
|
||||
'prof' => $professionEnc,
|
||||
'langs' => $languagesEnc,
|
||||
'about' => $aboutEnc,
|
||||
@@ -402,6 +408,10 @@ final class AccountPages
|
||||
'last_name' => '',
|
||||
'zip' => '',
|
||||
'city' => '',
|
||||
'region' => '',
|
||||
'lat' => null,
|
||||
'lng' => null,
|
||||
'street' => '',
|
||||
'profession' => '',
|
||||
'languages' => '',
|
||||
'about' => '',
|
||||
@@ -427,7 +437,7 @@ final class AccountPages
|
||||
static fn(string $column): string => 'p.' . $column,
|
||||
AvatarManager::allProfileColumns()
|
||||
));
|
||||
$stmt = $pdo?->prepare("SELECT u.email, u.status, p.display_name, p.first_name, p.last_name, p.zip, p.city, p.profession, p.languages, p.about, p.contact_phone, p.location_tracking_preference, $avatarColumns FROM users u LEFT JOIN user_profiles p ON p.user_id = u.id WHERE u.id = :id LIMIT 1");
|
||||
$stmt = $pdo?->prepare("SELECT u.email, u.status, p.display_name, p.first_name, p.last_name, p.street, p.zip, p.city, p.region, p.lat, p.lng, p.profession, p.languages, p.about, p.contact_phone, p.location_tracking_preference, $avatarColumns FROM users u LEFT JOIN user_profiles p ON p.user_id = u.id WHERE u.id = :id LIMIT 1");
|
||||
$stmt?->execute(['id' => $userId]);
|
||||
$row = $stmt?->fetch(\PDO::FETCH_ASSOC);
|
||||
if ($row) {
|
||||
|
||||
@@ -61,6 +61,7 @@ final class ProfileSettings
|
||||
$columnDefinitions = [
|
||||
'first_name' => 'VARBINARY(512) NULL',
|
||||
'last_name' => 'VARBINARY(512) NULL',
|
||||
'street' => 'VARBINARY(512) NULL',
|
||||
'contact_phone' => 'VARBINARY(512) NULL',
|
||||
'contact_email' => 'VARBINARY(512) NULL',
|
||||
'profession' => 'VARBINARY(512) NULL',
|
||||
@@ -70,6 +71,11 @@ final class ProfileSettings
|
||||
|
||||
foreach ($columnDefinitions as $column => $definition) {
|
||||
if (!$this->hasColumn('user_profiles', $column)) {
|
||||
if ($column === 'street') {
|
||||
$this->pdo->exec('ALTER TABLE user_profiles ADD COLUMN street VARBINARY(512) NULL AFTER last_name');
|
||||
$this->columnCache['user_profiles.street'] = true;
|
||||
$this->columnTypeCache['user_profiles.street'] = 'varbinary';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user