/[drupal]/contributions/modules/affiliate_products_shop/affiliate_products_shop.install
ViewVC logotype

Contents of /contributions/modules/affiliate_products_shop/affiliate_products_shop.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sat Dec 29 09:25:18 2007 UTC (22 months, 3 weeks ago) by evakoss
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
File MIME type: text/x-php
Initial Release for Drupal 5.0
1 <?php
2 // $Id: affiliate_products_shop.install,v 1.3.2.2 2007/12/26 17:32:12 dopry Exp $
3
4 function affiliate_products_shop_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysql':
7 case 'mysqli':
8 db_query("CREATE TABLE {affiliate_manager_coupon} (
9 coupon_id int(11) NOT NULL auto_increment,
10 coupon_link_id varchar(100) NOT NULL,
11 coupon_merchant_id varchar(100) NOT NULL,
12 coupon_category varchar(100) NOT NULL,
13 coupon_link_name varchar(255) NOT NULL,
14 coupon_display_text varchar(255) NOT NULL,
15 coupon_link_url varchar(255) NOT NULL,
16 coupon_track_url varchar(255) NOT NULL,
17 coupon_type varchar(10) NOT NULL,
18 coupon_status int(1) NOT NULL,
19 PRIMARY KEY (coupon_id)
20 ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
21 );
22 db_query("CREATE TABLE {affiliate_manager_merchants} (
23 mer_id int(11) NOT NULL auto_increment,
24 merchant_name varchar(255) NOT NULL,
25 merchant_id varchar(200) NOT NULL,
26 merchant_home_page_link varchar(255) NOT NULL,
27 merchant_description text NOT NULL,
28 merchant_logo varchar(255) NOT NULL,
29 merchant_logo_alt varchar(255) NOT NULL,
30 merchant_status int(1) NOT NULL,
31 PRIMARY KEY (mer_id)
32 ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
33 );
34 $succes = TRUE;
35 break;
36 case 'pgsql':
37 db_query("CREATE TABLE {affiliate_manager_coupon} (
38 coupon_id int(11) NOT NULL auto_increment,
39 coupon_link_id varchar(100) NOT NULL,
40 coupon_merchant_id varchar(100) NOT NULL,
41 coupon_category varchar(100) NOT NULL,
42 coupon_link_name varchar(255) NOT NULL,
43 coupon_display_text varchar(255) NOT NULL,
44 coupon_link_url varchar(255) NOT NULL,
45 coupon_track_url varchar(255) NOT NULL,
46 coupon_type varchar(10) NOT NULL,
47 coupon_status int(1) NOT NULL,
48 PRIMARY KEY (coupon_id)
49 );"
50 );
51 db_query("CREATE TABLE {affiliate_manager_merchants} (
52 mer_id int(11) NOT NULL auto_increment,
53 merchant_name varchar(255) NOT NULL,
54 merchant_id varchar(200) NOT NULL,
55 merchant_home_page_link varchar(255) NOT NULL,
56 merchant_description text NOT NULL,
57 merchant_logo varchar(255) NOT NULL,
58 merchant_logo_alt varchar(255) NOT NULL,
59 merchant_status int(1) NOT NULL,
60 PRIMARY KEY (mer_id)
61 );"
62 );
63 $succes = TRUE;
64 break;
65 default:
66 drupal_set_message(t('Unsupported database.'), 'error');
67 $succes = FALSE;
68 }
69
70 if ($succes) {
71 drupal_set_message(t('The installation of the Affiliate Products Shop Manager table was successful.'), 'status');
72 } else {
73 drupal_set_message(t('The installation of the Affiliate Products Shop Manager module failed.'), 'error');
74 }
75 }
76
77 function delete_directory($dirname) {
78 if (is_dir($dirname))
79 $dir_handle = opendir($dirname);
80 if (!$dir_handle)
81 return false;
82 while($file = readdir($dir_handle)) {
83 if ($file != "." && $file != "..") {
84 if (!is_dir($dirname."/".$file))
85 unlink($dirname."/".$file);
86 else
87 delete_directory($dirname.'/'.$file);
88 }
89 }
90 closedir($dir_handle);
91 rmdir($dirname);
92 return true;
93 }
94
95 /**
96 * Remove tables on uninstall.
97 */
98 function affiliate_products_shop_uninstall() {
99 $path = 'files/'.variable_get('merchant_logo_path', 'merchant_logo');
100 delete_directory($path);
101 db_query("DROP TABLE {affiliate_manager_coupon}");
102 db_query("DROP TABLE {affiliate_manager_merchants}");
103 db_query("DELETE FROM {variable} WHERE name = 'merchant_logo_path'");
104 cache_clear_all('variables', 'cache');
105 }

  ViewVC Help
Powered by ViewVC 1.1.2