You are here

function hansel_ui_delete_rule_form in Hansel breadcrumbs 7

Same name and namespace in other branches
  1. 8 hansel_ui/hansel_ui.module \hansel_ui_delete_rule_form()

Menu callback for the delete rule form.

1 string reference to 'hansel_ui_delete_rule_form'
_hansel_ui_menu in hansel_ui/hansel_ui.registry.inc
Registry function for hook_menu().

File

hansel_ui/hansel_ui.module, line 634
Hansel UI module

Code

function hansel_ui_delete_rule_form($form, &$form_state, $rid) {
  $form = array();
  $form['#rid'] = $rid;
  $sql = "SELECT r.name, (SELECT COUNT(*) FROM {hansel_rule} r2 WHERE r2.pid = r.rid) as children\n    FROM {hansel_rule} r WHERE r.rid = :rid";
  $res = db_query($sql, array(
    ':rid' => $rid,
  ))
    ->fetchObject();
  if (!($rule = $res)) {
    drupal_set_message(t('Rule not found'), 'error');
    drupal_goto('admin/config/search/hansel');
  }
  if ($rule->children) {
    $form['info'] = array(
      '#markup' => '<p>' . t('Are you sure you want to delete rule %rule with all its child rules?', array(
        '%rule' => $rule->name,
      )) . '</p>',
    );
  }
  else {
    $form['info'] = array(
      '#markup' => '<p>' . t('Are you sure you want to delete rule %rule?', array(
        '%rule' => $rule->name,
      )) . '</p>',
    );
  }
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
  );
  $form['buttons']['cancel'] = array(
    '#markup' => l(t('Cancel'), 'admin/config/search/hansel'),
  );
  return $form;
}