# HG changeset patch # User Tom Wolf # Date 1240461135 18000 # Node ID d52c1baec6fb0fd467ff85d0d0fa997aff587f7a # Parent 3d3d533f9eff7dae17dd5430bbd3cd1b22177490 Implemented Scald CRUD triggers based on field value updates. diff -r 3d3d533f9eff -r d52c1baec6fb mee.module --- a/mee.module Tue Apr 07 11:19:03 2009 -0500 +++ b/mee.module Wed Apr 22 23:32:15 2009 -0500 @@ -64,6 +64,7 @@ '#default_value' => url($field['mee_dnd_callback_url']) ? $field['mee_dnd_callback_url'] : '', '#description' => t('The absolute URL or relative path of a callback URL that provides proper JSON to the drag and drop library.'), ); + // @TODO: Add an "Editor Context" option on a per-field basis return $form; case 'save': @@ -92,30 +93,41 @@ break; // end 'submit' case 'insert': - // @@@TODO: register a new Atom based on this textarea foreach ($items as $delta => $item) { - $temp_atom = new stdClass; - $temp_atom->type = 'composite'; - $temp_atom->provider = 'mee'; - $temp_atom->base_id = $node->nid . ':' . $delta; - $temp_atom->uid = $node->uid; - $temp_atom->title = $node->title; - $temp_atom->authors = array(scald_uid_to_aid($node->uid)); - $scald_included = scald_included($node->body); + $scald_included = scald_included($item); + + $temp_atom = new stdClass; + $temp_atom->type = 'composite'; + $temp_atom->provider = 'mee'; + $temp_atom->base_id = $node->nid . ':' . $delta; + $temp_atom->publisher = $node->uid; + $temp_atom->title = $node->title; + $temp_atom->authors = array(scald_uid_to_aid($node->uid)); $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); + $sid = scald_register_atom($temp_atom); } break; // end 'insert' case 'update': foreach ($items as $delta => $item) { + $scald_included = scald_included($item); + // @@@TODO: Handle failure of fetch + $atom = scald_fetch(scald_search(array('base_id' => $node->nid . ':' . $delta), FALSE, TRUE)); + $atom->publisher = $node->uid; + $atom->title = $node->title; + $atom->authors = array( + $temp_atom->relationships = empty($scald_included) ? array() : array('includes' => $scald_included); + + scald_update_atom($atom); } - // @@@TODO: Update the existing Atom break; // end 'update' case 'delete': - // @@@TODO: Remove the Atom based on this instance of the field + foreach ($items as $delta => $item) { + scald_unregister_atom(scald_search(array('base_id' => $node->nid . ':' . $delta), FALSE, TRUE)); + } break; // end 'delete' case 'sanitize':