function media_browser_plus_move_subfolder in Media Browser Plus 7.3
Same name and namespace in other branches
- 7.2 includes/media_browser_plus.folders.inc \media_browser_plus_move_subfolder()
Helper function to move a subfolder - and update the related files.
Parameters
object $folder: The _updated_ folder term. Is used to generate the destination.
string $source: The current path without scheme.
string $destination: The new path. Including the directory name but without scheme!
Return value
array A list of batch operations to execute to finish the job.
3 calls to media_browser_plus_move_subfolder()
- media_browser_plus_form_taxonomy_overview_terms_submit in ./
media_browser_plus.module - Submit handler for the taxonomy term overview list.
- media_browser_plus_move_root_folder in includes/
media_browser_plus.folders.inc - Moves the root folder of media files.
- media_browser_plus_taxonomy_term_update in ./
media_browser_plus.module - Implements hook_taxonomy_term_update().
File
- includes/
media_browser_plus.folders.inc, line 96 - Folder manipulation functions.
Code
function media_browser_plus_move_subfolder($folder, $source, $destination) {
$operations = array();
foreach (media_get_local_stream_wrappers() as $scheme => $scheme_info) {
$source_path = file_stream_wrapper_uri_normalize($scheme . '://' . $source);
$destination_path = file_stream_wrapper_uri_normalize($scheme . '://' . $destination);
if ($source != $destination) {
// This will move all subfolders too. Thus we have to handle all child
// folder terms as well.
file_prepare_directory($destination_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
media_browser_plus_move_physical_folder($source_path, $destination_path, $scheme);
}
// @todo This could move into the condition, but this way it's more stable.
// Update files in folder and subfolders get folders.
$folders = array(
$folder->tid,
);
// Fetch all sub-folders.
$sub_folders = taxonomy_get_tree($folder->vid, $folder->tid);
foreach ($sub_folders as $sub_folder) {
$folders[] = $sub_folder->tid;
}
$operations[] = array(
'media_browser_plus_folder_update_file_locations_batch',
array(
$folders,
),
);
}
return $operations;
}