A node can have an Audience checkbox for Public allowing the posting to be visible by anyone in addition to a specific group. The problem is that this checkbox is only relevant if a group is actually assigned. If there are no assigned groups, then the posting should always be public, otherwise noone would see it. The confusion comes if one edits the node form and looks at the audience. If no groups are checked, then the public setting will be OFF. In addition, og_node_access_records will incorrectly see the public setting as off if there are no groups defined.

The problem can be fixed in the og_nodeapi during load. If there are no results returned from the og_ancestry table, then no groups have been assigned to the node. The default should be reset to public.

This is the original code:

    case 'load':
      if (!og_is_group_type($node->type)) {
        $node->og_public = db_result(db_query_range("SELECT is_public FROM {og_ancestry} WHERE nid = %d", $node->nid, 0, 1));
      }
      else {
        og_load_group($node);
      }

I believe that it should be:

    case 'load':
      if (!og_is_group_type($node->type)) {
        $result = db_query_range("SELECT is_public FROM {og_ancestry} WHERE nid = %d", $node->nid, 0, 1);
        $node->og_public = (db_num_rows($result) == 0 ? 1 : db_result($result));
      }
      else {
        og_load_group($node);
      }

This will force the og_public setting to be true when there are no assigned groups.

Comments

Veggieryan’s picture

subscribe.
I think there should be a small padlock icon that locks and unlocks with an exclamation behind it to really drive this home.
I think one checkbox is very confusing. just unchecking public doesn't scream private to most people.

Two checkboxes. One for public with an unlocked padlock, the other for private with a locked padlock.

When you click one checkbox, the other automatically unchecks.

that would be a great advance in usability.
thanks
ryan.

dkaragiozov’s picture

Hi All,

I had similar experience with the "Public" audience checkbox.
When you select it and then submit the form the node is visible for the public (not-logged in) users. However, if you open the node again, the Public checkbox is not selected (it's value is not saved) and the next update makes the node invisible to anonymous users.

In order to fix this problem, I've added few code lines in the method that saves the audience of the node in the group. I do not know if this is the best way to achieve consistent functionality, but my clients are happy for the moment :) If you are interested in such fix, please let me know.

greetings
Diman Karagiozov

pknag’s picture

Hi Diman,

Could you please post your fix to the problem mentioned here. I am using the 4.7.x versions of drupal and OG and I am hoping that someone has a patch against it. Otherwise please post the solution anyway and I can try modifying the og.module to fix this problem.

-PK

wallan’s picture

Thanks for this, swood!

I agree with your assessment on this issue. I've tried to use your fix, but I can't get it to work - the behaviour of the module seems unaffected. I've tested using a number of different settings under Organic groups configuration > Node authoring form, but I can't think of anything else affect this. Can you offer any advice?!

Thanks,

Allan

moshe weitzman’s picture

Status: Active » Closed (duplicate)