You are here

url_redirect_delete.inc in Url Redirect 7

Deletes Redirect URL.

File

url_redirect_delete.inc
View source
<?php

/**
 * @file
 * Deletes Redirect URL.
 */

/**
 * Implements deletion form.
 */
function url_redirect_delete_form($form, &$form_state) {
  $parameters = drupal_get_query_parameters();
  $delete_path = check_plain($parameters['path']);
  $path_data = url_redirect_path_edit($delete_path);
  if ($path_data) {
    $form['output'] = array(
      '#markup' => t("Are you to delete " . $delete_path . '? <br>'),
    );
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
    );
    $form['no'] = array(
      '#type' => 'submit',
      '#value' => t('No'),
    );
    return $form;
  }
  else {
    drupal_set_message(t('Path specified is not correct for deletion.'), 'error');
  }
}

/**
 * Implements delete operation for selected URL.
 */
function url_redirect_delete_form_submit($form, &$form_state) {
  if ($form_state['values']['op'] == $form_state['values']['no']) {
    drupal_goto('admin/config/url_redirect/list');
  }
  if ($form_state['values']['op'] == $form_state['values']['delete']) {
    $delete_path = check_plain($_GET['path']);
    db_delete('url_redirect')
      ->condition('path', $delete_path)
      ->execute();
    drupal_set_message(t("The path '@path' is deleted.", array(
      '@path' => $delete_path,
    )));
    drupal_goto('admin/config/url_redirect/list');
  }
}

Functions

Namesort descending Description
url_redirect_delete_form Implements deletion form.
url_redirect_delete_form_submit Implements delete operation for selected URL.