replace the conditional in the bookexpand_form_alter function from this:
if ($form_id === 'book_node_form')
to this:
if ($form_id === 'book_node_form' || $form_id === 'book_outline')
to allow the 'outline' tab on nodes of all types to work with this module.

Comments

rconstantine’s picture

It seems that was incomplete. I was not able to get the group-restricted method working without commenting out this:

if ($row['parent'] == 0) {
	  return array('<'. t('top-level') .'>');
	}

from the og_book_get_options function.

I can now see the books that belong to the group I'm in when on a node's 'outline' tab. If I have the create book permission, I get the option in the drop down, and it's gone if I don't. So that works. If I create a new book from inside a group, the drop down is correct, again based on permissions.

Was OG-restricted book management working for anybody without this code commented out?

I think the thinking was to make this function act like the others, but OG is unique in that you shouldn't have to be inside of a book itself, and so the parent will often (or always?) be zero, which was leading to the drop down not being populated correctly.

Comments? Reviews?

dwees’s picture

You know I've never once used the 'Outline' feature provided with the Book module?

I think your fix is a good one, not sure I understand why it matters if there is a 'top-level' in the hierarchy, but I guess I'll have to do some testing.

Dave

dwees’s picture

I've added the first of your two fixes to my module as I can see exactly why it is necessary. I'm not sure about the 2nd change though.

Dave

dwees’s picture

Assigned: rconstantine » dwees
Status: Needs review » Postponed (maintainer needs more info)

Changing status to 'needs more info' until we clear up this top-level issue. I seem to recall needing to add that code (which if I remember how I coded this module is required to make sure that the handbook top-level page can't be moved in the hierarchy) for some reason or another. Let me know what the issue you have is with it.

Dave

rconstantine’s picture

$row['parent'] == 0 was always evaluating to zero. So the code after it, which finds all applicable group-related books never fires.

The way I understand the code, you have created a top level book for each group, let's call that the 'group default book'. Without removing the above code, I am only able to select 'top level' both when using the outline feature and when creating new book pages. In other words, I'm never allowed to create or move pages into a book of any kind. I don't think that the group filter works at all. The 'group default book' and all other books belonging to the group don't show in the selector. Removing the code allows one to either add to that default book, or create other top level books and/or add to them.

I see that og_book_get_options is only used for the group filter case, so at least we can be safe in knowing that changes made to this function won't affect the other filters.

Anyway, the og_book_get_options function calls the og_book_get_root, passing in the group gid. Since we are sorting the books by gid, this is naturally the 'top level' and will NEVER have a parent, thus the problem of parent always being zero and the following query never firing.

Removing the code and allowing the query to fire (or, rather passing the query to bookexpand_toc) finds all children for the top level (or group) that we are in. The drop down selector is correctly populated with followed by the books and their leaves.

What still needs to be fixed is the in the bookexpand_toc_group function. Presently, it seems when we are not in a group context, site-wide books are not filling the drop down selector - both before and after my change to the code.

NEWFLASH -- I just took a closer look at that function. Seems that the %d in the two queries in that function are missing their 'd' and just read '%'. Adding the 'd' now populates the site-wide add a book page drop down with all books. I think this should be restricted to exclude books that belong to groups because we cannot expect users to also check the correct audience box. In other words, book pages added to group books from outside a group context ensures that those pages don't have a group context unless the user is savvy enough to know that the audience checkbox needs to be set. This causes users to go in and out of a group context as they browse the pages of a book.

The other alternative to removing group related books from the general list is to automatically set the audience upon submission or validation. As I don't presently allow users to create any content outside of a group context, I will leave that up to you for now.

I hope I have clarified this issue. If you have any other questions, let me know. I'm happy to help.

rconstantine’s picture

BTW, I can see the problem of moving the group's default book. It seems that my solution is incomplete but is a step in the right direction. Perhaps we just need to but more into the 'if' statement of the code I removed to make this work. In other words if ($row['parent'] == 0 && SOMETHING ELSE && MAYBE SOMETHING ELSE) {

dwees’s picture

Yeah I found all of those % missing their d, really no clue how that happened. I fixed em up and recommitted the module so we should have fewer sql errors.

Not sure what the best thing to do regarding the group/not group context. The site I use this filter for all content is created in a group context (except by administrative users).

Maybe I need to create another setting which is 'exclude group books when not in a group context' which shows up if the user has shown the group filter.

How that portion is supposed to work is that if we are at the top-level book page, we don't want to allow users to move it at all. It's supposed to show up as only being allowed to be top-level.

Can you confirm if the other book pages are able to be placed appropriately? They seem to be able on the site where I am using the filter.

Dave

rconstantine’s picture

For group/not group context, I would agree with you, that until the audience problems are addressed more generally by OG itself, that this module should disallow books outside of groups when using that filter. At least I would make this the default behavior and then explain that by turning it off that pages may reside outside of the group context if users don't select the right audience.

I too do not allow book page creation outside of groups since I am using my content_type_by_organic_group module (or whatever I called it); only admins (currently user 1) can post all types anywhere. So for me, I hopefully won't have too many problems as things are now.

I think I may be seeing a different behavior with the option. First let me explain what I think you are saying is the way things should work:

-Using the group filter, and posting a new book page from within a group, I should be presented with a drop down selector containing and then the hierarchically represented listing of all books and their pages within the group's overall book (which was created by this module as a container). Is this right?

-Instead, what I am seeing is and then the group's top level book that this module created. So if I select , I create a book parallel to the group's top book. So perhaps my changes messed things up. However, prior to my changes, I was unable to select anything as I mentioned before. But perhaps that was before I caught the missing '%'s. I'll roll back my changes except for the '%'s and compare.

dwees’s picture

Status: Postponed (maintainer needs more info) » Fixed

This should be fixed in the newest version.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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