You are here

function sharebar_addbutton_submit in ShareBar 7

Same name and namespace in other branches
  1. 6 sharebar.admin.inc \sharebar_addbutton_submit()
  2. 7.2 sharebar.admin.inc \sharebar_addbutton_submit()

Submit handler for hook_addbutton().

File

./sharebar.admin.inc, line 134
Admin page callbacks for the block module.

Code

function sharebar_addbutton_submit($form, &$form_state) {
  if ($form_state['clicked_button']['#value'] == t('Delete')) {
    $form_state['rebuild'] = TRUE;
    $form_state['confirm_delete'] = TRUE;
    return;
  }
  $buttons = unserialize(variable_get('sharebar_buttons', sharebar_buttons_def()));
  if ($form_state['values']['old_machine_name'] != '' && $form_state['values']['old_machine_name'] != $form_state['values']['machine_name']) {
    unset($buttons[$form_state['values']['old_machine_name']]);
  }
  $buttons[$form_state['values']['machine_name']] = new stdClass();
  $buttons[$form_state['values']['machine_name']]->machine_name = $form_state['values']['machine_name'];
  $buttons[$form_state['values']['machine_name']]->name = $form_state['values']['name'];
  $buttons[$form_state['values']['machine_name']]->big_button = $form_state['values']['big_button'];
  $buttons[$form_state['values']['machine_name']]->small_button = $form_state['values']['small_button'];
  $buttons[$form_state['values']['machine_name']]->enabled = $form_state['values']['enabled'];
  $buttons[$form_state['values']['machine_name']]->weight = $form_state['values']['weight'];
  variable_set('sharebar_buttons', serialize($buttons));
  $form_state['redirect'] = 'admin/config/sharebar/settings';
}