You are here

function cleantalk_install in Anti Spam by CleanTalk 7.2

Same name and namespace in other branches
  1. 8 cleantalk.module \cleantalk_install()
  2. 7.5 cleantalk.install \cleantalk_install()
  3. 7 cleantalk.module \cleantalk_install()
  4. 7.4 cleantalk.install \cleantalk_install()

Implements hook_install().

File

./cleantalk.install, line 11
Install and uninstall functions for the CleanTalk module.

Code

function cleantalk_install() {
  variable_set('ct_sfw_last_logs_sent', time());
  variable_set('ct_sfw_last_updated', time());
  db_drop_table('cleantalk_timelabels');
  $cleantalk_timelabels = array(
    'description' => 'Timelabels for admin notification sending.',
    'fields' => array(
      'ct_key' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Notification ID.',
      ),
      'ct_value' => array(
        'type' => 'int',
        'length' => 12,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Time of last notification.',
      ),
    ),
    'primary key' => array(
      'ct_key',
    ),
  );
  db_create_table('cleantalk_timelabels', $cleantalk_timelabels);
  db_drop_table('cleantalk_cids');
  $cleantalk_cids = array(
    'description' => 'Comment checking results - CIDs and server responces.',
    'fields' => array(
      'cid' => array(
        'type' => 'int',
        'length' => 12,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'ID of checked comment.',
      ),
      'ct_request_id' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'CleanTalk request ID for comment.',
      ),
      'ct_result_comment' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'CleanTalk result for comment.',
      ),
    ),
    'primary key' => array(
      'cid',
    ),
  );
  db_create_table('cleantalk_cids', $cleantalk_cids);
  db_drop_table('cleantalk_uids');
  $cleantalk_uids = array(
    'description' => 'New user checking results - UIDs and server responces.',
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'length' => 12,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'ID of checked user registration.',
      ),
      'ct_request_id' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'CleanTalk request ID for user registration.',
      ),
      'ct_result_comment' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'CleanTalk result for user registration.',
      ),
    ),
    'primary key' => array(
      'uid',
    ),
  );
  db_create_table('cleantalk_uids', $cleantalk_uids);
  db_drop_table('cleantalk_sfw');
  $cleantalk_sfw = array(
    'description' => 'SpamFireWall data.',
    'fields' => array(
      'network' => array(
        'type' => 'int',
        'length' => 11,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Spam network.',
      ),
      'mask' => array(
        'type' => 'int',
        'length' => 11,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Spam mask.',
      ),
    ),
    'primary key' => array(
      'network',
      'mask',
    ),
  );
  db_create_table('cleantalk_sfw', $cleantalk_sfw);
  db_drop_table('cleantalk_sfw_logs');
  $cleantalk_sfw_logs = array(
    'description' => 'Comment checking results - CIDs and server responces.',
    'fields' => array(
      'ip' => array(
        'type' => 'varchar',
        'length' => 15,
        'not null' => TRUE,
        'default' => '',
        'description' => 'IP.',
      ),
      'all' => array(
        'type' => 'int',
        'description' => 'All entries.',
      ),
      'blocked' => array(
        'type' => 'int',
        'description' => 'Blocked entries.',
      ),
      'timestamp' => array(
        'type' => 'int',
        'description' => 'time().',
      ),
    ),
    'primary key' => array(
      'ip',
    ),
  );
  db_create_table('cleantalk_sfw_logs', $cleantalk_sfw_logs);
  $myRoles = array(
    'spammer',
  );
  $roles = user_roles();
  $myRole = new stdClass();
  foreach ($myRoles as $r) {
    if (!in_array($r, $roles)) {
      $myRole->name = $r;
      user_role_save($myRole);
    }
  }
}