? ? Pending

User tests: Successful: Unsuccessful:

avatar particthistle
particthistle
19 Oct 2021

New PR to redo #19038

Thanks to @stutteringp0et for original PR.

What it does

This small change allows media fields to be used in user profiles, where a user is not authorized for core.create in com_users - they can be authorized in com_media. In conjunction with a filesystem plugin, a user can be granted access to com_media a limited area of the filesystem. This change should not impact anything other than front-end media modals.

Currently the change:

  • requires administrator to enable the permissions for Media component: Registered needs to have Create permissions set to Allow
    image
  • provides the user with the ability to upload an image, but also select ANY media available.

A future addition / feature enhancement would be to limit user to only viewing their own media and limit uploading to just a folder for that user.

Summary of Changes

In plugins/fields/media/media.php if com_media has core.create permissions, enable the select button.
In components/com_media/src/Dispatcher/Dispatcher.php add a check to see if the user has permissions for core.create on com_media

Testing Instructions

  • Create a user custom field of type media with Registered access level permissions.

  • Editing your profile, the media field will have no button to open the media manager a Select button, but will not load the Media Manager when clicked because the user has no access.

  • Apply this change

  • Go to options for Media

  • Change the permissions for the "Registered" user group, setting "create" permissions to "Allow".

  • The user is now given the "Select" access to the Media Manager when they go to select an image.

Before Patch applied

Media manager will not load due to permissions issue
image

Expected result

Media manager loads due to Registered Users having core.create permissions set on com_media
image

avatar particthistle particthistle - open - 19 Oct 2021
avatar particthistle particthistle - change - 19 Oct 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Oct 2021
Category Front End Plugins
avatar particthistle particthistle - change - 19 Oct 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 19 Oct 2021
Category Front End Plugins Front End com_media Plugins
avatar particthistle particthistle - change - 19 Oct 2021
Title
Update media.php (Reworks #19038)
Allow User Media Field to be accessible to Registered users (Reworks #19038)
avatar particthistle particthistle - edited - 19 Oct 2021
avatar richard67
richard67 - comment - 19 Oct 2021

@particthistle PR #19038 was for the 4.1-dev branch and this one here is for 4.0-dev. Is that by purpose?

avatar bembelimen
bembelimen - comment - 19 Oct 2021

@particthistle PR #19038 was for the 4.1-dev branch and this one here is for 4.0-dev. Is that by purpose?

Thx, done

avatar bembelimen bembelimen - change - 19 Oct 2021
Title
Allow User Media Field to be accessible to Registered users (Reworks #19038)
[4.1] Allow User Media Field to be accessible to Registered users (Reworks #19038)
avatar bembelimen bembelimen - edited - 19 Oct 2021
avatar particthistle particthistle - change - 21 Oct 2021
Labels Added: ?
Removed: ?
avatar particthistle
particthistle - comment - 21 Oct 2021

4.0 instead of 4.1 was an oversight.

JFactory changed to Factory

avatar particthistle
particthistle - comment - 2 Nov 2021

With #35886 doing a similar fix by removing code, which of the two PR is correct?

I've not got a moment to see if #35886 allows the User Media Field to be accessible to Registered Users, but will try and check later unless someone else has a moment to test it.

avatar richard67
richard67 - comment - 2 Nov 2021

@particthistle As far as I could see, the other PR just removed obsolete conditions, and only this here allows the registered user access to the media field, so both PRs are independent. They could have been made together in one, but keeping it separate makes testing safer because only the relevant change is tested, here the new access and in the other PR that removing the obsolete stuff doesn’t break anything.

avatar particthistle particthistle - change - 4 Nov 2021
The description was changed
avatar particthistle particthistle - edited - 4 Nov 2021
avatar particthistle
particthistle - comment - 4 Nov 2021

I've incorporated the changes from #35886 in advance of that being RTC.

The code removed in #35886 still leaves the problem of allowing those with core.create permissions from uploading new media. This PR resolves that based on what was initially added in #19038

avatar Shubhamverma2796 Shubhamverma2796 - test_item - 21 Nov 2021 - Tested successfully
avatar Shubhamverma2796
Shubhamverma2796 - comment - 21 Nov 2021

I have tested this item successfully on 20706fc


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35863.

avatar pritam825 pritam825 - test_item - 21 Nov 2021 - Tested successfully
avatar pritam825
pritam825 - comment - 21 Nov 2021

I have tested this item successfully on 20706fc


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35863.

avatar richard67 richard67 - change - 21 Nov 2021
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 21 Nov 2021

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35863.

avatar bembelimen bembelimen - change - 25 Nov 2021
Labels Added: ?
avatar bembelimen bembelimen - change - 25 Nov 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-11-25 09:54:57
Closed_By bembelimen
avatar bembelimen bembelimen - close - 25 Nov 2021
avatar bembelimen bembelimen - merge - 25 Nov 2021
avatar bembelimen
bembelimen - comment - 25 Nov 2021

Thx

Add a Comment

Login with GitHub to post a comment