Drupal: 5.7
I've got the project and Project Issue modules installed. The Create Content->Issue menu option is visible even for anonymous users, even though Create Project Issues is disabled in the access rules. I've tried to set and reset, flush cache, and can't seem to find any way to disable this from showing up. All my other content types obey their disabled state and don't show up in the Create Content list.

I've been trying to trace the code, but would greatly appreciate any suggestions on what might be going on.

Thanks much.

CommentFileSizeAuthor
#8 272618_pi_create_menu.patch744 bytesaclight

Comments

cybertoast’s picture

A bit more information, which I forgot to include in the previous post:
Although Create Content->Issue is visible, when I click on the link the next page gives me "You do not have access to any projects."
I would have expected that I would not be able to access issues at all if I don't have access to any projects (since the two are tied together right now).

beginner’s picture

confirmed.

I'm subscribing because I plan to work on a patch for D7 core that will modify the behavior of node/add (make its look and content more customizable).

cybertoast’s picture

Any suggestions on what could be done to change this behavior in 5.7?

aclight’s picture

I'd guess changing the following code in project_issue_menu() in project_issue.module:

    // Special menu item for the "first page" of submitting a new issue.
    // Instead of the treachery of a true multipage form, we just have
    // a simple form at node/add/project-issue that provides a project
    // selector which redirects to node/add/project-issue/[project-name].
    $types = node_get_types();
    $items[] = array(
      'path' => 'node/add/project-issue',
      'title' => $types['project_issue']->name,
      'callback' => 'project_issue_pick_project_page',
      'type' => MENU_NORMAL_ITEM,
    );

to

    // Special menu item for the "first page" of submitting a new issue.
    // Instead of the treachery of a true multipage form, we just have
    // a simple form at node/add/project-issue that provides a project
    // selector which redirects to node/add/project-issue/[project-name].
    $types = node_get_types();
    $items[] = array(
      'path' => 'node/add/project-issue',
      'title' => $types['project_issue']->name,
      'callback' => 'project_issue_pick_project_page',
      'access' => $access_create,
      'type' => MENU_NORMAL_ITEM,
    );

should do the trick.

cybertoast’s picture

Ok, more information:
When I just click on Create Content (even though it has Issue under it), the next page does NOT display Issue. I just get "No content types available". So something is goofy. I'd love to understand how this is possible and how it might be fixed.

aclight’s picture

Did you try my suggestion? I believe this is happening because the Create content page gets values via calls to node_access(), and project_issue correctly implements hook_access(). It's just that the node/add/project_issue menu item does not specifically declare what kind of access is needed for the menu item to be visible.

At least this I what I think is happening, after briefly looking at the code.

cybertoast’s picture

aclight, thanks for the suggestion, but it does not work.

According to the hook_menu() documentation:

Drupal will call this hook twice: once with $may_cache set to TRUE, and once with it set to FALSE

When I print_r the $may_cache value in project_issue_menu(), I only see the call being made once (with $may_cache=0). So the block does not get executed at all.
I changed the logic to if (!$may_cache) { ... }, but that did not change anything as far as the menu item being displayed.

aclight’s picture

Status: Active » Needs review
StatusFileSize
new744 bytes

Try this patch. It works for me.

If it doesn't work for you, do you have any node access control modules installed that might be complicating factors?

beginner’s picture

Status: Needs review » Reviewed & tested by the community

It works for me. Note: visit admin/build/menu to clear the cache.

cybertoast’s picture

No luck. Tried the following:
1. Applied change (access => $access_create) to the release version. Then went to admin/build/menu. Nothing changed. project_issue_menu() only get's called once ($may_cache = 0).
2. Upgraded to dev version of the module. Applied the patch, went to admin/build/menu. Nothing changed (still the same issue with $may_cache).
3. Tried disabling a few of the modules I've got installed in the hopes that there was a conflict triggering this problem. No such luck.

I guess this *must* be a problem in my config if it's working for others. I'll try it on a fresh install and see if that helps.

BTW, what kind of node access modules? I don't believe I have anything installed that might conflict, but I keep thinking that nodecarousel might have issues (tried disabling that and it did not help).

aclight’s picture

@cybertoast: I like to clear the cache by using the devel module's link in the devel block to clear all caches. The fact that project_issue_menu() is only ever called once indicates to me that you aren't really clearing your menu cache.

Examples of node access control modules include OG, Simple access, etc. They're used to give more fine grained control of who can view, edit, etc. a node. I don't think that's the problem here, but I suppose it's possible if you are indeed using such a module.

cybertoast’s picture

Damn - it turned out to be the cache! I truncated all the cache* tables and it helped clean all this up.

Dumb problem, but it helps to have someone aid in navigation sometimes :) Thanks so much aclight.

dww’s picture

Status: Reviewed & tested by the community » Fixed

Yup, good catch. Reviewed and committed to HEAD and DRUPAL-5--2. Thanks for the patch and the testing.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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