You are here

function i18nsync_node_delete_prepare in Internationalization 6

Prepare node for deletion, work out synchronization issues

1 call to i18nsync_node_delete_prepare()
i18nsync_node_delete_submit in i18nsync/i18nsync.module
Submit callback for

File

i18nsync/i18nsync.module, line 126
Internationalization (i18n) package. Synchronization of translations

Code

function i18nsync_node_delete_prepare($nid) {
  $node = node_load($nid);

  // Delete file associations when files are shared with existing translations
  // so they are not removed by upload module
  if (!empty($node->tnid) && module_exists('upload')) {
    $result = db_query('SELECT u.* FROM {upload} u WHERE u.nid = %d AND u.fid IN (SELECT t.fid FROM {upload} t WHERE t.fid = u.fid AND t.nid <> u.nid)', $nid);
    while ($up = db_fetch_object($result)) {
      db_query("DELETE FROM {upload} WHERE fid = %d AND vid = %d", $up->fid, $up->vid);
    }
  }
}