View source
<?php
function ad_channel_schema() {
$schema['ad_channel'] = array(
'description' => 'The ad_channel table allows advertisements to be organized into channels against which rules can be applied.',
'fields' => array(
'chid' => array(
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
'description' => 'Unique channel ID.',
),
'name' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'The name of the channel.',
),
'description' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
'description' => 'A description of the channel.',
),
'conid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
'description' => 'ID of the container the channel is in.',
),
'weight' => array(
'type' => 'int',
'size' => 'medium',
'not null' => TRUE,
'unsigned' => FALSE,
'default' => 0,
'description' => 'Used when displaying channels to admins, heavier weights sink to the bottom.',
),
'display' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'no_channel_percent' => array(
'type' => 'int',
'size' => 'medium',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'inventory' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'urls' => array(
'type' => 'text',
),
'groups' => array(
'type' => 'text',
),
),
'primary key' => array(
'chid',
),
'indexes' => array(
'name' => array(
'name',
),
),
);
$schema['ad_channel_remnant'] = array(
'fields' => array(
'aid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'remnant' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'aid',
'remnant',
),
);
$schema['ad_channel_container'] = array(
'description' => 'The ad_channel_container table stores channel container definitions.',
'fields' => array(
'conid' => array(
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
'description' => 'Unique container ID.',
),
'name' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'The name of the container.',
),
'description' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
'description' => 'A description of the container.',
),
'weight' => array(
'type' => 'int',
'size' => 'medium',
'not null' => TRUE,
'unsigned' => FALSE,
'default' => 0,
'description' => 'Used when displaying channels to admins, heavier weights sink to the bottom.',
),
),
'primary key' => array(
'conid',
),
);
$schema['ad_channel_node'] = array(
'description' => 'The ad_channel_node table stores per node channel information.',
'fields' => array(
'chid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'chid',
'nid',
),
'indexes' => array(
'nid_chid' => array(
'nid',
'chid',
),
),
);
$schema['ad_priority'] = array(
'fields' => array(
'aid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'priority' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'aid',
'priority',
),
);
return $schema;
}
function ad_channel_install() {
}
function ad_channel_uninstall() {
}
function ad_channel_update_6001() {
$ret = array();
$result = db_query('SELECT a.aid, p.priority FROM {ads} a LEFT JOIN {ad_priority} p ON a.aid = p.aid');
while ($ad = $result
->fetch()) {
if (!isset($ad->priority)) {
$ret[] = update_sql("INSERT INTO {ad_priority} (aid, priority) VALUES ({$ad->aid}, 0)");
}
}
return $ret;
}
function ad_channel_update_6002() {
cache_clear_all();
menu_rebuild();
return array();
}
function ad_channel_update_6003() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {ad_channel} ADD no_channel_weight INT(3) NOT NULL DEFAULT '0'");
return $ret;
}
function ad_channel_update_6004() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {ad_channel} CHANGE COLUMN no_channel_weight no_channel_percent INT(3) NOT NULL DEFAULT '0'");
$ret[] = update_sql("UPDATE {ad_channel} SET no_channel_percent=20 WHERE no_channel_percent=25");
$ret[] = update_sql("UPDATE {ad_channel} SET no_channel_percent=25 WHERE no_channel_percent=33");
$ret[] = update_sql("UPDATE {ad_channel} SET no_channel_percent=35 WHERE no_channel_percent=50");
$ret[] = update_sql("UPDATE {ad_channel} SET no_channel_percent=50 WHERE no_channel_percent=100");
$ret[] = update_sql("UPDATE {ad_channel} SET no_channel_percent=65 WHERE no_channel_percent=200");
$ret[] = update_sql("UPDATE {ad_channel} SET no_channel_percent=75 WHERE no_channel_percent=300");
$ret[] = update_sql("UPDATE {ad_channel} SET no_channel_percent=80 WHERE no_channel_percent=400");
return $ret;
}
function ad_channel_update_6005() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {ad_channel} ADD inventory INT(11)");
$ret[] = update_sql("CREATE TABLE {ad_channel_remnant} (aid INT(11) UNSIGNED NOT NULL DEFAULT '0', remnant TINYINT UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (aid, remnant))");
return $ret;
}
function ad_channel_update_6006() {
$ret = array();
db_change_field($ret, 'ad_channel', 'weight', 'weight', array(
'type' => 'int',
'size' => 'medium',
'not null' => TRUE,
'unsigned' => FALSE,
'default' => 0,
'description' => 'Used when displaying channels to admins, heavier weights sink to the bottom.',
));
db_change_field($ret, 'ad_channel_container', 'weight', 'weight', array(
'type' => 'int',
'size' => 'medium',
'not null' => TRUE,
'unsigned' => FALSE,
'default' => 0,
'description' => 'Used when displaying channels to admins, heavier weights sink to the bottom.',
));
return $ret;
}