I have the same issue as http://drupal.org/node/178610 , not only for hyphenated content types but for all content types.

CommentFileSizeAuthor
#1 og_user_roles.access-denied.patch826 bytessun

Comments

sun’s picture

Status: Active » Needs review
StatusFileSize
new826 bytes

Please try this patch and report back if it works for you.

somebodysysop’s picture

I have the same issue as http://drupal.org/node/178610 , not only for hyphenated content types but for all content types.

http://drupal.org/node/178610 consists of several issues. And, they have been resolved to my satisfaction. I need more specifics about your case in particular if you'd like me to look into it.

sun’s picture

Patch in #1 fixes the bug where /node/add/my-content-type is redirected to /node/ognodeadd?type=my_content_type&gid... since the conversion of the passed in $_GET parameter happens too late.

This is most likely the same issue that the original poster has.

somebodysysop’s picture

Here is the current code:

  $type = $_GET['type'];

  if ($type) {
    // Convert the dashes in the URL back to underscores. http://drupal.org/node/349648
    $type = str_replace('-', '_' , $type);
    // Got this from node.module (node_access)
    // No matter the type, this should return us the create permission.
    $module = node_get_types('module', $type);

    if ($module == 'node') {
      $module = 'node_content'; // Avoid function name collisions.
    }

    $access = module_invoke($module, 'access', 'create', $type, $user);

    if ($access === TRUE) {
      
    // Working on this issue: http://drupal.org/node/183096
      $content_type = node_get_types('type', str_replace('-', '_', $type));
      $output = '<p>'. filter_xss_admin($content_type->help) .'</p>';
      $output .= node_add($type);
    }

Note that '-' is replaced by '_' in $type before it is used in the condition.

You are suggesting:

  $type = str_replace('-', '_', $_GET['type']);

  if ($type) {
    // Convert the dashes in the URL back to underscores. http://drupal.org/node/349648
    $type = str_replace('-', '_' , $type);
    // Got this from node.module (node_access)
    // No matter the type, this should return us the create permission.
    $module = node_get_types('module', $type);

    if ($module == 'node') {
      $module = 'node_content'; // Avoid function name collisions.
    }

    $access = module_invoke($module, 'access', 'create', $type, $user);

    if ($access === TRUE) {
      
    // Working on this issue: http://drupal.org/node/183096
      $content_type = node_get_types('type', $type);
      $output = '<p>'. filter_xss_admin($content_type->help) .'</p>';
      $output .= node_add($type);
    }

I don't mind making the change if it helps, but functionally, I don't see the difference between the two.

Patch in #1 fixes the bug where /node/add/my-content-type is redirected to /node/ognodeadd?type=my_content_type&gid... since the conversion of the passed in $_GET parameter happens too late.

I don't see where it's too late since I do the conversion right at the top of the "if" condition for $type. What am I missing?

Which is why I asked for a clarification of this issue because it's not clear what this particular individual is having a problem with.

sun’s picture

Note that patch in #1 is against 6.x-1.2. I did not have time to look into CVS yet.

Without setting the proper content-type name for $type

$type = str_replace('-', '_', $_GET['type']);

the following access check tries to check access for a nonexistent content-type:

$access = module_invoke($module, 'access', 'create', $type, $user);

$type should always contain the proper content-type name, at any point in time in this function.

somebodysysop’s picture

Status: Needs review » Fixed

I don't think it will make a difference, but committed your change to dev branch.

heacu’s picture

subscribing

Status: Fixed » Closed (fixed)

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