When you click the "Add child page" link you normally come to a node add form where the right book parent is preselected. With Og User Roles the necessary arguments, /parent/[nid], are never passed along.

The add book form is looking for the parent nid in arg(4) so adding something like this just before the end of og_user_roles_init() should work. It does not look neat however and I'm unsure if there are some consequences of doing it.

      if (module_exists('book') && $type == 'book' && arg(3) == 'parent' && is_numeric(arg(4))) {
        $path .= '/0/parent/'. arg(4);
      }

Anyone else who have given this problem any thought?

Comments

somebodysysop’s picture

Assigned: Unassigned » somebodysysop
Status: Active » Needs review
StatusFileSize
new24.31 KB

That's strange because I don't get the same behaviour. When I click on "Add child page" I get:

/node/add/book/parent/225

and NOT ognodeadd.

You only get ognodeadd if gids[]= is a query in the URL. You have some special module or modification that is putting this query into the "Add child page" URL?

Of course, this is far easier to fix in any event. All I have to do is NOT redirect to ognodeadd if arg(2) = 'book'.

The only downside to this is that the current group is not automatically checked in the "Audience" checkbox if no group id is set in the query.

Your code is fine, but it seems like at some point it would conflict with relativity module code: http://drupal.org/node/166253

In any event, try this patch.

frjo’s picture

I did some more testing and it's this line that catch it:

if (arg(0) == 'node' && arg(1) == 'add' && $_SESSION['og_last'] && (!is_null(arg(2))) ) {

So it's here, line 798, one must place the code

      if (module_exists('book') && $type == 'book' && arg(3) == 'parent' && is_numeric(arg(4))) {
        $path .= '/0/parent/'. arg(4);
      }

I have tested it now and it seems to work.

P.S. I'm a bit unsure of the line number because vim and Textwrangler (on my Mac) disagree. I think it's because your textditor is not set to use unix line breaks.

somebodysysop’s picture

Status: Needs review » Fixed

Patch is in new 2.5 release which appears to have resolved the problem.

frjo’s picture

That fixes it! Thanks.

somebodysysop’s picture

Status: Fixed » Closed (fixed)