Skip to content

Fix no user name shown just after upload file#18

Merged
laoneo merged 8 commits intoDigital-Peak:developmentfrom
NitemareReal:development
Mar 5, 2024
Merged

Fix no user name shown just after upload file#18
laoneo merged 8 commits intoDigital-Peak:developmentfrom
NitemareReal:development

Conversation

@NitemareReal
Copy link
Copy Markdown
Contributor

When uploading a file, if no "created_by_alias" is set, user id is shown instead user name.
This is because after uploading file, "getItem" method is called, and just info about item (file) is loaded, and this only includes user id, not user name nor email.
If reloading/refresing page, it works ok because "getItems" method is called, which "joins" user id with user table and retrieves user name and email.
Solution is, after uploading file and loading item data and before rendering, calling a new method to load user information (name and email), using "$item->created_by" identifier from item object.

Copy link
Copy Markdown
Member

@laoneo laoneo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also some code style issues in this pr. Please fix them as described in the readme.

Comment thread com_dpattachments/admin/src/Model/AttachmentModel.php Outdated
Comment thread com_dpattachments/admin/src/Controller/AttachmentController.php
@laoneo laoneo merged commit 93d93e4 into Digital-Peak:development Mar 5, 2024
@laoneo
Copy link
Copy Markdown
Member

laoneo commented Mar 5, 2024

Thanks!

laoneo pushed a commit that referenced this pull request Mar 5, 2024
* 'Drag&Drop' events where binded to each 'upload form' as many times as input fields where present in screen, since loops where nested

* Whitespaces changes fixed

* Fixed no user name shown just after file uploaded (Id showed)

* Fixed no user name shown just after file uploaded (Id showed)

* Using 'UserFactoryAwareInterface' and 'UserFactoryAwareTrait' instead calling 'Factory' to get user data
@laoneo
Copy link
Copy Markdown
Member

laoneo commented Mar 5, 2024

Just to let you know that I renamed your changes and merged them into main. Probably you have to delete the development branch and recreate it again to pick up the changes.

@NitemareReal
Copy link
Copy Markdown
Contributor Author

Thanks for the code style fixes, I really appreciate them.

Be careful with lines 48, 49 and 50 in com_dpattachments/admin/src/Controller/AttachmentController.php:

$item->author_id = $author['author_id'];
$item->author_name = $author['author_name'];
$item->author_email = $author['author_email'];

Creation of dynamic property is deprecated in Joomla 5 and will be removed in Jooma 6.

@laoneo
Copy link
Copy Markdown
Member

laoneo commented Mar 5, 2024

Creation of dynamic property is deprecated in Joomla 5 and will be removed in Jooma 6.

Where do you have that information from? Dynamic properties are allowed on \stdClass where CMSObject is inheriting from since Joomla 5.1.

@NitemareReal
Copy link
Copy Markdown
Contributor Author

Creation of dynamic property is deprecated in Joomla 5 and will be removed in Jooma 6.

Where do you have that information from? Dynamic properties are allowed on \stdClass where CMSObject is inheriting from since Joomla 5.1.

Sorry, you are right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants