You are here

radioactivity_node.install in Radioactivity 5

Same filename and directory in other branches
  1. 6 plugins/radioactivity_node.install

File

plugins/radioactivity_node.install
View source
<?php

// Advanced node popularity install
function radioactivity_node_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {radioactivity_node_clicks} (\n                 nid int NOT NULL,\n                 uid int NOT NULL,\n                 remote_address VARCHAR(31) NOT NULL,\n                 click_timestamp int NOT NULL\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE INDEX {radioactivity_node_clicks_ix_nid_uid}\n                 ON {radioactivity_node_clicks} (nid, uid);");
      db_query("CREATE INDEX {radioactivity_node_clicks_ix_nid_ip}\n                 ON {radioactivity_node_clicks} (nid, remote_address);");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {radioactivity_node_clicks} (\n                 nid int NOT NULL,\n                 uid int NOT NULL,\n                 remote_address VARCHAR(31) NOT NULL,\n                 click_timestamp int NOT NULL\n        );");
      db_query("CREATE INDEX {radioactivity_node_clicks}_ix_nid_uid\n                 ON {radioactivity_node_clicks} (nid, uid);");
      db_query("CREATE INDEX {radioactivity_node_clicks}_ix_nid_ip\n                 ON {radioactivity_node_clicks} (nid, remote_address);");
      break;
  }
}
function radioactivity_node_uninstall() {
  db_query("DROP TABLE {radioactivity_node_clicks}");
  variable_del('radioactivity_node_click_duration');
  if (db_table_exists('radioactivity')) {
    db_query("DELETE FROM {radioactivity} WHERE class='node'");
  }
}