You are here

function noderelationships_settings_delete_nodereference in Node Relationships 6

Delete relationship settings when a nodereference field has been deleted.

1 call to noderelationships_settings_delete_nodereference()
noderelationships_content_fieldapi in ./noderelationships.module
Implementation of hook_content_fieldapi().

File

./noderelationships.inc, line 200
Common functions for the noderelationships module.

Code

function noderelationships_settings_delete_nodereference($nodetype, $field_name) {

  // Prepare data to delete relations related to a CCK field instance.
  $args = array(
    $nodetype,
    $field_name,
  );
  $noderef_conditions = "relation_type = 'noderef' AND type_name = '%s' AND field_name = '%s'";
  $backref_conditions = "relation_type = 'backref' AND related_type = '%s' AND field_name = '%s'";

  // Delete node reference extras settings.
  noderelationships_settings_delete($noderef_conditions, $args);

  // Scan all back reference settings affected by this instance.
  $types_to_sync = array();
  foreach (noderelationships_settings_list($backref_conditions, $args) as $row) {
    if (!isset($types_to_sync[$row->type_name])) {
      $types_to_sync[$row->type_name] = $row->type_name;
    }
  }

  // Delete back reference related settings.
  noderelationships_settings_delete($backref_conditions, $args);

  // Synchronize back reference settings with back reference fields.
  noderelationships_cck_backref_sync_fields($types_to_sync);
}