You are here

function js_injector_edit_save in JS injector 6

Same name and namespace in other branches
  1. 6.2 js_injector.admin.inc \js_injector_edit_save()
  2. 7 js_injector.admin.inc \js_injector_edit_save()

Submit button callback for the js rule edit form.

1 string reference to 'js_injector_edit_save'
js_injector_edit in ./js_injector.admin.inc
Constructor for the js rule edit form.

File

./js_injector.admin.inc, line 221

Code

function js_injector_edit_save($form, &$form_state) {
  $rule = $form_state['rule'];
  if (empty($rule['crid'])) {
    drupal_write_record('js_injector_rule', $rule);
    $directory = file_directory_path();
    $rule['file_path'] = file_create_path($directory . '/js_injector_' . $rule['crid'] . '.js');
  }
  drupal_write_record('js_injector_rule', $rule, array(
    'crid',
  ));
  file_save_data($rule['js_text'], file_create_path($rule['file_path']), FILE_EXISTS_REPLACE);
  _js_injector_load_rule(NULL, TRUE);
  drupal_set_message('Your js injection rule was saved.');
  $form_state['redirect'] = 'admin/settings/js_injector';
}