function media_browser_plus_move_subfolder 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_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 path of the old/current location.
string $destination: The path of the new location.
Return value
boolean Returns FALSE if the processing failed e.g. if the source and destination are the same location.
2 calls to media_browser_plus_move_subfolder()
- 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 484 - Folder manipulation functions
Code
function media_browser_plus_move_subfolder($folder, $source, $destination) {
if ($source != $destination) {
// This will move all subfolders too. Thus we have to handle all child
// folder terms as well.
media_browser_plus_move_physical_folder($source, $destination);
// 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;
}
// Set batch.
$batch = array(
'title' => t('Updating Media'),
'operations' => array(
array(
'media_browser_plus_folder_update_file_locations_batch',
array(
$folders,
),
),
),
'finished' => 'media_browser_plus_folder_update_file_locations_batch_complete',
'file' => drupal_get_path('module', 'media_browser_plus') . '/includes/media_browser_plus.folders.inc',
);
batch_set($batch);
return TRUE;
}
return FALSE;
}