You are here

public static function Preset::deletePreset in Video 7.2

Deletes a preset from the database.

3 calls to Preset::deletePreset()
video_features_revert in ./video.features.inc
Implements hook_features_revert().
video_preset_delete_confirm_submit in modules/video_ui/video.preset.inc
Execute preset deletion
video_preset_revert_confirm_submit in modules/video_ui/video.preset.inc
Execute preset revert

File

includes/Preset.inc, line 164
Class file used to store video presets on the video.

Class

Preset
@file Class file used to store video presets on the video.

Code

public static function deletePreset($preset_name) {
  $preset = self::getPreset($preset_name);
  if (empty($preset) || $preset['overridden'] === FALSE) {
    return;
  }

  // Find out whether there is a default watermark.
  $watermark_override = isset($preset['settings']['video_watermark_fid']) ? intval($preset['settings']['video_watermark_fid']) : 0;
  $watermark_default = 0;
  if ($preset['overridden']) {
    $default_presets = Preset::getDefaultPresets();
    $default_preset = $default_presets[$preset_name];
    $watermark_default = isset($default_preset['settings']['video_watermark_fid']) ? intval($default_preset['settings']['video_watermark_fid']) : 0;
  }

  // Delete the watermark when it is not the default one.
  if ($watermark_override > 0 && $watermark_override != $watermark_default) {
    $file = file_load($preset['settings']['video_watermark_fid']);
    if (!empty($file)) {
      file_usage_delete($file, 'video');
      $file->status = 0;
      file_save($file);
    }
  }

  // Delete the preset.
  db_delete('video_preset')
    ->condition('name', $preset_name)
    ->execute();

  // Rebuild Theme Registry
  drupal_theme_rebuild();
}