You are here

fb_app.install in Drupal for Facebook 5

Installs database tables and settings required by fb_app module.

File

fb_app.install
View source
<?php

/**
 * @file
 * Installs database tables and settings required by fb_app module.
 * 
 */

// TODO: some of these tables should be created by othe module install files.
function fb_app_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("\nCREATE TABLE IF NOT EXISTS {fb_app} (\nnid int(11) unsigned NOT NULL,\nlabel varchar(128) NOT NULL,\napikey varchar(128) NOT NULL,\nid varchar(128) NOT NULL,\nsecret varchar(128) NOT NULL,\ncanvas varchar(128) NOT NULL,\nrequire_login int(4) NOT NULL,\ncreate_account int(4) NOT NULL,\nunique_account int(4) NOT NULL,\ndata longtext,\nPRIMARY KEY (nid),\nUNIQUE KEY (apikey)\n) /*!40100 DEFAULT CHARACTER SET UTF8 */;\n");
      db_query("\nCREATE TABLE IF NOT EXISTS {fb_app_block} (\nnid int(11) unsigned NOT NULL,\ndelta varchar(32) NOT NULL,\nformat int(11) DEFAULT 0,\nbody longtext NOT NULL,\nPRIMARY KEY (nid, delta)\n) /*!40100 DEFAULT CHARACTER SET UTF8 */;\n");

      // This table schema has to match the cache_filter table.
      db_query("\nCREATE TABLE {fb_cache_filter} ( \ncid varchar(255) NOT NULL default '', \ndata longblob, \nexpire int NOT NULL default '0', \ncreated int NOT NULL default '0', \nheaders text, \nPRIMARY KEY (cid), \nINDEX expire (expire) \n) /*!40100 DEFAULT CHARACTER SET UTF8 */;\n\n");
  }
  drupal_set_message(t('Facebook Application module installed. Please grant yourself <a href="!perm">permissions</a> and then browse to <a href="!create">Create Content => Facebook Application</a> to get started.', array(
    '!perm' => url('admin/user/access'),
    '!create' => url('node/add/fb-app'),
  )));
}
function fb_app_update_1() {

  // Add id field
  $ret[] = update_sql('ALTER TABLE {fb_app} ADD id varchar(128) NOT NULL');
  return $ret;
}

Functions