-
Notifications
You must be signed in to change notification settings - Fork 0
/
uc_cron_gbase.install
161 lines (148 loc) · 4.88 KB
/
uc_cron_gbase.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
/**
* @file uc_cron_gbase.install
*
* Contains install and update functions for Afterhours Ubercart Google Base Integration
*/
/**
* Implementation of hook_install().
*/
function uc_cron_gbase_requirements($phase) {
$requirements = array();
$t = get_t();
if ($phase == 'runtime') {
$itemsFeedURL = 'http://www.google.com/base/feeds/items';
$token = uc_cron_gbase_token();
$next_url = url('uc_cron_gbase/exchange', array('absolute' => TRUE));
$redirect_url = 'https://www.google.com/accounts/AuthSubRequest?session=1';
$redirect_url .= '&next=';
$redirect_url .= urlencode($next_url);
$redirect_url .= "&scope=";
$redirect_url .= urlencode($itemsFeedURL);
if (!uc_cron_gbase_check_token($token)) {
$requirements['uc_cron_gbase_auth'] = array(
'title' => $t('Ubercart Google Base Integration'),
'value' => $t('Authentication failure'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('Your Google Base authentication token has expired. Please <a href="!url">login to your Google Account</a>.', array('!url' => url($redirect_url))),
);
}
else {
$requirements['uc_cron_gbase_auth'] = array(
'title' => $t('Ubercart Google Base Integration'),
'value' => $t('Authentication successful'),
'severity' => REQUIREMENT_OK,
'description' => $t('Ubercart Google Base Integration is successful'),
);
}
}
// elseif ($phase == 'install') {
if (!function_exists('simplexml_load_string')) {
$requirements['simplexml'] = array(
'title' => $t('SimpleXML'),
'value' => $t('Not found'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('The SimpleXML extension for PHP required by the Ubercart Google Base Integration module is not enabled. See <a href="!url">this page</a> for more information.', array('!url' => url('http://us.php.net/manual/en/intro.simplexml.php'))),
);
}
if (!function_exists('openssl_open')) {
$requirements['simplexml'] = array(
'title' => $t('OpenSSL'),
'value' => $t('Not found'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('The OpenSSL extension for PHP required by the Ubercart Google Base Integration module is not enabled. See <a href="!url">this page</a> for more information.', array('!url' => url('http://us2.php.net/manual/en/book.openssl.php'))),
);
}
//}
return $requirements;
}
/**
* Implementation of hook_install().
*/
function uc_cron_gbase_install() {
// Create tables.
$result = drupal_install_schema('uc_cron_gbase');
if ($result[0]['success']) {
drupal_set_message('Google Base Cron Integration module has been successfully installed.');
} else {
drupal_set_message('Failed to install Google Base Cron Module');
}
}
/**
* Implementation of hook_schema().
*/
function uc_cron_gbase_schema() {
$schema = array();
uc_cron_gbase_table_uc_cron_gbase($schema);
return $schema;
}
/**
* Contains the database schema for the uc_cron_gbase table.
*/
function uc_cron_gbase_table_uc_cron_gbase(&$schema) {
$schema['uc_cron_gbase'] = array(
'description' => t('Stores the data for products submitted to Google Base.'),
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => t('Drupal node ID.')
),
'gid' => array(
'type' => 'varchar',
'length' => '25',
'not null' => TRUE,
'description' => t('The id assigned by Google Base.')
),
'enabled' => array(
'type' => 'int',
'not null' => FALSE,
'description' => t('1 if product is enabled for cron')
),
'taxonomy' => array(
'type' => 'text',
'length' => 250,
'not null' => FALSE,
'description' => t('products gbase taxonomy')
),
'product_condition' => array(
'type' => 'text',
'length' => 11,
'not null' => FALSE,
'description' => t('products condition')
),
'new' => array(
'type' => 'int',
'not null' => FALSE,
'description' => t('TRUE if needs to be inserted on gbase by cron.')
),
'upc' => array(
'type' => 'varchar'
'length' => '25',
'not null' => FALSE,
'description' => t('for UPC-14, EAN-8 and other variants')
),
'created' => array(
'description' => t('Date/Time row created'),
'type' => 'datetime',
'not null' => TRUE,
'default' => 0
),
'updated' => array(
'description' => t('Date/Time row updated'),
'type' => 'datetime',
'not null' => TRUE,
'default' => 0
)
), // End Fields
'primary key' => array('nid')
);
return $schema;
}
/**
* Implementation of hook_uninstall().
*/
function uc_cron_gbase_uninstall() {
drupal_uninstall_schema('uc_cron_gbase');
}