You are here

function _javascript_libraries_file_submit in JavaScript Libraries Manager 7

1 call to _javascript_libraries_file_submit()
javascript_libraries_edit_form_submit in ./javascript_libraries.admin.inc
Form submit for javascript_libraries_edit_form().

File

./javascript_libraries.admin.inc, line 548
Administrative management forms for JavaScript libraries.

Code

function _javascript_libraries_file_submit($form, &$form_state) {
  $file = file_load($form_state['values']['js_file_upload']);
  $file->status = FILE_STATUS_PERMANENT;

  // Make the file permanent.
  file_save($file);
  file_usage_add($file, 'javascript_libraries', 'javascript_libraries', $file->fid);
  $custom = variable_get('javascript_libraries_custom_libraries', array());
  $id = 'file-' . $file->fid;
  $custom[$id] = array(
    'type' => 'file',
    'scope' => $form_state['values']['scope'],
    'name' => strlen($form_state['values']['name']) ? $form_state['values']['name'] : $file->filename,
    'weight' => $form['#library']['weight'],
    'id' => $id,
    'fid' => $file->fid,
    'uri' => $file->uri,
  );
  variable_set('javascript_libraries_custom_libraries', $custom);
  if (isset($form['#library']['fid']) && $form['#library']['fid'] != $file->fid) {

    // Replacement file. The id and file have changed, so delete the old one.
    javascript_libraries_custom_delete($form['#library']['id']);
  }
}