? ad_flash/activecontent_samples.zip
? ad_flash/scripts
Index: ad_flash/ad_flash.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/ad_flash/ad_flash.install,v
retrieving revision 1.1.4.1
diff -u -r1.1.4.1 ad_flash.install
--- ad_flash/ad_flash.install	20 Apr 2009 08:47:18 -0000	1.1.4.1
+++ ad_flash/ad_flash.install	22 Sep 2009 18:22:18 -0000
@@ -5,58 +5,129 @@
  * Ad_image module database schema.
  * 
  *
- * Based on the ad_image.module by Jeremy Andrews
+ * Based on the ad_image.module by Jeremy Andrews.
+ * Schema update for schema API by Pekka L.J. Jalkanen.
+ *
+ * Copyright (c) 2009
+ *   Pekka L.J. Jalkanen <plj@iki.fi>.
  *
  * Copyright (c) 2007
- *   Fabio Varesano <fvaresano at yahoo dot it> All rights reserved.
+ *   Fabio Varesano <fvaresano at yahoo dot it>.
  *
  * Copyright (c) 2005-2007.
- *   Jeremy Andrews <jeremy@kerneltrap.org>.  All rights reserved.
+ *   Jeremy Andrews <jeremy@tag1consulting.com>.
  */
 
-function ad_flash_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-    default:
+function ad_flash_schema() {
 
-      /**
-       * The ad_flash_format table provides format guidelines for a given group
-       * of image ads.
-       */
-      db_query("CREATE TABLE {ad_flash_format} (
-        gid INT(10) UNSIGNED NOT NULL UNIQUE,
-
-        min_width INT(5) UNSIGNED NOT NULL DEFAULT '0',
-        max_width INT(5) UNSIGNED NOT NULL DEFAULT '0',
-        min_height INT(5) UNSIGNED NOT NULL DEFAULT '0',
-        max_height INT(5) UNSIGNED NOT NULL DEFAULT '0',
-
-        PRIMARY KEY (gid)) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      /**
-       * The ad_flash table stores information about each image ad.
-       */
-      db_query("CREATE TABLE {ad_flash} (
-        aid INT(10) UNSIGNED NOT NULL DEFAULT '0',
-        fid INT(10) UNSIGNED NOT NULL DEFAULT '0',
-
-        url VARCHAR(255) NOT NULL DEFAULT '',
-        width INT UNSIGNED NOT NULL DEFAULT '0',
-        height INT UNSIGNED NOT NULL DEFAULT '0',
-
-        UNIQUE KEY (aid)) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-  }
+  /**
+   * The ad_flash table stores information about each image ad.
+   */
+  $schema['ad_flash'] = array(
+    'description' => 'The ad_flash table stores information about each image ad.',
+    'fields' => array(
+      'aid' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'default' => 0,
+        'description' => 'Ad ID. Equals to ad\'s node ID.',
+      ),
+      'fid' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'default' => 0,
+        'description' => 'File ID. Equals to file ID of the flash file.',
+      ),
+      'url' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+        'description' => 'Ad URL',
+      ),
+      'width' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'default' => 0,
+        'description' => 'Width of the flash file.',
+      ),
+      'height' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'default' => 0,
+        'description' => 'Height of the flash file.',
+      ),
+    ),
+    'primary key' => array('aid'),
+    'indexes' => array(
+      'fid' => array('fid'),
+    ),
+  );
+
+  /**
+   * The ad_flash_format table provides format guidelines for a given group
+   * of image ads.
+   */
+  $schema['ad_flash_format'] = array(
+    'description' => 'The ad_flash_format table provides format guidelines for a given group of image ads',
+    'fields' => array(
+      'gid' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'description' => 'Ad group ID, which equals to group\'s taxonomy term ID.',
+      ),
+      'min_width' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'default' => 0,
+        'description' => 'Minimum width for the groups\' ads.',
+      ),      
+      'max_width' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'default' => 0,
+        'description' => 'Maximum width for the groups\' ads.',
+      ),      
+      'min_height' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'default' => 0,
+        'description' => 'Minimum height for the groups\' ads.',
+      ),      
+      'max_height' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'unsigned' => TRUE,
+        'default' => 0,
+        'description' => 'Maximum height for the groups\' ads.',
+      ),
+    ),
+    'primary key' => array('gid'),
+  );
+  
+  return $schema;
+}
 
-  drupal_set_message(t('The necessary ad_flash module tables have been created.'));
+/**
+ * Install Flash Ad.
+ */
+function ad_flash_install() {
+  // Create tables.
+  drupal_install_schema('ad_flash');
 }
 
 /**
- * Allow complete uninstallation of the ad_image module.
+ * Allow a complete uninstallation of the Flash Ad module.
  */
-function ad_flash_uninstall() {
-	
+function ad_flash_uninstall() {	
 	// Delete all ad_flash content.
   $result = db_query("SELECT aid FROM {ad_flash}");
   while ($aid = db_result($result)) {
@@ -64,9 +135,25 @@
   }
 	
   // Remove tables.
-	db_query("DROP TABLE {ad_flash_format}");
-	db_query("DROP TABLE {ad_flash}");
+  drupal_uninstall_schema('ad_flash');
+}
 
+/**
+ * Update function for previous non-schema API MySQL databases.
+ * Note: Previous versions were MySQL-only, so running this on anything else is utterly pointless.
+ */
+function ad_flash_update_6000() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      db_drop_unique_key($ret, 'ad_flash', 'aid');
+      db_add_primary_key($ret, 'ad_flash', 'aid');
+      db_add_index($ret, 'ad_flash', 'aid', 'aid');
+      break;
+    default:
+  }
+  return $ret;
 }
 
 ?>
