You are here

function local_fonts_delete_font in @font-your-face 7

Same name and namespace in other branches
  1. 7.2 modules/local_fonts/local_fonts.module \local_fonts_delete_font()

Deletes given font.

1 call to local_fonts_delete_font()
local_fonts_delete_form_submit in modules/local_fonts/local_fonts.module
Handles submission of delete form.

File

modules/local_fonts/local_fonts.module, line 404

Code

function local_fonts_delete_font($font) {
  $metadata = unserialize($font->metadata);
  $directory = dirname($metadata['path']);

  // Delete all the files.
  $files = scandir($directory);
  foreach ($files as $file) {
    if ($file != '.' && $file != '..') {
      unlink($directory . '/' . $file);
    }

    // if
  }

  // foreach
  // Delete the directory.
  rmdir($directory);

  // Delete from the database.
  db_delete('fontyourface_font')
    ->condition('fid', $font->fid)
    ->execute();
  fontyourface_delete_unused_tags();
  return TRUE;
}