You are here

function spambot_update_7101 in Spambot 7

Same name and namespace in other branches
  1. 8 spambot.install \spambot_update_7101()

Update variables, create new table 'node_spambot'.

File

./spambot.install, line 57
Install and update hooks for Spambot module.

Code

function spambot_update_7101() {
  $messages = array();
  variable_del('spambot_user_register_report');
  $messages[] = t('Deleted variable <em>spambot_user_register_report.</em>');
  $message = variable_get('spambot_blocked_message', FALSE);
  if ($message !== FALSE) {
    variable_set('spambot_blocked_message_email', $message);
    variable_set('spambot_blocked_message_username', $message);
    variable_set('spambot_blocked_message_ip', $message);
    variable_del('spambot_blocked_message');
    $messages[] = t('Transferred user registration blocked message to new format.');
  }

  // Create new table node_spambot.
  if (!db_table_exists('node_spambot')) {
    $node_spambot = array(
      'description' => t('Node table to track author IP addresses. For use by spambot only.'),
      'fields' => array(
        'nid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'uid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'hostname' => array(
          'type' => 'varchar',
          'length' => 128,
          'not null' => FALSE,
        ),
      ),
      'primary key' => array(
        'nid',
      ),
      'indexes' => array(
        'uid' => array(
          'uid',
        ),
      ),
    );
    db_create_table('node_spambot', $node_spambot);
    $messages[] = t('Created new table <em>node_spambot</em>.');
  }
  return implode('<br />', $messages);
}