Drupal automatically hides menu items for paths that are not accessible
by the current visitor. This is often very useful, but occasionally it
is preferable to show the menu item, and show an 'access denied' page
after the user clicks on it.

Unfortunately, there is no such functionality in the Drupal core. This
module aims to fill this gap. It adds a new form element titled
'Ignore access' to the menu link edit screen. To use it, one or more
of the roles should be selected. If a visitor has one of the selected
roles the menu item will always be rendered, even if the current user
has no access to it!

If a visitor clicks on such a link but has no access to it, the standard
Drupal 'access denied' 403 page is shown.

I've been searching around and I believe there is no module around that already does this. But please correct me if I'm wrong.

Thank you for taking the time to review!

Project page: https://drupal.org/sandbox/bvanmeurs/1842438
Git: git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/bvanmeurs/1842438.git show_inaccessible_menu_link

To try it out:
Install the module.
Go to a menu link that would be hidden to some users.
Enable the role of those users.
The menu link will now appear for those users and lead to a 403 'access denied'.

Comments

odegard’s picture

Status: Needs review » Needs work

Coder shows no errors, good.
Manual inspection shows a few concerns:

Aren't you missing a return $form in hook_form_FORM_ID_alter?

Where is your module configured? There's no hook_menu() so I don't immediately understand where your form is shown.

I don't understand the roles part. You don't define any permissions. Seems something is missing. I was unable to test it.

EDIT: removed my comment on adding a license. DO does that automatically.

bvanmeurs’s picture

Status: Needs work » Needs review

Hi odegard,

Thanks for your review.

I wrapped several lines and included the 3rd parameter for the alter hook.

The alter hook should NOT return the $form. Please read the drupal_alter documentation on alter hooks.

I don't need to define a settings page, and I also don't need additional permissions. The roles define to which users the functionality applies. If someone of role 'X' has no permission to a menu item, and that menu item has role 'X' specified in the 'Ignore access' option added by this module, he will see the menu item. Is the README.txt not clear enough on this?

King regards,
Bas

odegard’s picture

Gotcha! I'm not sure if the README.txt could be more clear, or if it's me that's slow. How about adding some steps to test it?

This is what I did:

* As admin, go to admin/structure/menu, select "list links" for a menu that is not usually shown for, say, anonymous users
* Click "edit" on one of the top level links and check "anonymous user" under "Ignore access"
* Anonymous users should now see the previously hidden menu item
* Clicking on the menu itemstill provides an "Access denied" message, but the menu item is visible

-------------

Selecting ONLY a menu item on level 2 or further down doesn't show the menu item. I guess it depends on the use case?

Also, you are correct on not returning the $form in alter. My mistake.

bvanmeurs’s picture

Your steps seem fine to me.

Yeah, if you have a menu items with ancestor items that are also not accessible, you should also specify the 'ignore access' settings for those.

The only feature this module provides is that unaccessable links are no longer hidden. Very simple but sometimes very necessary.

r2integrated’s picture

Status: Needs review » Needs work
bvanmeurs’s picture

Status: Needs work » Needs review

Fixed the issues.. please re-review!

nesta_’s picture

Status: Needs review » Needs work

There is still a master branch, make sure to set the correct default branch: http://drupal.org/node/1659588 . Then remove the master branch, see also step 6 and 7 in http://drupal.org/node/1127732

bvanmeurs’s picture

Status: Needs work » Needs review

Done!

nesta_’s picture

Fix comment #7

:)

bvanmeurs’s picture

Bump. Does anyone care to give me project creation permissions?

Thanks.
Bas

maciej lukianski’s picture

Heh. I've been looking for a solution like this :)

My one suggestion is that you should have the "menu" module marked as a dependancy in your info file. Your module does not make sense without the menu module.

maciej lukianski’s picture

Status: Needs review » Needs work
bvanmeurs’s picture

Status: Needs work » Needs review

Thanks

klausi’s picture

We are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

monymirza’s picture

Code too short
This project is too short to approve you as git vetted user. We are currently discussing how much code we need, but everything with less than 120 lines of code or less than 5 functions cannot be seriously reviewed. However, it can promote this single project manually to a full project for you.

bvanmeurs’s picture

Guys,

What is this new requirement of 'project too short' all about? I've read the instructions on how to apply for a new project and this is new to me.

I have tried to get bigger projects approved but every time some new requirement pops up. Sometimes people have been asking me to evaluate other modules and write documentation on it as a part of the reviewing process. Right now I can only pray someone grants me and doesn't come with some big new requirement. It's crazy imho! I've been developing Drupal 7 for 32 hours a week since it came out and I'm confident my code is good enough to release. It seems that the tendency is that only perfect programmers are welcome. I'm going to wake you up: they don't exist!

I've seen full projects on drupal.org which code quality is very poor. They obviously didn't get the thorough reviews I'm experiencing. Also, when you finally have the permission you can release any crap you like. Isn't this reviewing process supposed to review code quality in general instead of a single project?

This attitude towards new developers will scare them off and kill the community if you are not careful.

Regards,
Bas

klausi’s picture

Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 1: http://drupal.org/node/1842466
Project 2: http://drupal.org/node/1512124

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

acbramley’s picture

Status: Needs review » Reviewed & tested by the community

Setting to RTBC, the other project application has been closed, his code is good, and as per his comments on #16 I don't see any reason not to promote this.

jthorson’s picture

Status: Reviewed & tested by the community » Fixed

A couple minor comments:

Code Length
The 'code too short' guideline was added to this process to ensure that modules contained enough code to give reviewers a good sense of the applicant's understanding and use of the Drupal APIs and security awareness ... we had to add this after receiving a few applications which were nothing more than a single hook_form_alter function. However, I would not apply that standard in this case, as your account and previous application contain more than enough code to provide this assurance to anyone doing more than a superficial pass.

The introduction of the 'review bonus' program in this queue has resulted in a much larger number of new reviewers looking at applications, with varied levels of experience.

show_inaccessible_menu_link.module
show_inaccessible_menu_link_help():
As explained at http://drupal.org/node/322774, it is generally preferred to break up translated strings to the block or sentence level, to simplify the job for translators.

Thanks for your contribution, bvanmeurs!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

bvanmeurs’s picture

Thanks guys!

This opens a new possibility of contributing to the Drupal project. I will do my best to repay the effort put into reviewing my project applications by creating some interesting new projects.

Kind regards,
Bas

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

fonant’s picture

Did this project get promoted to a full project? I'd be interested in using it.

bvanmeurs’s picture

fonant, I've promoted it to full project. The reason it was not already is because I ended up having to put it in another 'custom' module.

The code is simple enough to provide basic support though.

What is your coding experience? Do you feel interested in sharing the responsibility of maintaining this module?

https://drupal.org/project/show_inaccessible_menu_link

Thanks all.

avpaderno’s picture

Title: Show Inaccessible Menu Link » [D7] Show Inaccessible Menu Link
Issue summary: View changes