Skip to content

Commit

Permalink
[4.1] Allow User Media Field to be accessible to Registered users (Re…
Browse files Browse the repository at this point in the history
…works #19038) (#35863)

* Update media.php

New PR to redo #19038

* Update Dispatcher.php

Reworking #19038

* Update plugins/fields/media/media.php

JFactory > Factory

Refactor for Joomla 4

Co-authored-by: Brian Teeman <[email protected]>

* Update media.php

Added use Joomla\CMS\Factory;

* Update Dispatcher.php

Updating #35863 to incorporate changes made in #35886.

#35886 removes some code no longer required for `$asset` and `$author` variables.

#35863 then extends the changes to allow permissions for `core.create` in addition to `core.manage` to allow users with lower permissions to have create permissions assigned.

* Resolving 4.1-Dev conflict.

Resolving conflicts

Co-authored-by: Benjamin Trenkle <[email protected]>
Co-authored-by: Brian Teeman <[email protected]>
  • Loading branch information
3 people authored Nov 25, 2021
1 parent 137f19f commit 7b7a919
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion components/com_media/src/Dispatcher/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ protected function checkAccess()
$user = $this->app->getIdentity();

// Access check
if (!$user->authorise('core.manage', 'com_media'))
if (!$user->authorise('core.manage', 'com_media')
&& !$user->authorise('core.create', 'com_media'))
{
throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
}
Expand Down
8 changes: 7 additions & 1 deletion plugins/fields/media/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;

/**
Expand Down Expand Up @@ -39,7 +40,12 @@ public function onCustomFieldsPrepareDom($field, DOMElement $parent, Form $form)
}

$fieldNode->setAttribute('type', 'accessiblemedia');


if (Factory::getApplication()->getIdentity()->authorise('core.create', 'com_media'))
{
$fieldNode->setAttribute('disabled', 'false');
}

return $fieldNode;
}

Expand Down

0 comments on commit 7b7a919

Please sign in to comment.