You are here

function library_admin_action_submit in Library 7

Same name and namespace in other branches
  1. 5.2 library.admin.inc \library_admin_action_submit()
  2. 6.2 library.admin.inc \library_admin_action_submit()
  3. 6 library.admin.inc \library_admin_action_submit()

Menu callback: Edit Library Action.

See also

library_admin_action()

library_admin_action_validate()

theme_library_admin_new_action()

1 string reference to 'library_admin_action_submit'
library_admin_action in ./library.admin.inc
Menu callback: Edit Library Action.

File

./library.admin.inc, line 387
Administrative settings for the library module

Code

function library_admin_action_submit($form, &$form_state) {
  if ($form_state['values']['op'] == t('Save action')) {
    db_update('library_actions')
      ->fields(array(
      'name' => check_plain($form_state['values']['name']),
      'status_change' => $form_state['values']['status_change'],
    ))
      ->condition('aid', $form_state['values']['aid'])
      ->execute();
    drupal_set_message(t('The action has been renamed.'));
  }
  elseif ($form_state['values']['op'] == t('Delete action')) {
    db_delete('library_actions')
      ->condition('aid', $form_state['values']['aid'])
      ->execute();
    db_delete('library_transactions')
      ->condition('action_aid', $form_state['values']['aid'])
      ->execute();
    $available_display = variable_get('library_links_display_available', array());
    $unavailable_display = variable_get('library_links_display_unavailable', array());
    $reference_display = variable_get('library_links_display_reference', array());
    $key = array_search($form_state['values']['aid'], $available_display);
    if ($key !== FALSE) {
      unset($available_display[$key]);
      variable_set('library_links_display_available', $available_display);
    }
    $key2 = array_search($form_state['values']['aid'], $unavailable_display);
    if ($key2 !== FALSE) {
      unset($unavailable_display[$key2]);
      variable_set('library_links_display_unavailable', $unavailable_display);
    }
    $key3 = array_search($form_state['values']['aid'], $reference_display);
    if ($key3 !== FALSE) {
      unset($reference_display[$key3]);
      variable_set('library_links_display_reference', $reference_display);
    }
    drupal_set_message(t('The action has been deleted.'));
  }
  elseif ($form_state['values']['op'] == t('Add action')) {
    db_insert('library_actions')
      ->fields(array(
      'name' => check_plain($form_state['values']['name']),
      'status_change' => $form_state['values']['status_change'],
    ))
      ->execute();
    drupal_set_message(t('The action has been added.'));
  }
  $form_state['redirect'] = 'admin/config/workflow/library/actions';
}