You are here

function apachesolr_delete_index_form_submit in Apache Solr Search 5

Same name and namespace in other branches
  1. 5.2 apachesolr.admin.inc \apachesolr_delete_index_form_submit()

File

./apachesolr.module, line 230
Integration with the Apache Solr search application.

Code

function apachesolr_delete_index_form_submit($form, $form_values) {
  if ($form_values['delete_index']) {
    try {

      // Instantiate a new Solr object.
      $solr =& apachesolr_get_solr(variable_get('apachesolr_host', 'localhost'), variable_get('apachesolr_port', 8983), variable_get('apachesolr_path', '/solr'));

      // TODO: Add site so that you can only delete your site's content.
      $solr
        ->deleteByQuery('*:*');
      $solr
        ->commit();
      variable_del('apachesolr_last_change');
      variable_del('apachesolr_last_id');

      // This form can't be seen by anyone without 'administer site configuration'
      // permission, so no need to check perms before displaying a run-cron link.
      drupal_set_message(t('The Solr content index has been erased. You must now !run_cron until your entire site has been re-indexed.', array(
        '!run_cron' => l(t('run cron'), 'admin/logs/status/run-cron', array(
          'fragment' => 'module-user',
        )),
      )));
    } catch (Exception $e) {
      watchdog('Apache Solr', $e
        ->getMessage(), WATCHDOG_ERROR);
    }
  }
}