CiviCRM entities as Drupal Entities
I've recently been exploring creating CiviCRM entities as Drupal entities - using the drupal Entity API. I think so far I have only just touched the surface of the possibilities for this integration but I thought I'd post what I think some of them might be
- Rules integration
- Entity Reference fields
- Solr searching (not explored)
- Views bulk operations (not explored)
- Attaching drupal fields to CiviCRM entities (within drupal) (not explored)
Given Pete's love of Organic Groups most of what I have done so far is worked with adding OG integrations for Events and adding roles to users when they get relationships. Some potentials Pete has spotted are
- The rules integration creates the potential to create users in various back-office situations such as manual event registrations, contact imports or potentially a batch profile update or a views bulk integration
- Lots of opportunities to sync all sorts of things with Organic Groups :-) We are using a model when an OG is created for each event and participants added to the event have drupal accounts added (back office too) or loaded & those accounts are added to the event OG.
- We are also giving users a role based on their contact relationships
- Rules basically gives the power of civicrm_post hooks to non coders
Basically the entity module allows you to have an entity reference field for any type of entity. So, instead of just the existing contact reference field you can add an entity reference field to a relationship type or an event.
The entity reference then allows you to create views that incorporate both the entity with the reference and the one referred to without any extra code.
Chaining & tokens
I haven't looked so much at tokens but drupal has an idea of chaining so you can potentially add a token that gets an event participant's current employer & displays that or the event's creators username. At the moment I have made contact_id fields chainable.
Code is here - but we are running it against a patched version of 4.2 (or unpatched 4.3 in a sandbox)
(Our patched version is https://github.com/fuzionnz/civicrm - Branch 4.2-d7)