-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtaobaoke.install
123 lines (102 loc) · 3.01 KB
/
taobaoke.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
<?php
/**
* @file
* Install, update, and uninstall functions for the Taobaoke module.
*/
/**
* Implements hook_install().
*/
function taobaoke_install() {
// 'page_no' start form 0, to keep same with theme_pager.
$default_settings = array(
'nick' => '',
'pid' => '',
'keyword' => '',
'cid' => 162404,
'start_price' => 0,
'end_price' => 999999,
'auto_send' => '',
'area' => '',
'start_credit' => '2diamond',
'end_credit' => '5goldencrown',
'sort' => 'commissionRate_desc',
'guarantee' => '',
'start_commissionRate' => 1000,
'end_commissionRate' => 5000,
'start_commissionNum' => '',
'end_commissionNum' => '',
'start_totalnum' => '',
'end_totalnum' => '',
'cash_coupon' => '',
'vip_cart' => '',
'overseas_item' => '',
'sevendays_return' => '',
'real_describe' => '',
'onemonth_repair' => '',
'cash_ondelivery' => '',
'mail_item' => '',
'page_no' => 0,
'page_size' => 36,
'outer_code' => 'drupal',
'is_mobile' => '',
);
foreach ($default_settings as $key => $value) {
variable_set('taobaoke_' . $key, $value);
}
variable_set('taobaoke_block_count', 1);
}
/**
* Implements hook_uninstall().
*/
function taobaoke_uninstall() {
$query = "DELETE FROM {variable} WHERE name LIKE 'taobaoke_%'";
db_query($query);
}
/**
* Implements hook_requirements().
*/
function taobaoke_requirements($phase) {
$requirements = array();
if ($phase == 'install') {
// Module will not be installed if php curl extension is not enabled.
if (!extension_loaded('curl')) {
$requirements['curl'] = taobaoke_requirements_error('curl');
}
}
if ($phase == 'runtime') {
// Display a error message in status report page.
$library = libraries_detect('topsdk');
if (!$library['installed']) {
$requirements['topsdk'] = taobaoke_requirements_error('topsdk');
}
}
return $requirements;
}
/**
* Set requirments error message.
*/
function taobaoke_requirements_error($type) {
$requirements = array();
if ($type == 'curl') {
// Set error message.
$message = t('Taobaoke module needs PHP cURL extension loaded, please make sure that then try to enable taobaoke module again.');
// Set requirements message.
$requirements['curl'] = array(
'title' => t('cURL'),
'description' => $message,
'severity' => REQUIREMENT_ERROR,
);
}
if ($type == 'topsdk') {
// Set error message.
$message = t('The TopSDK library missing. Taobaoke module is not enabled. Download it from http://open.taobao.com and extract it into the sites/all/libraries/topsdk directory before you using Taobaoke module. More information about install taobaoke module please see README.txt file in taobaoke module directory.');
// Set requirements message.
$requirements['topsdk'] = array(
'title' => t('TopSDK'),
'value' => t('Not Found'),
'description' => $message,
'severity' => REQUIREMENT_ERROR,
);
}
return $requirements[$type];
}