You are here

signature_forum.install in Signatures for Forums 5

File

signature_forum.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function signature_forum_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {users_signature} (\n        uid int NOT NULL default '0',\n        signature text,\n        PRIMARY KEY (uid)\n        ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {users_signature} (\n        uid int NOT NULL default '0',\n        signature text,\n        PRIMARY KEY (uid)\n        )");
      break;
  }
}

/**
 * Implementation of hook_uninstall().
 */
function signature_forum_uninstall() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("UPDATE {users}, {users_signature}\n        SET {users}.signature={users_signature}.signature\n        WHERE {users}.uid={users_signature}.uid");
      break;
    case 'pgsql':
      db_query("UPDATE {users} SET signature={users_signature}.signature FROM {users_signature}\n        WHERE {users}.uid={users_signature}.uid");
      break;
  }
  db_query("DROP TABLE {users_signature}");
  variable_del('signature_forum_settings');
}

/**
 * Implementation of hook_update().
 */
function signature_forum_update_1() {
  $ret = array();

  // Get values and put into new array structure
  foreach (node_get_types('names') as $type => $name) {
    $settings['signature_forum_show_for_' . $type] = variable_get('signature_forum_show_for_' . $type, 0);
    variable_del('signature_forum_show_for_' . $type);
  }
  $settings['signature_forum_template'] = variable_get('signature_forum_template', "__________________\n<p>%s</p>");
  $settings['signature_forum_format'] = variable_get('signature_forum_format', FILTER_FORMAT_DEFAULT);
  $settings['signature_forum_line_limit'] = variable_get('signature_forum_line_limit', 0);
  $settings['signature_forum_min_content_length'] = variable_get('signature_forum_min_content_length', 0);
  $settings['signature_forum_min_content_length_action'] = variable_get('signature_forum_min_content_length_action', 0);
  $settings['signature_forum_min_content_length_filter'] = variable_get('signature_forum_min_content_length_filter', FILTER_FORMAT_DEFAULT);
  variable_set('signature_forum_settings', $settings);

  // Delete values
  variable_del('signature_forum_template');
  variable_del('signature_forum_format');
  variable_del('signature_forum_line_limit');
  variable_del('signature_forum_min_content_length');
  variable_del('signature_forum_min_content_length_action');
  variable_del('signature_forum_min_content_length_filter');
  variable_del('signature_forum_roles');
  return $ret;
}

/**
 * Implementation of hook_update().
 */
function signature_forum_update_2() {
  $ret = array();

  // We only bother to update MySQL here, before this version PostgreSQL didn't work
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {users_signature} MODIFY uid integer");
      $ret[] = update_sql("ALTER TABLE {users_signature} MODIFY signature text default NULL");
      break;
  }
  return $ret;
}

Functions

Namesort descending Description
signature_forum_install Implementation of hook_install().
signature_forum_uninstall Implementation of hook_uninstall().
signature_forum_update_1 Implementation of hook_update().
signature_forum_update_2 Implementation of hook_update().