When exporting a groupified org with settings for the group, those settings are exported as top level properties instead of values instead the data property.

This is what is output now and doesn't work:

...other org type properties...    
 "group" : 1,
 "group_settings" : {
   "private" : 1,
   "content_types" : {
     "event" : "event",
     "blog" : "blog",
     "page" : "page",
     "resource" : "resource",
     "webform" : "webform"
   }
 }

What works:

...other org type properties...    
"data" : {
  "group" : 1,
  "group_settings" : {
    "private" : 1,
    "content_types" : {
      "event" : "event",
      "blog" : "blog",
      "page" : "page",
      "resource" : "resource",
      "webform" : "webform"
    }
  }
}

Comments

levelos’s picture

Assigned: Unassigned » bleedev
bleedev’s picture

Status: Active » Closed (cannot reproduce)

Unable to reproduce this issue with the current code.

tauno’s picture

Assigned: bleedev » levelos
Status: Closed (cannot reproduce) » Active
levelos’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

dobe’s picture

Status: Active » Closed (fixed)

I am not sure if my problem pertains to this issue but it is what resembles it the closest. I am using the latest dev version. When I export my Redhen setup as a feature and attempt to install it in a profile I have created. Every time I flush cache I get this

Notice: Undefined property: RedhenOrgType::$data in redhen_org_group_redhen_org_type_update() (line 74 of /sites/all/modules/redhen/modules/redhen_org_group/redhen_org_group.module).

I am unclear why we do the following comments surrounded by tag:

function redhen_org_group_redhen_org_type_update(RedhenOrgType $org_type) {
  <strong>//**** WHY DO WE CHECK TO SEE IF THIS IS SET THEN...</strong>
  if (isset($org_type->group_settings['content_types'])) { 
    <strong>//**** SET THIS VARIABLE (that is only used once)....</strong>
    $content_types = $org_type->data['group_settings']['content_types'];

    // Delete field instances if a content type was removed.
    <strong>//**** THEN TRAVERSE THROUGH THIS ARRAY</strong>
    foreach ($org_type->group_settings['content_types'] as $old_type) {
      <strong>//**** ONLY IF THIS IS NOT SET...</strong>
      if (!isset($content_types[$old_type])) {
        $instance = field_read_instance('node', REDHEN_ORG_GROUP_FIELD, $old_type);
        if ($instance) {
          field_delete_instance($instance, FALSE);
          field_purge_batch(10);
          drupal_set_message(t('Field %label has been deleted from the %type content type.',
            array('%label' => $instance['label'], '%type' => $old_type)));
        }
      }
    }
  }

  // Create new field instances.
  redhen_org_group_create_instance($org_type);
}

Any help would be appreciated. I would suggest:

function redhen_org_group_redhen_org_type_update(RedhenOrgType $org_type) {
  if (isset($org_type->group_settings['content_types'])) {

    // Delete field instances if a content type was removed.
    foreach ($org_type->group_settings['content_types'] as $old_type) {
      if (!isset($org_type->data['group_settings']['content_types'][$old_type])) {
        $instance = field_read_instance('node', REDHEN_ORG_GROUP_FIELD, $old_type);
        if ($instance) {
          field_delete_instance($instance, FALSE);
          field_purge_batch(10);
          drupal_set_message(t('Field %label has been deleted from the %type content type.',
            array('%label' => $instance['label'], '%type' => $old_type)));
        }
      }
    }
  }

  // Create new field instances.
  redhen_org_group_create_instance($org_type);
}

I'll submit a patch but like I said I am unclear if this will cause issues down the line elsewhere. As I haven't dug deep into this module yet. Thanks for your time!

-Jesse

dobe’s picture

Status: Closed (fixed) » Active

Sorry had to reopen.

levelos’s picture

Separate issue Jesse, this one is still closed. If you're still having trouble, please open a separate focused ticket.

levelos’s picture

Issue summary: View changes

Fixing confusing type

  • Commit 91de697 on 7.x-1.x, tests, redhen-donation by levelos:
    #1864320: Property export org group settings.
    

  • Commit 91de697 on 7.x-1.x, tests, redhen-donation, relation-roles by levelos:
    #1864320: Property export org group settings.