function media_browser_plus_form_taxonomy_overview_terms_submit in Media Browser Plus 7.3
Submit handler for the taxonomy term overview list.
This is necessary since altering the hierarchy or weight of terms in the overview won't trigger any term hooks *blargh* :|
1 string reference to 'media_browser_plus_form_taxonomy_overview_terms_submit'
File
- ./
media_browser_plus.module, line 768 - Media Browser Plus - enhanced file management functions.
Code
function media_browser_plus_form_taxonomy_overview_terms_submit(&$form, &$form_state) {
module_load_include('inc', 'media_browser_plus', 'includes/media_browser_plus.folders');
$vocabulary = $form['#vocabulary'];
taxonomy_terms_static_reset();
$root_folder = media_browser_plus_get_media_root_folder();
$tree = taxonomy_get_tree($vocabulary->vid);
// Prepare batch.
$batch = array(
'title' => t('Updating Media'),
'operations' => array(),
'finished' => 'media_browser_plus_update_folder_hierarchy_batch_complete',
'file' => drupal_get_path('module', 'media_browser_plus') . '/includes/media_browser_plus.folders.inc',
);
foreach ($tree as $term) {
// Deal only with subfolders.
if ($term->tid != $root_folder->tid) {
// A subfolder term is always child of the root folder.
if (empty($term->parents[0])) {
// The presave hook will take care of fixing this.
taxonomy_term_save($term);
}
$path = media_browser_plus_construct_dir_path($term);
if ($form_state['#mbp_original_paths'][$term->tid] != $path) {
$batch['operations'] = array_merge($batch['operations'], media_browser_plus_move_subfolder($term, $form_state['#mbp_original_paths'][$term->tid], $path));
}
}
}
// If necessary start the batch to update the structure.
if (!empty($batch['operations'])) {
batch_set($batch);
}
// Clear view cache for media browser plus folders.
media_browser_plus_clear_views_cache('media_browser_plus_folders');
}