diff -urp mailsave_to_audio/mailsave_to_audio.info mailsave_to_audio/mailsave_to_audio.info --- mailsave_to_audio/mailsave_to_audio.info 2008-08-20 18:00:27.000000000 -0400 +++ mailsave_to_audio/mailsave_to_audio.info 2010-06-05 08:39:00.000000000 -0400 @@ -2,7 +2,8 @@ name = Mailsave to audio - beta description = Works with mailsave to create audio nodes from incoming mp3 files -dependencies = mailsave audio +dependencies[] = mailsave +dependencies[] = audio package = "Mailsave" ; Information added by drupal.org packaging script on 2008-08-20 diff -urp mailsave_to_image_attach/mailsave_to_image_attach.info mailsave_to_image_attach/mailsave_to_image_attach.info --- mailsave_to_image_attach/mailsave_to_image_attach.info 2008-08-20 18:00:27.000000000 -0400 +++ mailsave_to_image_attach/mailsave_to_image_attach.info 2010-06-05 08:39:00.000000000 -0400 @@ -2,7 +2,8 @@ name = Mailsave to image attach description = Works with mailsave to create image nodes and attach them to the main node -dependencies = mailsave image_attach +dependencies[]= mailsave +dependencies[] = image_attach package = "Mailsave" diff -urp mailsave_to_imagefield/mailsave_to_imagefield.info mailsave_to_imagefield/mailsave_to_imagefield.info --- mailsave_to_imagefield/mailsave_to_imagefield.info 2008-08-20 18:00:27.000000000 -0400 +++ mailsave_to_imagefield/mailsave_to_imagefield.info 2010-06-05 08:39:00.000000000 -0400 @@ -1,6 +1,7 @@ name = Mailsave to CCK Imagefield description = Works with mailsave to create CCK imagefield items from attached images -dependencies = mailsave imagefield +dependencies[] = mailsave +dependencies[] = imagefield package = "Mailsave" ; Information added by drupal.org packaging script on 2008-08-20 version = "6.x-1.3" diff -urp mailsave_to_imagefield/mailsave_to_imagefield.module mailsave_to_imagefield/mailsave_to_imagefield.module --- mailsave_to_imagefield/mailsave_to_imagefield.module 2007-11-27 17:03:44.000000000 -0500 +++ mailsave_to_imagefield/mailsave_to_imagefield.module 2010-06-10 13:45:13.000000000 -0400 @@ -65,7 +65,7 @@ function _mailsave_to_imagefield_attempt if (is_array($cck_info['fields'])) { foreach ($cck_info['fields'] as $cck_field => $field_info) { - if ($field_info['type'] == 'image') { + if ($field_info['widget']['type'] == 'imagefield_widget') { $cck_imagefield = $cck_field; $cck_multiple = $field_info['multiple']; $cck_image_extensions = $field_info['widget']['file_extensions']; @@ -87,37 +87,46 @@ function _mailsave_to_imagefield_attempt // branch 5--2 onwards. So we check that the extension list is empty, or the extension is otherwise allowed /// but we also check the mime type is image/. This might cause problems for some webmail type clients that // report image uploads as octet streams, but will have to do for now! + if ( (trim($cck_image_extensions) == '' || strpos($cck_image_extensions, _file_ext($file['filename'])) !== FALSE ) && strpos(strtolower($file['filemime']), 'image/') === 0 ) { // Let's scale the image per the imagefield max settings - $file = _imagefield_scale_image($file, $field_info['widget']['max_resolution']); + if ($field_info['widget']['max_resolution']) { + $file = _imagefield_scale_image($file, $field_info['widget']['max_resolution']); + } // If there are tokenized as part of imagefield 2.x let's use them if (function_exists('token_replace')) { global $user; - $widget_image_path = token_replace($field_info['widget']['image_path'], 'user', $user); + $widget_image_path = token_replace($field_info['widget']['file_path'], 'user', $user); } else { - $widget_image_path = $field_info['widget']['image_path']; + $widget_image_path = $field_info['widget']['file_path']; } - // Let's create the directory path if it hasn't been created already - imagefield_check_directory($widget_image_path); + $directory = file_directory_path()."/".$widget_image_path; + module_load_include('inc','filefield','field_file'); + field_file_check_directory($directory, FILE_CREATE_DIRECTORY); + $destination = file_destination(file_create_path($widget_image_path .''. $file['filename']), FILE_EXISTS_RENAME); + file_move($file['filepath'], $destination); // Build the array for the image found - $cckimageinfo = array( - 'flags' => array('delete' => '0'), - 'alt' => $file['filename'], - 'title' => '', - 'filename' => $file['filename'], - 'filepath' => $file['filepath'], - 'filemime' => $file['filemime'], - 'filesize' => $file['filesize'], - 'fid' => 'upload', - ); + $file['list'] = 0; + $file['data'] = array('description' => '', 'alt' => $file['filename'], 'title' => ''); + $file['uid'] = $node->uid; + $file['filepath'] = $destination; + $file['status'] = 1; + $file['timestamp'] = time(); + + drupal_write_record('files', $file); + + foreach (module_implements('file_insert') as $module) { + $function = $module .'_file_insert'; + $function((object) $file); + } // Add the image info to the imagefield array - $node->{$cck_imagefield}[] = $cckimageinfo; + $node->{$cck_imagefield}[] = $file; // Lets remove the CCK image we found from attachments // We will leave the temp file though, as imagefield will need it @@ -138,3 +147,21 @@ function _file_ext($filename) { $ext = $parts[(sizeof($parts) - 1)]; return $ext; } + + +//ABE + +function _imagefield_scale_image($file, $resolution = 0) { + $info = image_get_info($file['filepath']); + if ($info) { + list($width, $height) = explode('x', $resolution); + if ($width && $height) { + $result = image_scale($file['filepath'], $file['filepath'], $width, $height); + if ($result) { + $file['filesize'] = filesize($file['filepath']); + drupal_set_message(t('The image %filename was resized to fit within the maximum allowed resolution of %resolution pixels', array('%resolution' => $resolution, '%filename' => $file['filename']))); + } + } + } + return $file; +} \ No newline at end of file