You are here

function media_browser_plus_taxonomy_term_update in Media Browser Plus 7.3

Same name and namespace in other branches
  1. 7.2 media_browser_plus.module \media_browser_plus_taxonomy_term_update()

Implements hook_taxonomy_term_update().

See also

media_browser_plus_taxonomy_term_presave()

File

./media_browser_plus.module, line 606
Media Browser Plus - enhanced file management functions.

Code

function media_browser_plus_taxonomy_term_update($term) {
  if ($term->vocabulary_machine_name == 'media_folders') {

    // Check if the folder term was moved. Only folder terms have this property.
    if (!empty($term->media_browser_plus_original_path)) {
      $destination = media_browser_plus_construct_dir_path($term);
      if ($term->media_browser_plus_original_path != $destination) {
        module_load_include('inc', 'media_browser_plus', '/includes/media_browser_plus.folders');

        // Prepare batch to move folder and files.
        $batch = array(
          'title' => t('Updating file locations'),
          'operations' => media_browser_plus_move_subfolder($term, $term->media_browser_plus_original_path, $destination),
          'file' => drupal_get_path('module', 'media_browser_plus') . '/includes/media_browser_plus.folders.inc',
        );

        // If necessary start the batch to update the folder 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');
  }
}