You are here

function shorten_cs_delete_submit in Shorten URLs 7

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

Submits the form to delete a custom service.

1 string reference to 'shorten_cs_delete_submit'
shorten_cs_delete in ./shorten_cs.admin.inc
Builds the form to delete a custom service.

File

./shorten_cs.admin.inc, line 221
Provides the configuration page for Shorten URLs Custom Services.

Code

function shorten_cs_delete_submit($form, $form_state) {
  $service = $form_state['values']['service'];
  if ($service == variable_get('shorten_service', 'is.gd')) {
    if (variable_get('shorten_service_backup', 'TinyURL') == 'is.gd') {
      variable_set('shorten_service', 'TinyURL');
    }
    else {
      variable_set('shorten_service', 'is.gd');
    }
    drupal_set_message(t('The default URL shortening service was deleted, so it has been reset to @service.', array(
      '@service' => variable_get('shorten_service', 'is.gd'),
    )));
  }
  if ($service == variable_get('shorten_service_backup', 'TinyURL')) {
    if (variable_get('shorten_service', 'is.gd') == 'TinyURL') {
      variable_set('shorten_service_backup', 'is.gd');
    }
    else {
      variable_set('shorten_service_backup', 'TinyURL');
    }
    drupal_set_message(t('The backup URL shortening service was deleted, so it has been reset to @service.', array(
      '@service' => variable_get('shorten_service_backup', 'TinyURL'),
    )));
  }
  db_delete('shorten_cs')
    ->condition('name', $service)
    ->execute();
  drupal_set_message(t('The service %service has been deleted.', array(
    '%service' => $service,
  )));
  $_GET['destination'] = 'admin/config/services/shorten/custom';
}