aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglen201 <glen201@527446.no-reply.drupal.org>2009-07-24 01:10:42 +0000
committerglen201 <glen201@527446.no-reply.drupal.org>2009-07-24 01:10:42 +0000
commit794aa2d5c3f67ba94d60a36fc922ea6308ae6f02 (patch)
tree628866630005d05dde623f2b7eda293c93ba406c
parenta5238df2e95897de8ce6ff1300d92ac46fd48da2 (diff)
downloadvideo-794aa2d5c3f67ba94d60a36fc922ea6308ae6f02.tar.gz
video-794aa2d5c3f67ba94d60a36fc922ea6308ae6f02.tar.bz2
#518396 by decibel.places : "Video type not supported" video_upload.module, fixed rebuilding derivative images when video updated
#502606 by glen201 : Permissions error in Video Image module prevents users from uploading image thumbnail, fixed #495886 by glen201: Autogenerated thumbnail sticks and is not replaceable by new video/image uploaded, fixed dependency on Image module Enhanced video_upload module to fix files left behind after delete video Enhanced video_upload module to prevent error when replacing ffmpeg converted video with video that will not be auto-converted
-rw-r--r--README.txt1
-rw-r--r--plugins/video_ffmpeg_helper/README.txt5
-rw-r--r--plugins/video_image/video_image.module23
-rw-r--r--po/video-module.pot8
-rw-r--r--types/video_upload/video_upload.module68
5 files changed, 76 insertions, 29 deletions
diff --git a/README.txt b/README.txt
index 21e2ea7..0a5281a 100644
--- a/README.txt
+++ b/README.txt
@@ -23,6 +23,7 @@ Maintainers:
David Norman: deekayen (at) deekayen [dot-} net
Luke Last: luke [at] lukelast dot com
Vernon Mauery: vernon at mauery dot com
+ Glen Marianko: twitter@demoforum, glenm at demoforum dot com
Porting to Drupal 6
Heshan Wanigasooriya :heshan@heidisoft.com,heshanmw@gmail.com
diff --git a/plugins/video_ffmpeg_helper/README.txt b/plugins/video_ffmpeg_helper/README.txt
index 8f460b4..73716b7 100644
--- a/plugins/video_ffmpeg_helper/README.txt
+++ b/plugins/video_ffmpeg_helper/README.txt
@@ -20,7 +20,10 @@ Install instructions
6. You now have two options to execute the video_scheduler.php script:
6.1 (default) Enable the execution of video_scheduler.php using standard drupal cron.
-
+ GMM: 07/23/2009 Note: ** Do not use this method if your Apache server is running with suPHP **
+ As of this writing, suPHP will cause the Drupal cron to loop infinitely and no video
+ will be rendered. In this case crontab should be used instead of Drupal cron!
+
6.2 Schedule the execution of video_scheduler.php using unix cron
The crontab should look something like this:
diff --git a/plugins/video_image/video_image.module b/plugins/video_image/video_image.module
index f8a3efb..db06d77 100644
--- a/plugins/video_image/video_image.module
+++ b/plugins/video_image/video_image.module
@@ -7,6 +7,7 @@
* @author Fabio Varesano <fvaresano at yahoo dot it>
* porting to Drupal 6
* @author Heshan Wanigasooriya <heshan at heidisoft.com><heshanmw@gmail.com>
+ * @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
* @todo
*/
@@ -44,6 +45,8 @@ function video_image_menu() {
/**
* Implementation of hook_perm
*/
+//GMM: define positions in perm array to reference later (without misspellings :)
+ define('OVERRIDE_IMAGE', 0);
function video_image_perm() {
$array = array('override autothumbnailing using uploaded image');
return $array;
@@ -152,9 +155,9 @@ function video_image_form_alter(&$form, &$form_state, $form_id) {
}
$auto_thumbable = video_image_is_autothumbable($node);
-
- if(!$auto_thumbable || user_access('override autothumnailing using uploaded images')) {
- // let's be sure that image directories are ready
+ //GMM: fix permission misspelling
+ $perm=video_image_perm();
+ if(!$auto_thumbable || user_access($perm[OVERRIDE_IMAGE])) { // let's be sure that image directories are ready
if (function_exists('_image_check_settings')) {
_image_check_settings();
}
@@ -328,8 +331,13 @@ function _video_image_submit(&$node) {
$image = _video_image_temp_image_load(array_values($node->tempimage['fids']));
//print_r($image);
//exit;
- db_query("DELETE FROM {files} WHERE fid in (%s)",
- implode(',', array_values($node->tempimage['fids'])));
+
+ //GMM: This DELETE query causes the uploaded video file to disappear
+ // especially when using ffmpeg to convert the video - no need to kill the
+ // tempimage, since its status is 0 in {files} Drupal cron will nix it
+ //db_query("DELETE FROM {files} WHERE fid in (%s)",
+ // implode(',', array_values($node->tempimage['fids'])));
+
// initialize standard node fields
//print_r($image);
//exit;
@@ -348,7 +356,10 @@ function _video_image_submit(&$node) {
$oldimage->images = $image->images;
// delete the old images?
- $oldimage->new_image = 1;
+ //GMM: Fix to use the proper variable to trigger current Image module to rebuild derivative images
+ // Tested against Image 6.x-1.0-aplha4
+ // $oldimage->new_image = 1;
+ $oldimage->new_file = true;
node_save($oldimage);
$node->iid = $oldimage->nid;
$node->serial_data['iid'] = $node->iid;
diff --git a/po/video-module.pot b/po/video-module.pot
index d04c734..3a08301 100644
--- a/po/video-module.pot
+++ b/po/video-module.pot
@@ -1131,6 +1131,14 @@ msgstr ""
msgid "video_image"
msgstr ""
+#: types/video_upload/video_upload.module:0
+msgid "encoded"
+msgstr ""
+
+#: types/video_upload/video_upload.module:0
+msgid "Auto-encoded to @ext"
+msgstr ""
+
#: plugins/video_multidownload/video_multidownload.module:18
msgid "Enable multiple file download in video module."
msgstr ""
diff --git a/types/video_upload/video_upload.module b/types/video_upload/video_upload.module
index 7f7e29c..4241306 100644
--- a/types/video_upload/video_upload.module
+++ b/types/video_upload/video_upload.module
@@ -5,8 +5,9 @@
*
* @author Heshan Wanigasooriya <heshan at heidisoft dot com>
* <heshanmw at gmail dot com>
- * @todo
- * implement the help of the video upload (Implement the internal hook for the help video_upload_v_help()).
+ * @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
+ * @todo implement the help of the video upload (Implement the internal hook for the help video_upload_v_help()).
+ * @todo GMM: video upload allowed extensions broken, all uploads allowed
*/
@@ -311,6 +312,13 @@ function _video_upload_load(&$node) {
$output = array();
$output['video_fid'] = $fileBuf->fid;
$file = _video_upload_get_file($output['video_fid']);
+ //GMM: If original file is deleted from {files} refer to the encoded file
+ if($node->serial_data['video_encoded_fid'])
+ $node->encoded_video_upload_file = _video_upload_get_file($node->serial_data['video_encoded_fid']);
+ if(!$file) {
+ $output['video_fid'] = $node->serial_data['video_encoded_fid'];
+ $file = $node->encoded_video_upload_file;
+ }
$output['current_video_upload_file'] = $file;
$output['vidfile'] = file_create_url($file->filepath);
// set the filesize
@@ -423,7 +431,8 @@ function _video_upload_presave(&$node) {
$fid = $node->current_video_upload_file_fid;
}
$node->serial_data['video_fid'] = $fid;
- $node->vidfile = $node->new_video_upload_file->path;
+ //GMM: corrected reference from >path to >filepath
+ $node->vidfile = $node->new_video_upload_file->filepath;
$node->size = $node->new_video_upload_file->filesize;
// _video_upload_insert($file,$node);
}
@@ -459,11 +468,13 @@ function _video_upload_delete(&$node) {
//print 'delete';
// delete file
- file_delete($node->current_video_upload_file->path);
+ // file_delete($node->current_video_upload_file->path);
// delete file information from database
- db_query('DELETE FROM {upload} WHERE fid = %d', $node->current_video_upload_file->fid);
- db_query('DELETE FROM {files} WHERE fid = %d', $node->current_video_upload_file->fid);
+ db_query('DELETE FROM {video_upload} WHERE fid = %d', $node->current_video_upload_file->fid);
+ //GMM: set original file to be deleted by Drupal cron file garbage collection
+ db_query('UPDATE {files} SET status = %d WHERE fid = %d', FILE_STATUS_TEMPORARY, $node->current_video_upload_file->fid);
+ //db_query('DELETE FROM {files} WHERE fid = %d', $node->current_video_upload_file->fid);
}
@@ -485,17 +496,23 @@ function _video_upload_store_file(&$file, &$node) {
_video_upload_get_path($file, $node);
if (file_move($file, file_directory_path())) { // file moved successfully
- if(variable_get('video_ffmpeg_helper_auto_conversion', false))
- $status = 0; // ffmpeg will use this as source, so let drupal delete the file later
+ //GMM: Set uploaded file as permanent if no ffmpeg conversion
+ if(variable_get('video_ffmpeg_helper_auto_conversion', false) && !$node->video_ffmpeg_helper_convertion_bypass )
+ $status = FILE_STATUS_TEMPORARY; // ffmpeg will use file as source, so let drupal delete the file later
else
- $status = 1; // ffmpeg will not be called, this video file will play as-is
+ $status = FILE_STATUS_PERMANENT; // ffmpeg will not be called, this video file will play as-is
// update the file db entry
db_query("UPDATE {files} SET filename = '%s', filepath = '%s', filemime = '%s', filesize = %d, status = %d WHERE fid = %d", $file->filename, $file->filepath, $file->filemime, $file->filesize, $status, $file->fid);
+ //GMM: delete previous revision, if there was one
+ db_query("DELETE FROM {video_upload} WHERE vid = %d AND nid = %d",$node->vid, $node->nid);
// add an entry in the file_revisions table
db_query("INSERT INTO {video_upload} (vid, nid, fid) VALUES (%d, %d, %d)", $node->vid, $node->nid, $file->fid);
// update the file db entry
- //db_query("UPDATE {video} SET serialized_data = '%s' WHERE vid = %d", $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->fid);
-
+ //GMM: Remove the serialized encoded fid information in case we're replacing an already encoded video
+ if (isset($node->serial_data['video_encoded_fid'])) {
+ $node->serial_data['video_encoded_fid'] = 0;
+ db_query("UPDATE {video} SET serialized_data = '%s' WHERE vid = %d", serialize($node->serial_data), $node->vid);
+ }
}
else {
drupal_set_message(t('An error occurred during file saving. Your video file has not been stored.'), 'error');
@@ -533,7 +550,7 @@ function _video_upload_get_file($fid) {
static $files = array();
if (!$fid) {
- return null;
+ return NULL;
}
if (!isset($files[$fid])) {
$files[$fid] = db_fetch_object(db_query('SELECT * from {files} WHERE fid = %d', $fid));
@@ -545,14 +562,16 @@ function _video_upload_get_file($fid) {
/**
* Delete a file
*/
-function _video_upload_delete_file($file) {
-
- // delete file
- file_delete($file->path);
+function _video_upload_delete_file($fid) {
+ //GMM: delete file if one requested
+ if($fid) {
+ //GMM: file_delete($file);
// delete file information from database
- db_query('DELETE FROM {video_upload} WHERE fid = %d', $file);
- db_query('DELETE FROM {files} WHERE fid = %d', $file);
+ db_query('DELETE FROM {video_upload} WHERE fid = %d', $fid);
+ //GMM: set original file to be deleted by Drupal cron file garbage collection
+ db_query('UPDATE {files} SET status = %d WHERE fid = %d', FILE_STATUS_TEMPORARY, $fid);
+ }
}
@@ -560,10 +579,15 @@ function _video_upload_delete_file($file) {
* Display informations about already uploaded file
*/
function theme_video_upload_file_info_form($file, $node) {
- // create array containing uploaded file informations
- $items = array(
- '<b>'. t('file name') .':</b> ' . _video_get_original_filename(basename($file->filename)), // do not display parent folders
- '<b>'. t('file size') .':</b> ' . format_size($file->filesize),
+//GMM: let user know we're showing uploaded video stats
+ if($node->serial_data['video_encoded_fid']) {
+ $ext = split ("\.", basename($node->encoded_video_upload_file->filename));
+ $encoded = $ext[count($ext)-1];
+ }
+// create array containing uploaded file informations
+$items = array(
+ '<b>'. t('file name') .':</b> ' . _video_get_original_filename(basename($file->filename)) . ($encoded ? '&nbsp;&nbsp;('.t('Auto-encoded to @ext', array("@ext" => strtoupper($encoded))).')' : '' ), // do not display parent folders
+ '<b>'. t('file size') .':</b> ' . format_size($file->filesize) . ($node->serial_data['video_encoded_fid']&&$node->serial_data['video_encoded_fid']!=$file->fid ? '&nbsp;&nbsp;('.format_size($node->encoded_video_upload_file->filesize).' '.t('encoded').')' : '') ,
);
// create information list