You are here

function message_deleted_entity_cleanup in Message 6

Delete message instances that are related to a a deleted entity.

For example, if a node is deleted then all the message instances that are related to that node will be deleted.

Parameters

$entity_type: The entity type.

$eid: The entity ID.

2 calls to message_deleted_entity_cleanup()
message_nodeapi in ./message.module
Implementation of hook_nodeapi().
message_user in ./message.module
Implementation of hook_user().

File

./message.module, line 753
API functions to manipulate messages.

Code

function message_deleted_entity_cleanup($entity_type, $eid) {

  // Get all the message instanced.
  $result = db_query("SELECT iid FROM {message_instance} WHERE entity_type = '%s' AND eid = %d", $entity_type, $eid);
  $iids = array();
  while ($row = db_fetch_object($result)) {
    $iids[] = $row->iid;
  }

  // Instances were found and need to be deleted.
  if ($iids) {
    message_instance_delete($iids);
    message_realm_delete($entity_type, $eid);
  }
}