Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Rendering menu items #288

Open
Calemsw opened this issue Apr 24, 2013 · 6 comments
Open

Rendering menu items #288

Calemsw opened this issue Apr 24, 2013 · 6 comments
Assignees
Milestone

Comments

@Calemsw
Copy link
Contributor

Calemsw commented Apr 24, 2013

The menu should not render items that refer to non-public pages (Archive, private, draft) if I am not logged as administrator.
I have a page with status = private, linked to an menu item.
I see menu voice as anonymous user and can click it; so I receive a HTTP_Exception_404 [ 404 ]: Attempt to non-existent post.

@ghost ghost assigned sandeepone Apr 26, 2013
@sandeepone
Copy link
Member

Current menu render does not support ACL, will be added in future. But developer can use Events {module}_Event to hide temporary ugly hack.

@sergeyklay
Copy link
Contributor

I did some research and found that all route names for menu items we can get using Path::lookup, Path::load, Path::alias.

Using these methods, we can get the name of route.

Very little left to do — add a simple method to Routes that it was possible use them like this:

    Route::set('page', 'page(/<action>)(/<id>)(/p<page>)', array(
        'id'         => '\d+',
        'page'       => '\d+',
        'action'     => 'index|list|view|add|edit|delete|term|tag'
    ))
    ->perms(array('perm_name_1', 'perm_name_2', 'perm_name_3', ...))
    ->defaults(array(
        'controller' => 'page',
        'action'     => 'index'
    ));

Where Route::perms should be setter and getter.
Yes, it's little ugly, but this should work, can be rapidly implemented, may be cached and at first glance looks quite stable ;-)

@sandeepone What do you think about this?

@sandeepone
Copy link
Member

Good idea..

@sandeepone
Copy link
Member

@sergeyklay at request level we could not determine the permission of the menu item for pages/blogs, since the route exists and the page/blog may be in draft status, so we should not allow the menu item to be displayed for normal users and admin users can see the menu item.

@sergeyklay
Copy link
Contributor

We just don't have to show a menu item. And hide it from the array of items can be on Menu::links stage

@sergeyklay
Copy link
Contributor

Menu entry has a URL. The URL can have alias. If the alias is exists - you can get Route by alias, if not - then get Route by URL.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants