Hello,
I don't manage to make the bookexpand module work like I think it should.
I copied last version, activated it, selected Group in Book Expansion filter type.
Now I create a new group with a normal user (which gets automatically "group leader" role in this group, thanks to OG User Roles, this role authorizes the user to create book pages inside the group).
Then, with this user, I access node/add/book?gids[]=54 (where 54 is the last group id).
In the parent field, I get a list of all books already created.
What am I doing wrong?

Thank you,
David

Comments

David Stosik’s picture

Title: Can't seem to make it work it » Can't seem to make it work with Group filter

node/add/book?gids[]=54 is renamed in node/ognodeadd?type=book&gids[]=54, which doesn't match the expression '/node\/add\/book\?gids\[\]\=(.*)/' .
I may be wrong, but maybe if you used

$group_node = og_get_group_context();
$gid = $group_node->nid;

to get the gid, instead of the URL, the module would work better.

Indeed, I tried replacing
preg_match('/node\/add\/book\?gids\[\]\=(.*)/', $request, $match);
preg_match('/node\/ognodeadd\?type=book&gids\[\]\=(.*)/', $request, $match);
And it worked better.
Would it be possible to update the module to avoid parsing URL to retrieve GID, and use instead og_get_group_context() ?

Thanks,
David

David Stosik’s picture

Component: Miscellaneous » Code
Priority: Normal » Critical

I also tried this:

  if (($uid != 1)&&(module_exists('og'))) {
//  if ($match[1]) {
//    $output = og_book_get_options($match[1]);
// instead of parsing URL, we call og_get_group_context()
    $group_node = og_get_group_context();
    if (isset( $group_node->nid )) {
      $output = og_book_get_options($group_node->nid);
//(...)

And it works great, but I'm not sure it is the only thing to change to make it work perfectly...

Please let me know... ;)

David

David Stosik’s picture

Another problem I just raised: clicking on "add child page" link when viewing a group book page looses context, and allows creating a book page anywhere in the books hierarchy.

dwees’s picture

Assigned: Unassigned » dwees

I like your changes and will test them out. Seems like a good thing to do, especially as we test for the existence of the Og module just ahead of using a function from it. Of course it means keeping this module up to date with the Og module.

I'll add your changes to the next version, thanks.

Dave

dwees’s picture

Should be fixed with the newest version.

dwees’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)