pierre@1: . pierre@1: */ pierre@1: pierre@1: /** pierre@1: * Create the ad_channel schema. pierre@1: */ pierre@1: function ad_channel_install() { pierre@1: switch ($GLOBALS['db_type']) { pierre@1: case 'mysql': pierre@1: case 'mysqli': pierre@1: default: pierre@1: // TODO: PostgreSQL support. Patches welcome. pierre@1: /* The ad_channel table stores channel definitions and rules. pierre@1: */ pierre@1: db_query("CREATE TABLE {ad_channel} ( pierre@1: chid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, pierre@1: name VARCHAR(64) NOT NULL DEFAULT '', pierre@1: description LONGTEXT NULL, pierre@1: conid INT(11) UNSIGNED NOT NULL DEFAULT '0', pierre@1: weight TINYINT(4) SIGNED NOT NULL DEFAULT '0', pierre@1: display TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', pierre@1: urls TEXT NULL, pierre@1: groups TEXT NULL, pierre@1: PRIMARY KEY (chid), pierre@1: KEY (name) pierre@1: );"); pierre@1: /* The ad_channel_container table stores channel container definitions. pierre@1: */ pierre@1: db_query("CREATE TABLE {ad_channel_container} ( pierre@1: conid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, pierre@1: name VARCHAR(64) NOT NULL DEFAULT '', pierre@1: description LONGTEXT NULL, pierre@1: weight TINYINT(4) SIGNED NOT NULL DEFAULT '0', pierre@1: PRIMARY KEY (conid) pierre@1: );"); pierre@1: /* The ad_channel_node table stores per node channel information. pierre@1: */ pierre@1: db_query("CREATE TABLE {ad_channel_node} ( pierre@1: chid INT(11) UNSIGNED NOT NULL DEFAULT '0', pierre@1: nid INT(11) UNSIGNED NOT NULL DEFAULT '0', pierre@1: PRIMARY KEY (chid, nid), pierre@1: KEY (nid, chid) pierre@1: );"); pierre@1: /* The ad_channel_node table stores per node channel information. pierre@1: */ pierre@1: db_query("CREATE TABLE {ad_priority} ( pierre@1: aid INT(11) UNSIGNED NOT NULL DEFAULT '0', pierre@1: priority TINYINT UNSIGNED NOT NULL DEFAULT '0', pierre@1: PRIMARY KEY (aid, priority) pierre@1: );"); pierre@1: } pierre@1: } pierre@1: pierre@1: /** pierre@1: * Completely uninstall the ad channel module. pierre@1: */ pierre@1: function ad_channel_uninstall() { pierre@1: switch ($GLOBALS['db_type']) { pierre@1: case 'mysql': pierre@1: case 'mysqli': pierre@1: default: pierre@1: // TODO: PostgreSQL support. Patches welcome. pierre@1: db_query('DROP TABLE {ad_channel}'); pierre@1: db_query('DROP TABLE {ad_channel_container}'); pierre@1: db_query('DROP TABLE {ad_channel_node}'); pierre@1: } pierre@1: } pierre@1: pierre@1: /** pierre@1: * Populate the ad_priority table. pierre@1: */ pierre@1: function ad_channel_update_6001() { pierre@1: $ret = array(); pierre@1: pierre@1: $result = db_query('SELECT a.aid, p.priority FROM {ads} a LEFT JOIN {ad_priority} p ON a.aid = p.aid'); pierre@1: while ($ad = db_fetch_object($result)) { pierre@1: if (!isset($ad->priority)) { pierre@1: $ret[] = update_sql("INSERT INTO {ad_priority} (aid, priority) VALUES ($ad->aid, 0)"); pierre@1: } pierre@1: } pierre@1: pierre@1: return $ret; pierre@1: } pierre@1: