| 1 |
<?php |
<?php |
| 2 |
// $Id: flashvideo.module,v 1.73.2.105 2009/07/22 03:20:39 travist Exp $ |
// $Id: flashvideo.module,v 1.73.2.111 2009/07/29 01:17:58 attheshow Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Enables the ability to attach a Flash video to a node. |
* Enables the ability to attach a Flash video to a node. |
| 736 |
|
|
| 737 |
// Create the appropriate database entry for the newly converted video file. |
// Create the appropriate database entry for the newly converted video file. |
| 738 |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { // Using FileField |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { // Using FileField |
| 739 |
// Names of the different video fields? Let's find out. |
// Names of the different video fields? Ask CCK for the details. |
| 740 |
$cck_original_video_field = flashvideo_variable_get($node_type, 'cck_original_video_field', ''); |
$cck_original_video_field = content_fields(flashvideo_variable_get($node_type, 'cck_original_video_field', ''), $node_type); |
| 741 |
$cck_finished_video_field = flashvideo_variable_get($node_type, 'cck_finished_video_field', ''); |
$cck_finished_video_field = content_fields(flashvideo_variable_get($node_type, 'cck_finished_video_field', ''), $node_type); |
| 742 |
$cck_finished_thumbnail_field = flashvideo_variable_get($node_type, 'cck_finished_thumbnail_field', ''); |
$cck_finished_thumbnail_field = content_fields(flashvideo_variable_get($node_type, 'cck_finished_thumbnail_field', ''), $node_type); |
| 743 |
$cck_table = 'content_type_'. $node_type; |
// Ask CCK for db info about the fields (table names and column info) |
| 744 |
|
$cck_original_video_field_db_info = content_database_info($cck_original_video_field); |
| 745 |
|
$cck_finished_video_field_db_info = content_database_info($cck_finished_video_field); |
| 746 |
|
$cck_finished_thumbnail_field_db_info = content_database_info($cck_finished_thumbnail_field); |
| 747 |
|
|
| 748 |
if ($create_thumbnail) { // This is for the finished thumbnail. |
if ($create_thumbnail) { // This is for the finished thumbnail. |
| 749 |
// For single-upload file fields |
// For single-upload file fields |
| 750 |
if (db_column_exists($cck_table, $cck_original_video_field .'_fid')) { |
if ($cck_finished_thumbnail_field['db_storage'] == 1) { |
| 751 |
db_query("UPDATE {". $cck_table ."} SET ". $cck_finished_thumbnail_field ."_fid = %d, ". $cck_finished_thumbnail_field ."_list = 0 WHERE nid = %d", $newfile->fid, $newfile->nid); |
// db_storage = 0 means 'stored in its own table'. Single upload fields = 1. Shared fields and Multi-values = 0. |
| 752 |
|
db_query("UPDATE {". $cck_finished_thumbnail_field_db_info['table'] ."} SET ". $cck_finished_thumbnail_field_db_info['columns']['fid']['column'] ." = %d, ". $cck_finished_thumbnail_field_db_info['columns']['list']['column'] ." = 0 WHERE nid = %d", $newfile->fid, $newfile->nid); |
| 753 |
} |
} |
| 754 |
else { // For multi-upload file fields |
else { // For multi-upload file fields |
| 755 |
// Get rid of the initial NULL entry. |
// Get rid of the initial NULL entry. |
| 756 |
db_query("DELETE FROM {content_". $cck_finished_thumbnail_field ."} WHERE nid = %d AND ". $cck_finished_thumbnail_field ."_fid IS NULL", $newfile->nid); |
db_query("DELETE FROM {". $cck_finished_thumbnail_field_db_info['table'] ."} WHERE nid = %d AND ". $cck_finished_thumbnail_field_db_info['columns']['fid']['column'] ." IS NULL", $newfile->nid); |
| 757 |
db_query("INSERT INTO {content_". $cck_finished_thumbnail_field ."} (vid, nid, delta, ". $cck_finished_thumbnail_field ."_fid, ". $cck_finished_thumbnail_field ."_list) VALUES (%d, %d, %d, %d, 0)", $newfile->vid, $newfile->nid, $params->video_index, $newfile->fid); |
db_query("INSERT INTO {". $cck_finished_thumbnail_field_db_info['table'] ."} (vid, nid, delta, ". $cck_finished_thumbnail_field_db_info['columns']['fid']['column'] .", ". $cck_finished_thumbnail_field_db_info['columns']['list']['column'] .") VALUES (%d, %d, %d, %d, 0)", $newfile->vid, $newfile->nid, $params->video_index, $newfile->fid); |
| 758 |
} |
} |
| 759 |
} |
} |
| 760 |
else { // This is for the finished video. |
else { // This is for the finished video. |
| 761 |
// For single-upload file fields |
// For single-upload file fields |
| 762 |
if (db_column_exists($cck_table, $cck_original_video_field .'_fid')) { |
if ($cck_finished_video_field['db_storage'] == 1) { |
| 763 |
db_query("UPDATE {". $cck_table ."} SET ". $cck_finished_video_field ."_fid = %d, ". $cck_finished_video_field ."_list = 0 WHERE nid = %d", $newfile->fid, $newfile->nid); |
// db_storage = 0 means 'stored in its own table'. Single upload fields = 1. Shared fields and Multi-values = 0. |
| 764 |
|
db_query("UPDATE {". $cck_finished_video_field_db_info['table'] ."} SET ". $cck_finished_video_field_db_info['columns']['fid']['column'] ." = %d, ". $cck_finished_video_field_db_info['columns']['list']['column'] ." = 0 WHERE nid = %d", $newfile->fid, $newfile->nid); |
| 765 |
} |
} |
| 766 |
else { // For multi-upload file fields |
else { // For multi-upload file fields |
| 767 |
// Get rid of the initial NULL entry. |
// Get rid of the initial NULL entry. |
| 768 |
db_query("DELETE FROM {content_". $cck_finished_video_field ."} WHERE nid = %d AND ". $cck_finished_video_field ."_fid IS NULL", $newfile->nid); |
db_query("DELETE FROM {". $cck_finished_video_field_db_info['table'] ."} WHERE nid = %d AND ". $cck_finished_video_field_db_info['columns']['fid']['column'] ." IS NULL", $newfile->nid); |
| 769 |
db_query("INSERT INTO {content_". $cck_finished_video_field ."} (vid, nid, delta, ". $cck_finished_video_field ."_fid, ". $cck_finished_video_field ."_list) VALUES (%d, %d, %d, %d, 0)", $newfile->vid, $newfile->nid, $params->video_index, $newfile->fid); |
db_query("INSERT INTO {". $cck_finished_video_field_db_info['table'] ."} (vid, nid, delta, ". $cck_finished_video_field_db_info['columns']['fid']['column'] .", ". $cck_finished_video_field_db_info['columns']['list']['column'] .") VALUES (%d, %d, %d, %d, 0)", $newfile->vid, $newfile->nid, $params->video_index, $newfile->fid); |
| 770 |
} |
} |
| 771 |
} |
} |
| 772 |
cache_clear_all('content:'. $newfile->nid .':'. $newfile->vid, 'cache_content'); // Clear the CCK cache for this node. |
cache_clear_all('content:'. $newfile->nid .':'. $newfile->vid, 'cache_content'); // Clear the CCK cache for this node. |
| 792 |
|
|
| 793 |
// Delete the original file from the appropriate table. |
// Delete the original file from the appropriate table. |
| 794 |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { // Using FileField |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { // Using FileField |
| 795 |
|
// Names of the different video fields? Ask CCK for the details. |
| 796 |
|
$cck_original_video_field = content_fields(flashvideo_variable_get($node_type, 'cck_original_video_field', ''), $node_type); |
| 797 |
|
// Ask CCK for db info about the fields (table names and column info) |
| 798 |
|
$cck_original_video_field_db_info = content_database_info($cck_original_video_field); |
| 799 |
// For single-upload file fields |
// For single-upload file fields |
| 800 |
if (db_column_exists($cck_table, $cck_original_video_field .'_fid')) { |
if ($cck_original_video_field['db_storage'] == 1) { |
| 801 |
db_query("UPDATE {". $cck_table ."} SET ". $cck_original_video_field ."_fid = NULL, ". $cck_original_video_field ."_list = NULL WHERE nid = %d", $oldfile->nid); |
db_query("UPDATE {". $cck_original_video_field_db_info['table'] ."} SET ". $cck_original_video_field_db_info['columns']['fid']['column'] ." = NULL, ". $cck_original_video_field_db_info['columns']['list']['column'] ." = NULL WHERE nid = %d", $oldfile->nid); |
| 802 |
} |
} |
| 803 |
else { // For multi-upload file fields |
else { // For multi-upload file fields |
| 804 |
db_query("DELETE FROM {content_". $cck_original_video_field ."} WHERE nid = %d", $node->nid); |
db_query("DELETE FROM {". $cck_original_video_field_db_info['table'] ."} WHERE nid = %d", $node->nid); |
| 805 |
} |
} |
| 806 |
} |
} |
| 807 |
else { // They're using the core Upload module. |
else { // They're using the core Upload module. |
| 1026 |
$output_path = getcwd() .'/'. $newfile->filepath; |
$output_path = getcwd() .'/'. $newfile->filepath; |
| 1027 |
|
|
| 1028 |
// We should only continue if there is an input file. |
// We should only continue if there is an input file. |
| 1029 |
if ((file_exists($filepath) && filesize($filepath) > 0)) { |
if ((file_exists($filepath) && filesize($filepath) > 0)) { |
| 1030 |
|
|
| 1031 |
$command = ''; // For scope reasons. |
$command = ''; // For scope reasons. |
| 1032 |
$ffmpeg_data = ''; // For scope reasons. |
$ffmpeg_data = ''; // For scope reasons. |
| 1422 |
|
|
| 1423 |
// Insert the new file into the appropriate tables. |
// Insert the new file into the appropriate tables. |
| 1424 |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { // Using FileField |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { // Using FileField |
| 1425 |
// Names of the different video fields? Let's find out. |
// Names of the different video fields? Ask CCK for the details. |
| 1426 |
$cck_original_video_field = flashvideo_variable_get($node_type, 'cck_original_video_field', ''); |
$cck_original_video_field = content_fields(flashvideo_variable_get($node_type, 'cck_original_video_field', ''), $node_type); |
| 1427 |
$cck_table = 'content_type_'. $node_type; |
// Ask CCK for db info about the fields (table names and column info) |
| 1428 |
|
$cck_original_video_field_db_info = content_database_info($cck_original_video_field); |
| 1429 |
|
|
| 1430 |
// For single-upload file fields |
// For single-upload file fields |
| 1431 |
if (db_column_exists($cck_table, $cck_original_video_field .'_fid')) { |
if ($cck_original_video_field['db_storage'] == 1) { |
| 1432 |
db_query("UPDATE {". $cck_table ."} SET ". $cck_original_video_field ."_fid = %d, ". $cck_original_video_field ."_list = 0 WHERE nid = %d", $tempfile->fid, $node->nid); |
db_query("UPDATE {". $cck_original_video_field_db_info['table'] ."} SET ". $cck_original_video_field_db_info['columns']['fid']['column'] ." = %d, ". $cck_original_video_field_db_info['columns']['list']['column'] ." = 0 WHERE nid = %d", $tempfile->fid, $node->nid); |
| 1433 |
} |
} |
| 1434 |
else { // For multi-upload file fields |
else { // For multi-upload file fields |
|
db_query("INSERT INTO {content_". $cck_original_video_field ."} (vid, nid, delta, ". $cck_original_video_field ."_fid, ". $cck_original_video_field ."_list) VALUES (%d, %d, %d, %d, 0)", $node->nid, $node->nid, 0, $tempfile->fid); |
|
| 1435 |
// Get rid of the initial NULL entry. |
// Get rid of the initial NULL entry. |
| 1436 |
db_query("DELETE FROM {content_". $cck_original_video_field ."} WHERE nid = %d AND ". $cck_original_video_field ."_fid IS NULL", $node->nid); |
db_query("DELETE FROM {". $cck_original_video_field_db_info['table'] ."} WHERE nid = %d AND ". $cck_original_video_field_db_info['columns']['fid']['column'] ." IS NULL", $node->nid); |
| 1437 |
|
db_query("INSERT INTO {". $cck_original_video_field_db_info['table'] ."} (vid, nid, delta, ". $cck_original_video_field_db_info['columns']['fid']['column'] .", ". $cck_original_video_field_db_info['columns']['list']['column'] .") VALUES (%d, %d, %d, %d, 0)", $node->nid, $node->nid, 0, $tempfile->fid); |
| 1438 |
} |
} |
| 1439 |
} |
} |
| 1440 |
else { // They're using the core Upload module. |
else { // They're using the core Upload module. |
| 1520 |
$video_index = 0; |
$video_index = 0; |
| 1521 |
|
|
| 1522 |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { |
| 1523 |
// Names of the different video fields? Let's find out. |
// Names of the different video fields? Ask CCK for the details. |
| 1524 |
$cck_original_video_field = flashvideo_variable_get($node->type, 'cck_original_video_field', ''); |
$cck_original_video_field = content_fields(flashvideo_variable_get($node->type, 'cck_original_video_field', ''), $node->type); |
| 1525 |
$cck_finished_video_field = flashvideo_variable_get($node->type, 'cck_finished_video_field', ''); |
$cck_finished_video_field = content_fields(flashvideo_variable_get($node->type, 'cck_finished_video_field', ''), $node->type); |
| 1526 |
$cck_finished_thumbnail_field = flashvideo_variable_get($node->type, 'cck_finished_thumbnail_field', ''); |
$cck_finished_thumbnail_field = content_fields(flashvideo_variable_get($node->type, 'cck_finished_thumbnail_field', ''), $node->type); |
| 1527 |
|
// Ask CCK for db info about the fields (table names and column info) |
| 1528 |
|
$cck_original_video_field_db_info = content_database_info($cck_original_video_field); |
| 1529 |
|
$cck_finished_video_field_db_info = content_database_info($cck_finished_video_field); |
| 1530 |
|
$cck_finished_thumbnail_field_db_info = content_database_info($cck_finished_thumbnail_field); |
| 1531 |
// If they removed at least one file from the node... |
// If they removed at least one file from the node... |
| 1532 |
if (count($node->$cck_original_video_field) < count($node->$cck_finished_video_field)) { |
if (count($node->$cck_original_video_field['field_name']) < count($node->$cck_finished_video_field['field_name'])) { |
| 1533 |
// Figure out which file(s) was removed. |
// Figure out which file(s) was removed. |
| 1534 |
$removed_files = db_query("SELECT * FROM {flashvideo} WHERE fid NOT IN (SELECT fid FROM {files}) AND nid = %d", $node->nid); |
$removed_files = db_query("SELECT * FROM {flashvideo} WHERE fid NOT IN (SELECT fid FROM {files}) AND nid = %d", $node->nid); |
| 1535 |
while ($removed_file = db_fetch_object($removed_files)) { |
while ($removed_file = db_fetch_object($removed_files)) { |
| 1542 |
while ($oldfile = db_fetch_object($files)) { |
while ($oldfile = db_fetch_object($files)) { |
| 1543 |
// Delete that file from the files and CCK content type tables as well as from the file system. |
// Delete that file from the files and CCK content type tables as well as from the file system. |
| 1544 |
db_query("DELETE FROM {files} WHERE fid = %d", $oldfile->fid); |
db_query("DELETE FROM {files} WHERE fid = %d", $oldfile->fid); |
|
$cck_table = 'content_type_'. $node->type; |
|
| 1545 |
// For single-upload file fields |
// For single-upload file fields |
| 1546 |
if (db_column_exists($cck_table, $cck_original_video_field .'_fid')) { |
if ($cck_original_video_field['db_storage'] == 1) { |
| 1547 |
db_query("UPDATE {". $cck_table ."} SET ". $cck_original_video_field ."_fid = NULL, ". $cck_original_video_field ."_list = NULL, ". $cck_finished_video_field ."_fid = NULL, ". $cck_finished_video_field ."_list = NULL, ". $cck_finished_thumbnail_field ."_fid = NULL, ". $cck_finished_thumbnail_field ."_list = NULL WHERE nid = %d", $node->nid); |
db_query("UPDATE {". $cck_original_video_field_db_info['table'] ."} SET ". $cck_original_video_field_db_info['columns']['fid']['column'] ." = NULL, ". $cck_original_video_field_db_info['columns']['list']['column'] ." = NULL, ". $cck_finished_video_field_db_info['columns']['fid']['column'] ." = NULL, ". $cck_finished_video_field_db_info['columns']['list']['column'] ." = NULL, ". $cck_finished_thumbnail_field_db_info['columns']['fid']['column'] ." = NULL, ". $cck_finished_thumbnail_field_db_info['columns']['list']['column'] ." = NULL WHERE nid = %d", $node->nid); |
| 1548 |
} |
} |
| 1549 |
else { // For multi-upload file fields |
else { // For multi-upload file fields |
| 1550 |
db_query("DELETE FROM {content_". $cck_original_video_field ."} WHERE ". $cck_original_video_field ."_fid = %d", $oldfile->fid); |
db_query("DELETE FROM {". $cck_original_video_field_db_info['table'] ."} WHERE ". $cck_original_video_field_db_info['columns']['fid']['column'] ." = %d", $oldfile->fid); |
| 1551 |
db_query("DELETE FROM {content_". $cck_finished_video_field ."} WHERE ". $cck_finished_video_field ."_fid = %d", $oldfile->fid); |
db_query("DELETE FROM {". $cck_finished_video_field_db_info['table'] ."} WHERE ". $cck_finished_video_field_db_info['columns']['fid']['column'] ." = %d", $oldfile->fid); |
| 1552 |
db_query("DELETE FROM {content_". $cck_finished_thumbnail_field ."} WHERE ". $cck_finished_thumbnail_field ."_fid = %d", $oldfile->fid); |
db_query("DELETE FROM {". $cck_finished_thumbnail_field_db_info['table'] ."} WHERE ". $cck_finished_thumbnail_field_db_info['columns']['fid']['column'] ." = %d", $oldfile->fid); |
| 1553 |
} |
} |
| 1554 |
file_delete($oldfile->filepath); |
file_delete($oldfile->filepath); |
| 1555 |
module_invoke_all('flashvideo_delete_file', $oldfile, $node->type); |
module_invoke_all('flashvideo_delete_file', $oldfile, $node->type); |
| 1565 |
cache_clear_all('content:'. $newfile->nid .':'. $newfile->vid, 'cache_content'); // Clear the CCK cache for this node. |
cache_clear_all('content:'. $newfile->nid .':'. $newfile->vid, 'cache_content'); // Clear the CCK cache for this node. |
| 1566 |
} |
} |
| 1567 |
// Make sure that they uploaded some files to the "original" field. |
// Make sure that they uploaded some files to the "original" field. |
| 1568 |
elseif (!empty($node->$cck_original_video_field)) { |
elseif (!empty($node->$cck_original_video_field['field_name'])) { |
| 1569 |
// Initialize new index of the video. |
// Initialize new index of the video. |
| 1570 |
$result = db_query("SELECT DISTINCT video_index FROM {flashvideo} WHERE nid = %d ORDER BY video_index ASC", $node->nid); |
$result = db_query("SELECT DISTINCT video_index FROM {flashvideo} WHERE nid = %d ORDER BY video_index ASC", $node->nid); |
| 1571 |
while ($row = db_fetch_object($result)) { |
while ($row = db_fetch_object($result)) { |
| 1572 |
$video_index = $row->video_index + 1; |
$video_index = $row->video_index + 1; |
| 1573 |
} |
} |
| 1574 |
// Iterate through all of the files. |
// Iterate through all of the files. |
| 1575 |
foreach ($node->$cck_original_video_field as $file) { |
foreach ($node->$cck_original_video_field['field_name'] as $file) { |
| 1576 |
// Convert the file to a file object. |
// Convert the file to a file object. |
| 1577 |
$file = (object)$file; |
$file = (object)$file; |
| 1578 |
// Only continue if it is a video |
// Only continue if it is a video |
| 1584 |
// Get the size of the video. Width and Height. |
// Get the size of the video. Width and Height. |
| 1585 |
$size = flashvideo_get_size($node, $file); |
$size = flashvideo_get_size($node, $file); |
| 1586 |
// See if we need to adjust the index to account for previously-uploaded videos. |
// See if we need to adjust the index to account for previously-uploaded videos. |
| 1587 |
$video_index = (!empty($node->cck_finished_video_field) && is_array($node->cck_finished_video_field)) ? count($node->cck_finished_video_field) : $video_index; |
$video_index = (!empty($node->$cck_finished_video_field['field_name']) && is_array($node->$cck_finished_video_field['field_name'])) ? count($node->$cck_finished_video_field['field_name']) - 1 : $video_index; |
| 1588 |
// Now insert our flashvideo into our table. |
// Now insert our flashvideo into our table. |
| 1589 |
db_query("INSERT INTO {flashvideo} (fid, nid, oid, status, video_index, width, height, flags) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", $file->fid, $node->nid, $file->fid, FLASHVIDEO_STATUS_OK, $video_index, $size['width'], $size['height'], 0); |
db_query("INSERT INTO {flashvideo} (fid, nid, oid, status, video_index, width, height, flags) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", $file->fid, $node->nid, $file->fid, FLASHVIDEO_STATUS_OK, $video_index, $size['width'], $size['height'], 0); |
| 1590 |
// If we don't want to wait for cron, call it immediately. |
// If we don't want to wait for cron, call it immediately. |
| 2477 |
db_query("DELETE FROM {flashvideo} WHERE nid = %d", $node->nid); |
db_query("DELETE FROM {flashvideo} WHERE nid = %d", $node->nid); |
| 2478 |
|
|
| 2479 |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { |
if (module_exists('filefield') && flashvideo_variable_get(NULL, 'flashvideo_filefield', 0)) { |
| 2480 |
// Names of the different video fields? Let's find out. |
// Names of the different video fields? Ask CCK for the details. |
| 2481 |
$cck_original_video_field = flashvideo_variable_get($node->type, 'cck_original_video_field', ''); |
$cck_original_video_field = content_fields(flashvideo_variable_get($node->type, 'cck_original_video_field', ''), $node->type); |
| 2482 |
$cck_finished_video_field = flashvideo_variable_get($node->type, 'cck_finished_video_field', ''); |
$cck_finished_video_field = content_fields(flashvideo_variable_get($node->type, 'cck_finished_video_field', ''), $node->type); |
| 2483 |
$cck_finished_thumbnail_field = flashvideo_variable_get($node->type, 'cck_finished_thumbnail_field', ''); |
$cck_finished_thumbnail_field = content_fields(flashvideo_variable_get($node->type, 'cck_finished_thumbnail_field', ''), $node->type); |
| 2484 |
$cck_table = 'content_type_'. $node->type; |
// Ask CCK for db info about the fields (table names and column info) |
| 2485 |
|
$cck_original_video_field_db_info = content_database_info($cck_original_video_field); |
| 2486 |
|
$cck_finished_video_field_db_info = content_database_info($cck_finished_video_field); |
| 2487 |
|
$cck_finished_thumbnail_field_db_info = content_database_info($cck_finished_thumbnail_field); |
| 2488 |
|
|
| 2489 |
// Grab all of the files associated with the node. |
// Grab all of the files associated with the node. |
| 2490 |
$video_files = array(); |
$video_files = array(); |
| 2491 |
foreach ($node->$cck_original_video_field as $file) { |
if (is_array($node->$cck_original_video_field)) { |
| 2492 |
$video_files[] = $file; |
foreach ($node->$cck_original_video_field as $file) { |
| 2493 |
|
$video_files[] = $file; |
| 2494 |
|
} |
| 2495 |
} |
} |
| 2496 |
foreach ($node->$cck_finished_video_field as $file) { |
if (is_array($node->$cck_finished_video_field)) { |
| 2497 |
$video_files[] = $file; |
foreach ($node->$cck_finished_video_field as $file) { |
| 2498 |
|
$video_files[] = $file; |
| 2499 |
|
} |
| 2500 |
} |
} |
| 2501 |
foreach ($node->$cck_finished_thumbnail_field as $file) { |
if (is_array($node->$cck_finished_thumbnail_field)) { |
| 2502 |
$video_files[] = $file; |
foreach ($node->$cck_finished_thumbnail_field as $file) { |
| 2503 |
|
$video_files[] = $file; |
| 2504 |
|
} |
| 2505 |
} |
} |
| 2506 |
// If this node had files... |
// If this node had files... |
| 2507 |
if (count($video_files)) { |
if (count($video_files)) { |
| 2514 |
// Delete that file from the files and CCK tables as well as from the file system. |
// Delete that file from the files and CCK tables as well as from the file system. |
| 2515 |
db_query("DELETE FROM {files} WHERE fid = %d", $file->fid); |
db_query("DELETE FROM {files} WHERE fid = %d", $file->fid); |
| 2516 |
// For single-upload file fields |
// For single-upload file fields |
| 2517 |
if (db_column_exists($cck_table, $cck_original_video_field .'_fid')) { |
if ($cck_original_video_field['db_storage'] == 1) { |
| 2518 |
db_query("UPDATE {". $cck_table ."} SET ". $cck_original_video_field ."_fid = NULL, ". $cck_original_video_field ."_list = NULL, ". $cck_finished_video_field ."_fid = NULL, ". $cck_finished_video_field ."_list = NULL, ". $cck_finished_thumbnail_field ."_fid = NULL, ". $cck_finished_thumbnail_field ."_list = NULL WHERE nid = %d", $node->nid); |
db_query("UPDATE {". $cck_original_video_field_db_info['table'] ."} SET ". $cck_original_video_field_db_info['columns']['fid']['column'] ." = NULL, ". $cck_original_video_field_db_info['columns']['list']['column'] ." = NULL, ". $cck_finished_video_field_db_info['columns']['fid']['column'] ." = NULL, ". $cck_finished_video_field_db_info['columns']['list']['column'] ." = NULL, ". $cck_finished_thumbnail_field_db_info['columns']['fid']['column'] ." = NULL, ". $cck_finished_thumbnail_field_db_info['columns']['list']['column'] ." = NULL WHERE nid = %d", $node->nid); |
| 2519 |
} |
} |
| 2520 |
else { // For multi-upload file fields |
else { // For multi-upload file fields |
| 2521 |
db_query("DELETE FROM {content_". $cck_original_video_field ."} WHERE nid = %d", $node->nid); |
db_query("DELETE FROM {". $cck_original_video_field_db_info['table'] ."} WHERE nid = %d", $node->nid); |
| 2522 |
db_query("DELETE FROM {content_". $cck_finished_video_field ."} WHERE nid = %d", $node->nid); |
db_query("DELETE FROM {". $cck_finished_video_field_db_info['table'] ."} WHERE nid = %d", $node->nid); |
| 2523 |
db_query("DELETE FROM {content_". $cck_finished_thumbnail_field ."} WHERE nid = %d", $node->nid); |
db_query("DELETE FROM {". $cck_finished_thumbnail_field_db_info['table'] ."} WHERE nid = %d", $node->nid); |
| 2524 |
} |
} |
| 2525 |
file_delete($file->filepath); |
file_delete($file->filepath); |
| 2526 |
module_invoke_all('flashvideo_delete_file', $file, $node->type); |
module_invoke_all('flashvideo_delete_file', $file, $node->type); |