1. pickupman
  2. zencart-gv-delay-send

Commits

pickupman  committed a44e3f2

Add installation file to install queries to update coupon_email_track table

  • Participants
  • Parent commits 5c48c36
  • Branches default

Comments (0)

Files changed (1)

File RENAME-to-ADMIN-folder/includes/functions/extra_functions/gv_delay_send_functions.php

View file
+<?php
+
+/**
+ * Install file for GV Delay Send add on
+ * 
+ * @author Joe McFrederick
+ * @date   2012-02-29
+ * 
+ * @package ZenCart
+ * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
+ */
+ 
+    //Auto install check
+     $gvdelaysendCheck = $db->Execute("SHOW COLUMNS FROM " . TABLE_COUPON_EMAIL_TRACK);
+          
+     $install = FALSE;
+     $install_sql = array();
+     $fields = array();
+     while ( !$gvdelaysendCheck->EOF) {
+        $fields[] = $gvdelaysendCheck->fields['Field'];
+        $gvdelaysendCheck->MoveNext();
+     }
+     
+     if ( ! in_array('send_future', $fields))
+     {
+        $install = TRUE;
+        $install_sql[] = "ALTER TABLE " . TABLE_COUPON_EMAIL_TRACK . " ADD COLUMN send_future TINYINT(1) DEFAULT 0;";
+     }
+     if ( ! in_array('message', $fields))
+     {
+        $install = TRUE;
+        $install_sql[] = "ALTER TABLE " . TABLE_COUPON_EMAIL_TRACK . " ADD COLUMN message TEXT;";
+     }
+     if ( ! in_array('to_name', $fields)) {
+        $install = TRUE;
+        $install_sql[] = "ALTER TABLE " . TABLE_COUPON_EMAIL_TRACK . " ADD COLUMN to_name VARCHAR(150);";
+     }
+     
+     
+     if($install == TRUE AND basename($_SERVER['PHP_SELF']) == 'index.php')
+     {
+        echo '<div class="messageStackWarning">GV Delay Send <b>not installed</b>';
+        echo zen_draw_form('install', 'index.php', 'install_gv_delay_send=yes', 'post', '', true);
+        echo '<input type="submit" value="Install Now" />';
+        echo '</div>';
+     }
+     
+     function remove_gv_delay_send()
+     {
+        global $db;
+        
+        $db->Execute("ALTER TABLE " . TABLE_COUPON_EMAIL_TRACK . " DROP COLUMN send_future");
+        $db->Execute("ALTER TABLE " . TABLE_COUPON_EMAIL_TRACK . " DROP COLUMN message");
+        $db->Execute("ALTER TABLE " . TABLE_COUPON_EMAIL_TRACK . " DROP COLUMN to_name");
+        
+        zen_redirect(zen_href_link('index'));
+     }
+     
+     function install_gv_delay_send()
+     {
+        global $db, $install_sql;
+        
+        //By default the table is not setup to store email addesses over 32 characters. Make column bigger
+        $install_sql[] = "ALTER TABLE " . TABLE_COUPON_EMAIL_TRACK . " MODIFY emailed_to VARCHAR(150);";
+        
+        foreach ($install_sql as $sql) {
+            $db->Execute($sql);
+        }        
+        zen_redirect(zen_href_link('index'));
+     }
+     
+     if(basename($_SERVER['PHP_SELF']) == 'index.php' AND isset($_GET) AND $_GET['install_gv_delay_send'] == 'yes')
+     {
+        install_gv_delay_send();
+     }
+     
+     if(basename($_SERVER['PHP_SELF']) == 'index.php' AND isset($_GET) AND $_GET['remove_gv_delay_send'] == 'yes')
+     {
+        remove_gv_delay_send();
+     }