Skip to content

Commit 9f40c78

Browse files
permission filtering to the main ModulesModel manager list
1 parent 27110f3 commit 9f40c78

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

administrator/components/com_modules/src/Model/ModulesModel.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,28 @@ protected function translate(&$items)
220220
{
221221
$lang = Factory::getLanguage();
222222
$clientPath = $this->getState('client_id') ? JPATH_ADMINISTRATOR : JPATH_SITE;
223+
$user = Factory::getApplication()->getIdentity();
223224

224-
foreach ($items as $item) {
225+
foreach ($items as $key => $item) {
225226
$extension = $item->module;
226227
$source = $clientPath . "/modules/$extension";
228+
229+
$path = $source . '/' . $extension . '.xml';
230+
231+
if (file_exists($path)) {
232+
$xml = simplexml_load_file($path);
233+
234+
if (isset($xml->permissions)) {
235+
$action = (string) $xml->permissions;
236+
$asset = isset($xml->permissions->attributes()->asset) ? (string) $xml->permissions->attributes()->asset : null;
237+
238+
if (!$user->authorise($action, $asset)) {
239+
unset($items[$key]);
240+
continue;
241+
}
242+
}
243+
}
244+
227245
$lang->load("$extension.sys", $clientPath)
228246
|| $lang->load("$extension.sys", $source);
229247
$item->name = Text::_($item->name);

0 commit comments

Comments
 (0)