annotate image/ad_image.install @ 2:e5584a19768b ad

maj module ad
author sly
date Wed, 15 Apr 2009 07:58:32 +0000
parents 948362c2a207
children
rev   line source
pierre@0 1 <?php
sly@2 2 // $Id: ad_image.install,v 1.2.2.2.2.6.2.4.2.3 2009/04/02 15:48:29 jeremy Exp $
pierre@0 3
pierre@0 4 /**
pierre@0 5 * @file
pierre@0 6 * Ad_image module database schema.
pierre@0 7 *
pierre@0 8 * Copyright (c) 2005-2009.
pierre@0 9 * Jeremy Andrews <jeremy@tag1consulting.com>.
pierre@0 10 */
pierre@0 11
pierre@0 12 /**
pierre@0 13 * Implementation of hook_schema().
pierre@0 14 */
pierre@0 15 function ad_image_schema() {
pierre@0 16 $schema['ad_image'] = array(
pierre@0 17 'description' => 'The ad_image table stores image information such as file ID, title, width, height of corresponding image ads.',
pierre@0 18 'fields' => array(
pierre@0 19 'aid' => array(
pierre@0 20 'type' => 'int',
pierre@0 21 'unsigned' => TRUE,
pierre@0 22 'not null' => TRUE,
pierre@0 23 'default' => 0,
pierre@0 24 ),
pierre@0 25 'fid' => array(
pierre@0 26 'type' => 'int',
pierre@0 27 'unsigned' => TRUE,
pierre@0 28 'not null' => TRUE,
pierre@0 29 'default' => 0,
pierre@0 30 ),
pierre@0 31 'url' => array(
pierre@0 32 'type' => 'varchar',
pierre@0 33 'length' => '255',
pierre@0 34 'not null' => TRUE,
pierre@0 35 'default' => '',
pierre@0 36 ),
pierre@0 37 'tooltip' => array(
pierre@0 38 'type' => 'varchar',
pierre@0 39 'length' => '255',
pierre@0 40 'not null' => TRUE,
pierre@0 41 'default' => '',
pierre@0 42 ),
pierre@1 43 'remote_image' => array(
pierre@1 44 'type' => 'varchar',
pierre@1 45 'length' => '255',
pierre@1 46 'not null' => TRUE,
pierre@1 47 'default' => '',
pierre@1 48 ),
pierre@0 49 'width' => array(
pierre@0 50 'type' => 'int',
pierre@0 51 'unsigned' => TRUE,
pierre@0 52 'not null' => TRUE,
pierre@0 53 'default' => 0,
pierre@0 54 ),
pierre@0 55 'height' => array(
pierre@0 56 'type' => 'int',
pierre@0 57 'unsigned' => TRUE,
pierre@0 58 'not null' => TRUE,
pierre@0 59 'default' => 0,
pierre@0 60 ),
pierre@0 61 ),
pierre@0 62 'unique keys' => array(
pierre@0 63 'aid' => array('aid')
pierre@0 64 ),
pierre@0 65 );
pierre@0 66 $schema['ad_image_format'] = array(
pierre@0 67 'description' => 'The ad_image_format table stores dimensions for image ads.',
pierre@0 68 'fields' => array(
pierre@0 69 'gid' => array(
pierre@0 70 'type' => 'int',
pierre@0 71 'unsigned' => TRUE,
pierre@0 72 'not null' => TRUE,
pierre@0 73 ),
pierre@0 74 'min_width' => array(
pierre@0 75 'type' => 'int',
pierre@0 76 'unsigned' => TRUE,
pierre@0 77 'not null' => TRUE,
pierre@0 78 'default' => 0,
pierre@0 79 ),
pierre@0 80 'max_width' => array(
pierre@0 81 'type' => 'int',
pierre@0 82 'unsigned' => TRUE,
pierre@0 83 'not null' => TRUE,
pierre@0 84 'default' => 0,
pierre@0 85 ),
pierre@0 86 'min_height' => array(
pierre@0 87 'type' => 'int',
pierre@0 88 'unsigned' => TRUE,
pierre@0 89 'not null' => TRUE,
pierre@0 90 'default' => 0,
pierre@0 91 ),
pierre@0 92 'max_height' => array(
pierre@0 93 'type' => 'int',
pierre@0 94 'unsigned' => TRUE,
pierre@0 95 'not null' => TRUE,
pierre@0 96 'default' => 0,
pierre@0 97 ),
sly@2 98 'max_size' => array(
sly@2 99 'type' => 'int',
sly@2 100 'unsigned' => TRUE,
sly@2 101 'not null' => TRUE,
sly@2 102 'default' => 0,
sly@2 103 ),
pierre@0 104 ),
pierre@0 105 'primary key' => array('gid'),
pierre@0 106 );
pierre@0 107
pierre@0 108 return $schema;
pierre@0 109 }
pierre@0 110
pierre@0 111
pierre@0 112 /**
pierre@0 113 * ad_image module installation.
pierre@0 114 */
pierre@0 115 function ad_image_install() {
pierre@0 116 drupal_install_schema('ad_image');
pierre@0 117 }
pierre@0 118
pierre@0 119 /**
pierre@0 120 * Allow complete uninstallation of the ad_image module.
pierre@0 121 */
pierre@0 122 function ad_image_uninstall() {
pierre@0 123 // Delete all ad_image content.
pierre@0 124 $result = db_query("SELECT aid FROM {ad_image}");
pierre@0 125 while ($aid = db_result($result)) {
pierre@0 126 node_delete($aid);
pierre@0 127 }
pierre@0 128
pierre@0 129 // Remove tables.
pierre@0 130 drupal_uninstall_schema('ad_image');
pierre@0 131 }
pierre@1 132
pierre@1 133 /**
pierre@1 134 * Introduce remote_image field for remotely hosted images.
pierre@1 135 */
pierre@1 136 function ad_image_update_6001() {
pierre@1 137 $ret = array();
pierre@1 138 db_add_field($ret, 'ad_image', 'remote_image',
pierre@1 139 array(
pierre@1 140 'type' => 'varchar',
pierre@1 141 'length' => '255',
pierre@1 142 'not null' => TRUE,
pierre@1 143 'default' => '',
pierre@1 144 ));
pierre@1 145 return $ret;
pierre@1 146 }
sly@2 147
sly@2 148 /**
sly@2 149 * Introduce remote_image field for remotely hosted images.
sly@2 150 */
sly@2 151 function ad_image_update_6002() {
sly@2 152 $ret = array();
sly@2 153 db_add_field($ret, 'ad_image_format', 'max_size',
sly@2 154 array(
sly@2 155 'type' => 'int',
sly@2 156 'unsigned' => TRUE,
sly@2 157 'not null' => TRUE,
sly@2 158 'default' => '0',
sly@2 159 ));
sly@2 160 return $ret;
sly@2 161 }