Skip to content

Commit

Permalink
[ACL] [com_menus items view] Correct check when "All Menus" is select…
Browse files Browse the repository at this point in the history
…ed (#12815)

* add menu type id to the model so we can use it on acl checks

* add the correct acl check
  • Loading branch information
andrepereiradasilva authored and rdeutz committed Nov 15, 2016
1 parent c584c48 commit 9416db2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions administrator/components/com_menus/models/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected function getListQuery()
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');

// Join over the menu types.
$query->select($db->quoteName('mt.title', 'menutype_title'))
$query->select($db->quoteName(array('mt.id', 'mt.title'), array('menutype_id', 'menutype_title')))
->join('LEFT', $db->quoteName('#__menu_types', 'mt') . ' ON ' . $db->qn('mt.menutype') . ' = ' . $db->qn('a.menutype'));

// Join over the associations.
Expand All @@ -273,7 +273,7 @@ protected function getListQuery()
$query->select('COUNT(asso2.id)>1 as association')
->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_menus.item'))
->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key')
->group('a.id, e.enabled, l.title, l.image, u.name, c.element, ag.title, e.name, mt.title');
->group('a.id, e.enabled, l.title, l.image, u.name, c.element, ag.title, e.name, mt.id, mt.title');
}

// Join over the extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
$ordering = ($listOrder == 'a.lft');
$canOrder = $user->authorise('core.edit.state', 'com_menus');
$saveOrder = ($listOrder == 'a.lft' && strtolower($listDirn) == 'asc');
$menuTypeId = (int) $this->state->get('menutypeid');
$menuType = (string) $app->getUserState('com_menus.items.menutype', '', 'string');

if ($saveOrder && $menuType)
Expand Down Expand Up @@ -109,12 +108,13 @@

<tbody>
<?php

foreach ($this->items as $i => $item) :
$orderkey = array_search($item->id, $this->ordering[$item->parent_id]);
$canCreate = $user->authorise('core.create', 'com_menus.menu.' . $menuTypeId);
$canEdit = $user->authorise('core.edit', 'com_menus.menu.' . $menuTypeId);
$canCreate = $user->authorise('core.create', 'com_menus.menu.' . $item->menutype_id);
$canEdit = $user->authorise('core.edit', 'com_menus.menu.' . $item->menutype_id);
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id')|| $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state', 'com_menus.menu.' . $menuTypeId) && $canCheckin;
$canChange = $user->authorise('core.edit.state', 'com_menus.menu.' . $item->menutype_id) && $canCheckin;

// Get the parents of item for sorting
if ($item->level > 1)
Expand Down

0 comments on commit 9416db2

Please sign in to comment.