Drupal 5.5
Og 4.1
Og actions 1.0
Og content type admin 1.4

Installed and configured (defaults) on an existing site with ~25 groups and ~14 content types. Behavior is as expected, except ...

When creating a new node, the fieldset for Audience(og) only contains "public" along with the help text for the groups field but the pull down for groups is missing.
*Screen capture: http://drupal.org/files/2007-12-18_111043.png

Interestingly, if I don't select "Disallow changes..." I get the first group the user belongs to but it fails to enumerate the rest of the groups. In my case, this first group doesn't even allow this content type (according to Og CTA). This list should be a list of groups that the user belongs to filtered by the groups that allow that content type.
*Screen capture: http://drupal.org/files/2007-12-18_111129.png

If I uninstall, the regular Og behavior is returned and the audience field is fully enumerated.
*Screen capture: http://drupal.org/files/2007-12-18_111452.png

I appreciate any help you can provide. Thanks.

Comments

Michael Hofmockel’s picture

no editing of issues allowed. :(

click on attachments for screen captures.

rconstantine’s picture

That's strange. I've never had that problem and I assume nobody else has since you're using a standard set of modules. I don't know what to try here. Perhaps you could tell me what your audience settings are in the OG settings as well as the content type settings for Site-wide and Default groups.

Has anyone else had this problem?

Michael Hofmockel’s picture

StatusFileSize
new11.84 KB
new14.45 KB
new3.92 KB
new22.64 KB
new10.59 KB

I appreciate the quick response.
Here are the settings.

site wide settings (default - no change)
http://drupal.org/files/issues/2007-12-18_130429.png

default (default - no change)
http://drupal.org/files/issues/2007-12-18_130448.png

Og content type settings (default - no change)
http://drupal.org/files/issues/2007-12-18_130551.png

Og authoring settings (enable audience box, default private, required audience)
http://drupal.org/files/issues/2007-12-18_130645.png

Watchdog event (am looking at this now)
http://drupal.org/files/issues/2007-12-18_131813.png

Might there be some residual effect from enabling, uninstalling and then enabling again?

Michael Hofmockel’s picture

I'm missing table og_content_type_admin. Will make by hand and see what results. This could be the residual from not fully uninstalling so then not fully installing. Or maybe there is something wrong with the .install file.

rconstantine’s picture

I just looked at this too. And figured the table was missing. Looking at the install file now... Uh, please verify which DB you are using. I'm not sure whether PGSQL has been verified. Did you not get any errors at install? I throw errors if the queries aren't successful.

rconstantine’s picture

Note that this module implements the enable and disable hooks, both of which should only affect the display of the group detail block. So those should not be the source of the problem.

Michael Hofmockel’s picture

removed "system" table entry for CTA.
reinstalled og-content_type_admin was created and populated when enabled.

No more watchdog errors but audience enumeration problem persists.

Michael Hofmockel’s picture

MySQL 4.1.20
PHP 4.3.9

I don't think install or table creation is problem.

I'm delving into the function og_content_type_admin_form_alter($form_id, &$form) to search for the problem.

rconstantine’s picture

It is possible that there is a MySQL or PHP problem since I don't generally program for ancient-version capatibility. ;-(

With the announced death of PHP4 especially, I won't be implementing any PHP4-specific code, but will make available any code here in the queue for users to use should this turn out to be the problem and you provide a patch.

Otherwise, keep digging. You aren't getting any errors... hmm... maybe try saving the admin content type assignment page even if you aren't making any changes.

Michael Hofmockel’s picture

don't think php or db is problem.

problem lies in function og_content_type_admin_form_alter()
if you remove that function, you are returned to standard OG audience list.

I think I found one problem in module. In the "if" statement just before unset form variables.
You have $activated_types->{$form['type']['#value']}))
But $activated_types is an array not an object.

Should it be if (empty($activated_types[$form['type']['#value']])) {?

This gets me 99% there. The list only contains the expected groups except the first group is still sneaking through.
I think there is another error that doesn't catch the first case.

What do you think?

The entire function with my one line edit for reference.

function og_content_type_admin_form_alter($form_id, &$form) {
  if ($form_id == 'og_admin_settings') {
    $form['#submit']['_og_content_type_admin_rebuild_table'] = array();
  }
  elseif (isset($form['type']) && $form['type']['#value']. '_node_form' == $form_id) {
    $group = new stdClass;  // used for call _og_content_type_admin_is_admin()
    if (!empty($form['og_nodeapi']['visible']['og_groups']['#options'])) {
      foreach ($form['og_nodeapi']['visible']['og_groups']['#options'] as $nid => $name) {
        //see if they can add this content-type for this group
        $group->nid = $nid;
        if (_og_content_type_admin_is_admin($group) || (arg(2) == 'edit')) {
          continue;
        }
        else {
          //see if they are allowed to add this content type
          $sql = "SELECT octa.types_active FROM {og_content_type_admin} octa WHERE octa.gid = %d";
          if (!$result = db_fetch_object(db_query($sql, $nid))) {
            $result = db_fetch_object(db_query($sql, 0));
          }
          $activated_types = unserialize($result->types_active);
	  if (empty($activated_types[$form['type']['#value']])) {
            unset($form['og_nodeapi']['visible']['og_groups']['#options'][$nid]); // remove the checkbox to add this content to the og
          }
        }
      }
    }
  }
}
Michael Hofmockel’s picture

I can solve the first case slipping through by enabling "Disallow changes by all group owners". I want this enabled anyway so I have found a temporary solution.

I'll try to chase this a little as I am making progress.

rconstantine’s picture

I just don't understand why I haven't had any problems. I'm still looking too. Will test some things a little later.

ywidyatama’s picture

I came across the same problem as you are, and reached a similar conclusion.
The code :

          if (empty($activated_types->{$form['type']['#value']})) {
            unset($form['og_nodeapi']['visible']['og_groups']['#options'][$nid]); // remove the checkbox to add this content to the og
          }

is the culprit.
The outcome of running this code in PHP4 and PHP5 is different.
empty($activated_types->{$form['type']['#value']}) returns true in PHP4 when $activated_types is an array.
empty($activated_types->{$form['type']['#value']}) returns false in PHP5 when $activated_types is an array, and the element can be found in the array.
but strange enough, $activated_types->{$form['type']['#value']} in PHP5 (without reference to empty function) returns empty string, in contradiction to the return value of empty(..) function.
So, the result is, in PHP4 all checkboxes will be unset. In PHP4, after submitting the new node, and node_save called, the new node is not associated to any group (because the default checkbox is removed).
I am suggesting the code to be altered into :

          if (empty($activated_types[$form['type']['#value']])) {
            unset($form['og_nodeapi']['visible']['og_groups']['#options'][$nid]); // remove the checkbox to add this content to the og
          }
rconstantine’s picture

Title: Audience field missing from node/add/* » [SOLVED] PHP4: Audience field missing from node/add/*
Status: Active » Reviewed & tested by the community

That's reasonable. I just knew there was a PHP4-related answer here. Thanks for the investigative work. It will be in the next release (whenever that is.)

Panaromic.webdesign.com’s picture

I have (no had) the same problem. I spent 2 hours trying to solve this before I read this forum discussion. Yes it has fixed my problem. Thanks for saving my time.

Anonymous’s picture

Assigned: Unassigned »
Status: Reviewed & tested by the community » Closed (fixed)

@Ryan

As this discussion has come to the end prior to the most current release of this module i will make the judgment that this problem has been resolved in the current release and will close this issue,