<?php
/**
 * @file
 * Database table schema definitions, database updates.
 */

/**
 * Implements hook_install().
 */
function bassets_media_install() {
  _bassets_media_disable_media_default();
}

/**
 * The feature bassets_client_media has a modified version of the view.
 */
function _bassets_media_disable_media_default() {
  $name = 'media_default';
  $status = variable_get('views_defaults', array());
  $status[$name] = TRUE;
  variable_set('views_defaults', $status);

  $media_plugins = variable_get('media__wysiwyg_browser_plugins', array());
  foreach ($media_plugins as $key => $media_plugin) {
    if (strpos($media_plugin, 'media_default') === 0) {
      unset($media_plugins[$key]);
    }
  }
  array_unshift($media_plugins, 'bassets', 'media_browser_bassets--media_browser_1', 'media_browser_bassets--media_browser_my_files');
  variable_set('media__wysiwyg_browser_plugins', $media_plugins);
  cache_clear_all('media:browser:plugin:info:', 'cache', TRUE);
}
