? Paycom-534066.patch
Index: paycom.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/Paycom/paycom.install,v
retrieving revision 1.2
diff -u -p -r1.2 paycom.install
--- paycom.install	17 Jan 2009 05:27:48 -0000	1.2
+++ paycom.install	29 Jul 2009 05:14:09 -0000
@@ -1,118 +1,126 @@
 <?php
-/********************************************************************
-* Paycom / Epoch payment gateway for the Drupal
-* Author : Heshan Wanigasooriy (heshan@heidisoft.com)
-* Date : 22/12/2008
-********************************************************************/
+// $Id$
 
+/**
+ * Implementation of hook_install().
+ */
 function paycom_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {paycom} (
-        pid int(11) NOT NULL,
-        uid int(11) NOT NULL,
-        product_id varchar(30) NOT NULL,
-        PRIMARY KEY  (pid, uid)
-      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      db_query("CREATE TABLE {EpochTransStats} (
-        ets_transaction_id int(11) NOT NULL default '0',
-        ets_member_idx int(11) NOT NULL default '0',
-        ets_transaction_date datetime default NULL,
-        ets_transaction_type char(1) NOT NULL default '',
-        ets_co_code varchar(6) NOT NULL default '',
-        ets_pi_code varchar(32) NOT NULL default '',
-        ets_reseller_code varchar(64) default 'a',
-        ets_transaction_amount decimal(10,2) NOT NULL default '0.00',
-        ets_payment_type char(1) default 'A',
-        ets_username varchar(32) default NULL,
-        ets_ref_trans_ids int(11) default NULL,
-        ets_password_expire varchar(20) default NULL,
-        PRIMARY KEY (ets_transaction_id),
-        KEY idx_reseller (ets_reseller_code),
-        KEY idx_product (ets_pi_code),
-        KEY idx_transdate (ets_transaction_date),
-        KEY idx_type (ets_transaction_type)
-        ) TYPE=MyISAM;");
-        
-      db_query("CREATE TABLE {MemberCancelStats} (
-        mcs_or_idx int(11) NOT NULL default '0',
-        mcs_canceldate datetime default NULL,
-        mcs_signupdate datetime default NULL,
-        mcs_cocode varchar(16) NOT NULL default '',
-        mcs_picode varchar(32) NOT NULL default '',
-        mcs_reseller varchar(32) default NULL,
-        mcs_reason varchar(64) default NULL,
-        mcs_memberstype char(1) default NULL,
-        mcs_username varchar(32) default NULL,
-        mcs_email varchar(64) default NULL,
-        mcs_passwordremovaldate datetime default NULL,
-        PRIMARY KEY (mcs_or_idx),
-        KEY ix_initdate (mcs_canceldate),
-        KEY ix_signupdate (mcs_signupdate),
-        KEY ix_pwdremdate (mcs_passwordremovaldate)
-        ) TYPE=MyISAM;");
-      break;  
-
-    case 'pgsql';
-      db_query("CREATE TABLE {paycom} (
-        pid integer NOT NULL default '0',
-        uid integer NOT NULL default '0',
-        product_id varchar(30) NOT NULL default '',
-        PRIMARY KEY  (pid, uid)
-      )");
-      
-      db_query("CREATE TABLE {EpochTransStats} (
-        ets_transaction_id integer NOT NULL default '0',
-        ets_member_idx integer NOT NULL default '0',
-        ets_transaction_date datetime default NULL,
-        ets_transaction_type char(1) NOT NULL default '',
-        ets_co_code varchar(6) NOT NULL default '',
-        ets_pi_code varchar(32) NOT NULL default '',
-        ets_reseller_code varchar(64) default 'a',
-        ets_transaction_amount decimal(10,2) NOT NULL default '0.00',
-        ets_payment_type char(1) default 'A',
-        ets_username varchar(32) default NULL,
-        ets_ref_trans_ids integer default NULL,
-        ets_password_expire varchar(20) default NULL,
-        PRIMARY KEY (ets_transaction_id),
-        KEY idx_reseller (ets_reseller_code),
-        KEY idx_product (ets_pi_code),
-        KEY idx_transdate (ets_transaction_date),
-        KEY idx_type (ets_transaction_type)
-      )");
-        
-      db_query("CREATE TABLE {MemberCancelStats} (
-        mcs_or_idx integer NOT NULL default '0',
-        mcs_canceldate datetime default NULL,
-        mcs_signupdate datetime default NULL,
-        mcs_cocode varchar(16) NOT NULL default '',
-        mcs_picode varchar(32) NOT NULL default '',
-        mcs_reseller varchar(32) default NULL,
-        mcs_reason varchar(64) default NULL,
-        mcs_memberstype char(1) default NULL,
-        mcs_username varchar(32) default NULL,
-        mcs_email varchar(64) default NULL,
-        mcs_passwordremovaldate datetime default NULL,
-        PRIMARY KEY (mcs_or_idx),
-        KEY ix_initdate (mcs_canceldate),
-        KEY ix_signupdate (mcs_signupdate),
-        KEY ix_pwdremdate (mcs_passwordremovaldate)
-      )");
-      
-      break;
-  }
-  drupal_set_message(t('Paycom tables have been created.'));
+  drupal_install_schema('paycom');
 }
 
-// unstall module
+/**
+ * Implementation of hook_schema().
+ */
+function paycom_schema() {
+  $schema['paycom'] = array(
+    'description' => t('TODO: please describe this table!'),
+    'fields' => array(
+      'pid' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'uid' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'product_id' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'varchar',
+        'length' => '30',
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array('pid', 'uid'),
+  );
+
+  $schema['paycom_MemberCancelStats'] = array(
+    'description' => t('TODO: please describe this table!'),
+    'fields' => array(
+      'mcs_or_idx' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'mcs_canceldate' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'datetime',
+        'not null' => FALSE,
+      ),
+      'mcs_signupdate' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'datetime',
+        'not null' => FALSE,
+      ),
+      'mcs_cocode' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'varchar',
+        'length' => '16',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'mcs_picode' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'varchar',
+        'length' => '32',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'mcs_reseller' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'varchar',
+        'length' => '32',
+        'not null' => FALSE,
+      ),
+      'mcs_reason' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'varchar',
+        'length' => '64',
+        'not null' => FALSE,
+      ),
+      'mcs_memberstype' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'char',
+        'length' => '1',
+        'not null' => FALSE,
+      ),
+      'mcs_username' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'varchar',
+        'length' => '32',
+        'not null' => FALSE,
+      ),
+      'mcs_email' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'varchar',
+        'length' => '64',
+        'not null' => FALSE,
+      ),
+      'mcs_passwordremovaldate' => array(
+        'description' => t('TODO: please describe this field!'),
+        'type' => 'datetime',
+        'not null' => FALSE,
+      ),
+    ),
+    'primary key' => array('mcs_or_idx'),
+    'indexes' => array(
+      'ix_initdate' => array('mcs_canceldate'),
+      'ix_pwdremdate' => array('mcs_passwordremovaldate'),
+      'ix_signupdate' => array('mcs_signupdate'),
+    ),
+  );
+  
+  return $schema;
+}
 
+/**
+ * Implementation of hook_uninstall().
+ */
 function paycom_uninstall() {
-  db_query('DROP TABLE {paycom}');
-  db_query('DROP TABLE {EpochTransStats}');
-  db_query('DROP TABLE {MemberCancelStats}');
-
+  drupal_uninstall_schema('paycom');
+  
   variable_del('paycom_role');
   variable_del('paycom_co_code');
   variable_del('paycom_reseller');
Index: paycom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/Paycom/paycom.module,v
retrieving revision 1.4
diff -u -p -r1.4 paycom.module
--- paycom.module	17 Apr 2009 04:40:41 -0000	1.4
+++ paycom.module	29 Jul 2009 05:14:10 -0000
@@ -523,7 +523,7 @@ function paycom_process_transaction() {
  */
 function _paycom_check_cancellations($last_ran) {
 
-  $sql = db_query("SELECT * FROM {MemberCancelStats} WHERE mcs_canceldate > %d", $last_ran);
+  $sql = db_query("SELECT * FROM {paycom_MemberCancelStats} WHERE mcs_canceldate > %d", $last_ran);
   while ($result = db_fetch_object($sql)) {
     if ($sql_user = db_fetch_object(db_query("SELECT * FROM {users} WHERE mail = '%s'", $result->mcs_email))) {
         if (db_query("DELETE FROM {users_roles} WHERE uid = %d AND rid = %d", $sql_user->uid, variable_get('paycom_role', ''))) {
