You are here

elysia_cron.install in Elysia Cron 5

File

elysia_cron.install
View source
<?php

// $Id: elysia_cron.install,v 1.1.4.4 2009/03/17 17:15:56 gotheric Exp $

/**
 * Implementation of hook_install().
 */
function elysia_cron_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("create table if not exists {elysia_cron} (\n          name varchar(120) not null,\n          disable tinyint(1),\n          rule varchar(32),\n          weight int(11),\n          context varchar(32),\n          running int(11) not null default '0',\n          last_run int(11) not null default '0',\n          last_aborted tinyint(1) not null default '0',\n          abort_count int(11) not null default '0',\n          last_abort_function varchar(32),\n          last_execution_time int(11) not null default '0',\n          execution_count int(11) not null default '0',\n          avg_execution_time float(5,2) not null default '0',\n          max_execution_time int(11) not null default '0',\n          last_shutdown_time int(11) not null default '0',\n          primary key (name)\n        )");
      break;
    case 'pgsql':
      db_query("create table {elysia_cron} (\n          name varchar(120) not null,\n          disable smallint,\n          rule varchar(32),\n          weight integer,\n          context varchar(32),\n          running integer not null default '0',\n          last_run integer not null default '0',\n          last_aborted smallint not null default '0',\n          abort_count integer not null default '0',\n          last_abort_function varchar(32),\n          last_execution_time integer not null default '0',\n          execution_count integer not null default '0',\n          avg_execution_time float not null default '0',\n          max_execution_time integer not null default '0',\n          last_shutdown_time integer not null default '0',\n          primary key (name)\n        )");
  }

  // elysia_cron MUST be the first returned by module_list
  // This is to ensure elysia_cron_cron is the first hook called by standard cron.php.
  $min = db_result(db_query("select min(weight) from {system}"));
  if ($min > -65535) {
    $min = -65535;
  }
  else {
    $min--;
  }
  db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", $min, 'elysia_cron');
  variable_set('elysia_cron_version', 20100507);
  drupal_set_message('Elysia cron installed. Setup could be found at ' . l(t('Settings page'), 'admin/build/cron/settings') . '. See INSTALL.TXT for more info.');
}

/**
 * Implementation of hook_uninstall().
 */
function elysia_cron_uninstall() {
  $rs = db_query("select name from {variable} where name like 'elysia_cron_%%'");
  while ($o = db_fetch_object($rs)) {
    variable_del($o->name);
  }
  $rs = db_query("select name from {variable} where name like 'ec_%%'");
  while ($o = db_fetch_object($rs)) {
    if (preg_match('/^ec_.*_[a-z]{1,3}$/', $o->name)) {
      variable_del($o->name);
    }
  }
  $rs = db_query("select name from {variable} where name like 'ecc_%%'");
  while ($o = db_fetch_object($rs)) {
    if (preg_match('/^ecc_.*_[a-z]{1,3}$/', $o->name)) {
      variable_del($o->name);
    }
  }
  drupal_set_message('Elysia cron uninstalled.');
}
function elysia_cron_update_1() {
  $cron_key = variable_get('elysia_cron_key', false);
  if ($cron_key) {
    variable_set('cron_key', $cron_key);
  }
  variable_del('elysia_cron_key');
  return array();
}

Functions

Namesort descending Description
elysia_cron_install Implementation of hook_install().
elysia_cron_uninstall Implementation of hook_uninstall().
elysia_cron_update_1