| 1 |
<?php
|
| 2 |
// $Id: ad_ubercart.install,v 1.6 2009/04/19 19:04:15 neochief Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Ad_html module database schema.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* ad_ubercart module installation.
|
| 11 |
*/
|
| 12 |
function ad_ubercart_schema() {
|
| 13 |
$schema['ad_quota'] = array(
|
| 14 |
'fields' => array(
|
| 15 |
'month' => array(
|
| 16 |
'type' => 'varchar',
|
| 17 |
'length' => 10,
|
| 18 |
'not null' => TRUE
|
| 19 |
),
|
| 20 |
'daily' => array(
|
| 21 |
'type' => 'int',
|
| 22 |
'not null' => TRUE,
|
| 23 |
'description' => t('Allowed quota of daily plans by month.'),
|
| 24 |
),
|
| 25 |
'monthly' => array(
|
| 26 |
'type' => 'int',
|
| 27 |
'not null' => TRUE,
|
| 28 |
'description' => t('Allowed quota of monthly plans by month.'),
|
| 29 |
),
|
| 30 |
),
|
| 31 |
'primary key' => array('month'),
|
| 32 |
);
|
| 33 |
$schema['ad_used_quota'] = array(
|
| 34 |
'fields' => array(
|
| 35 |
'nid' => array(
|
| 36 |
'type' => 'int',
|
| 37 |
'not null' => TRUE
|
| 38 |
),
|
| 39 |
'order_id' => array(
|
| 40 |
'type' => 'int',
|
| 41 |
'not null' => TRUE
|
| 42 |
),
|
| 43 |
'type' => array(
|
| 44 |
'type' => 'varchar',
|
| 45 |
'length' => 100,
|
| 46 |
'not null' => TRUE
|
| 47 |
),
|
| 48 |
'date' => array(
|
| 49 |
'type' => 'varchar',
|
| 50 |
'length' => 10,
|
| 51 |
'not null' => TRUE
|
| 52 |
),
|
| 53 |
),
|
| 54 |
);
|
| 55 |
$schema['ad_orders'] = array(
|
| 56 |
'fields' => array(
|
| 57 |
'order_id' => array(
|
| 58 |
'type' => 'int',
|
| 59 |
'not null' => TRUE,
|
| 60 |
'description' => t('Order ID.'),
|
| 61 |
),
|
| 62 |
'order_product_id' => array(
|
| 63 |
'type' => 'int',
|
| 64 |
'not null' => TRUE,
|
| 65 |
'description' => t('Order product ID.'),
|
| 66 |
),
|
| 67 |
'aid' => array(
|
| 68 |
'type' => 'int',
|
| 69 |
'not null' => TRUE,
|
| 70 |
'description' => t('NID of Advertisement linked to order item.'),
|
| 71 |
),
|
| 72 |
'paid' => array(
|
| 73 |
'type' => 'int',
|
| 74 |
'size' => 'tiny',
|
| 75 |
'not null' => TRUE,
|
| 76 |
'description' => t('Paid or not.'),
|
| 77 |
),
|
| 78 |
),
|
| 79 |
'primary key' => array('order_product_id', 'aid'),
|
| 80 |
);
|
| 81 |
return $schema;
|
| 82 |
}
|
| 83 |
|
| 84 |
/**
|
| 85 |
* ad_ubercart module installation.
|
| 86 |
*/
|
| 87 |
function ad_ubercart_install() {
|
| 88 |
drupal_install_schema('ad_ubercart');
|
| 89 |
db_query("INSERT INTO {uc_product_classes} (pcid, name, description) VALUES ('%s', '%s', '%s')", 'ad_product_daily', 'Ad product: daily', 'Ad product');
|
| 90 |
db_query("INSERT INTO {uc_product_classes} (pcid, name, description) VALUES ('%s', '%s', '%s')", 'ad_product_monthly', 'Ad product: monthly', 'Ad product');
|
| 91 |
// disabling comments by default
|
| 92 |
variable_set('comment_ad_product_daily', 0);
|
| 93 |
variable_set('comment_ad_product_monthly', 0);
|
| 94 |
// ...and not promoting ads to front page
|
| 95 |
variable_set('node_options_ad_product_daily', array('status'));
|
| 96 |
variable_set('node_options_ad_product_monthly', array('status'));
|
| 97 |
// ...and not displaying useless Ubercart fields
|
| 98 |
variable_set('uc_product_field_enabled', array(
|
| 99 |
'model' => 0,
|
| 100 |
'image' => 0,
|
| 101 |
'display_price' => 0,
|
| 102 |
'list_price' => 0,
|
| 103 |
'cost' => 0,
|
| 104 |
'sell_price' => 1,
|
| 105 |
'weight' => 0,
|
| 106 |
'dimensions' => 0,
|
| 107 |
'add_to_cart' => variable_get('uc_product_add_to_cart_text', t('Add to cart')),
|
| 108 |
));
|
| 109 |
}
|
| 110 |
|
| 111 |
/**
|
| 112 |
* Allow complete uninstallation of the ad_html module.
|
| 113 |
*/
|
| 114 |
function ad_ubercart_uninstall() {
|
| 115 |
// Remove tables.
|
| 116 |
drupal_uninstall_schema('ad_ubercart');
|
| 117 |
db_query("DELETE FROM {uc_product_classes} WHERE pcid = 'ad_product_daily' OR pcid = 'ad_product_monthly'");
|
| 118 |
}
|
| 119 |
|
| 120 |
function ad_ubercart_update_6001() {
|
| 121 |
$ret = array();
|
| 122 |
db_change_field($ret, 'ad_used_quota', 'oid', 'order_id', array('type' => 'int', 'not null' => TRUE));
|
| 123 |
return $ret;
|
| 124 |
}
|