| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id: mm_dir.module,v 1.1.2.2 2009/10/19 02:52:57 arthuregg Exp $ |
// $Id: mm_dir.module,v 1.1.2.3 2009/10/19 11:45:54 arthuregg Exp $ |
| 4 |
|
|
| 5 |
/** |
/** |
| 6 |
* Implementation of hook_media_mover(). |
* Implementation of hook_media_mover(). |
| 169 |
* @param int $action |
* @param int $action |
| 170 |
* @return string |
* @return string |
| 171 |
*/ |
*/ |
| 172 |
function mm_dir_save ($file, $configuration, $action) { |
function mm_dir_save ($step, $file) { |
| 173 |
// make sure destination directory exists |
// make sure destination directory exists |
| 174 |
if (is_dir($configuration['path'])) { |
if (! file_check_directory($step->settings['path'], FILE_CREATE_DIRECTORY)) { |
| 175 |
// figure out what verb is currently running |
return false; |
|
$verb = $action == 2 ? 'storage' : 'complete'; |
|
|
// get the last file that was used by media mover |
|
|
$orig_file = $verb == 'storage' ? $file['process_file'] : $file['storage_file']; |
|
|
// assign the new path to the file name |
|
|
$new_file = file_create_filename(basename($orig_file), $configuration['path']); |
|
|
// now copy this file from the old to the new location |
|
|
copy($orig_file, $new_file); |
|
|
media_mover_api_set_file_perm($new_file); |
|
|
// return the file |
|
|
return $new_file; |
|
| 176 |
} |
} |
| 177 |
|
// assign the new path to the file name |
| 178 |
|
$new_file = file_create_filename(basename($file->filepath), $step->settings['path']); |
| 179 |
|
// now copy this file from the old to the new location |
| 180 |
|
copy($file->filepath, $new_file); |
| 181 |
|
media_mover_api_set_file_perm($new_file); |
| 182 |
|
// return the file |
| 183 |
|
return $new_file; |
| 184 |
} |
} |
| 185 |
|
|
| 186 |
|
|