Skip to content

Menu Manager ACL#212

Closed
rmcdaniel wants to merge 14 commits intojoomla:masterfrom
rmcdaniel:master
Closed

Menu Manager ACL#212
rmcdaniel wants to merge 14 commits intojoomla:masterfrom
rmcdaniel:master

Conversation

@rmcdaniel
Copy link
Copy Markdown

This adds ACL to the menu manager. Most of the code was copied from the content manager. I tried to follow all the conventions in the original code. I hope this helps!

@rmcdaniel
Copy link
Copy Markdown
Author

@realityking
Copy link
Copy Markdown
Contributor

Haven't tested it yet but the idea is awesome!

Note: We'll have to update the sample data after this has landed.

@rmcdaniel
Copy link
Copy Markdown
Author

I forgot something else. In order to install properly, in installation/sql/mysql/joomla.sql this line:

INSERT INTO #__menu_types VALUES (1, 'mainmenu', 'Main Menu', 'The main menu for the site');

should be:

INSERT INTO #__menu_types VALUES (1, 0, 'mainmenu', 'Main Menu', 'The main menu for the site');

How do I add this to the pull request? Or should I make a new one?

@realityking
Copy link
Copy Markdown
Contributor

You can just add another commit to your branch, it will automatically be part of the pull request.

Another note that just occured to me: We probably need a migration script for this. I'm pretty sure something weird will happen if there isn't an entry in the asset table for a menu or menu item.

@rmcdaniel
Copy link
Copy Markdown
Author

Thanks for the help.

Regarding the migration script, when I was working on this, I started by just doing ALTER TABLE to add the asset_id column. Everything defaulted to 0 asset_id and nothing blew up. That might be enough.

@infograf768
Copy link
Copy Markdown
Member

Created an update sql file containing
ALTER TABLE #__menu_types ADD COLUMN asset_id INTEGER UNSIGNED NOT NULL DEFAULT '0' COMMENT 'FK to the #__assets table.' AFTER id;
ALTER TABLE #__menu ADD COLUMN asset_id INTEGER UNSIGNED NOT NULL DEFAULT '0' COMMENT 'FK to the #__assets table.' AFTER id;

Ran it and then tested on existing site

saw some errors preventing the tmpl from displaying wen editing a menu item

$canDo = $this->canDo; // error
$canDoAlso = $this->canDoAlso; //error

Also some errors with divs in views/item/tmpl/edit.php

@rmcdaniel
Copy link
Copy Markdown
Author

Alright, this latest commit should fix the problems that infograf768 saw.

@infograf768
Copy link
Copy Markdown
Member

The above errors are now corrected.
@test
Default Administrator has no access to menus/menu items permissions.

@rmcdaniel
Copy link
Copy Markdown
Author

I fixed the permissions for new installations. For current installations you need to execute:

UPDATE #__assets SET rules = '{"core.admin":{"7":1},"core.manage":{"6":1},"core.create":{"3":1},"core.delete":[],"core.edit":{"4":1},"core.edit.state":{"5":1},"core.edit.own":[]}' WHERE id = 16;

@infograf768
Copy link
Copy Markdown
Member

@ test
This does not work here.

@rmcdaniel
Copy link
Copy Markdown
Author

The only thing I can think of is that maybe the group and/or asset ids are different on your dataset.

@infograf768
Copy link
Copy Markdown
Member

I am using default trunk install with sampledata, patched with your diff and both queries.
I suggest you test this environment

@sanderpotjer
Copy link
Copy Markdown
Member

@rmcdaniel great idea to add ACL support to menu's! Much requested feature among the users of Joomla ACL.

Just started testing this new feature, and during the installation of fresh site with sampledata errors are visible while installing sampledata. The reason for this is that for example "installation/sql/mysql/sample_data.sq" should be updates as well with asset_id values for the #__menu and #__menu_types. Same for any other sample data file. In addition to this there should be references for all menu items and menus in the #__assets table as well.

@infograf768
Copy link
Copy Markdown
Member

@sanderpotjer
Indeed. This is what I tried to convey above. If we want to implemnt this for 3.x, we will not only have to change sampledatas, but also provide a migration for existing sites.

@rmcdaniel
Copy link
Copy Markdown
Author

Thanks for the information. I'll try to get the sample data and the assets done today. As for the migration script, can you give me any ideas on how to start? Is there an example in the installation folder already? Any documentation? Another thing that someone with more experience could look at is how I implemented _getAssetParentId(). I think it might be supposed to return the menutype id, or maybe it should return the parent menu item if that exists?

@infograf768
Copy link
Copy Markdown
Member

We do not have any migration script in present trunk. Just some simple updates to the db in com_admin.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The core.edit.own action is missing in the component section. So next line after core.edit.state should be core.edit.own

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's because it doesn't make sense for the component wide access control we have now. However with the item level access you're adding it does make sense.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Each action you add in additional access sections in an access.xml file should be available in the component access section. So the core.edit.own action is available in the menu section, and should be added to the component section as well. Otherwise you can't set an action component wide.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, I understand now. Thanks for your help. I have added the needed line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually in content for example edit.own only applies at the category adn compoent level, you can't further specify it at the item level for performance and other reasons. You give edit own in a category and the user can edit everything belonging to her in the category.

@sanderpotjer
Copy link
Copy Markdown
Member

Actually, the core.edit.own action is not needed in this component at the moment. There is no information stored in the menu tables about the creators of menutypes/menus. So it is better to remove the entire core.edit.own action for this component or we need to extend the menu tables with the creator information.

@rmcdaniel
Copy link
Copy Markdown
Author

Does that mean I should remove it from the menu section as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At the moment the menu types are stored in the assets table with a wrong parent id and level, to fix this add the following code over here to retrieve the correct information:

        // This is a menutype that needs to parent with the extension.
        if ($assetId === null)
        {
            // Build the query to get the asset id of the parent component.
            $query = $this->_db->getQuery(true);
            $query->select($this->_db->quoteName('id'));
            $query->from($this->_db->quoteName('#__assets'));
            $query->where($this->_db->quoteName('name') . ' = ' . $this->_db->quote('com_menus'));

            // Get the asset id from the database.
            $this->_db->setQuery($query);
            if ($result = $this->_db->loadResult())
            {
                $assetId = (int) $result;
            }
        }

@sanderpotjer
Copy link
Copy Markdown
Member

@rmcdaniel yes that is correct to remove core.edit.own from the menu section as well. Sorry for the confusing btw, just noticed edit.own isn't possible at the moment, so better to remove it for now.

@sanderpotjer
Copy link
Copy Markdown
Member

Another thing I noticed, when installing new components an entry in the #__menu table is created for each of the backend menu items of the component (this is currently default in Joomla). Now with this new menu ACL an entry in the assets table is created as well, but missing the correct parent and level id's. This is more difficult to fix because there is no 'menutype' for the backend menu items.

This might be solved if the backend menu will be transformed in a similar system as the frontend menus. I know there are plans for that, but don't know the status of that. So need to look into this (but want to share it already).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add

<div class="clr"></div>

@elinw
Copy link
Copy Markdown
Contributor

elinw commented Jun 1, 2012

In what sense is there ownership in menus?
the edit.own management is very messy to start out with since it violates a number of principles of ACL. There were very good reasons it was decided not to implement it below the category level for anything but articles in 1.6+.

You need to look at com_categories as that is the only core component that has a table extending jtablenested. That should show you how to work with nesting correctly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Rebuild button in the toolbar is now visible for users with access to the component but no edit/create/etc permissions. I suggest to show the button to users with core.admin permission, so it is in line with the com_categories for example. Line 68-72 of this file will become:

        if ($canDo->get('core.admin')) {
            JToolBarHelper::divider();
            JToolBarHelper::custom('menus.rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false);
            JToolBarHelper::preferences('com_menus');
        }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree, we need to look at all of those buttons if we are letting more
people into that ui.

On Sat, Jun 2, 2012 at 4:53 AM, Sander Potjer <
reply@reply.github.com

wrote:

@@ -51,7 +51,7 @@ protected function addToolbar()
{
require_once JPATH_COMPONENT.'/helpers/menus.php';

  •         $canDo  =
    
    MenusHelper::getActions($this->state->get('filter.parent_id'));
  •         $canDo  = MenusHelper::getActions();
    

JToolBarHelper::title(JText::_('COM_MENUS_VIEW_MENUS_TITLE'),
'menumgr.png');

The Rebuild button in the toolbar is now visible for users with access to
the component but no edit/create/etc permissions. I suggest to show the
button to users with core.admin permission, so it is in line with the
com_categories for example. Line 68-72 of this file will become:

               if ($canDo->get('core.admin')) {
                       JToolBarHelper::divider();
                       JToolBarHelper::custom('menus.rebuild',
'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false);
                       JToolBarHelper::preferences('com_menus');
               }

Reply to this email directly or view it on GitHub:
https://github.com/joomla/joomla-cms/pull/212/files#r918892

@rmcdaniel
Copy link
Copy Markdown
Author

We'd really like to see this in Joomla 3.0 if not sooner. Please advise on what needs to be done in order to keep this alive. I've seen a lot of support for the idea so far.

@klah
Copy link
Copy Markdown

klah commented Oct 2, 2012

Is there any news on whether this will be included in a future Joomla version?

Also (to me) the menu item management option doesn't seem to be working. I set the permissions of a menu item for Manager to Denied for all the actions. But a manager can still happily open, edit and save the item. He can even change his own permissions.

@elinw
Copy link
Copy Markdown
Contributor

elinw commented Oct 3, 2012

1,2,3,4,5,6,7,8,9,10

As always the only "news" that matters is that from people who have tested
and done code review and placed those comments in the feature tracker. So
I am assuming you have done that?

Elin

On Tue, Oct 2, 2012 at 5:35 AM, klah notifications@github.com wrote:

Is there any news on whether this will be included in a future Joomla
version?


Reply to this email directly or view it on GitHubhttps://github.com//pull/212#issuecomment-9065336.

@rmcdaniel rmcdaniel closed this Jul 19, 2013
wilsonge pushed a commit that referenced this pull request Jun 4, 2017
wilsonge pushed a commit to wilsonge/joomla-cms that referenced this pull request May 26, 2019
Let RIPS only run on the main repo
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.

6 participants