You are here

function javascript_libraries_custom_delete in JavaScript Libraries Manager 7

API function - delete one custom library by ID.

2 calls to javascript_libraries_custom_delete()
javascript_libraries_delete_form_submit in ./javascript_libraries.admin.inc
Form submit function for avascript_libraries_delete_form().
_javascript_libraries_file_submit in ./javascript_libraries.admin.inc

File

./javascript_libraries.module, line 110
Toggle the inclusion of Drupal system libraries. Upload and reference custom libraries as well.

Code

function javascript_libraries_custom_delete($id) {
  $library = javascript_libraries_custom_load($id);
  switch ($library['type']) {
    case 'external':

      // Nothing to do.
      break;
    case 'file':

      // Delete associated file.
      $file = file_load($library['fid']);
      file_usage_delete($file, 'javascript_libraries');
      file_delete($file);
      break;
  }
  $custom = variable_get('javascript_libraries_custom_libraries', array());
  unset($custom[$library['id']]);
  variable_set('javascript_libraries_custom_libraries', $custom);
}