You are here

function support_install in Support Ticketing System 6

Same name and namespace in other branches
  1. 7 support.install \support_install()

Install support database schema.

File

./support.install, line 354

Code

function support_install() {

  // Check if we're upgrading a previous jobtrack installation.
  if (db_table_exists('jobtrack_client')) {
    $ret = array();
    db_rename_table($ret, 'jobtrack_client', 'support_client');
    db_rename_table($ret, 'jobtrack_ticket', 'support_ticket');
    db_rename_table($ret, 'jobtrack_ticket_comment', 'support_ticket_comment');
    db_rename_table($ret, 'jobtrack_assigned', 'support_assigned');
    db_rename_table($ret, 'jobtrack_states', 'support_states');
    db_rename_table($ret, 'jobtrack_priority', 'support_priority');
    db_query("UPDATE {node} SET type = 'support_ticket' WHERE type = 'jobtrack_ticket'");
    cache_clear_all();
    menu_rebuild();
  }
  else {
    drupal_install_schema('support');

    // default
    db_query("INSERT INTO {support_states} (state, weight, phase1, phase2, isdefault) VALUES('new', 0, 1, 0, 1)");
    db_query("INSERT INTO {support_states} (state, weight, phase1, phase2) VALUES('active', 1, 0, 1)");
    db_query("INSERT INTO {support_states} (state, weight, phase1, phase2) VALUES('pending', 2, 0, 1)");
    db_query("INSERT INTO {support_states} (state, weight, phase1, phase2, isclosed) VALUES('closed', 3, 0, 1, 1)");

    // default priorities
    db_query("INSERT INTO {support_priority} (priority, weight) VALUES('low', 0)");
    db_query("INSERT INTO {support_priority} (priority, weight, isdefault) VALUES('normal', 1, 1)");
    db_query("INSERT INTO {support_priority} (priority, weight) VALUES('high', 2)");
    db_query("INSERT INTO {support_priority} (priority, weight) VALUES('critical', 3)");

    // default comment settings
    variable_set('comment_default_mode_support_ticket', COMMENT_MODE_THREADED_EXPANDED);
    variable_set('comment_default_order_support_ticket', COMMENT_ORDER_OLDEST_FIRST);

    // Set default weight
    db_query("UPDATE {system} SET weight = 10 WHERE name = 'support'");
  }
}