A mapper is needed for organic group reference so that nodes may be imported into a specific group (or multiple groups). My specific use case is importing content into Open Atrium. Open Atrium behaves slightly differently than normal OG because it uses Spaces OG which requires that a separate field have a value set. I've attached my first attempt at a mapper which offers both Spaces OG and regular OG mapping. Currently, it only maps based on a the OG Title (exact match).

I've confirmed this works with Open Atrium but I do not have a regular OG installation, so I haven't tested the straight OG functionality.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex_b’s picture

Title: organic groups mapper » Mapper for Organic Groups
Status: Active » Needs work

Could you please roll a patch. Check out http://drupal.org/patch and Google cvsdo. Thank you!

pdrake’s picture

FileSize
2.56 KB

Is this what you are looking for?

pdrake’s picture

FileSize
5.37 KB

Here's another version which adds user inheritance. Users can inherit groups from the feed node (if the feed is attached to a node). Use this in conjunction with the patches posted in http://drupal.org/node/632920#comment-3281476

pdrake’s picture

FileSize
5.37 KB

Ok, so the previous patch included some extra code I added to support multiple values via a newline character. It would probably be best to ignore that version and use this one.

DanielJohnston’s picture

Hi pdrake,
This issue now encompasses #855126: Mapper for a user's OG's I'm guessing. Will check it out and give feedback here and directly in the next day or so. Would be faster but it's my birthday!

DanielJohnston’s picture

OK, feedback on attempting this set of patches:

base-uk:~/drupal-6.17/sites/all/modules/feeds$ patch -p0 < feeds.api_.php_.patch
patching file feeds.api.php
patch: **** unexpected end of file in patch

base-uk:~/drupal-6.17/sites/all/modules/feeds$ patch -p0 < FeedsUserProcessor.inc_.patch
patching file plugins/FeedsUserProcessor.inc
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n] y
Hunk #1 FAILED at 2.
1 out of 6 hunks FAILED -- saving rejects to file plugins/FeedsUserProcessor.inc.rej

base-uk:~/drupal-6.17/sites/all/modules/feeds$ patch -p0 < og.inc__1.patch
patching file mappers/og.inc

Contents of the reject file:

***************
*** 2
- // $Id: FeedsUserProcessor.inc,v 1.18 2010/07/27 20:27:41 alexb Exp $
--- 2 -----
+ // $Id: FeedsUserProcessor.inc,v 1.17 2010/07/18 19:47:37 alexb Exp $

Current setup:
Feeds beta 4 patched from http://drupal.org/node/632920#comment-3261608 with manual replacement of 'mygroupnode' to 'member_organisation' to enable organic groups inheritance
Drupal 6.17

Result of trying to use Feeds following patches:
The entire Feeds module is broken.
Navigating to /admin/build/feeds returns Parse error: syntax error, unexpected ';', expecting ')' in /var/aegir/drupal-6.17/sites/all/modules/feeds/plugins/FeedsUserProcessor.inc on line 163
Attempting to create a Feed node at /admin/node/add/user-import results in http://welfaretowork.co.uk/admin/node/add/user-import

Hope this helps!

DanielJohnston’s picture

To clarify, the problems I posted above were with patches posted on #632920: Inherit properties from parent feed node (taxonomy, author, OG, language). Those patches have been rerolled and work just fine, so the current patch in this issue works fine for me.

boogsbobo’s picture

subscribing

klonos’s picture

subscribing...

wgrunberg’s picture

subscribe

alex_b’s picture

A very basic mapper for OG is now part of #632920-205: Inherit properties from parent feed node (taxonomy, author, OG, language) - the reason that an OG mapper got included in #632920 is that feed node -> feed item property inheritance is now using the mapping API.

alex_b’s picture

Status: Needs work » Closed (duplicate)

Much or all of this patch's functionality has been committed with #632920: Inherit properties from parent feed node (taxonomy, author, OG, language). #632920 contains the OG configuration of a feed node as mapping source *and* the OG configuration of a feed item as mapping target.

I'll set this issue here to duplicate, feel free to reopen if I am missing something.

xatoo_’s picture

Status: Closed (duplicate) » Active

AFAIK there is currently no way to import data into the OG description or to set other OG settings like private/public group, directory listing and membership request method.

Also for the user processor there is no way to provide groups to which the user should be subscribed. Something, which as it looks, is provided by the above patch. I therefore reopen this issue hoping to draw some attention to it.

alex_b’s picture

Status: Active » Postponed

Postponing as I'm not planning to work on this. Please change status when posting a patch.

pdrake’s picture

Status: Postponed » Needs work
FileSize
9.49 KB
3.43 KB

Given the inclusion of a basic OG mapper through the inheritance work (#632920), I have split this into two patches. One applies only to Spaces OG Audience, a vital field for anyone importing nodes into Spaces OG based sites such as OpenAtrium. The second includes improvements to the current OG mapper to allow mapping by NID, Title, Feed URL and Feed GUID as well as to allow User mapping to OGs.

stevestaso’s picture

I installed the patch in #16 and see the mapping choices for my CSV importer.
All other info is mapping correctly.
But I can't seem to get it to add the nodes to a group.
I've tried by NID (my group NID is 16, so I added a column in the CSV file and put 16 in all the rows.)
I've tried by Title (my Title is Area 057, so I added a column in the CSV file and put Area 057, area-057. Neither works.)

The target node type is a valid Group post, but the nodes are created without any Group audience selected, they become Public.

Am I missing something? what type of syntax in the CSV file is it looking for?
BTW, I don't think the basic OG importer that comes with feeds didn't work either, so I doubt your patch is a culprit.
Just looking for help with how to pick up the Group from the CSV file.

thanks.

stevestaso’s picture

FileSize
72.02 KB

Is this what I should see? See screenshot.
Should I have a selection choice for the Source or the text input like shown here?
Should I have a checkbox for the Unique target?

Standalone or attached to a node, With our without the patch, I can't add the nodes into groups.

Quentin’s picture

I can confirm stevestaso's findings (subscribe).

stevestaso’s picture

Addition to comments in #18, seems like taxonomy from the parent node is also NOT handed down to the feed item nodes.

RJL-dupe’s picture

subscribe

servantleader’s picture

Status: Needs work » Needs review
FileSize
9.49 KB

Typo in the name of a variable on line 123.
function og_feeds_set_target($node, $target, $values) {
should be
function og_feeds_set_target($node, $target, $value) {
Here is a new patch. I have only tested it with title based import, but it is working great for that.

pdrake’s picture

servantleader, thanks for finding that and posting it. I must have somehow included a patch based on an older version. With that fix, it is importing properly based on the title? If you're still having any trouble, please post here and I'll take another look at it.

R.J. Steinert’s picture

Subscribe

paying my dues -> http://1BeerToKillSubscribeComments.com

notasheep’s picture

subscribe

pdcarto’s picture

I'm trying to get mailhandler to work in Open Atrium, using the two feed mapper patches og.inc and spaces_og.inc (#16 & #22). The mail is coming in fine, but not getting mapped to the organic group (Message: "'' does not match a valid node title for Spaces OG Audience.").

The mapper is configured as follows...

Source                         Target
subject                        Title
Authenticated UID	             User ID
status	                       Published status
Body	                         Body
Feed node: Organic group(s)    Spaces OG Audience (by title)

I added the following debug statement in og.inc...

/**
 * Callback, returns OG of feed node.
 */
function og_feeds_get_source(FeedsImportBatch $batch, $key) {
  dpm(array('batch'=>$batch,'key'=>$key));
 switch($key) {
   case 'parent:og_groups':
      if ($node = node_load($batch->feed_nid)) {
        if (in_array($node->type, og_get_types('group'))) {
          return array(
            $node->nid => $node->nid,
          );
        }
        else {
          return isset($node->og_groups) ? $node->og_groups : NULL;
        }
      }      
      break;
...

And see that $batch is empty...

#
... (Array, 2 elements)

    *
      batch (Object) MailhandlerImportBatch
          o
            title (String, 0 characters )
          o
            description (String, 0 characters )
          o
            link (String, 0 characters )
          o
            items (Array, 0 elements)
          o
            feed_nid (Integer) 0
          o
            created (Integer) 0
          o
            updated (Integer) 0
    *
      key (String, 16 characters ) parent:og_groups

      #

I'm at a loss. Any suggestions?

jvieille’s picture

When importing items in the context of a group, they are correctly set in the group audience, but they are public. any way to control this, or is this a forgotten feature?

R.J. Steinert’s picture

@jvieille The public checkbox is a separate field and would best go in another plugin, especially because this plugin is for Group Posts, not Group nodes. I would create a new feature request ticket.

jvieille’s picture

I don't understand: the public checkbox is on group posts, not group nodes (yes, we can set groups as public, but it is something else)

SocialNicheGuru’s picture

I am using spaces_og which uses purl. can the purl settings be mapped using the patch in #16?

alibama’s picture

just imported ~40,000 users and they seem to be in groups now... except they're unapproved and there are several hundred groups = Views bulk operations only gives me the action to approve users of one specific group at a time = what's a good way to set the approval field?

checked the database, og_uid.is_active is set to 1 on all of the imports.. uncertain what is going on

pdrake’s picture

@SocialNicheGuru - no, there isn't a purl mapper in the patch, just og and spaces_og

@alibama - I believe is_active=1 should be all you need. I wrote an action to approve users and used views bulk operations to bulk approve imported users.

alibama’s picture

@pdrake - thank you = I'm definitely running into something silly here - i'm going to test with http://drupal.org/project/feeds_ridmap since i see that all the og_uid.og_role values are set to 0... where is this action that you are talking about and does it work against all of the groups in a go? There's a fair chance that my problem stems from an unfamiliarity with OG in general.. so I apologize if this is off topic - my goal is just to have all the users imported and show up on the OG group nodes - I do have "hide membership" turned on, but I assumed that user/1 would be able to see everyone

thanks
ap

TommyK’s picture

Using patch in #22. Attempting to add users to groups via feeds and an XML source.

Is the intended functionality to only add users to groups upon new user creation?

I have existing users being updated by feeds and none of them are getting added to groups upon import. There are no entries created in the og_uid table.

pdrake’s picture

Is your feed configured to update existing nodes? If so, it may be a bug in the implementation of this mapper.

TommyK’s picture

@ #35

I'm actually using the User processor in Feeds for this particular one with the "Replace existing users" option checked.

twistor’s picture

Status: Needs review » Closed (duplicate)

This needs to go into OG, and first into 7.x

#1298238: Groups Audience field not available for Feeds Mapping.

achton’s picture

Status: Closed (duplicate) » Needs work

@twistor: That implementation seems to be aimed at using entities and/or the Entity reference module. The 6.x backport would be very different from what will eventually come out of that.

Why not continue work on the approach in #22? It seems like what's left is ironing out the last few bugs, and you will end up with a solid OG groups import mapper for Feeds 6.x ...

achton’s picture

Here's a straight reroll of the patches in #16 and #22 against current 1.x-dev.

alibama’s picture

#22 still works for me, the others not so much - am testing against the latest dev

ok - actually none of these work - anyone working against the latest dev? Thanks

Rustan’s picture

For anyone looking for how to get group membership import to work for D7, try latest dev of feeds, entityreference and possibly feeds_tamper if you need multiple groups.

twistor’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)