Attached is a module to provide CiviCRM fields in CCK (http://drupal.org/project/cck). Is loosely based on CiviNode (in that it uses a few functions from civinode_utils.inc. Also, it seems logical to make it part of this project, rather than a separate project.

Right now, this module provides reference fields to CiviCRM...

  • contacts
  • groups
  • profiles
  • relationships
  • activities (non-system activities)
  • locations
  • tags

At this time, the module does not render the data (as rendering most of these things does not make sense out of context -- eg. how do you render a location without a contact record?). It does store the data in a node, however, allowing you to act on it with custom modules, themes, etc.

Future work will include providing lists of fields for each entity type and combining the fields to create more useful default renderings (eg: a widget to select a contact record and a profile, which could be usefully rendered).

As CCK develops, I hope it will add more developer centric features - such as content type serialization and module call backs. These fields will become much more useful when those features are available.

One last note: This tar.gz includes a 'move_to_civinode.inc' file of functions which should probably be integrated back into the larger civinode_utils.inc. This file does not currently do much with the ACL features - those should probably be integrated. This module does respect the default civicrm.module role to group access control.

Comments

Torenware’s picture

Assigned: Unassigned » Torenware
Status: Needs review » Needs work

Mark,

I like what you're doing here, and will probably accept this with some rather minor modifications.

I would like to integrate this with my ACL stuff, so I'd recommend the following change:

/**
 * Get target groups as allowed for the current user
 *
 */
function civinode_get_drupal_allowed_groups() {
	$gids = civinode_get_current_group_memberships();
	$groups = array();
	if (count($gids)) {
		foreach ($gids as $gid) {
			$group = civinode_get_group_by_id($gid);
			$groups[$gid] = $group->title;
		}
	}
  return $groups;
}

civinode_get_current_group_memberships() is new; I'm just exposing data that the ACL system already maintains in an easily useable way.

The rest of your submission looks good. I'll try it out locally, and see how it works. You may also want to look at some of the newer theming stuff I've put in, since I can now render a profile for a contact in an attractive way.

Torenware’s picture

Mark,

I've merged in your recommended stuff for civinode_utils.inc. So just alter your code so that it takes advantage of my picking up your utility routines, and I'll add it to a "contribs" directory under civinode/. You may also want to submit a short README along with it.

Torenware’s picture

Hm.... asleep at the switch today. civinode_get_current_group_memberships() isn't right, since you really need the legal target groups. So I just made the appropriate changes in CVS.

mfredrickson’s picture

Hi Rob-

What do you need me to do? I see my move_to_civinode.inc methods are in civinode. Do you need a new version of the civicrmdata.module?

-M

Torenware’s picture

Mark,

Exactly that. If you change civicrmdata.module to refer to the methods as moved into civinode_utils.inc, I'll happily include your module in the contribs directory under civinode/.

Thanks,
Rob

mfredrickson’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new5.65 KB

So I've updated the include but I'm not sure that civinode_get_drupal_allowed_groups() works. I am unable to test it further until http://drupal.org/node/60188 is resolved.

You should be able to safely include my code - but we need to figure out what is not working in civinode_utils.inc

Torenware’s picture

Status: Reviewed & tested by the community » Fixed

Mark,

This looks fine, and at any rate, needs to get committed so people can try it out and test it.

Thanks much. One thing: if you can put together a small README about the use of your module, sent it to me as well, since I'd like to add that to the repository as well along with your module.

Thanks,
Rob

bomarmonk’s picture

I submitted an issue for this. I'm testing it out. See the bug reports for Civinode. Thanks for any suggestions on how to get this working.

Anonymous’s picture

Status: Fixed » Closed (fixed)