-
Notifications
You must be signed in to change notification settings - Fork 144
Use file processor for user avatar #6051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 39 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
afb055f
Add basic file processor for avatar
Cyperghost 882f7a9
Add `wcf1_user.avatarFileID` column
Cyperghost 782ceb5
Add session variable so that the user can delete the previous avatar
Cyperghost 86805f9
Add a new user menu item to manage the avatar
Cyperghost e027ed5
Add dialog to edit the avatar file id
Cyperghost 2df6b89
Add a command to set the avatar from a user
Cyperghost dfe7e6e
Support `File` in `AvatarDecorator` as avatar object
Cyperghost 4e8a4f6
Remove old `AvatarEditForm`
Cyperghost 6d92aa3
Load user avatar on `UserListPage`
Cyperghost 74843d4
Use `CloseOverlay` to close the user menu
Cyperghost 2897de9
`WCF.User.Avatar` and `WCF.User.Avatar.Upload` are no longer used
Cyperghost d785e06
Avatar is now no longer saved in `UserEditForm`
Cyperghost 27faeb7
Do not reload the page in the ACP when editing the user after his ava…
Cyperghost be50736
Delete old avatar file only if it is set
Cyperghost 8eaed86
Deprecated `UserAvatar`
Cyperghost 16d278a
Move the old user avatar to the new file storage in the `UserRebuildD…
Cyperghost 1d15c2b
Add new constant for the size of the avatar images in `UserAvatarFile…
Cyperghost 1991832
Remove unused function `UserAvatarAction::validateUpload()` and `User…
Cyperghost 315043d
Use `UserAvatarFileProcessor::AVATAR_SIZE` instead of `UserAvatar::AV…
Cyperghost 4cae70a
Delete user avatar files when user accounts are deleted
Cyperghost 614553e
No longer use `wcf1_user_avatar` to load the user's avatar
Cyperghost 27a5982
Add since information
Cyperghost 3f7182f
Use `avatarFileID` instead of `avatarID
Cyperghost 8f06441
Add php doc to `SetAvatar`
Cyperghost 3007ce3
No longer use `avatarID`
Cyperghost 5f0fa41
Move `canEditAvatar()` into `UserProfile`
Cyperghost c734e90
Use the new dialog to manage the avatar on the UserPage
Cyperghost 526aadf
Add an extra button next to *Edit cover photo* for avatar management
Cyperghost 0944073
Implement `FileRuntimeCache`, which also loads the thumbnails
Cyperghost 21b96a1
Use `FileRuntimeCache`
Cyperghost af4056e
Import the avatar in `UserImporter` and remove `UserAvatarImporter`
Cyperghost 0f6732c
Removing the user object from the cache after setting the avatar
Cyperghost 4a6b290
Remove unnecessary code
Cyperghost 26b9ee9
Resize or make the avatar quadratic if required
Cyperghost 6156406
Revert "Import the avatar in `UserImporter` and remove `UserAvatarImp…
Cyperghost e3c7bb4
Add a parameter to optionally copy the file, but it will still be mov…
Cyperghost bfcd4d3
Insert the avatar into the new file system during import, instead of …
Cyperghost a2c0339
Open the correct avatar management of the user on the profile page
Cyperghost b4adf28
Load a 256x256 or 128x128 thumbnail, depending on what thumbnails are…
Cyperghost 2cff601
Apply suggestions from code review
Cyperghost 4ad4afc
Run `tsc`
Cyperghost b3289a9
Check if `objectIDs` is empty
Cyperghost 91e657f
Check whether the user is in the accessible user groups
Cyperghost eee7fb8
Avatar size may also be 256x256 and not only a maximum of 128x128
Cyperghost 3f16df7
Merge branch 'file-upload-image-crop' into avatar-file-processor
Cyperghost 0eb36d5
Run `tsc`
Cyperghost 41f636d
Merge branch 'file-upload-image-crop' into avatar-file-processor
Cyperghost 043b3fc
Add foreign key for `wcf1_user.avatarFileID` to `wcf1_file.fileID`
Cyperghost 5265f0a
Merge branch 'file-upload-image-crop' into avatar-file-processor
Cyperghost 662416c
`createExact` renamed to `forExact`
Cyperghost 8e2734d
Merge branch 'file-upload-image-crop' into avatar-file-processor
Cyperghost 5f9a322
Merge branch 'file-upload-image-crop' into avatar-file-processor
Cyperghost f90b328
Merge branch 'file-upload-image-crop' into avatar-file-processor
Cyperghost e378fed
Use the user profile header template
Cyperghost ea529be
Use `File::getFullSizeImageSource()` instead of `File::getLink()`
Cyperghost 70871a7
Add `simpleReplace` and `hideDeleteButton` to the `FileProcessorFormF…
Cyperghost 8705964
Display thumbnail size by file processor
Cyperghost a44bea3
Merge branch 'file-upload-image-crop' into avatar-file-processor
Cyperghost 001ac17
Unset `uploadResolve`
Cyperghost 42a4c69
Add a callback that is triggered when the value of a FileProcessorFor…
Cyperghost 4150800
Notify only when the value has really changed.
Cyperghost a395125
Fix crop cancel event handling
Cyperghost 72fcd87
Update avatar in ACP live
Cyperghost 4a2d461
Remove round
Cyperghost 22fcdb5
Find the exact size for the image or use the minimum size for the image
Cyperghost File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Handles the user avatar edit buttons. | ||
* | ||
* @author Olaf Braun | ||
* @copyright 2001-2024 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
* @since 6.2 | ||
*/ | ||
|
||
import { promiseMutex } from "WoltLabSuite/Core/Helper/PromiseMutex"; | ||
import { wheneverFirstSeen } from "WoltLabSuite/Core/Helper/Selector"; | ||
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog"; | ||
import { show as showNotification } from "WoltLabSuite/Core/Ui/Notification"; | ||
import UiCloseOverlay from "WoltLabSuite/Core/Ui/CloseOverlay"; | ||
|
||
interface Result { | ||
avatar: string; | ||
} | ||
|
||
async function editAvatar(button: HTMLElement): Promise<void> { | ||
// If the user is editing their own avatar, the control panel is open and can overlay the dialog. | ||
UiCloseOverlay.execute(); | ||
|
||
const { ok, result } = await dialogFactory().usingFormBuilder().fromEndpoint<Result>(button.dataset.editAvatar!); | ||
|
||
if (ok) { | ||
const avatarForm = document.getElementById("avatarForm"); | ||
if (avatarForm) { | ||
// In the ACP, the form should not be reloaded after changing the avatar. | ||
avatarForm.querySelector<HTMLImageElement>("img.userAvatarImage")!.src = result.avatar; | ||
showNotification(); | ||
} else { | ||
window.location.reload(); | ||
} | ||
} | ||
} | ||
|
||
export function setup(): void { | ||
wheneverFirstSeen( | ||
"#wcf\\\\action\\\\UserAvatarAction_avatarFileIDContainer woltlab-core-file img", | ||
(img: HTMLImageElement) => { | ||
img.classList.add("userAvatarImage"); | ||
img.parentElement!.classList.add("userAvatar"); | ||
}, | ||
); | ||
|
||
wheneverFirstSeen("[data-edit-avatar]", (button) => { | ||
button.addEventListener( | ||
"click", | ||
promiseMutex(() => editAvatar(button)), | ||
); | ||
}); | ||
} |
29 changes: 29 additions & 0 deletions
29
wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.2.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* Updates the database layout during the update from 6.1 to 6.2. | ||
* | ||
* @author Olaf Braun | ||
* @copyright 2001-2024 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
*/ | ||
|
||
use wcf\system\database\table\column\IntDatabaseTableColumn; | ||
use wcf\system\database\table\index\DatabaseTableForeignKey; | ||
use wcf\system\database\table\PartialDatabaseTable; | ||
|
||
return [ | ||
PartialDatabaseTable::create('wcf1_user') | ||
->columns([ | ||
IntDatabaseTableColumn::create('avatarFileID') | ||
->length(10) | ||
->defaultValue(null), | ||
]) | ||
->foreignKeys([ | ||
DatabaseTableForeignKey::create() | ||
->columns(['avatarFileID']) | ||
->referencedTable('wcf1_file') | ||
->referencedColumns(['fileID']) | ||
->onDelete('SET NULL'), | ||
]), | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.