Comments

bulldozer2003’s picture

Status: Active » Needs review
Issue tags: +Needs committer feedback
StatusFileSize
new13.3 KB

Here is my rewrite of og_menu_form_node_form_alter() and associated code.

rv0’s picture

I will need to review this thoroughly

One a sidenote, check the comments/discussion in #1847110: Menu affiliation lost when editing a node in a group, improve menu settings on administer node type form.

bulldozer2003’s picture

I don't suffer from #1847110: Menu affiliation lost when editing a node in a group, improve menu settings on administer node type form. after applying my patch. I had to rewrite parts of og_menu_node_prepare(), this is a major (good :) patch.

rv0’s picture

Status: Needs review » Needs work

Testing the patch
can't get it to work the way it should.

I created a normal user and made him member of the group.
I gave normal members the "administer menu" permission (on group level)

Normally I would expect then, if I add a node to the group with this user, I would see the menu.
In ideal case, the user is only possible to add pages linked to groups he has access to.
he would use the link node/add/group-page?og_group_ref=4 (in my case)
In node_prepare we can already provide the correct menu data. This does not seem to happen.

I retried with admin. Same thing, menu selection does not show up at all.

Tried to see what happens in the code.
You lost me around

      if (!empty($ids) && empty($groups[$field['settings']['target_type']])) {
        $groups[$field['settings']['target_type']] = array_keys($ids);
      }

$ids is an array

Array
(
    [group] => Array
        (
            [4] => MyGroupName
        )

)

if i'm gonna array_keys that, i'll array(0 => 'group'); and not the group id's at all..

Help is welcome if I'm doing something wrong, but I can't commit this if I even can't get the basic functionality to work.

bulldozer2003’s picture

Help is welcome if I'm doing something wrong, but I can't commit this if I even can't get the basic functionality to work.

Absolutely agree.
Most of my patches get tested and pushed to my production intranet before getting submitted here.

Which commit of OG are you using, somewhere back a couple of commits, they switched the way getReferenceableEntities() returns results, then when I last did a git pull, the return had switched back. I was going to update this patch, but then the change reverted so I no longer needed to.

My code here is assuming $ids is an array of gids and group_names of one entity typed, keyed by the gid.

$ids = array(
  0 => group0,
  1 => group1,
);

I'll check is against the latest OG head right now.

rv0’s picture

 Drupal core       7.18     7.18     Up to date                               
 Chaos tool suite  7.x-1.2  7.x-1.2  Up to date                                                                                                
 Devel             7.x-1.3  7.x-1.3  Up to date                               
 Entity API        7.x-1.0  7.x-1.0  Up to date                               
 Entity reference  7.x-1.0  7.x-1.0  Up to date                               
 Entityreference   7.x-1.1  7.x-1.1  Up to date                               
 prepopulate                                                                                              
 Organic groups    7.x-2.0  7.x-2.0  Up to date                               
                   -rc1     -rc1                                              
 OG Extras         7.x-1.1  7.x-1.1  Up to date                               
 Views             7.x-3.5  7.x-3.5  Up to date                               
 Views Bulk        7.x-3.1  7.x-3.1  Up to date                               
 Operations (VBO)             

If you are on #drupal IRC you may be able to contact me more directly

bulldozer2003’s picture

Needs to be updated to the new format getReferenceableEntities() spits out results in an array of bundle types.

bulldozer2003’s picture

Status: Needs work » Needs review
StatusFileSize
new13.49 KB
rv0’s picture

Status: Needs review » Fixed

Committed!

Thanks for your hard work.

Next up:
In #3 you say:

I don't suffer from #1847110: Menu affiliation lost when editing a node in a group after applying my patch. I had to rewrite parts of og_menu_node_prepare(), this is a major (good :) patch.

Actually, I just tested. Menu _IS_ lost under the conditions mentioned in #1847110: Menu affiliation lost when editing a node in a group, improve menu settings on administer node type form.
I renamed that issue and ongoing development will happen there.

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

xjm’s picture

Issue summary: View changes
Issue tags: -Needs committer feedback