function media_browser_plus_move_physical_folder in Media Browser Plus 7.2
Same name and namespace in other branches
- 7.3 includes/media_browser_plus.folders.inc \media_browser_plus_move_physical_folder()
- 7 media_browser_plus.module \media_browser_plus_move_physical_folder()
Cut-paste a directory with its children into a new filesystem location.
Parameters
string $source: The current folder path.
string $destination: The path we want the folder moved to.
2 calls to media_browser_plus_move_physical_folder()
- media_browser_plus_folder_list_submit in includes/
media_browser_plus.folders.inc - @todo Document what this function is does.
- media_browser_plus_move_subfolder in includes/
media_browser_plus.folders.inc - Helper function to move a subfolder - and update the related files.
File
- ./
media_browser_plus.module, line 2058 - Adds fields to the media browser forms for better UX
Code
function media_browser_plus_move_physical_folder($source, $destination) {
$destination = drupal_realpath($destination);
$source = drupal_realpath($source);
$jail = drupal_realpath(variable_get('file_default_scheme', 'public') . '://');
// @todo Please avoid an error by checking the preconditions instead.
$files = @scandir($source);
if ($files && count($files) > 2) {
$transfer = new FileTransferLocal($jail);
$transfer
->copyDirectory($source, $destination);
$transfer
->removeDirectory($source);
}
else {
// The folder is empty so just delete and create the new one.
drupal_rmdir($source);
file_prepare_directory($destination, FILE_CREATE_DIRECTORY);
}
return TRUE;
}