diff --git a/app/classes/user.php b/app/classes/user.php index 55dc137..4014990 100644 --- a/app/classes/user.php +++ b/app/classes/user.php @@ -137,19 +137,19 @@ class User { ':user_id' => $user_id ]); // all went OK - $_SESSION['notice'] = 'Avatar updated successfully!'; + $_SESSION['notice'] .= 'Avatar updated successfully. '; return true; } catch (Exception $e) { return $e->getMessage(); } } else { - $_SESSION['error'] = 'Error moving the uploaded file.'; + $_SESSION['error'] .= 'Error moving the uploaded file. '; } } else { - $_SESSION['error'] = 'Invalid avatar file type.'; + $_SESSION['error'] .= 'Invalid avatar file type. '; } } else { - $_SESSION['error'] = 'Error uploading the avatar file.'; + $_SESSION['error'] .= 'Error uploading the avatar file. '; } } catch (Exception $e) { diff --git a/app/pages/profile.php b/app/pages/profile.php index 417f968..f1639aa 100644 --- a/app/pages/profile.php +++ b/app/pages/profile.php @@ -14,22 +14,13 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $item = $_REQUEST['item'] ?? ''; - // avatar editing - if ($item === 'avatar') { - switch ($action) { - case 'remove': - $result = $userObject->removeAvatar($user_id, $config['avatars_path'].$userDetails[0]['avatar']); - if ($result === true) { - $_SESSION['notice'] = "Avatar for user \"{$user}\" is removed."; - } else { - $_SESSION['error'] = "Removing the avatar failed. Error: $result"; - } - break; - case 'edit': - $result = $userObject->changeAvatar($user_id, $_FILES['avatar_file'], $config['avatars_path']); - break; - default: - $_SESSION['error'] = "Unspecified avatar editing action."; + // avatar removal + if ($item === 'avatar' && $action === 'remove') { + $result = $userObject->removeAvatar($user_id, $config['avatars_path'].$userDetails[0]['avatar']); + if ($result === true) { + $_SESSION['notice'] .= "Avatar for user \"{$user}\" is removed. "; + } else { + $_SESSION['error'] .= "Removing the avatar failed. Error: $result "; } header("Location: $app_root?page=profile"); @@ -44,9 +35,14 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { ]; $result = $userObject->editUser($user_id, $updatedUser); if ($result === true) { - $_SESSION['notice'] = "User details for \"{$updatedUser['name']}\" are edited."; + $_SESSION['notice'] .= "User details for \"{$updatedUser['name']}\" are edited. "; } else { - $_SESSION['error'] = "Editing the user details failed. Error: $result"; + $_SESSION['error'] .= "Editing the user details failed. Error: $result "; + } + + // update the avatar + if (!empty($_FILES['avatar_file']['tmp_name'])) { + $result = $userObject->changeAvatar($user_id, $_FILES['avatar_file'], $config['avatars_path']); } header("Location: $app_root?page=profile"); diff --git a/app/templates/profile-edit.php b/app/templates/profile-edit.php index 740ad88..68db8ce 100644 --- a/app/templates/profile-edit.php +++ b/app/templates/profile-edit.php @@ -5,55 +5,31 @@

Profile of

-
-

edit the profile fields

+
+
+

edit the profile fields

+
+
+ avatar +
-
-
- avatar - - - + - - -
- -
- -
-
-
- - -
- -
+
+ +
diff --git a/app/templates/profile.php b/app/templates/profile.php index b421c1e..f2ea6e4 100644 --- a/app/templates/profile.php +++ b/app/templates/profile.php @@ -47,7 +47,7 @@
- +
diff --git a/public_html/static/all.css b/public_html/static/all.css index 7879954..a3c1786 100644 --- a/public_html/static/all.css +++ b/public_html/static/all.css @@ -133,7 +133,7 @@ .main-content { flex-grow: 1; transition: width 0.5s ease; - width: 80%; +/* width: 80%;*/ } .main-content.expanded { width: calc(70% + 250px); @@ -170,12 +170,18 @@ resize: none; font-family: inherit; font-size: 14px; + user-select: text; + cursor: default; + outline: none; + box-shadow: none; } -/* avatar */ +/* avatars */ .avatar-container { + position: relative; text-align: center; } + .avatar-img { width: 200px; height: 200px; @@ -183,6 +189,44 @@ object-fit: cover; /* Ensures proper cropping of image */ border: 3px solid #ccc; } + +.avatar-wrapper { + position: relative; + display: inline-block; +} + .avatar-btn { - margin-top: 10px; -} \ No newline at end of file + position: absolute; + bottom: 10px; /* Adjust this value as needed */ +/* background: rgba(0, 0, 0, 0.5); /* Semi-transparent background */ + color: white; + border: none; + border-radius: 4px; + padding: 10px; +} + +.avatar-btn-container { + position: absolute; + left: 50%; + transform: translateX(-50%); + display: flex; + gap: 10px; /* Space between buttons */ +} + +.avatar-btn-select, +.avatar-btn-remove { +/* background: rgba(0, 0, 0, 0.5); /* Semi-transparent background */ + color: white; + border: none; + border-radius: 4px; + padding: 10px; +} +.avatar-btn-select { + width: 50px; + left: -55px; +} +.avatar-btn-remove { + width: 50px; + left: 5px; +} +