Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants