You are here

function bueditor_editor_submit in BUEditor 6

Same name and namespace in other branches
  1. 6.2 admin/bueditor.admin.inc \bueditor_editor_submit()
  2. 7 admin/bueditor.admin.inc \bueditor_editor_submit()

Save editor & buttons.

1 string reference to 'bueditor_editor_submit'
bueditor_editor_form in ./bueditor.admin.inc
Editor form.

File

./bueditor.admin.inc, line 318

Code

function bueditor_editor_submit($form, &$form_state) {

  //editor
  $editor = (object) $form_state['values']['editor'];
  $update = $editor->eid ? array(
    'eid',
  ) : array();
  if (SAVED_NEW == drupal_write_record('bueditor_editors', $editor, $update)) {
    drupal_set_message(t('New editor has been added.'));
    $form_state['redirect'] = 'admin/settings/bueditor/' . $editor->eid;
  }

  //buttons
  foreach ($form_state['values']['buttons'] as $bid => $button) {
    if ($button['title']) {
      $button = (object) $button;
      $button->bid = is_numeric($bid) ? $bid : NULL;
      $button->eid = $editor->eid;
      $button->content = str_replace("\r\n", "\n", $button->content);
      $button->icon = $button->icon ? $button->icon : $button->caption;
      $update = $button->bid ? array(
        'bid',
      ) : array();
      drupal_write_record('bueditor_buttons', $button, $update);
    }
  }
  drupal_set_message(t('Changes have been saved.'));
}