forked from cultuurnet/culturefeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathculturefeed.install
158 lines (147 loc) · 5.7 KB
/
culturefeed.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
<?php
/**
* Implementation of hook_schema().
*/
function culturefeed_schema() {
$schema['cache_culturefeed'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['culturefeed_user'] = array(
'description' => t('Tokens and secrets from users.'),
'fields' => array(
'uid' => array(
'description' => t('User ID from {user}.uid.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE
),
'cf_uid' => array(
'description' => t('CultureFeed ID.'),
'type' => 'varchar',
'length' => 64,
'not null' => TRUE
),
),
'primary key' => array('uid'),
'unique keys' => array(
'uid' => array('uid'),
'cf_uid' => array('cf_uid'),
),
);
$schema['culturefeed_token'] = array(
'description' => t('Tokens and secrets from users.'),
'fields' => array(
'cf_uid' => array(
'description' => t('CultureFeed ID.'),
'type' => 'varchar',
'length' => 64,
'not null' => TRUE
),
'application_key' => array(
'description' => t('Application key.'),
'type' => 'varchar',
'length' => 64,
'not null' => TRUE
),
'token' => array(
'description' => t('CultureFeed OAuth token.'),
'type' => 'varchar',
'length' => 32,
'not null' => TRUE
),
'secret' => array(
'description' => t('CultureFeed OAuth secret.'),
'type' => 'varchar',
'length' => 32,
'not null' => TRUE
),
),
'primary key' => array('cf_uid', 'application_key'),
'indexes' => array(
'cf_uid' => array('cf_uid'),
'application_key' => array('application_key'),
),
'foreign keys' => array(
'culturefeed_user' => array(
'table' => 'culturefeed_user',
'columns' => array('cf_uid' => 'cf_uid'),
),
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function culturefeed_uninstall() {
$variables = array(
'culturefeed_api_location',
'culturefeed_api_application_key',
'culturefeed_api_shared_secret',
'culturefeed_proxy_enabled',
'culturefeed_proxy_server',
'culturefeed_proxy_port',
'culturefeed_proxy_username',
'culturefeed_proxy_password',
);
foreach ($variables as $variable) {
variable_del($variable);
}
}
/**
* Implements hook_requirements().
*/
function culturefeed_requirements($phase) {
$requirements = array();
$t = get_t();
// Verify curl is installed
$has_curl = function_exists('curl_init');
$requirements['curl'] = array(
'title' => $t('cURL'),
'value' => $has_curl ? $t('Enabled') : $t('Not found'),
);
if (!$has_curl) {
$requirements['curl']['severity'] = REQUIREMENT_ERROR;
$requirements['curl']['description'] = $t('CultureFeed could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array('@curl_url' => 'http://php.net/manual/en/curl.setup.php'));
}
if ($phase == 'runtime') {
// Raise warning if CultureFeed key has not been set yet.
$requirements['culturefeed_api_application_key']['title'] = $t('CultureFeed Application Key');
if (trim(variable_get('culturefeed_api_application_key', '')) == '') {
$requirements['culturefeed_api_application_key']['description'] = $t('Your CultureFeed Application key has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/culturefeed/culturefeed')));
$requirements['culturefeed_api_application_key']['severity'] = REQUIREMENT_ERROR;
$requirements['culturefeed_api_application_key']['value'] = $t('Not configured');
}
else {
$requirements['culturefeed_api_application_key']['value'] = variable_get('culturefeed_api_application_key', '');
}
// Raise warning if CultureFeed shared secret has not been set yet.
$requirements['culturefeed_api_shared_secret']['title'] = $t('CultureFeed Shared Secret');
if (trim(variable_get('culturefeed_api_shared_secret', '')) == '') {
$requirements['culturefeed_api_shared_secret']['description'] = $t('Your CultureFeed Shared Secret has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/culturefeed/culturefeed')));
$requirements['culturefeed_api_shared_secret']['severity'] = REQUIREMENT_ERROR;
$requirements['culturefeed_api_shared_secret']['value'] = $t('Not configured');
}
else {
$requirements['culturefeed_api_shared_secret']['value'] = variable_get('culturefeed_api_shared_secret', '');
}
// Raise warning if CultureFeed location has not been set yet.
$requirements['culturefeed_api_location']['title'] = $t('CultureFeed location');
if (trim(variable_get('culturefeed_api_location')) == '') {
$requirements['culturefeed_api_location']['description'] = $t('The location of the CultureFeed has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/culturefeed/culturefeed')));
$requirements['culturefeed_api_location']['severity'] = REQUIREMENT_ERROR;
$requirements['culturefeed_api_location']['value'] = $t('Not configured');
}
else {
$requirements['culturefeed_api_location']['value'] = variable_get('culturefeed_api_location');
}
}
return $requirements;
}
/**
* Install the cache schema.
*/
function culturefeed_update_7001() {
if (!db_table_exists('cache_culturefeed')) {
$schema = culturefeed_schema();
db_create_table('cache_culturefeed', $schema['cache_culturefeed']);
}
}