You are here

function botcha_install in BOTCHA Spam Prevention 6.3

Same name and namespace in other branches
  1. 6 botcha.install \botcha_install()
  2. 6.2 botcha.install \botcha_install()
  3. 7.4 botcha.install \botcha_install()
  4. 7 botcha.install \botcha_install()
  5. 7.2 botcha.install \botcha_install()
  6. 7.3 botcha.install \botcha_install()

Implementation of hook_install().

File

./botcha.install, line 208

Code

function botcha_install() {

  // This enables autoload magic.
  autoload_flush_caches();
  $dependencies = array(
    'autoload',
    'dbtng',
  );
  foreach ($dependencies as $module) {
    module_invoke($module, 'boot');
  }
  $t = get_t();
  drupal_install_schema('botcha');
  $i18n_variables = variable_get('i18n_variables', '');
  if (!is_array($i18n_variables)) {
    $i18n_variables = array();
  }
  $i18n_variables = array_merge($i18n_variables, _botcha_variables(TRUE));
  variable_set('i18n_variables', $i18n_variables);

  /* @todo Find a way to force autoloading of Botcha class during Simpletest is installing Botcha.
    // Be friendly to your users: what to do after install?
    drupal_set_message($t('You can now <a href="@botcha_admin">configure BOTCHA module</a> for your site.',
      array('@botcha_admin' => url(Botcha::ADMIN_PATH))), 'status');
     *
     */

  // Explain to users that page caching may be disabled.
  if (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED) {
    drupal_set_message($t('Note that BOTCHA module disables <a href="%performance_admin">page caching</a> of pages that include forms processed by BOTCHA. ', array(
      '%performance_admin' => url('admin/settings/performance'),
    )), 'warning');
  }

  // Generate unique secret for this site
  variable_set('botcha_secret', md5(uniqid(mt_rand(), TRUE)));

  // Ensure statistics variables exist
  variable_set('botcha_form_passed_counter', variable_get('botcha_form_passed_counter', 0));
  variable_set('botcha_form_blocked_counter', variable_get('botcha_form_blocked_counter', 0));

  // DRY: Re-use once written.
  botcha_update_6200();
  botcha_update_6201();

  // Clear the cache to get updates to menu router and themes.
  cache_clear_all();
}