function sharebar_addbutton_submit in ShareBar 6
Same name and namespace in other branches
- 7.2 sharebar.admin.inc \sharebar_addbutton_submit()
- 7 sharebar.admin.inc \sharebar_addbutton_submit()
Submit handler for hook_addbutton().
File
- ./
sharebar.admin.inc, line 112 - Admin page callbacks for the block module.
Code
function sharebar_addbutton_submit($form, &$form_state) {
if ($form_state['clicked_button']['#value'] == t('Delete')) {
// Rebuild the form to confirm vocabulary deletion.
$form_state['rebuild'] = TRUE;
$form_state['confirm_delete'] = TRUE;
return;
}
$buttons = unserialize(variable_get('sharebar_buttons', sharebar_buttons_def()));
$form_state['values']['machine_name'] = preg_replace('/[^a-z0-9_]+/', '_', $form_state['values']['name']);
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/settings/sharebar';
}