function upload_delete_revision in Drupal 6
Same name and namespace in other branches
- 4 modules/upload.module \upload_delete_revision()
- 5 modules/upload/upload.module \upload_delete_revision()
1 call to upload_delete_revision()
- upload_nodeapi in modules/
upload/ upload.module - Implementation of hook_nodeapi().
File
- modules/
upload/ upload.module, line 447 - File-handling and attaching files to nodes.
Code
function upload_delete_revision($node) {
if (is_array($node->files)) {
foreach ($node->files as $file) {
// Check if the file will be used after this revision is deleted
$count = db_result(db_query('SELECT COUNT(fid) FROM {upload} WHERE fid = %d', $file->fid));
// if the file won't be used, delete it
if ($count < 2) {
db_query('DELETE FROM {files} WHERE fid = %d', $file->fid);
file_delete($file->filepath);
}
}
}
// delete the revision
db_query('DELETE FROM {upload} WHERE vid = %d', $node->vid);
}