<?php
// $Id$

function mapi_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
        // programs have to be installed in order to use them
        db_query("CREATE TABLE {mapi_programs} (
          name varchar(32) NOT NULL default '',
          path varchar(255) NOT NULL default '',
          settings text
        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");

        // and profiles are used throughout the
        db_query("CREATE TABLE {mapi_profiles} (
          pid int unsigned NOT NULL default '0',
          name varchar(32) NOT NULL default '',
          PRIMARY KEY (pid),
          KEY name (name)
        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");

      break;
    case 'pgsql':
      break;
  }

  // make sure this is the top of the media list
  db_query("UPDATE {system} SET weight = -10 WHERE name = 'mapi'");
}

function mapi_uninstall() {
  // wipe ALL mapi related variables
  db_query("DELETE FROM {variables} WHERE name LIKE 'mapi_%s'");

  // remove the tables.
  db_query("DROP TABLE {mapi_programs}");
  db_query("DROP TABLE {mapi_profiles}");
}
